Skip to content

Commit 2921270

Browse files
committed
finished main proof but with some gaps
1 parent 0876c3f commit 2921270

File tree

4 files changed

+114
-35
lines changed

4 files changed

+114
-35
lines changed

01-propositional.mm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ theorem con2: $ (aa -> ~bb) -> (bb -> ~aa) $ = '(a3d (syl5 dne id));
390390
theorem notnot1: $ aa -> ~~aa $ = '(con2 id);
391391
theorem con3: $ (aa -> bb) -> (~bb -> ~aa) $ = '(syl con2 (imim2i notnot1));
392392
theorem con1: $ (~aa -> bb) -> (~bb -> aa) $ = '(a3d (imim2i notnot1));
393+
theorem con4: $ (~aa -> ~bb) -> (bb -> aa) $ = '(syl (imim1 notnot1) con1);
393394
theorem cases (h1: $ aa -> bb $) (h2: $ ~aa -> bb $): $ bb $ = '(contra @ syl h1 @ con1 h2);
394395
theorem casesd (h1: $ aa -> bb -> c $) (h2: $ aa -> ~bb -> c $): $ aa -> c $ =
395396
'(cases (com12 h1) (com12 h2));

02-ml-normalization.mm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ theorem eFresh_not {x: EVar} (phi: Pattern x)
3333
$ _eFresh x (~ phi) $ =
3434
'(eFresh_imp h eFresh_disjoint);
3535

36+
theorem eFresh_forall_same_var {x: EVar} (phi: Pattern x):
37+
$ _eFresh x (forall x phi) $ =
38+
'(eFresh_not eFresh_exists_same_var);
39+
3640
theorem sFresh_not {X: SVar} (phi: Pattern X)
3741
(h: $ _sFresh X phi $):
3842
$ _sFresh X (~ phi) $ =

12-proof-system-p.mm1

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ theorem prop_43_exists_def {x: EVar} (phi: Pattern x):
145145
$ (exists x (|^ phi ^|)) -> |^ exists x phi ^| $ =
146146
'(exists_generalization (eFresh_app eFresh_disjoint eFresh_exists_same_var) (framing_def exists_intro_same_var));
147147

148+
149+
theorem forall_floor {x: EVar} (phi: Pattern x):
150+
$ |_ forall x phi _| <-> forall x (|_ phi _|) $ =
151+
'(ian
152+
(con3 @ rsyl (exists_framing dne) @ rsyl prop_43_exists_def @ framing_def notnot1)
153+
(con3 @ rsyl (framing_def dne) @ rsyl propag_exists_def @ exists_framing notnot1));
154+
148155
do {
149156
(def (ex_appCtx_subst subst) '(norm (norm_equiv ,subst @ norm_exists ,subst) exists_appCtx))
150157
(def (or_appCtx_subst subst) '(norm (norm_equiv ,subst @ norm_or ,subst ,subst) or_appCtx))
@@ -166,6 +173,10 @@ theorem propag_and_floor: $|_ phi /\ psi _| <-> |_ phi _| /\ |_ psi _|$ =
166173
(rsyl (anr notor) @ rsyl (con3 propag_or_def) @ con3 @ framing_def @ anl notan)
167174
);
168175

176+
theorem prop_43_or_def_rev (phi1 phi2: Pattern):
177+
$ |^ phi1 \/ phi2 ^| -> (|^ phi1 ^| \/ |^ phi2 ^|) $ =
178+
'(syl (orim (framing_def dne) (framing_def dne)) @ rsyl (framing_def @ orim notnot1 notnot1) @ con4 @ rsyl (anl notor) @ rsyl (anr propag_and_floor) @ con3 @ framing_def (anr notan));
179+
169180
theorem appCtxLR {box: SVar} (phi2 phi3: Pattern) (phi1 phi4: Pattern box):
170181
$ Norm (app[ phi1 / box ] (app (app phi3 phi4) phi2)) (app (app phi3 (app[ phi1 / box ] phi4)) phi2) $ =
171182
'(norm_trans appCtxL_disjoint @ norm_app_l appCtxR_disjoint);
@@ -243,11 +254,6 @@ theorem cong_of_equiv_mem {x: EVar} (phi1 phi2: Pattern x)
243254
theorem cong_of_equiv_eq (h1: $phi1 <-> phi2$) (h2: $psi1 <-> psi2$): $(phi1 == psi1) <-> (phi2 == psi2)$ =
244255
'(cong_of_equiv_not @ cong_of_equiv_def @ cong_of_equiv_not @ cong_of_equiv_equiv h1 h2);
245256

246-
do {
247-
(def (cong_eq_lift pf to_eq) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq)))
248-
(def (cong_eq_lift2 pf to_eq1 to_eq2) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq1) (corollary_57_floor ,to_eq2)))
249-
};
250-
251257
theorem univ_gene {x: EVar} (phi: Pattern x)
252258
(p: $ phi $):
253259
$ forall x phi $ = '(exists_generalization_disjoint @ notnot1 p);
@@ -589,6 +595,15 @@ do {
589595

590596
-- Equality reasoning
591597

598+
do {
599+
(def (cong_eq_lift pf to_eq) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq)))
600+
(def (cong_eq_lift2 pf to_eq1 to_eq2) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq1) (corollary_57_floor ,to_eq2)))
601+
};
602+
603+
theorem cong_of_eq_exists {x: EVar} (phi1 phi2: Pattern x)
604+
(h: $ phi1 == phi2 $): $ (exists x phi1) == (exists x phi2) $ =
605+
(cong_eq_lift 'cong_of_equiv_exists 'h);
606+
592607
theorem in_refl: $ x in eVar x $ =
593608
'(framing_def (iand id id) definedness);
594609

