Skip to content

Commit b0ea5c7

Browse files
committed
almost finished proof
1 parent 2921270 commit b0ea5c7

File tree

2 files changed

+99
-53
lines changed

2 files changed

+99
-53
lines changed

12-proof-system-p.mm1

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ theorem swap_exists {x y: EVar} (phi: Pattern x y): $ exists x (exists y phi) ->
111111
theorem swap_exists_bi {x y: EVar} (phi: Pattern x y): $ exists x (exists y phi) <-> exists y (exists x phi) $ =
112112
'(ibii swap_exists swap_exists);
113113

114+
115+
theorem swap_forall {x y: EVar} (phi: Pattern x y): $ forall x (forall y phi) -> forall y (forall x phi) $ =
116+
'(con3 @ rsyl (exists_framing dne) @ rsyl swap_exists @ exists_framing notnot1);
117+
118+
theorem swap_forall_bi {x y: EVar} (phi: Pattern x y): $ forall x (forall y phi) <-> forall y (forall x phi) $ =
119+
'(ibii swap_forall swap_forall);
120+
114121
theorem prop_43_bot (rho: Pattern): $ bot -> rho $ = 'absurdum;
115122
theorem prop_43_or {box: SVar} (ctx: Pattern box) (phi1 phi2: Pattern):
116123
$ (app[ phi1 / box ] ctx \/ app[ phi2 / box ] ctx) -> app[ phi1 \/ phi2 / box ] ctx $ =
@@ -1218,9 +1225,9 @@ theorem domain_func_sorting {x: EVar} (phi psi: Pattern):
12181225
rsyl (anim2 @ rsyl eq_sym eq_imp_subset) @
12191226
impcom subset_trans);
12201227

1221-
theorem forall_exists_lemma {box: SVar} {x: EVar} (ctx: Pattern box) (phi: Pattern):
1222-
$ ( forall x ((app[ (eVar x) / box ] ctx) C= phi)) ->
1223-
((exists x (app[ (eVar x) / box ] ctx)) C= phi ) $ =
1228+
theorem forall_exists_lemma (phi psi: Pattern):
1229+
$ ( forall x (phi C= psi)) ->
1230+
((exists x phi) C= psi ) $ =
12241231
'(con3 @
12251232
rsyl (framing_def @ con3 @ imim2 dne) @
12261233
rsyl (framing_def and_exists_disjoint_r_reverse) @
@@ -1231,9 +1238,21 @@ theorem forall_exists_lemma {box: SVar} {x: EVar} (ctx: Pattern box) (phi: Patte
12311238
con3 @
12321239
imim2 notnot1);
12331240

1234-
theorem forall_exists_lemma_domain {box: SVar} {x: EVar} (ctx: Pattern box) (phi psi: Pattern):
1235-
$ ( forall x (((eVar x) C= psi) -> ((app[ (eVar x) / box ] ctx) C= phi))) ->
1236-
((exists x (((eVar x) C= psi) /\ (app[ (eVar x) / box ] ctx))) C= phi ) $ =
1241+
theorem forall_exists_lemma_rev (phi psi: Pattern):
1242+
$ ((exists x phi) C= psi ) ->
1243+
( forall x (phi C= psi)) $ =
1244+
'(con3 @
1245+
syl (framing_def @ con3 @ imim2 notnot1) @
1246+
syl (framing_def @ and_exists_disjoint_r_forwards) @
1247+
syl prop_43_exists_def @
1248+
exists_framing @
1249+
con1 @
1250+
framing_floor @
1251+
imim2 dne);
1252+
1253+
theorem forall_exists_lemma_domain {x: EVar} (phi rho: Pattern x) (psi: Pattern):
1254+
$ ( forall x (((eVar x) C= rho) -> (phi C= psi))) ->
1255+
((exists x (((eVar x) C= rho) /\ phi)) C= psi ) $ =
12371256
'(con3 @
12381257
rsyl (framing_def @ con3 @ imim2 dne) @
12391258
rsyl (framing_def and_exists_disjoint_r_reverse) @
@@ -1293,3 +1312,12 @@ theorem imp_eq_to_conj_in_eq:
12931312
(com12 @ rsyl anr @ com12 absurd)
12941313
) @
12951314
eq_equiv_to_eq_eq @ eq_to_and_l_bi eq_to_intro_bi);
1315+
1316+
theorem swap_sorted_forall {x y: EVar} (phi: Pattern x y) (phi_x: Pattern x) (phi_y: Pattern y):
1317+
$ forall x (phi_x -> (forall y (phi_y -> phi))) -> forall y (phi_y -> (forall x (phi_x -> phi))) $ =
1318+
'(
1319+
rsyl (forall_framing @ anl imp_forall) @
1320+
rsyl swap_forall @
1321+
forall_framing @
1322+
rsyl (forall_framing @ anl com12b) @
1323+
anr imp_forall);

