Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MirceaS committed Sep 4, 2024
1 parent 5ebf6d3 commit 42babb6
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 75 deletions.
10 changes: 9 additions & 1 deletion nominal/core.mm1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ axiom EV_abstraction {a b: EVar} (alpha tau: Pattern) (phi psi: Pattern a b):
(is_of_sort phi alpha) ->
(is_of_sort psi tau) ->
((swap (eVar a) (eVar b) (abstraction phi psi)) == abstraction (swap (eVar a) (eVar b) phi) (swap (eVar a) (eVar b) psi)))) $;
-- add EV axiom for swap

axiom EV_swap {a b c d: EVar} (alpha tau: Pattern) (phi: Pattern a b c d):
$ is_atom_sort alpha $ >
$ is_nominal_sort tau $ >
$ s_forall alpha a (s_forall alpha b (s_forall alpha c (s_forall alpha d (
(is_of_sort phi alpha) ->
(is_of_sort psi tau) ->
((swap (eVar a) (eVar b) (swap (eVar c) (eVar d) phi)) == swap (swap (eVar a) (eVar b) (eVar c)) (swap (eVar a) (eVar b) (eVar d)) (swap (eVar a) (eVar b) phi)))))) $;

axiom EV_supp {a b: EVar} (tau: Pattern) (phi: Pattern a b):
$ is_atom_sort alpha $ >
$ is_nominal_sort tau $ >
Expand Down
162 changes: 88 additions & 74 deletions nominal/lambda.mm1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ axiom EV_lc_var {a b: EVar} (c: Pattern a b):
term lc_app_sym: Symbol;
def lc_app (phi rho: Pattern): Pattern = $ (sym lc_app_sym) @@ phi @@ rho $;
axiom function_lc_app: $ ,(is_function '(sym lc_var_app) '[Exp Exp] 'Exp) $;
axiom EV_lc_app {a b: EVar} (phi psi: Pattern a b):
$ s_forall Var a (s_forall Var b (
(is_of_sort phi Exp) ->
(is_of_sort psi Exp) ->
((swap (eVar a) (eVar b) (lc_app phi psi)) == lc_app (swap (eVar a) (eVar b) phi) (swap (eVar a) (eVar b) psi)))) $;

term lc_lam_sym: Symbol;
def lc_lam (phi: Pattern): Pattern = $ (sym lc_lam_sym) @@ phi $;
Expand Down Expand Up @@ -454,6 +459,24 @@ theorem curried_function_swap_atom {a b c: EVar}:
theorem satisfying_exps2_is_exp: $ is_exp satisfying_exps2 $ =
(named '(imp_to_subset @ exists_generalization_disjoint @ rsyl (anim2 anl) @ curry subset_to_imp));

theorem subset_trans_var_lemma {x: EVar} (phi psi: Pattern x):
$ (phi C= psi) -> (x in phi) -> ((eVar x) C= psi) $ =
'(rsyl (com12 subset_trans) @ imim1 eVar_in_subset_forward);

theorem var_in_satisfying_exps2:
$(x in satisfying_exps2) <-> (is_exp (eVar x)) /\ s_forall Var a (s_forall Var b (s_forall Exp plug1 (s_forall Exp plug2 ((fresh_for (eVar a) (eVar plug2)) /\ (eVar a != eVar b) -> subst_induction_pred (eVar a) (eVar b) (eVar x) (eVar plug1) (eVar plug2)))))$ =
(named '(ibii
(iand (subset_trans_var_lemma satisfying_exps2_is_exp) @
rsyl (anl ,(propag_mem 'x $exists y (|_ _ _| /\ (eVar y /\ (forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> ((~(|_ _ _|)) /\ ~(|_ _ _|)) -> |_ _ _|)))))))$)) @
exists_generalization_disjoint @
rsyl anr @
curry @
syl anr ,(func_subst_explicit_helper 'x $forall _ (bot -> (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> bot -> ((app (app bot (app (app bot (eVar x)) bot)) bot) == (app (app bot (app (app bot (eVar x)) bot)) bot)))))))))$)) @

syl (anr ,(propag_mem 'x $exists y (|_ _ _| /\ (eVar y /\ (forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> ((~(|_ _ _|)) /\ ~(|_ _ _|)) -> |_ _ _|)))))))$)) @
syl ,(exists_intro_subst @ propag_e_subst 'x $((eVar x) C= bot) /\ ((bot == (eVar x)) /\ (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> bot -> ((app (app bot (app (app bot (eVar x)) bot)) bot) == (app (app bot (app (app bot (eVar x)) bot)) bot)))))))))))$) @
anim2 @ ian eq_refl));

theorem EV_set: $ EV_pattern Var satisfying_exps2 $ =
(named '(univ_gene @ anr imp_r_forall_disjoint @ univ_gene @ exp @ syl (curry subset_to_eq) @ syl
(iand anr @ rsyl (anim
Expand Down Expand Up @@ -586,11 +609,9 @@ theorem mem_func_lemma_neg:
(named '(com12 ,(func_subst_explicit_thm 'y2 $~(z in (eVar y2)) -> ~((eVar z) == (eVar y2))$) @ univ_gene @ con3 membership_var_reverse));

theorem subst_induction_var2: $ (lc_var Vars) C= satisfying_exps2 $ =
(named '(imp_to_subset @ membership_elim @ forall_framing membership_imp_reverse @ univ_gene @
syl (anr ,(propag_mem 'x $exists y (|_ _ _| /\ (eVar y /\ (forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> ((~(|_ _ _|)) /\ ~(|_ _ _|)) -> |_ _ _|)))))))$)) @
syl ,(exists_intro_subst @ propag_e_subst 'x $((eVar x) C= bot) /\ ((bot == (eVar x)) /\ (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> bot -> ((app (app bot (app (app bot (eVar x)) bot)) bot) == (app (app bot (app (app bot (eVar x)) bot)) bot)))))))))))$) @
iand (rsyl eVar_in_subset_forward @ com12 subset_trans @ mp ,(function_sorting_full 1) function_lc_var) @
iand (a1i eq_refl) @
(named '(imp_to_subset @ membership_elim_implicit @ membership_imp_reverse @
syl (anr var_in_satisfying_exps2) @
iand (subset_trans_var_lemma @ mp ,(function_sorting_full 1) function_lc_var) @
anr ,(forall_extract $_ -> _$) @ univ_gene @
anr ,(forall_extract $_ -> _ -> _$) @ univ_gene @
anr ,(forall_extract $_ -> _ -> _ -> _$) @ univ_gene @
Expand Down Expand Up @@ -682,77 +703,70 @@ theorem subst_induction_var2: $ (lc_var Vars) C= satisfying_exps2 $ =
a1i eq_refl));

theorem subst_induction_app2: $ (lc_app satisfying_exps2 satisfying_exps2) C= satisfying_exps2 $ =
'(imp_to_subset _);

theorem subst_induction_app_lemma
(a_var: $ is_sorted_func Var a $)
(b_var: $ is_sorted_func Var b $)
(plug1_exp: $ is_exp plug1 $)
(plug2_exp: $ is_exp plug2 $):
$ (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 $ =
(named '(rsyl (anl an4) @ rsyl (anim2 @
syl (curry eq_trans) @
iand
(rsyl anl @ eq_equiv_to_eq_eq ,(func_subst_explicit_helper 'z $_ @@ (eVar z) @@ _$))
(rsyl anr @ eq_equiv_to_eq_eq ,(func_subst_explicit_helper 'z $_ @@ (eVar z)$))
) @
rsyl (anim1 @ iand id id) @
rsyl (anl anass) @
rsyl (anim2 @ anim1 @ syl (curry @ subst_app b_var plug2_exp) (anim
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting a_var)) plug1_exp)
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting a_var)) plug1_exp)
)) @
rsyl (anim2 @ curry eq_trans) @
rsyl (anim1 @ iand id id) @
rsyl (anl anass) @
rsyl (anim2 @ anim1 @ syl ,(imp_eq_framing_subst 'appCtxLRVar) @ curry @ subst_app a_var plug1_exp) @
rsyl (anim2 @ curry eq_trans) @
rsyl (anim1 @ iand id id) @
rsyl (anl anass) @
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
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting b_var)) plug2_exp)
(mp (com12 @ mp ,(function_sorting 3 'function_subst) (domain_func_sorting b_var)) plug2_exp)
)) @
rsyl (anim2 @ impcom eq_trans) @
rsyl (anim1 @ iand id id) @
rsyl (anl anass) @
rsyl (anim2 @ anim1 @ syl eq_sym @ syl ,(imp_eq_framing_subst 'appCtxLRVar) @ curry @ subst_app b_var plug2_exp) @
rsyl (anim2 @ impcom eq_trans) @
anr));

theorem subst_induction_app (a b plug1 plug2: Pattern)
(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 $):
$ (lc_app (satisfying_exps a b plug1 plug2) (satisfying_exps a b plug1 plug2)) C= (satisfying_exps a b plug1 plug2) $ =
(named '(imp_to_subset @
rsyl (anl ,(ex_appCtx_subst 'appCtxLRVar)) @
(named '(imp_to_subset @ membership_elim_implicit @ membership_imp_reverse @
syl (anr var_in_satisfying_exps2) @
iand (subset_trans_var_lemma @ mp ,(function_sorting 2 'function_lc_app) satisfying_exps2_is_exp satisfying_exps2_is_exp) @
anr ,(forall_extract $_ -> _$) @ univ_gene @
anr ,(forall_extract $_ -> _ -> _$) @ univ_gene @
anr ,(forall_extract $_ -> _ -> _ -> _$) @ univ_gene @
anr ,(forall_extract $_ -> _ -> _ -> _ -> _$) @ univ_gene @
rsyl (anl ,(membership_appCtx_subst 'appCtxLRVar)) @
rsyl (exists_framing @ anim2 @ anl ,(membership_appCtx_subst 'appCtxRVar)) @
exists_generalization_disjoint @
rsyl (anl ,(ex_appCtx_subst 'appCtxRVar)) @
rsyl and_exists_disjoint_reverse @
exists_generalization_disjoint @
rsyl ,(appCtx_floor_commute_b_subst 'appCtxLRVar) @
rsyl (anim1 @ iand id id) @
rsyl (anl anass) @
rsyl (anim2 @
rsyl (anim2 ,(appCtx_floor_commute_subst 'appCtxLRVar)) @
rsyl (anim2 ancom) @
rsyl (anr anass) @
rsyl (anim2 @
rsyl ,(appCtx_floor_commute_b_subst 'appCtxRVar) @
rsyl (anim1 @ iand id id) @
rsyl (anl anass) @
anim2 @
rsyl (anim2 ,(appCtx_floor_commute_subst 'appCtxRVar)) @
rsyl (anim2 ancom) @
anr anass
) @
rsyl (anl anlass) @
anim2 @
anr anass) @
rsyl (anr anass) @
rsyl (anim2 @ anim1 lemma) @
rsyl (anim2 @ ancom) @
rsyl (anim1 @ curry @ mp ,(inst_foralls 2) function_lc_app) @
curry ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ ((app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _))$)
));
rsyl (iand anl @ iand anr anl) @
rsyl (anim2 @ syl appl @ anim2 @ syl mem_func_lemma @ syl (exists_framing anr) @ syl (curry @ mp ,(inst_foralls 2) function_lc_app) @ anim (subset_trans_var_lemma satisfying_exps2_is_exp) (subset_trans_var_lemma satisfying_exps2_is_exp)) @
impcom @
mp ,(func_subst_imp_to_var 'y3 $bot -> bot -> bot -> bot -> bot -> bot -> ((bot @@ bot @@ (bot @@ bot @@ (eVar y3) @@ bot) @@ bot) == (bot @@ bot @@ (bot @@ bot @@ (eVar y3) @@ bot) @@ bot))$) @
exp @ exp @ exp @ exp @ exp @
sylc eq_trans (
syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @
syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @
iand4 an4lr anllr (rsyl an6l @ subset_trans_var_lemma satisfying_exps2_is_exp) (rsyl an5lr @ subset_trans_var_lemma satisfying_exps2_is_exp)) @
sylc eq_trans (
syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @
iand4 an3lr anlr (syl (curry @ curry subst_sorting) @ iand3 an4lr (rsyl an6l @ subset_trans_var_lemma satisfying_exps2_is_exp) anllr)
(syl (curry @ curry subst_sorting) @ iand3 an4lr (rsyl an5lr @ subset_trans_var_lemma satisfying_exps2_is_exp) anllr)) @
syl eq_sym @
sylc eq_trans (
syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @
syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @
iand4 an3lr anlr (rsyl an6l @ subset_trans_var_lemma satisfying_exps2_is_exp) (rsyl an5lr @ subset_trans_var_lemma satisfying_exps2_is_exp)) @
sylc eq_trans (
syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @
iand4 an4lr (syl (curry @ curry subst_sorting) @ iand3 an3lr anllr anlr) (syl (curry @ curry subst_sorting) @ iand3 an3lr (rsyl an6l @ subset_trans_var_lemma satisfying_exps2_is_exp) anlr)
(syl (curry @ curry subst_sorting) @ iand3 an3lr (rsyl an5lr @ subset_trans_var_lemma satisfying_exps2_is_exp) anlr)) @
syl (curry eq_trans) @
syl (anim ,(eq_framing_imp_subst 'appCtxLRVar) ,(eq_framing_imp_subst 'appCtxRVar)) @
iand
(curry @ curry @ curry @ curry @ curry @
rsyl anl @
rsyl (anl var_in_satisfying_exps2) @
rsyl anr @
rsyl var_subst_same_var @ imim2 @
rsyl var_subst_same_var @ imim2 @
rsyl var_subst_same_var @ imim2 @
rsyl var_subst_same_var @ imim2 @
imim2 eq_sym)
(curry @ curry @ curry @ curry @ curry @
rsyl anr @
rsyl (anl var_in_satisfying_exps2) @
rsyl anr @
rsyl var_subst_same_var @ imim2 @
rsyl var_subst_same_var @ imim2 @
rsyl var_subst_same_var @ imim2 @
rsyl var_subst_same_var @ imim2 @
imim2 eq_sym)));


theorem subst_induction_lam2: $ (lc_lam (abstraction Vars satisfying_exps2)) C= satisfying_exps2 $ =
'(imp_to_subset @ membership_elim_implicit @ membership_imp_reverse @
syl (anr var_in_satisfying_exps2) @
iand (subset_trans_var_lemma @ mp ,(function_sorting 1 'function_lc_lam) @ mp ,(function_sorting 2 '(function_abstraction Var_atom Exp_sort)) subset_refl satisfying_exps2_is_exp) @
_);


theorem subst_induction_lam_lemma (a b c plug1 plug2: Pattern)
(diff_atoms_ab: $ a != b $)
Expand Down Expand Up @@ -823,7 +837,7 @@ theorem subst_induction_lemma:
satisfying_exps2_is_exp
EV_set
subst_induction_var2
_
subst_induction_app2
_);

do {
Expand Down

0 comments on commit 42babb6

Please sign in to comment.