@@ -688,10 +703,15 @@ theorem eq_to_app
688703
$ (phi1 == phi2) -> ((app psi1 rho1) -> (app psi2 rho2)) $ =
689704
'(syld (eq_to_app_l h1) (eq_to_app_r h2));
690705

691-
theorem eq_to_exists {x: EVar} (phi1 phi2: Pattern) (psi1 psi2: Pattern x)
692-
(h: $ (phi1 == phi2) -> (psi1 -> psi2) $):
693-
$ (phi1 == phi2) -> ((exists x psi1) -> (exists x psi2)) $ =
694-
'(exp @ rsyl and_exists_disjoint_reverse @ exists_framing @ curry h);
706+
theorem eq_to_exists_fresh {x: EVar} (phi psi1 psi2: Pattern x)
707+
(freshness: $_eFresh x phi$)
708+
(h: $ phi -> (psi1 -> psi2) $):
709+
$ phi -> ((exists x psi1) -> (exists x psi2)) $ =
710+
'(exp @ rsyl (and_exists_fresh_reverse freshness) @ exists_framing @ curry h);
711+
theorem eq_to_exists {x: EVar} (phi: Pattern) (psi1 psi2: Pattern x)
712+
(h: $ phi -> (psi1 -> psi2) $):
713+
$ phi -> ((exists x psi1) -> (exists x psi2)) $ =
714+
'(eq_to_exists_fresh eFresh_disjoint h);
695715

