Skip to content

Commit 0876c3f

Browse files
committed
proved the first chunk of subst_induction
1 parent 138a5d3 commit 0876c3f

File tree

5 files changed

+227
-52
lines changed

5 files changed

+227
-52
lines changed

02-ml-normalization.mm1

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,29 @@ theorem forall_framing {x: EVar} (phi1 phi2: Pattern x)
183183
$ (forall x phi1) -> forall x phi2 $ =
184184
'(con3 @ exists_framing @ con3 h);
185185

186-
theorem or_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
186+
theorem disjoint_forall: $ phi -> forall x phi $ = '(con2 @ exists_generalization_disjoint id);
187+
188+
theorem or_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
187189
$ (phi1 \/ exists x phi2) <-> exists x (phi1 \/ phi2) $ =
188190
'(ibii
189191
(eori
190192
(syl exists_intro_same_var orl)
191193
(exists_generalization eFresh_exists_same_var @ syl exists_intro_same_var orr))
192-
(exists_generalization (eFresh_or eFresh_disjoint eFresh_exists_same_var) @ eori orl @ orrd exists_intro_same_var));
194+
(exists_generalization (eFresh_or freshness_phi1 eFresh_exists_same_var) @ eori orl @ orrd exists_intro_same_var));
193195

194-
theorem imp_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
196+
theorem or_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
197+
$ (phi1 \/ exists x phi2) <-> exists x (phi1 \/ phi2) $ =
198+
'(or_exists_fresh eFresh_disjoint);
199+
200+
theorem imp_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
195201
$ (phi1 -> exists x phi2) <-> exists x (phi1 -> phi2) $ =
196202
'(ibii
197-
(rsyl (imim1 dne) @ rsyl (anl or_exists_disjoint) @ exists_framing @ imim1 notnot1)
198-
(rsyl (exists_framing @ imim1 dne) @ rsyl (anr or_exists_disjoint) @ imim1 notnot1));
203+
(rsyl (imim1 dne) @ rsyl (anl @ or_exists_fresh @ eFresh_not freshness_phi1) @ exists_framing @ imim1 notnot1)
204+
(rsyl (exists_framing @ imim1 dne) @ rsyl (anr @ or_exists_fresh @ eFresh_not freshness_phi1) @ imim1 notnot1));
205+
206+
theorem imp_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
207+
$ (phi1 -> exists x phi2) <-> exists x (phi1 -> phi2) $ =
208+
'(imp_exists_fresh eFresh_disjoint);
199209

200210
theorem and_exists {x: EVar} (phi1 phi2: Pattern x):
201211
$ (exists x (phi1 /\ phi2)) -> ((exists x phi1) /\ (exists x phi2)) $ =
@@ -212,14 +222,23 @@ theorem or_exists_bi {x: EVar} (phi1 phi2: Pattern x):
212222
$ (exists x (phi1 \/ phi2)) <-> ((exists x phi1) \/ (exists x phi2)) $ =
213223
'(ibii or_exists_forwards or_exists_reverse);
214224

