78 |
78 |
79 lemma psubst_eqvt[eqvt]: |
79 lemma psubst_eqvt[eqvt]: |
80 fixes pi::"name prm" |
80 fixes pi::"name prm" |
81 and t::"trm" |
81 and t::"trm" |
82 shows "pi\<bullet>(\<theta><t>) = (pi\<bullet>\<theta>)<(pi\<bullet>t)>" |
82 shows "pi\<bullet>(\<theta><t>) = (pi\<bullet>\<theta>)<(pi\<bullet>t)>" |
83 by (nominal_induct t avoiding: \<theta> rule: trm.induct) |
83 by (nominal_induct t avoiding: \<theta> rule: trm.strong_induct) |
84 (perm_simp add: fresh_bij lookup_eqvt)+ |
84 (perm_simp add: fresh_bij lookup_eqvt)+ |
85 |
85 |
86 lemma fresh_psubst: |
86 lemma fresh_psubst: |
87 fixes z::"name" |
87 fixes z::"name" |
88 and t::"trm" |
88 and t::"trm" |
89 assumes "z\<sharp>t" and "z\<sharp>\<theta>" |
89 assumes "z\<sharp>t" and "z\<sharp>\<theta>" |
90 shows "z\<sharp>(\<theta><t>)" |
90 shows "z\<sharp>(\<theta><t>)" |
91 using assms |
91 using assms |
92 by (nominal_induct t avoiding: z \<theta> t rule: trm.induct) |
92 by (nominal_induct t avoiding: z \<theta> t rule: trm.strong_induct) |
93 (auto simp add: abs_fresh lookup_fresh) |
93 (auto simp add: abs_fresh lookup_fresh) |
94 |
94 |
95 lemma psubst_empty[simp]: |
95 lemma psubst_empty[simp]: |
96 shows "[]<t> = t" |
96 shows "[]<t> = t" |
97 by (nominal_induct t rule: trm.induct) |
97 by (nominal_induct t rule: trm.strong_induct) |
98 (auto simp add: fresh_list_nil) |
98 (auto simp add: fresh_list_nil) |
99 |
99 |
100 text {* Single substitution *} |
100 text {* Single substitution *} |
101 abbreviation |
101 abbreviation |
102 subst :: "trm \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> trm" ("_[_::=_]" [100,100,100] 100) |
102 subst :: "trm \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> trm" ("_[_::=_]" [100,100,100] 100) |
114 and t\<^isub>1::"trm" |
114 and t\<^isub>1::"trm" |
115 and t2::"trm" |
115 and t2::"trm" |
116 assumes a: "z\<sharp>t\<^isub>1" "z\<sharp>t\<^isub>2" |
116 assumes a: "z\<sharp>t\<^isub>1" "z\<sharp>t\<^isub>2" |
117 shows "z\<sharp>t\<^isub>1[y::=t\<^isub>2]" |
117 shows "z\<sharp>t\<^isub>1[y::=t\<^isub>2]" |
118 using a |
118 using a |
119 by (nominal_induct t\<^isub>1 avoiding: z y t\<^isub>2 rule: trm.induct) |
119 by (nominal_induct t\<^isub>1 avoiding: z y t\<^isub>2 rule: trm.strong_induct) |
120 (auto simp add: abs_fresh fresh_atm) |
120 (auto simp add: abs_fresh fresh_atm) |
121 |
121 |
122 lemma fresh_subst': |
122 lemma fresh_subst': |
123 assumes "x\<sharp>e'" |
123 assumes "x\<sharp>e'" |
124 shows "x\<sharp>e[x::=e']" |
124 shows "x\<sharp>e[x::=e']" |
125 using assms |
125 using assms |
126 by (nominal_induct e avoiding: x e' rule: trm.induct) |
126 by (nominal_induct e avoiding: x e' rule: trm.strong_induct) |
127 (auto simp add: fresh_atm abs_fresh fresh_nat) |
127 (auto simp add: fresh_atm abs_fresh fresh_nat) |
128 |
128 |
129 lemma forget: |
129 lemma forget: |
130 assumes a: "x\<sharp>e" |
130 assumes a: "x\<sharp>e" |
131 shows "e[x::=e'] = e" |
131 shows "e[x::=e'] = e" |
132 using a |
132 using a |
133 by (nominal_induct e avoiding: x e' rule: trm.induct) |
133 by (nominal_induct e avoiding: x e' rule: trm.strong_induct) |
134 (auto simp add: fresh_atm abs_fresh) |
134 (auto simp add: fresh_atm abs_fresh) |
135 |
135 |
136 lemma psubst_subst_psubst: |
136 lemma psubst_subst_psubst: |
137 assumes h: "x\<sharp>\<theta>" |
137 assumes h: "x\<sharp>\<theta>" |
138 shows "\<theta><e>[x::=e'] = ((x,e')#\<theta>)<e>" |
138 shows "\<theta><e>[x::=e'] = ((x,e')#\<theta>)<e>" |
139 using h |
139 using h |
140 by (nominal_induct e avoiding: \<theta> x e' rule: trm.induct) |
140 by (nominal_induct e avoiding: \<theta> x e' rule: trm.strong_induct) |
141 (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh') |
141 (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh') |
142 |
142 |
143 text {* Typing Judgements *} |
143 text {* Typing Judgements *} |
144 |
144 |
145 inductive |
145 inductive |
262 fixes \<Gamma>::"(name \<times> ty) list" |
262 fixes \<Gamma>::"(name \<times> ty) list" |
263 assumes "(x,T')#\<Gamma> \<turnstile> e : T" |
263 assumes "(x,T')#\<Gamma> \<turnstile> e : T" |
264 and "\<Gamma> \<turnstile> e': T'" |
264 and "\<Gamma> \<turnstile> e': T'" |
265 shows "\<Gamma> \<turnstile> e[x::=e'] : T" |
265 shows "\<Gamma> \<turnstile> e[x::=e'] : T" |
266 using assms |
266 using assms |
267 proof (nominal_induct e avoiding: \<Gamma> e' x arbitrary: T rule: trm.induct) |
267 proof (nominal_induct e avoiding: \<Gamma> e' x arbitrary: T rule: trm.strong_induct) |
268 case (Var y \<Gamma> e' x T) |
268 case (Var y \<Gamma> e' x T) |
269 have h1: "(x,T')#\<Gamma> \<turnstile> Var y : T" by fact |
269 have h1: "(x,T')#\<Gamma> \<turnstile> Var y : T" by fact |
270 have h2: "\<Gamma> \<turnstile> e' : T'" by fact |
270 have h2: "\<Gamma> \<turnstile> e' : T'" by fact |
271 show "\<Gamma> \<turnstile> (Var y)[x::=e'] : T" |
271 show "\<Gamma> \<turnstile> (Var y)[x::=e'] : T" |
272 proof (cases "x=y") |
272 proof (cases "x=y") |
419 lemma V_eqvt: |
419 lemma V_eqvt: |
420 fixes pi::"name prm" |
420 fixes pi::"name prm" |
421 assumes a: "x\<in>V T" |
421 assumes a: "x\<in>V T" |
422 shows "(pi\<bullet>x)\<in>V T" |
422 shows "(pi\<bullet>x)\<in>V T" |
423 using a |
423 using a |
424 apply(nominal_induct T arbitrary: pi x rule: ty.induct) |
424 apply(nominal_induct T arbitrary: pi x rule: ty.strong_induct) |
425 apply(auto simp add: trm.inject) |
425 apply(auto simp add: trm.inject) |
426 apply(simp add: eqvts) |
426 apply(simp add: eqvts) |
427 apply(rule_tac x="pi\<bullet>xa" in exI) |
427 apply(rule_tac x="pi\<bullet>xa" in exI) |
428 apply(rule_tac x="pi\<bullet>e" in exI) |
428 apply(rule_tac x="pi\<bullet>e" in exI) |
429 apply(simp) |
429 apply(simp) |
529 lemma termination_aux: |
529 lemma termination_aux: |
530 assumes h1: "\<Gamma> \<turnstile> e : T" |
530 assumes h1: "\<Gamma> \<turnstile> e : T" |
531 and h2: "\<theta> Vcloses \<Gamma>" |
531 and h2: "\<theta> Vcloses \<Gamma>" |
532 shows "\<exists>v. \<theta><e> \<Down> v \<and> v \<in> V T" |
532 shows "\<exists>v. \<theta><e> \<Down> v \<and> v \<in> V T" |
533 using h2 h1 |
533 using h2 h1 |
534 proof(nominal_induct e avoiding: \<Gamma> \<theta> arbitrary: T rule: trm.induct) |
534 proof(nominal_induct e avoiding: \<Gamma> \<theta> arbitrary: T rule: trm.strong_induct) |
535 case (App e\<^isub>1 e\<^isub>2 \<Gamma> \<theta> T) |
535 case (App e\<^isub>1 e\<^isub>2 \<Gamma> \<theta> T) |
536 have ih\<^isub>1:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^isub>1 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^isub>1> \<Down> v \<and> v \<in> V T" by fact |
536 have ih\<^isub>1:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^isub>1 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^isub>1> \<Down> v \<and> v \<in> V T" by fact |
537 have ih\<^isub>2:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^isub>2 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^isub>2> \<Down> v \<and> v \<in> V T" by fact |
537 have ih\<^isub>2:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^isub>2 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^isub>2> \<Down> v \<and> v \<in> V T" by fact |
538 have as\<^isub>1:"\<theta> Vcloses \<Gamma>" by fact |
538 have as\<^isub>1:"\<theta> Vcloses \<Gamma>" by fact |
539 have as\<^isub>2: "\<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T" by fact |
539 have as\<^isub>2: "\<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T" by fact |