nominal/lambda.mm1

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,40 @@ axiom subst_diff_var {a b: EVar} (plug: Pattern a b):
190190
((eVar a) != (eVar b)) ->
191191
(is_exp plug) ->
192192
((subst (eVar b) (lc_var (eVar a)) plug) == (lc_var (eVar a))) $;
193+
axiom subst_var {a b: EVar} (plug: Pattern a b):
194+
$ (is_var (eVar a)) ->
195+
(is_var (eVar b)) ->
196+
((eVar a) == (eVar b)) ->
197+
(is_exp plug) ->
198+
((subst (eVar b) (lc_var (eVar a)) plug) == plug) $;
193199
axiom subst_app (a phi1 phi2 plug: Pattern):
194200
$ (is_sorted_func Var a) ->
195201
(is_exp plug) ->
196202
(is_exp phi1) ->
197203
(is_exp phi2) ->
198204
((subst a (lc_app phi1 phi2) plug) == (lc_app (subst a phi1 plug) (subst a phi2 plug))) $;
205+
axiom subst_lam_same_var {a: EVar} (plug phi: Pattern a):
206+
$ (is_var (eVar a)) ->
207+
(is_exp plug) ->
208+
(is_exp phi) ->
209+
(fresh_for (eVar a) plug) ->
210+
((subst (eVar a) (lc_lam_a a phi) plug) == (lc_lam_a a phi)) $;
211+
axiom subst_lam_diff_var (a b plug phi: Pattern):
212+
$ (a != b) ->
213+
(fresh_for a plug) ->
214+
(is_sorted_func Var a) ->
215+
(is_sorted_func Var b) ->
216+
(is_exp plug) ->
217+
(is_exp phi) ->
218+
((subst b (lc_lam (abstraction a phi)) plug) == (lc_lam (abstraction a (subst b phi plug)))) $;
199219
axiom subst_lam {a b: EVar} (plug phi: Pattern a b):
200-
$ ((eVar a) != (eVar b)) ->
220+
$ ((eVar a) == (eVar b)) ->
201221
(is_var (eVar a)) ->
202222
(is_var (eVar b)) ->
203223
(is_exp plug) ->
204224
(is_exp phi) ->
205225
(fresh_for (eVar a) plug) ->
206-
((subst (eVar b) (lc_lam_a a phi) plug) == (lc_lam_a a (subst (eVar b) phi plug))) $;
226+
((subst (eVar b) (lc_lam_a a phi) plug) == (lc_lam_a a phi)) $;
207227

208228