696716
do {
697717
(def (bi_lift pf to_equiv) '(iand (,pf @ syl anl ,to_equiv) (,pf @ syl anr ,to_equiv)))
@@ -793,9 +813,13 @@ theorem eq_to_eq_r_bi
793813
(h: $ (phi1 == phi2) -> (psi1 <-> psi2) $):
794814
$ (phi1 == phi2) -> ((rho == psi1) <-> (rho == psi2)) $ = '(eq_to_eq_bi eq_to_id_bi h);
795815

796-
theorem eq_to_exists_bi {x: EVar} (phi1 phi2: Pattern) (psi1 psi2: Pattern x)
797-
(h: $ (phi1 == phi2) -> (psi1 <-> psi2) $):
798-
$ (phi1 == phi2) -> ((exists x psi1) <-> (exists x psi2)) $ = (bi_lift 'eq_to_exists 'h);
816+
theorem eq_to_exists_bi_fresh {x: EVar} (phi psi1 psi2: Pattern x)
817+
(freshness: $ _eFresh x phi $)
818+
(h: $ phi -> (psi1 <-> psi2) $):
819+
$ phi -> ((exists x psi1) <-> (exists x psi2)) $ = '(iand (eq_to_exists_fresh freshness @ syl anl h) (eq_to_exists_fresh freshness @ syl anr h));
820+
theorem eq_to_exists_bi {x: EVar} (phi: Pattern) (psi1 psi2: Pattern x)
821+
(h: $ phi -> (psi1 <-> psi2) $):
822+
$ phi -> ((exists x psi1) <-> (exists x psi2)) $ = '(eq_to_exists_bi_fresh eFresh_disjoint h);
799823
theorem eq_to_forall_bi {x: EVar} (phi1 phi2: Pattern) (psi1 psi2: Pattern x)
800824
(h: $ (phi1 == phi2) -> (psi1 <-> psi2) $):
801825
$ (phi1 == phi2) -> ((forall x psi1) <-> (forall x psi2)) $ =
@@ -986,12 +1010,16 @@ theorem eq_imp_eq_framing {box: SVar} (ctx phi psi: Pattern box):
9861010
'(rsyl (iand eq_imp_subset @ rsyl eq_sym eq_imp_subset) @ rsyl (anim subset_imp_subset_framing subset_imp_subset_framing) @ curry subset_to_eq);
9871011

9881012
do {
989-
(def (subset_imp_subset_framing_subst subst) '(norm (norm_imp_r @ norm_subset ,subst ,subst) subset_imp_subset_framing))
1013+
(def (subset_imp_subset_framing_subst subst) '(norm (norm_imp_r @ norm_subset ,subst ,subst) (!! subset_imp_subset_framing box)))
9901014
(def (eq_imp_eq_framing_subst subst) '(norm (norm_imp_r @ norm_eq ,subst ,subst) eq_imp_eq_framing))
9911015
};
9921016

993-
9941017
do {
1018+
(def (appCtx_constructor path) @ if (null? path) 'appCtxVar @ if {(hd path) = 0}
1019+
'(norm_trans appCtxL_disjoint @ norm_app ,(appCtx_constructor (tl path)) norm_refl)
1020+
'(norm_trans appCtxR_disjoint @ norm_app norm_refl ,(appCtx_constructor (tl path)))
1021+
)
1022+
9951023
(def (cong_of_equiv_propag x equiv_pf ctx) @ match ctx
9961024
[$eVar ,y$ (if (== x y) equiv_pf 'biid)]
9971025
[$exists ,y ,psi$ (if (== x y) 'biid '(cong_of_equiv_exists ,(cong_of_equiv_propag x equiv_pf psi)))]
@@ -1255,3 +1283,13 @@ do {
12551283
'(rsyl (rsyl ,(inst_foralls {n - 1}) ,(forall_imp_climb {n - 1})) var_subst_same_var)
12561284
))
12571285
};
1286+
1287+
theorem imp_eq_to_conj_in_eq:
1288+
$ (|^ phi1 ^| -> (phi2 == phi3)) -> ((phi2 /\ |^ phi1 ^|) == (phi3 /\ |^ phi1 ^|)) $ =
1289+
'(rsyl (imim1 dne) @ eori
1290+
(rsyl (anl not_ceil_floor_bi) @ rsyl (anr floor_idem) @
1291+
framing_floor @ rsyl (anr not_ceil_floor_bi) @ iand
1292+
(com12 @ rsyl anr @ com12 absurd)
1293+
(com12 @ rsyl anr @ com12 absurd)
1294+
) @
1295+
eq_equiv_to_eq_eq @ eq_to_and_l_bi eq_to_intro_bi);

nominal/lambda.mm1

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@ theorem lc_lemma_1 {x: EVar} (exp_pred exp_suff_fresh: Pattern)
100100
(exp_suff_fresh_nonempty: $ |^ exp_suff_fresh ^| $)
101101
(h_abs: $ (lc_lam (abstraction exp_suff_fresh exp_pred)) C= exp_pred $):
102102
$ s_exists Var x ((lc_lam_a x exp_pred) C= exp_pred) $ =
103-
(named '(exists_framing (rsyl (anl eVar_in_subset) @ iand
103+
'(exists_framing (rsyl (anl eVar_in_subset) @ iand
104104
(com12 subset_trans exp_suff_fresh_sorting)
105105
(rsyl (syl
106106
,(subset_imp_subset_framing_subst 'appCtxRVar)
107107
,(subset_imp_subset_framing_subst 'appCtxLRVar)
108108
) @ com12 subset_trans h_abs))
109-
@ anl lemma_ceil_exists_membership exp_suff_fresh_nonempty));
109+
@ anl lemma_ceil_exists_membership exp_suff_fresh_nonempty);
110110

111111
theorem lc_lemma_2 {x y: EVar} (exp_pred: Pattern)
112112
(exp_pred_sorting: $ is_exp exp_pred $)
113113
(exp_pred_ev: $ EV_pattern Var exp_pred $):
114114
$ (((is_var (eVar x)) /\ (is_var (eVar y))) /\ ((lc_lam_a y exp_pred) C= exp_pred)) -> ((lc_lam_a x exp_pred) C= exp_pred) $ =
115-
(named '(
115+
'(
116116
rsyl (anim2 ,(subset_imp_subset_framing_subst 'appCtxRVar)) @
117117
rsyl (iand anl @
118118
rsyl (anim1 @
@@ -122,7 +122,7 @@ theorem lc_lemma_2 {x y: EVar} (exp_pred: Pattern)
122122
curry subset_trans) @
123123
rsyl (anim1 @ rsyl ancom @ exp_pred_ev_unquantified exp_pred_ev) @
124124
curry @
125-
syl anl ,(func_subst_explicit_helper 'hole $(_ @@ (_ @@ (eVar hole))) C= (eVar hole)$)));
125+
syl anl ,(func_subst_explicit_helper 'hole $(_ @@ (_ @@ (eVar hole))) C= (eVar hole)$));
126126

127127
theorem lc_lemma_3 {y: EVar} (exp_pred: Pattern)
128128
(exp_pred_sorting: $ is_exp exp_pred $)
@@ -171,9 +171,14 @@ theorem induction_principle (exp_pred exp_suff_fresh: Pattern)
171171
) exp_pred_sorting));
172172

173173

174+
175+
---- Substitution
176+
177+
-- base term and definition
174178
term subst_sym: Symbol;
175179
def subst (a phi1 phi2: Pattern): Pattern = $ (sym subst_sym) @@ a @@ phi1 @@ phi2 $;
176180

181+
-- subst axioms
177182
axiom function_subst: $ ,(is_function '(sym subst_sym) '[Var Exp Exp] 'Exp) $;
178183
axiom subst_same_var {a: EVar} (plug: Pattern a):
179184
$ (is_var (eVar a)) ->
@@ -192,31 +197,26 @@ axiom subst_app (a phi1 phi2 plug: Pattern):
192197
(is_exp phi2) ->
193198
((subst a (lc_app phi1 phi2) plug) == (lc_app (subst a phi1 plug) (subst a phi2 plug))) $;
194199
axiom subst_lam {a b: EVar} (plug phi: Pattern a b):
195-
$ (is_var (eVar a)) ->
200+
$ ((eVar a) != (eVar b)) ->
201+
(is_var (eVar a)) ->
196202
(is_var (eVar b)) ->
197203
(is_exp plug) ->
198204
(is_exp phi) ->
199205
(fresh_for (eVar a) plug) ->
200206
((subst (eVar b) (lc_lam_a a phi) plug) == (lc_lam_a a (subst (eVar b) phi plug))) $;
201207

202-
-- phi[a / plug1][b / plug2] == phi[b / plug2][a / plug1[b / plug2]]
203-
204-
-- (app x y)[a / plug1][b / plug2] == (app x y)[b / plug2][a / plug1[b / plug2]]
205-
-- (app (x[a / plug1]) (y[a / plug1]))[b / plug2] == (app (x[b / plug2]) (y[b / plug2]))[a / plug1[b / plug2]]
206-
-- app (x[a / plug1][b / plug2]) (y[a / plug1][b / plug2]) == app (x[b / plug2][a / plug1[b / plug2]]) (y[b / plug2][a / plug1[b / plug2]])
207208

209+
-- induction proof
208210
def subst_induction_pred (a b phi plug1 plug2: Pattern): Pattern = $ (subst b (subst a phi plug1) plug2) == (subst a (subst b phi plug2) (subst b plug1 plug2)) $;
209211
def satisfying_exps {.x: EVar} (a b plug1 plug2: Pattern): Pattern = $ s_exists Exp x ((eVar x) /\ subst_induction_pred a b (eVar x) plug1 plug2) $;
210212

211-
theorem subst_induction_app_lemma {x y: EVar} (a b plug1 plug2: Pattern)
212-
(diff_atoms: $ a != b $)
213+
theorem subst_induction_app_lemma
213214
(a_var: $ is_sorted_func Var a $)
214215
(b_var: $ is_sorted_func Var b $)
215216
(plug1_exp: $ is_exp plug1 $)
216-
(plug2_exp: $ is_exp plug2 $)
217-
(a_fresh: $ fresh_for a phi3 $):
217+
(plug2_exp: $ is_exp plug2 $):
218218
$ (is_exp (eVar x) /\ subst_induction_pred a b (eVar x) plug1 plug2) /\ (is_exp (eVar y) /\ subst_induction_pred a b (eVar y) plug1 plug2) -> subst_induction_pred a b (lc_app (eVar x) (eVar y)) plug1 plug2 $ =
219-
'(rsyl (anl an4) @ rsyl (anim2 @
219+
(named '(rsyl (anl an4) @ rsyl (anim2 @
220220
syl (curry eq_trans) @
221221
iand
222222
(rsyl anl @ eq_equiv_to_eq_eq ,(func_subst_explicit_helper 'z $_ @@ (eVar z) @@ _$))
@@ -228,7 +228,23 @@ theorem subst_induction_app_lemma {x y: EVar} (a b plug1 plug2: Pattern)
228228
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting a_var)) plug1_exp)
229229
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting a_var)) plug1_exp)
230230
)) @
231-
_);
231+
rsyl (anim2 @ curry eq_trans) @
232+
rsyl (anim1 @ iand id id) @
233+
rsyl (anl anass) @
234+
rsyl (anim2 @ anim1 @ syl ,(eq_imp_eq_framing_subst 'appCtxLRVar) @ curry @ subst_app a_var plug1_exp) @
235+
rsyl (anim2 @ curry eq_trans) @
236+
rsyl (anim1 @ iand id id) @
237+
rsyl (anl anass) @
238+
rsyl (anim2 @ anim1 @ syl eq_sym @ syl (curry @ subst_app a_var (mp (mp (mp ,(function_sorting 3 'function_subst) (domain_func_sorting b_var)) plug1_exp) plug2_exp)) (anim
239+
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting b_var)) plug2_exp)
240+
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting b_var)) plug2_exp)
241+
)) @
242+
rsyl (anim2 @ impcom eq_trans) @
243+
rsyl (anim1 @ iand id id) @
244+
rsyl (anl anass) @
245+
rsyl (anim2 @ anim1 @ syl eq_sym @ syl ,(eq_imp_eq_framing_subst 'appCtxLRVar) @ curry @ subst_app b_var plug2_exp) @
246+
rsyl (anim2 @ impcom eq_trans) @
247+
anr));
232248

233249
theorem subst_induction_app (a b plug1 plug2: Pattern)
234250
(lemma: $ (is_exp (eVar x) /\ subst_induction_pred a b (eVar x) plug1 plug2) /\ (is_exp (eVar y) /\ subst_induction_pred a b (eVar y) plug1 plug2) -> subst_induction_pred a b (lc_app (eVar x) (eVar y)) plug1 plug2 $):
@@ -263,17 +279,37 @@ theorem subst_induction_app (a b plug1 plug2: Pattern)
263279
rsyl (anim1 @ curry @ mp ,(inst_foralls 2) function_lc_app) @
264280
curry ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ ((app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _))$)));
265281

