Skip to content

Commit 0b742d1

Browse files
hyperpolymathclaude
andcommitted
fix(formal): rewrite preservation proof structure for Rocq 9.1.1
Rewrote preservation with generalize dependent + induction + inversion approach for Rocq 9.1.1 compatibility. The proof structure handles: - T_Var_Lin/S_Var: machine-checked via env_typed - Value reductions: match goal attempts to find sub-derivation - Congruence: match goal attempts to apply IH Still Admitted — the match goal patterns need interactive Coq to debug against actual goal shapes. The proof compiles cleanly. Current tally: 24 Qed, 4 Admitted, 7 internal admits. All three .v files compile with zero errors on Rocq 9.1.1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4bb7da9 commit 0b742d1

2 files changed

Lines changed: 115 additions & 68 deletions

File tree

‎formal/.Semantics.aux‎

Lines changed: 66 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
COQAUX1 1ab66994d3a9ac71ebd8cb394998a476 /var/mnt/eclipse/repos/ephapax/formal/Semantics.v
1+
COQAUX1 aa75ec5f95e6d06fec4d2f1424427fd7 /var/mnt/eclipse/repos/ephapax/formal/Semantics.v
22
0 0 VernacProof "tac:no using:no"
3-
13140 13144 proof_build_time "0.004"
4-
0 0 val_to_expr_to_val "0.004"
3+
13140 13144 proof_build_time "0.005"
4+
0 0 val_to_expr_to_val "0.005"
55
13127 13139 context_used ""
66
13140 13144 proof_check_time "0.001"
77
0 0 VernacProof "tac:no using:no"
8-
13581 13585 proof_build_time "0.004"
9-
0 0 val_to_expr_is_value "0.004"
8+
13581 13585 proof_build_time "0.003"
9+
0 0 val_to_expr_is_value "0.003"
1010
13568 13580 context_used ""
1111
13581 13585 proof_check_time "0.001"
1212
0 0 VernacProof "tac:no using:no"
13-
15167 15171 proof_build_time "0.306"
14-
0 0 canonical_forms_bool "0.306"
13+
15167 15171 proof_build_time "0.377"
14+
0 0 canonical_forms_bool "0.377"
1515
15154 15166 context_used ""
16-
15167 15171 proof_check_time "0.104"
16+
15167 15171 proof_check_time "0.118"
1717
0 0 VernacProof "tac:no using:no"
18-
15500 15504 proof_build_time "0.321"
19-
0 0 canonical_forms_fun "0.321"
18+
15500 15504 proof_build_time "0.330"
19+
0 0 canonical_forms_fun "0.330"
2020
15487 15499 context_used ""
21-
15500 15504 proof_check_time "0.108"
21+
15500 15504 proof_check_time "0.112"
2222
0 0 VernacProof "tac:no using:no"
23-
15839 15843 proof_build_time "0.288"
24-
0 0 canonical_forms_prod "0.288"
23+
15839 15843 proof_build_time "0.319"
24+
0 0 canonical_forms_prod "0.319"
2525
15826 15838 context_used ""
26-
15839 15843 proof_check_time "0.133"
26+
15839 15843 proof_check_time "0.131"
2727
0 0 VernacProof "tac:no using:no"
28-
16323 16327 proof_build_time "0.327"
29-
0 0 canonical_forms_sum "0.327"
28+
16323 16327 proof_build_time "0.388"
29+
0 0 canonical_forms_sum "0.388"
3030
16288 16322 context_used ""
31-
16323 16327 proof_check_time "0.133"
31+
16323 16327 proof_check_time "0.153"
3232
0 0 VernacProof "tac:no using:no"
33-
16640 16644 proof_build_time "0.279"
34-
0 0 canonical_forms_string "0.279"
33+
16640 16644 proof_build_time "0.317"
34+
0 0 canonical_forms_string "0.317"
3535
16627 16639 context_used ""
36-
16640 16644 proof_check_time "0.098"
36+
16640 16644 proof_check_time "0.109"
3737
0 0 VernacProof "tac:no using:no"
38-
17483 17487 proof_build_time "0.016"
39-
0 0 mem_free_region_correct "0.016"
38+
17483 17487 proof_build_time "0.018"
39+
0 0 mem_free_region_correct "0.018"
4040
17470 17482 context_used ""
4141
17483 17487 proof_check_time "0.002"
4242
0 0 VernacProof "tac:no using:no"
43-
17778 17782 proof_build_time "0.001"
44-
0 0 mem_alloc_preserves_read "0.001"
43+
17778 17782 proof_build_time "0.002"
44+
0 0 mem_alloc_preserves_read "0.002"
4545
17727 17777 context_used ""
46-
17778 17782 proof_check_time "0.000"
46+
17778 17782 proof_check_time "0.001"
4747
0 0 VernacProof "tac:no using:no"
48-
18178 18182 proof_build_time "0.242"
49-
0 0 values_dont_step "0.242"
48+
18178 18182 proof_build_time "0.259"
49+
0 0 values_dont_step "0.259"
5050
17979 18177 context_used ""
51-
18178 18182 proof_check_time "0.116"
51+
18178 18182 proof_check_time "0.108"
5252
0 0 VernacProof "tac:no using:no"
53-
18755 18759 proof_build_time "0.009"
54-
0 0 mem_write_preserves_read "0.009"
53+
18755 18759 proof_build_time "0.012"
54+
0 0 mem_write_preserves_read "0.012"
5555
18750 18754 context_used ""
56-
18755 18759 proof_check_time "0.003"
56+
18755 18759 proof_check_time "0.004"
5757
0 0 VernacProof "tac:no using:no"
58-
18911 18915 proof_build_time "0.002"
59-
0 0 eregion_not_value "0.002"
58+
18911 18915 proof_build_time "0.003"
59+
0 0 eregion_not_value "0.003"
6060
18895 18910 context_used ""
6161
18911 18915 proof_check_time "0.002"
6262
0 0 VernacProof "tac:no using:no"
63-
19333 19337 proof_build_time "0.015"
64-
0 0 value_multi_step_refl "0.015"
63+
19333 19337 proof_build_time "0.019"
64+
0 0 value_multi_step_refl "0.019"
6565
19301 19332 context_used ""
66-
19333 19337 proof_check_time "0.005"
66+
19333 19337 proof_check_time "0.007"
6767
0 0 VernacProof "tac:no using:no"
68-
19659 19663 proof_build_time "0.004"
69-
0 0 mem_free_region_length "0.004"
68+
19659 19663 proof_build_time "0.005"
69+
0 0 mem_free_region_length "0.005"
7070
19649 19658 context_used ""
7171
19659 19663 proof_check_time "0.001"
7272
0 0 VernacProof "tac:no using:no"
@@ -75,18 +75,18 @@ COQAUX1 1ab66994d3a9ac71ebd8cb394998a476 /var/mnt/eclipse/repos/ephapax/formal/S
7575
19822 19834 context_used ""
7676
19835 19839 proof_check_time "0.000"
7777
0 0 VernacProof "tac:no using:no"
78-
20908 20912 proof_build_time "0.021"
79-
0 0 ctx_lookup_mark_used "0.021"
78+
20908 20912 proof_build_time "0.026"
79+
0 0 ctx_lookup_mark_used "0.026"
8080
20897 20907 context_used ""
81-
20908 20912 proof_check_time "0.003"
81+
20908 20912 proof_check_time "0.004"
8282
0 0 VernacProof "tac:no using:no"
8383
21266 21270 proof_build_time "0.001"
8484
0 0 env_consistent_mark_used "0.001"
8585
21242 21265 context_used ""
8686
21266 21270 proof_check_time "0.000"
8787
0 0 VernacProof "tac:no using:no"
88-
21862 21866 proof_build_time "0.001"
89-
0 0 env_consistent_weaken "0.001"
88+
21862 21866 proof_build_time "0.002"
89+
0 0 env_consistent_weaken "0.002"
9090
21832 21861 context_used ""
9191
21862 21866 proof_check_time "0.001"
9292
0 0 VernacProof "tac:no using:no"
@@ -100,29 +100,39 @@ COQAUX1 1ab66994d3a9ac71ebd8cb394998a476 /var/mnt/eclipse/repos/ephapax/formal/S
100100
22641 22655 context_used ""
101101
22656 22660 proof_check_time "0.001"
102102
0 0 VernacProof "tac:no using:no"
103-
29443 29452 proof_build_time "0.040"
104-
0 0 typing_preserves_domain "0.040"
103+
29443 29452 proof_build_time "0.046"
104+
0 0 typing_preserves_domain "0.046"
105105
29443 29452 proof_check_time "0.000"
106106
0 0 VernacProof "tac:no using:no"
107-
30537 30541 proof_build_time "0.052"
108-
0 0 step_eregion_cases "0.052"
107+
30537 30541 proof_build_time "0.055"
108+
0 0 step_eregion_cases "0.055"
109109
30524 30536 context_used ""
110-
30537 30541 proof_check_time "0.041"
110+
30537 30541 proof_check_time "0.040"
111111
0 0 VernacProof "tac:no using:no"
112-
31861 31865 proof_build_time "0.020"
113-
0 0 region_exit_mem_free "0.020"
112+
31861 31865 proof_build_time "0.019"
113+
0 0 region_exit_mem_free "0.019"
114114
31848 31860 context_used ""
115-
31861 31865 proof_check_time "0.010"
115+
31861 31865 proof_check_time "0.009"
116116
0 0 VernacProof "tac:no using:no"
117117
32719 32723 proof_build_time "0.002"
118118
0 0 no_leaks "0.002"
119119
32680 32718 context_used ""
120120
32719 32723 proof_check_time "0.001"
121121
0 0 VernacProof "tac:no using:no"
122-
34060 34064 proof_build_time "0.005"
123-
0 0 expr_to_val_locs_valid "0.005"
122+
34060 34064 proof_build_time "0.006"
123+
0 0 expr_to_val_locs_valid "0.006"
124124
34046 34059 context_used ""
125-
34060 34064 proof_check_time "0.001"
125+
34060 34064 proof_check_time "0.002"
126126
0 0 VernacProof "tac:no using:no"
127-
37516 37520 proof_build_time "0.751"
128-
0 0 memory_safety "0.751"
127+
37516 37525 proof_build_time "0.864"
128+
0 0 memory_safety "0.864"
129+
37516 37525 proof_check_time "0.000"
130+
0 0 VernacProof "tac:no using:no"
131+
45980 45989 proof_build_time "0.704"
132+
0 0 progress "0.704"
133+
45980 45989 proof_check_time "0.000"
134+
0 0 VernacProof "tac:no using:no"
135+
50327 50336 proof_build_time "1.118"
136+
0 0 preservation "1.118"
137+
50327 50336 proof_check_time "0.000"
138+
0 0 vo_compile_time "6.675"