215-
theorem and_exists_disjoint_forwards {x: EVar} (phi1: Pattern) (phi2: Pattern x):
225+
theorem and_exists_fresh_forwards {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
216226
$ (exists x (phi1 /\ phi2)) -> (phi1 /\ exists x phi2) $ =
217227
'(iand
218-
(rsyl (exists_framing anl) (exists_generalization_disjoint id))
228+
(rsyl (exists_framing anl) (exists_generalization freshness_phi1 id))
219229
(exists_framing anr));
230+
theorem and_exists_disjoint_forwards {x: EVar} (phi1: Pattern) (phi2: Pattern x):
231+
$ (exists x (phi1 /\ phi2)) -> (phi1 /\ exists x phi2) $ =
232+
'(and_exists_fresh_forwards eFresh_disjoint);
233+
theorem and_exists_fresh_reverse {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
234+
$ (phi1 /\ exists x phi2) -> (exists x (phi1 /\ phi2)) $ =
235+
'(impcom @ syl (anr @ imp_exists_fresh freshness_phi1) (exists_framing ian2));
220236
theorem and_exists_disjoint_reverse {x: EVar} (phi1: Pattern) (phi2: Pattern x):
221237
$ (phi1 /\ exists x phi2) -> (exists x (phi1 /\ phi2)) $ =
222-
'(impcom @ syl (anr imp_exists_disjoint) (exists_framing ian2));
238+
'(and_exists_fresh_reverse eFresh_disjoint);
239+
theorem and_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
240+
$ (exists x (phi1 /\ phi2)) <-> (phi1 /\ exists x phi2) $ =
241+
'(ibii (and_exists_fresh_forwards freshness_phi1) (and_exists_fresh_reverse freshness_phi1));
223242
theorem and_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
224243
$ (exists x (phi1 /\ phi2)) <-> (phi1 /\ exists x phi2) $ =
225244
'(ibii and_exists_disjoint_forwards and_exists_disjoint_reverse);

12-proof-system-p.mm1

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ theorem eFresh_mem {x y: EVar} (phi: Pattern x y)
2121
theorem eFresh_ctximp_same_var {box: SVar} (ctx phi: Pattern box):
2222
$ _eFresh x (ctximp_app box ctx phi) $ =
2323
'(eFresh_exists_same_var);
24+
theorem eFresh_subset {x: EVar} (phi psi: Pattern x)
25+
(h1: $ _eFresh x phi $)
26+
(h2: $ _eFresh x psi $):
27+
$ _eFresh x (phi C= psi) $ =
28+
'(eFresh_not @ eFresh_ceil @ eFresh_not @ eFresh_imp h1 h2);
2429

2530
theorem sFresh_ceil {X: SVar} (phi: Pattern X)
2631
(h: $ _sFresh X phi $):
@@ -114,6 +119,12 @@ theorem prop_43_exists {box: SVar} {x: EVar} (ctx: Pattern box) (phi: Pattern bo
114119
$ (exists x (app[ phi / box ] ctx)) -> app[ exists x phi / box ] ctx $ =
115120
'(exists_generalization (eFresh_appCtx eFresh_disjoint eFresh_exists_same_var) (framing exists_intro_same_var));
116121

122+
theorem prop_43_exists_fresh {box: SVar} {x: EVar} (ctx phi: Pattern box x)
123+
(ctx_fresh: $ _eFresh x ctx $):
124+
$ (exists x (app[ phi / box ] ctx)) -> app[ exists x phi / box ] ctx $ =
125+
'(exists_generalization (eFresh_appCtx ctx_fresh eFresh_exists_same_var) (framing exists_intro_same_var));
126+
127+
117128
theorem exists_appCtx {x: EVar} {box: SVar} (ctx: Pattern box) (phi: Pattern x):
118129
$ (app[ exists x phi / box ] ctx) <-> exists x (app[ phi / box ] ctx) $ =
119130
'(ibii propag_exists_disjoint prop_43_exists);
@@ -246,6 +257,16 @@ theorem var_subst {x y: EVar} (phi: Pattern x y):
246257
theorem var_subst_same_var {x: EVar} (phi: Pattern x):
247258
$ (forall x phi) -> phi $ = '(con1 exists_intro_same_var);
248259

260+
261+
theorem imp_forall_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
262+
$ (phi1 -> forall x phi2) <-> forall x (phi1 -> phi2) $ =
263+
'(con2b @ bitr (cong_of_equiv_exists @ con3b @ imeq2i notnot) @ and_exists_fresh freshness_phi1);
264+
265+
theorem imp_forall {x: EVar} (phi1: Pattern) (phi2: Pattern x):
266+
$ (phi1 -> forall x phi2) <-> forall x (phi1 -> phi2) $ =
267+
'(imp_forall_fresh eFresh_disjoint);
268+
269+
249270
theorem lemma_46 (phi: Pattern) {box: SVar} (ctx: Pattern box)
250271
(p : $ phi $):
251272
$ ~ (app[ (~ phi) / box ] ctx) $ = '(syl propag_bot @ framing @ notnot1 p);
@@ -555,7 +576,7 @@ theorem lemma_14 {box: SVar} (ctx psi phi1 phi2: Pattern box)
555576
(imim2 @ norm (norm_imp_l @ norm_trans appCtxNested_disjoint @ norm_ctxApp_pt norm_refl defNorm) (! lemma_56 box2))
556577
);
557578

558-
theorem appCtx_pointwise {box: SVar} (ctx: Pattern box) (phi: Pattern):
579+
theorem appCtx_pointwise {box: SVar} {x: EVar} (ctx: Pattern box) (phi: Pattern):
559580
$ app[ phi / box ] ctx <-> exists x ((app[ eVar x / box ] ctx) /\ x in phi) $ =
560581
'(bitr (cong_of_equiv_appCtx (bicom lemma_62)) @
561582
bitr exists_appCtx @
@@ -1027,6 +1048,12 @@ do {
10271048
(def (func_subst x phi1 phi1_pf func_phi2) '(
10281049
exists_generalization_disjoint (mp (com12 @ syl anl ,(func_subst_explicit_helper x phi1)) ,phi1_pf) ,func_phi2
10291050
))
1051+
(def (func_subst_alt x phi1 func_phi2) '(
1052+
anr imp_exists_disjoint (mp (exists_framing @ syl anr ,(func_subst_explicit_helper x phi1)) ,func_phi2)
1053+
))
1054+
(def (func_subst_alt_thm_sorted x phi1) '(
1055+
syl (rsyl (exists_framing imancom) (anr imp_exists_disjoint)) @ exists_framing @ anim2 @ syl anr ,(func_subst_explicit_helper x phi1)
1056+
))
10301057
(def (func_subst_thm func_phi2 x phi1) '(
10311058
exists_generalization_disjoint (mp (com12 @ syl anl ,(func_subst_explicit_helper x (nth 4 @ get-decl phi1))) ,phi1) ,func_phi2
10321059
))
@@ -1101,6 +1128,12 @@ theorem propag_mem_test_12 {x y z: EVar}:
11011128
(propag_mem 'x $~(app (sym defSym) (bot -> eVar y))$);
11021129

11031130

1131+
1132+
theorem eq_equiv_to_eq_eq
1133+
(eq_equiv: $ (phi1 == phi2) -> (psi1 <-> psi2) $):
1134+
$ (phi1 == phi2) -> (psi1 == psi2) $ =
1135+
'(syl (framing_floor eq_equiv) @ anr floor_idem);
1136+
11041137
theorem lemma_14_subset {box: SVar} (ctx psi phi1 phi2: Pattern box)
11051138
(h: $ |_ psi _| -> (phi1 C= phi2) $):
11061139
$ |_ psi _| -> ((app[ phi1 / box ] ctx) C= app[ phi2 / box ] ctx) $ =
@@ -1208,4 +1241,17 @@ theorem pointwise_decomposition_imp {box: SVar} {x: EVar} (ctx: Pattern box) (ph
12081241

12091242
do {
12101243
(def (pointwise_decomposition_imp_subst subst) '(norm (norm_imp (norm_forall @ norm_imp_r @ norm_subset ,subst norm_refl) @ norm_subset ,subst norm_refl) pointwise_decomposition_imp))
1211-
};
1244+
};
1245+
1246+
theorem subset_mem_disjoint_lemma {x: EVar} (phi: Pattern) (psi: Pattern x)
1247+
(freshness_psi: $ _eFresh x psi $):
1248+
$ (phi C= psi) -> forall x ((x in phi) -> x in psi) $ =
1249+
'(anr (imp_forall_fresh @ eFresh_subset eFresh_disjoint freshness_psi) @ univ_gene @ com12 @ rsyl eVar_in_subset_forward @ rsyl subset_trans @ imim2 eVar_in_subset_reverse);
1250+
1251+
do {
1252+
(def (forall_imp_climb n) (iterate n (fn (pf) '(syl (anl imp_forall) @ imim2 ,pf)) 'id))
1253+
1254+
(def (inst_foralls n) (if {n = 0} 'id
1255+
'(rsyl (rsyl ,(inst_foralls {n - 1}) ,(forall_imp_climb {n - 1})) var_subst_same_var)
1256+
))
1257+
};

nominal/core.mm1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ term abstraction_sym: Symbol;
2727
def abstraction (phi rho: Pattern): Pattern = $ (sym abstraction_sym) @@ phi @@ rho $;
2828
term supp_sym: Symbol;
2929
def supp (phi: Pattern): Pattern = $ (sym supp_sym) @@ phi $;
30-
def fresh_for {a: EVar} (phi: Pattern a): Pattern a = $ ~ (a in supp phi) $;
30+
def fresh_for (phi psi: Pattern): Pattern = $ ~ (phi C= supp psi) $;
3131

3232
def EV_pattern {.a .b: EVar} (alpha phi: Pattern): Pattern =
3333
$ s_forall alpha a (s_forall alpha b ((swap a b phi) == phi)) $;
@@ -88,25 +88,24 @@ axiom F1 (alpha tau: Pattern) {a b: EVar} (phi: Pattern a b):
8888
$ (is_atom a alpha) ->
8989
(is_atom b alpha) ->
9090
(is_of_sort phi tau) ->
91-
((fresh_for a phi) /\ (fresh_for b phi) -> ((swap a b phi) == phi)) $;
92-
axiom F23 (alpha1 alpha2: Pattern) {a b: EVar}:
91+
((fresh_for (eVar a) phi) /\ (fresh_for (eVar b) phi) -> ((swap a b phi) == phi)) $;
92+
axiom F2 (alpha: Pattern) {a b: EVar}:
93+
$ is_atom_sort alpha $ >
94+
$ (is_atom a alpha) ->
95+
(is_atom b alpha) ->
96+
(((eVar a) != (eVar b)) <-> (fresh_for (eVar a) (eVar b))) $;
97+
axiom F3 (alpha1 alpha2: Pattern) {a b: EVar}:
9398
$ is_atom_sort alpha1 $ >
9499
$ is_atom_sort alpha2 $ >
95100
$ (is_atom a alpha1) ->
96101
(is_atom b alpha2) ->
97-
(fresh_for a (eVar b)) $;
102+
(alpha1 != alpha2) ->
103+
((eVar a) != (eVar b)) $;
98104
axiom F4 (alpha tau phi: Pattern) {a: EVar}:
99105
$ is_atom_sort alpha $ >
100106
$ is_nominal_sort tau $ >
101107
$ (is_of_sort phi tau) ->
102-
(s_exists alpha a (fresh_for a phi)) $;
103-
axiom A1_same (alpha tau: Pattern) {a: EVar} (phi rho: Pattern a):
104-
$ is_atom_sort alpha $ >
105-
$ is_nominal_sort tau $ >
106-
$ (is_atom a alpha) ->
107-
(is_of_sort phi tau) ->
108-
(is_of_sort rho tau) ->
109-
(((abstraction (eVar a) phi) == (abstraction (eVar a) rho)) <-> (phi == rho)) $;
108+
(s_exists alpha a (fresh_for (eVar a) phi)) $;
110109
axiom A1 (alpha tau: Pattern) {a b: EVar} (phi rho: Pattern a b):
111110
$ is_atom_sort alpha $ >
112111
$ is_nominal_sort tau $ >
@@ -115,7 +114,8 @@ axiom A1 (alpha tau: Pattern) {a b: EVar} (phi rho: Pattern a b):
115114
(is_of_sort phi tau) ->
116115
(is_of_sort rho tau) ->
117116
(((abstraction (eVar a) phi) == (abstraction (eVar b) rho)) <->
118-
((fresh_for a rho) /\ ((swap a b phi) == rho))) $;
117+
((eVar a == eVar b) /\ (phi == rho)) \/
118+
((fresh_for (eVar a) rho) /\ ((swap a b phi) == rho))) $;
119119
axiom A2 (alpha tau: Pattern) {x a y: EVar}:
120120
$ is_atom_sort alpha $ >
121121
$ is_nominal_sort tau $ >

0 commit comments

Comments
 (0)