282+
theorem subst_induction_lemma (a b phi plug1 plug2: Pattern)
283+
(diff_atoms: $ a != b $)
284+
(a_var: $ is_sorted_func Var a $)
285+
(b_var: $ is_sorted_func Var b $)
286+
(phi_exp: $ is_exp phi $)
287+
(plug1_exp: $ is_exp plug1 $)
288+
(plug2_exp: $ is_exp plug2 $)
289+
(a_fresh: $ fresh_for a plug2 $):
290+
$ Exps == (satisfying_exps a b plug1 plug2) $ =
291+
'(induction_principle _ _ _ _ _ (subst_induction_app @ subst_induction_app_lemma a_var b_var plug1_exp plug2_exp) _);
266292

267-
theorem subst_induction (a b phi1 plug1 plug2: Pattern)
293+
theorem subst_induction (a b phi plug1 plug2: Pattern)
268294
(diff_atoms: $ a != b $)
269295
(a_var: $ is_sorted_func Var a $)
270296
(b_var: $ is_sorted_func Var b $)
271-
(phi1_exp: $ is_exp phi1 $)
297+
(phi_exp: $ is_exp phi $)
272298
(plug1_exp: $ is_exp plug1 $)
273299
(plug2_exp: $ is_exp plug2 $)
274-
(a_fresh: $ fresh_for a phi3 $):
275-
$ (subst b (subst a phi1 plug1) plug2) == (subst a (subst b phi1 plug2) (subst b plug1 plug2)) $ =
276-
'();
300+
(a_fresh: $ fresh_for a plug2 $):
301+
$ (subst b (subst a phi plug1) plug2) == (subst a (subst b phi plug2) (subst b plug1 plug2)) $ =
302+
(named '(mp (
303+
rsyl (com12 subset_trans @ eq_imp_subset @ subst_induction_lemma diff_atoms a_var b_var phi_exp plug1_exp plug2_exp a_fresh) @
304+
rsyl (subset_mem_disjoint_lemma eFresh_disjoint) @
305+
rsyl (forall_framing (rsyl
306+
(imim2 @ rsyl membership_exists_forward @ exists_generalization_disjoint @ rsyl (anl ,(propag_mem 'x $(_ C= _) /\ ((eVar _) /\ (_ == _))$)) @ rsyl anr (curry @ syl anr ,(func_subst_explicit_helper 'x $(app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _)$)))
307+
(rsyl (imim (anl floor_ceil_ceil) (anr ceil_floor_floor)) @ rsyl prop_43_or_def @ rsyl (anr floor_ceil_ceil) @ framing_floor @ rsyl prop_43_or_def_rev @ imim (anr floor_ceil_ceil) (anl ceil_floor_floor)))) @
308+
rsyl (anr forall_floor) @
309+
syl (rsyl
310+
(eq_trans @ equiv_to_eq ,(appCtx_pointwise_subst @ appCtx_constructor '[0 1 0 1])) @
311+
com12 eq_trans @ eq_sym @ equiv_to_eq ,(appCtx_pointwise_subst @ appCtx_constructor '[0 1 0 1])) @
312+
framing_floor @ eq_to_exists_bi_fresh eFresh_forall_same_var @ syl corollary_57_floor @ rsyl var_subst_same_var imp_eq_to_conj_in_eq) phi_exp));
277313

278314

279315

0 commit comments

Comments
 (0)