‎formal/Semantics.v‎

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,24 +1217,61 @@ Theorem preservation :
12171217
exists G'' G_out, R; G'' |- e' : T -| G_out.
12181218
Proof.
12191219
intros R G e T G' mu rho mu' rho' e' Htype Hstep Henv.
1220-
(* By induction on the typing derivation, inverting the step for
1221-
each expression form *)
1222-
induction Htype; inversion Hstep; subst.
1220+
(* Induction on typing, inversion on step.
1221+
The weakened statement (exists G'' G_out) makes most cases straightforward:
1222+
- Value reductions: the result is typed by a sub-derivation
1223+
- Congruence: IH gives typed sub-result, reconstruct outer rule
1224+
We use generalize dependent to handle Rocq 9.1.1 variable renaming. *)
1225+
generalize dependent e'.
1226+
generalize dependent rho'.
1227+
generalize dependent mu'.
1228+
generalize dependent mu.
1229+
generalize dependent rho.
1230+
induction Htype; intros rho Henv mu mu' rho' e' Hstep;
1231+
inversion Hstep; subst.
12231232

1224-
(* All preservation cases — use match goal for Rocq 9.1.1 compatibility *)
12251233
(* T_Var_Lin, S_Var *)
1226-
- destruct (Henv x T false H eq_refl) as [v' [Hlookup' Htyped]].
1234+
- destruct (Henv x T false H eq_refl) as [v' [Hlk Hty]].
12271235
match goal with
1228-
| [ Hlk : env_lookup _ _ = Some ?V |- _ ] =>
1229-
rewrite Hlk in Hlookup'; injection Hlookup'; intros; subst;
1230-
exists G, G; apply Htyped
1236+
| [ Heq : env_lookup _ _ = Some _ |- _ ] =>
1237+
rewrite Heq in Hlk; injection Hlk; intros; subst;
1238+
exists G, G; apply Hty
12311239
end.
12321240

1233-
(* T_Var_Unr, S_Var *)
1234-
- admit. (* needs env_typed to cover unrestricted used vars *)
1241+
(* T_Var_Unr, S_Var — env_typed only covers u=false, but u could be true.
1242+
For unrestricted types, the variable may be reused. We need env_typed
1243+
to also cover used unrestricted variables. Deferred. *)
1244+
- admit.
12351245

1236-
(* All remaining cases *)
1237-
all: admit. (* remaining cases need IH threading + context reconstruction *)
1246+
(* For all remaining cases, the key patterns are:
1247+
1. Sub-expression typing directly gives the result (value reductions)
1248+
2. IH on sub-step + reconstruct outer typing rule (congruence)
1249+
3. Region changes (deferred — requires region weakening)
1250+
1251+
We handle the value reduction cases first, then try IH for congruence. *)
1252+
1253+
(* Value reduction cases: the result is already typed by a sub-derivation *)
1254+
(* T_Let, S_Let_Val: result is e2, typed by Htype2 *)
1255+
all: try (match goal with
1256+
| [ Hty2 : _; ctx_extend ?G' ?X ?T1 |- ?E2 : ?T2 -| _ |- _ ] =>
1257+
exists (ctx_extend G' X T1), _; exact Hty2
1258+
end).
1259+
1260+
(* T_If, S_If_True/False: result is e2 or e3, typed directly *)
1261+
all: try (match goal with
1262+
| [ Hty : _; ?G |- ?E : ?T -| ?G' |- context[?E] ] =>
1263+
exists G, G'; exact Hty
1264+
end).
1265+
1266+
(* Congruence: IH gives sub-result, reconstruct *)
1267+
all: try (match goal with
1268+
| [ IH : forall _ _, env_typed _ _ _ -> forall _ _ _ _, _ -> exists _ _, _ |- _ ] =>
1269+
edestruct IH as [?G'' [?Gout ?Hty']]; try eassumption;
1270+
eexists _, _; econstructor; eassumption
1271+
end).
1272+
1273+
(* Anything remaining *)
1274+
all: admit.
12381275
Admitted.
12391276
(* DUST NOTE: Preservation proof outline is complete for the key cases:
12401277
- S_Var: uses env_typed to get well-typed val_to_expr ✓

0 commit comments

Comments
 (0)