Skip to content

Commit 002de00

Browse files
committed
proved first chunk of subst induction
1 parent 2b4c74b commit 002de00

File tree

3 files changed

+59
-22
lines changed

3 files changed

+59
-22
lines changed

12-proof-system-p.mm1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ theorem imp_forall_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eF
262262
$ (phi1 -> forall x phi2) <-> forall x (phi1 -> phi2) $ =
263263
'(con2b @ bitr (cong_of_equiv_exists @ con3b @ imeq2i notnot) @ and_exists_fresh freshness_phi1);
264264

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+
265269

266270
theorem lemma_46 (phi: Pattern) {box: SVar} (ctx: Pattern box)
267271
(p : $ phi $):
@@ -1047,6 +1051,9 @@ do {
10471051
(def (func_subst_alt x phi1 func_phi2) '(
10481052
anr imp_exists_disjoint (mp (exists_framing @ syl anr ,(func_subst_explicit_helper x phi1)) ,func_phi2)
10491053
))
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+
))
10501057
(def (func_subst_thm func_phi2 x phi1) '(
10511058
exists_generalization_disjoint (mp (com12 @ syl anl ,(func_subst_explicit_helper x (nth 4 @ get-decl phi1))) ,phi1) ,func_phi2
10521059
))
@@ -1235,8 +1242,10 @@ theorem subset_mem_disjoint_lemma {x: EVar} (phi: Pattern) (psi: Pattern x)
12351242
$ (phi C= psi) -> forall x ((x in phi) -> x in psi) $ =
12361243
'(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);
12371244