209229
-- induction proof
@@ -277,7 +297,49 @@ theorem subst_induction_app (a b plug1 plug2: Pattern)
277297
rsyl (anim2 @ anim1 lemma) @
278298
rsyl (anim2 @ ancom) @
279299
rsyl (anim1 @ curry @ mp ,(inst_foralls 2) function_lc_app) @
280-
curry ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ ((app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _))$)));
300+
curry ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ ((app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _))$)
301+
));
302+
303+
-- (lam c phi)[a / plug1][b / plug2] == lam
304+
305+
theorem subst_induction_lam_lemma (a b c plug1 plug2: Pattern)
306+
(diff_atoms_ab: $ a != b $)
307+
(diff_atoms_bc: $ b != c $)
308+
(diff_atoms_ca: $ c != a $)
309+
(a_var: $ is_sorted_func Var a $)
310+
(b_var: $ is_sorted_func Var b $)
311+
(c_var: $ is_sorted_func Var c $)
312+
(c_fresh_in_plug1: $ fresh_for c plug1 $)
313+
(phi_exp: $ is_exp phi $)
314+
(plug1_exp: $ is_exp plug1 $)
315+
(plug2_exp: $ is_exp plug2 $)
316+
(a_fresh: $ fresh_for a plug2 $):
317+
$ is_exp (eVar x) /\ subst_induction_pred a b (eVar x) plug1 plug2 -> subst_induction_pred a b (lc_lam (abstraction c (eVar x))) plug1 plug2 $ =
318+
'(rsyl (anim1 @ iand id id) @
319+
rsyl (anl anass) @
320+
rsyl (anim2 @ anim1 @ syl (subst_lam_diff_var diff_atoms_ca c_fresh_in_plug1 c_var a_var plug1_exp) @ rsyl (mp ,(function_sorting 2 '(function_abstraction Var_atom Exp_sort)) (domain_func_sorting c_var)) ,(function_sorting 1 'function_lc_lam)) @
321+
rsyl (anim2 @ _)
322+
_);
323+
324+
theorem subst_induction_lam (a b c plug1 plug2: Pattern)
325+
(c_sorting: $ is_sorted_func Var c $)
326+
(lemma: $ is_exp (eVar x) /\ subst_induction_pred a b (eVar x) plug1 plug2 -> subst_induction_pred a b (lc_lam (abstraction c (eVar x))) plug1 plug2 $):
327+
$ (lc_lam (abstraction c (satisfying_exps a b plug1 plug2))) C= (satisfying_exps a b plug1 plug2) $ =
328+
(named '(imp_to_subset @
329+
rsyl (anl ,(ex_appCtx_subst @ appCtx_constructor '[1 1])) @
330+
exists_generalization_disjoint @
331+
rsyl ,(appCtx_floor_commute_b_subst @ appCtx_constructor '[1 1]) @
332+
rsyl (anim2 ,(appCtx_floor_commute_subst @ appCtx_constructor '[1 1])) @
333+
rsyl (anim1 @ iand id id) @
334+
rsyl (anl anass) @
335+
rsyl (anim2 @ rsyl (anl anlass) @ anim2 lemma) @
336+
rsyl (anim1 @ rsyl (mp ,(inst_foralls 1) (swap_sorted_forall @ function_abstraction Var_atom Exp_sort))
337+
(rsyl (con1 @ anr imp_exists_disjoint (exists_framing (syl con3 @ syl anl ,(func_subst_explicit_helper 'x $((eVar x) C= _) -> exists _ (_ /\ (_ == (_ @@ (eVar x) @@ _)))$)) (exists_framing anr c_sorting))) @ rsyl (mpcom @ domain_func_sorting c_sorting) @
338+
exists_generalization_disjoint @ rsyl (anim1 @ var_subst_same_var function_lc_lam) @ impcom @ syl anl ,(func_subst_explicit_helper 'x $exists _ (_ /\ (_ == (_ @@ (eVar x))))$))
339+
) @
340+
curry ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ ((app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _))$)
341+
));
342+
281343

282344
theorem subst_induction_lemma (a b phi plug1 plug2: Pattern)
283345
(diff_atoms: $ a != b $)
@@ -310,47 +372,3 @@ theorem subst_induction (a b phi plug1 plug2: Pattern)
310372
(eq_trans @ equiv_to_eq ,(appCtx_pointwise_subst @ appCtx_constructor '[0 1 0 1])) @
311373
com12 eq_trans @ eq_sym @ equiv_to_eq ,(appCtx_pointwise_subst @ appCtx_constructor '[0 1 0 1])) @
312374
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));
313-
314-
315-
316-
term reduce_sym: Symbol;
317-
def reduce (phi: Pattern): Pattern = $ (sym reduce_sym) @@ phi $;
318-
319-
-- axiom reduce_subst {a: EVar} (phi1 phi2: Pattern a):
320-
-- $
321-
-- (reduce (lc_app (lc_lam_a a phi1) phi2)) == () $;
322-
323-
324-
325-
326-
-- term red_sym: Symbol;
327-
-- def red (phi: Pattern) : Pattern = $ (sym red_sym) @@ phi $;
328-
329-
-- axiom red_app (phi rho: Pattern)
330-
-- (phi_sorting: $ is_of_sort phi Exp $)
331-
-- (rho_sorting: $ is_of_sort rho Exp $):
332-
-- $ (red (app phi rho)) == (app (red phi) rho) \/ (app phi (red rho)) \/ (s_exists )$;
333-
334-
335-
-- def double (phi: Pattern) = exists x (a(a(x)) /\ a(x) in phi)
336-
337-
338-
339-
340-
--- term Type_sym: Symbol;
341-
--- def Type: Pattern = $ sym Type_sym $;
342-
--- def Types: Pattern = $ dom Type $;
343-
---
344-
--- term fn_type_sym: Symbol;
345-
--- def fn_type (phi rho: Pattern): Pattern = $ (sym fn_type_sym) @@ phi @@ rho $;
346-
--- axiom function_fn_type: $ ,(is_function '(sym fn_type_symfn_type_sym) '[Type] 'Type) $;
347-
---
348-
---
349-
--- def is_typing_context (phi: Pattern): Pattern = $ ,(is_function '(phi) '[Var] 'Type) $;
350-
---
351-
--- def wf (c t: Pattern) {a u t1 t2: EVar} {X: SVar}: Pattern =
352-
--- $ mu X (
353-
--- (s_exists Var a ((lc_var a) /\ t == (c @@ a)))
354-
--- \/ (s_exists Type u (lc_app () ()))
355-
--- \/ ()
356-
--- ) $;

0 commit comments

Comments
 (0)