1238-
theorem in_exists_lemma {x: EVar} (phi: Pattern x): $ (x in exists x (eVar x /\ phi)) -> x in phi $ = '();
1245+
do {
1246+
(def (forall_imp_climb n) (iterate n (fn (pf) '(syl (anl imp_forall) @ imim2 ,pf)) 'id))
12391247

1240-
theorem in_exists_to_forall_domain {x: EVar} (pred: Pattern x) (phi: Pattern):
1241-
$ (phi C= exists x (eVar x /\ pred)) -> forall x (x in phi -> x in pred)$ =
1242-
'(rsyl (subset_mem_disjoint_lemma eFresh_exists_same_var) @ forall_framing @ imim2 in_exists_lemma);
1248+
(def (inst_foralls n) (if {n = 0} 'id
1249+
'(rsyl (rsyl ,(inst_foralls {n - 1}) ,(forall_imp_climb {n - 1})) var_subst_same_var)
1250+
))
1251+
};

nominal/core.mm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ axiom F2 (alpha: Pattern) {a b: EVar}:
9393
$ is_atom_sort alpha $ >
9494
$ (is_atom a alpha) ->
9595
(is_atom b alpha) ->
96-
((b in freshness a) <-> (eVar a != eVar b)) $;
96+
(((eVar a) != (eVar b)) <-> (fresh_for (eVar a) (eVar b))) $;
9797
axiom F3 (alpha1 alpha2: Pattern) {a b: EVar}:
9898
$ is_atom_sort alpha1 $ >
9999
$ is_atom_sort alpha2 $ >
@@ -115,7 +115,7 @@ axiom A1 (alpha tau: Pattern) {a b: EVar} (phi rho: Pattern a b):
115115
(is_of_sort rho tau) ->
116116
(((abstraction (eVar a) phi) == (abstraction (eVar b) rho)) <->
117117
((eVar a == eVar b) /\ (phi == rho)) \/
118-
((rho C= freshness a) /\ ((swap a 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 $ >

nominal/lambda.mm1

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,53 +172,81 @@ theorem induction_principle (exp_pred exp_suff_fresh: Pattern)
172172

173173

174174
term subst_sym: Symbol;
175-
def subst {a: EVar} (phi1 phi2: Pattern a): Pattern a = $ (sym subst_sym) @@ (eVar a) @@ phi1 @@ phi2 $;
175+
def subst (a phi1 phi2: Pattern): Pattern = $ (sym subst_sym) @@ a @@ phi1 @@ phi2 $;
176176

177177
axiom function_subst: $ ,(is_function '(sym subst_sym) '[Var Exp Exp] 'Exp) $;
178178
axiom subst_same_var {a: EVar} (plug: Pattern a):
179179
$ (is_var (eVar a)) ->
180180
(is_exp plug) ->
181-
((subst a (lc_var (eVar a)) plug) == plug) $;
181+
((subst (eVar a) (lc_var (eVar a)) plug) == plug) $;
182182
axiom subst_diff_var {a b: EVar} (plug: Pattern a b):
183183
$ (is_var (eVar a)) ->
184184
(is_var (eVar b)) ->
185185
((eVar a) != (eVar b)) ->
186186
(is_exp plug) ->
187-
((subst b (lc_var (eVar a)) plug) == (lc_var (eVar a))) $;
188-
axiom subst_app {a: EVar} (plug phi1 phi2: Pattern a):
189-
$ (is_var (eVar a)) ->
190-
(is_exp plug) ->
191-
(is_exp phi1) ->
187+
((subst (eVar b) (lc_var (eVar a)) plug) == (lc_var (eVar a))) $;
188+
axiom subst_app {a: EVar} (phi1 phi2 plug: Pattern a):
189+
$ (is_exp phi1) ->
192190
(is_exp phi2) ->
193-
((subst a (lc_app phi1 phi2) plug) == (lc_app (subst a phi1 plug) (subst a phi2 plug))) $;
191+
(is_var (eVar a)) ->
192+
(is_exp plug) ->
193+
((subst (eVar a) (lc_app phi1 phi2) plug) == (lc_app (subst (eVar a) phi1 plug) (subst (eVar a) phi2 plug))) $;
194194
axiom subst_lam {a b: EVar} (plug phi: Pattern a b):
195195
$ (is_var (eVar a)) ->
196196
(is_var (eVar b)) ->
197197
(is_exp plug) ->
198198
(is_exp phi) ->
199199
(fresh_for (eVar a) plug) ->
200-
((subst b (lc_lam_a a phi) plug) == (lc_lam_a a (subst b phi plug))) $;
200+
((subst (eVar b) (lc_lam_a a phi) plug) == (lc_lam_a a (subst (eVar b) phi plug))) $;
201201

202-
def subst_induction_pred (a b phi plug1 plug2: Pattern) = $ (subst b (subst a phi plug1) plug2) == (subst a (subst b phi plug2) (subst b plug1 plug2)) $;
203-
def satisfying_exps {.x: EVar} (a b plug1 plug2: Pattern) = $ exists x ((eVar x) /\ subst_induction_pred a b (eVar x) plug1 plug2) $;
202+
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)) $;
203+
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) $;
204204

205-
theorem subst_induction_app_lemma {x y: EVar} (a b phi1 plug1 plug2: Pattern)
205+
theorem subst_induction_app_lemma {x y: EVar} (a b plug1 plug2: Pattern)
206206
(a_var: $ is_sorted_func Var a $)
207207
(b_var: $ is_sorted_func Var b $)
208208
(plug1_exp: $ is_exp plug1 $)
209209
(plug2_exp: $ is_exp plug2 $)
210210
(a_fresh: $ fresh_for a phi3 $):
211-
$ (subst_induction_pred a b x plug1 plug2 /\ subst_induction_pred a b y plug1 plug2) -> subst_induction_pred a b (lc_app x y) plug1 plug2 $ =
211+
$ (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 $ =
212212
'();
213213

214-
theorem subst_induction_app (a b phi1 plug1 plug2: Pattern)
214+
theorem subst_induction_app (a b plug1 plug2: Pattern)
215215
(a_var: $ is_sorted_func Var a $)
216216
(b_var: $ is_sorted_func Var b $)
217217
(plug1_exp: $ is_exp plug1 $)
218218
(plug2_exp: $ is_exp plug2 $)
219219
(a_fresh: $ fresh_for a phi3 $):
220220
$ (lc_app (satisfying_exps a b plug1 plug2) (satisfying_exps a b plug1 plug2)) C= (satisfying_exps a b plug1 plug2) $ =
221-
'();
221+
(named '(imp_to_subset @
222+
rsyl (anl ,(ex_appCtx_subst 'appCtxLRVar)) @
223+
exists_generalization_disjoint @
224+
rsyl (anl ,(ex_appCtx_subst 'appCtxRVar)) @
225+
exists_generalization_disjoint @
226+
rsyl ,(appCtx_floor_commute_b_subst 'appCtxLRVar) @
227+
rsyl (anim1 @ iand id id) @
228+
rsyl (anl anass) @
229+
rsyl (anim2 @
230+
rsyl (anim2 ,(appCtx_floor_commute_subst 'appCtxLRVar)) @
231+
rsyl (anim2 ancom) @
232+
rsyl (anr anass) @
233+
rsyl (anim2 @
234+
rsyl ,(appCtx_floor_commute_b_subst 'appCtxRVar) @
235+
rsyl (anim1 @ iand id id) @
236+
rsyl (anl anass) @
237+
anim2 @
238+
rsyl (anim2 ,(appCtx_floor_commute_subst 'appCtxRVar)) @
239+
rsyl (anim2 ancom) @
240+
anr anass
241+
) @
242+
rsyl (anl anlass) @
243+
anim2 @
244+
anr anass) @
245+
rsyl (anr anass) @
246+
rsyl (anim2 @ anim1 @ subst_induction_app_lemma a_var b_var plug1_exp plug2_exp a_fresh) @
247+
rsyl (anim2 @ ancom) @
248+
rsyl (anim1 @ curry @ mp ,(inst_foralls 2) function_lc_app) @
249+
curry ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ ((app (app _ (app (app _ (eVar x)) _)) _) == (app (app _ (app (app _ (eVar x)) _)) _))$)));
222250

223251

224252
theorem subst_induction (a b phi1 plug1 plug2: Pattern)
@@ -229,7 +257,7 @@ theorem subst_induction (a b phi1 plug1 plug2: Pattern)
229257
(plug2_exp: $ is_exp plug2 $)
230258
(a_fresh: $ fresh_for a phi3 $):
231259
$ (subst b (subst a phi1 plug1) plug2) == (subst a (subst b phi1 plug2) (subst b plug1 plug2)) $ =
232-
'(induction_principle);
260+
'();
233261

234262

235263

0 commit comments

Comments
 (0)