author | urbanc |
Tue, 29 Nov 2005 19:26:38 +0100 | |
changeset 18284 | cd217d16c90d |
parent 18269 | 3f36e2165e51 |
child 18298 | f7899cb24c79 |
permissions | -rw-r--r-- |
18269 | 1 |
(* $Id$ *) |
18106 | 2 |
|
3 |
theory lam_substs |
|
4 |
imports "../nominal" |
|
5 |
begin |
|
6 |
||
18269 | 7 |
text {* Contains all the reasoning infrastructure for the |
8 |
lambda-calculus that the nominal datatype package |
|
9 |
does not yet provide. *} |
|
10 |
||
18106 | 11 |
atom_decl name |
12 |
||
13 |
nominal_datatype lam = Var "name" |
|
14 |
| App "lam" "lam" |
|
15 |
| Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100) |
|
16 |
||
18269 | 17 |
section {* Strong induction principles for lam *} |
18106 | 18 |
|
19 |
lemma lam_induct_aux: |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
20 |
fixes P :: "'a \<Rightarrow> lam \<Rightarrow> bool" |
18269 | 21 |
and f :: "'a \<Rightarrow> 'a" |
22 |
assumes fs: "\<And>x. finite ((supp (f x))::name set)" |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
23 |
and h1: "\<And>x a. P x (Var a)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
24 |
and h2: "\<And>x t1 t2. (\<And>z. P z t1) \<Longrightarrow> (\<And>z. P z t2) \<Longrightarrow> P x (App t1 t2)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
25 |
and h3: "\<And>x a t. a\<sharp>f x \<Longrightarrow> (\<And>z. P z t) \<Longrightarrow> P x (Lam [a].t)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
26 |
shows "\<And>(pi::name prm) x. P x (pi\<bullet>t)" |
18106 | 27 |
proof (induct rule: lam.induct_weak) |
28 |
case (Lam a t) |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
29 |
have ih: "\<And>(pi::name prm) x. P x (pi\<bullet>t)" by fact |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
30 |
show "\<And>(pi::name prm) x. P x (pi\<bullet>(Lam [a].t))" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
31 |
proof (simp add: abs_perm) |
18106 | 32 |
fix x::"'a" and pi::"name prm" |
18269 | 33 |
have "\<exists>c::name. c\<sharp>(f x,pi\<bullet>a,pi\<bullet>t)" |
34 |
by (rule at_exists_fresh[OF at_name_inst], simp add: supp_prod fs_name1 fs) |
|
18106 | 35 |
then obtain c::"name" |
36 |
where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>(f x)" and f3: "c\<sharp>(pi\<bullet>t)" |
|
18269 | 37 |
by (force simp add: fresh_prod fresh_atm) |
38 |
have "Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t)) = Lam [(pi\<bullet>a)].(pi\<bullet>t)" using f1 f3 |
|
18106 | 39 |
by (simp add: lam.inject alpha) |
18269 | 40 |
moreover |
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
41 |
from ih have "\<And>x. P x (([(c,pi\<bullet>a)]@pi)\<bullet>t)" by force |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
42 |
hence "\<And>x. P x ([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t))" by (simp add: pt_name2[symmetric]) |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
43 |
hence "P x (Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t)))" using h3 f2 |
18106 | 44 |
by (auto simp add: fresh_def at_fin_set_supp[OF at_name_inst, OF fs]) |
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
45 |
ultimately show "P x (Lam [(pi\<bullet>a)].(pi\<bullet>t))" by simp |
18106 | 46 |
qed |
47 |
qed (auto intro: h1 h2) |
|
48 |
||
49 |
lemma lam_induct'[case_names Fin Var App Lam]: |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
50 |
fixes P :: "'a \<Rightarrow> lam \<Rightarrow> bool" |
18106 | 51 |
and x :: "'a" |
52 |
and t :: "lam" |
|
18269 | 53 |
and f :: "'a \<Rightarrow> 'a" |
54 |
assumes fs: "\<And>x. finite ((supp (f x))::name set)" |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
55 |
and h1: "\<And>x a. P x (Var a)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
56 |
and h2: "\<And>x t1 t2. (\<And>z. P z t1)\<Longrightarrow>(\<And>z. P z t2)\<Longrightarrow>P x (App t1 t2)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
57 |
and h3: "\<And>x a t. a\<sharp>f x \<Longrightarrow> (\<And>z. P z t)\<Longrightarrow> P x (Lam [a].t)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
58 |
shows "P x t" |
18106 | 59 |
proof - |
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
60 |
from fs h1 h2 h3 have "\<And>(pi::name prm) x. P x (pi\<bullet>t)" by (rule lam_induct_aux, auto) |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
61 |
hence "P x (([]::name prm)\<bullet>t)" by blast |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
62 |
thus "P x t" by simp |
18106 | 63 |
qed |
64 |
||
65 |
lemma lam_induct[case_names Var App Lam]: |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
66 |
fixes P :: "('a::fs_name) \<Rightarrow> lam \<Rightarrow> bool" |
18106 | 67 |
and x :: "'a::fs_name" |
68 |
and t :: "lam" |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
69 |
assumes h1: "\<And>x a. P x (Var a)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
70 |
and h2: "\<And>x t1 t2. (\<And>z. P z t1)\<Longrightarrow>(\<And>z. P z t2)\<Longrightarrow>P x (App t1 t2)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
71 |
and h3: "\<And>x a t. a\<sharp>x \<Longrightarrow> (\<And>z. P z t)\<Longrightarrow> P x (Lam [a].t)" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
72 |
shows "P x t" |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
73 |
apply(rule lam_induct'[of "\<lambda>x. x" "P"]) |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
74 |
apply(simp add: fs_name1) |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
75 |
apply(auto intro: h1 h2 h3) |
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
76 |
done |
18106 | 77 |
|
78 |
types 'a f1_ty = "name\<Rightarrow>('a::pt_name)" |
|
79 |
'a f2_ty = "'a\<Rightarrow>'a\<Rightarrow>('a::pt_name)" |
|
80 |
'a f3_ty = "name\<Rightarrow>'a\<Rightarrow>('a::pt_name)" |
|
81 |
||
82 |
lemma f3_freshness_conditions: |
|
83 |
fixes f3::"('a::pt_name) f3_ty" |
|
84 |
and y ::"name prm \<Rightarrow> 'a::pt_name" |
|
85 |
and a ::"name" |
|
86 |
and pi1::"name prm" |
|
87 |
and pi2::"name prm" |
|
88 |
assumes a: "finite ((supp f3)::name set)" |
|
89 |
and b: "finite ((supp y)::name set)" |
|
90 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
91 |
shows "\<exists>(a''::name). a''\<sharp>(\<lambda>a'. f3 a' (y (pi1@[(a,pi2\<bullet>a')]))) \<and> |
|
92 |
a''\<sharp>(\<lambda>a'. f3 a' (y (pi1@[(a,pi2\<bullet>a')]))) a''" |
|
93 |
proof - |
|
94 |
from c obtain a' where d0: "a'\<sharp>f3" and d1: "\<forall>(y::'a::pt_name). a'\<sharp>f3 a' y" by force |
|
95 |
have "\<exists>(a''::name). a''\<sharp>(f3,a,a',pi1,pi2,y)" |
|
96 |
by (rule at_exists_fresh[OF at_name_inst], simp add: supp_prod fs_name1 a b) |
|
97 |
then obtain a'' where d2: "a''\<sharp>f3" and d3: "a''\<noteq>a'" and d3b: "a''\<sharp>(f3,a,pi1,pi2,y)" |
|
98 |
by (auto simp add: fresh_prod at_fresh[OF at_name_inst]) |
|
99 |
have d3c: "a''\<notin>((supp (f3,a,pi1,pi2,y))::name set)" using d3b by (simp add: fresh_def) |
|
100 |
have d4: "a''\<sharp>f3 a'' (y (pi1@[(a,pi2\<bullet>a'')]))" |
|
101 |
proof - |
|
102 |
have d5: "[(a'',a')]\<bullet>f3 = f3" |
|
103 |
by (rule pt_fresh_fresh[OF pt_name_inst, OF at_name_inst, OF d2, OF d0]) |
|
104 |
from d1 have "\<forall>(y::'a::pt_name). ([(a'',a')]\<bullet>a')\<sharp>([(a'',a')]\<bullet>(f3 a' y))" |
|
105 |
by (simp add: pt_fresh_bij[OF pt_name_inst, OF at_name_inst]) |
|
106 |
hence "\<forall>(y::'a::pt_name). a''\<sharp>(f3 a'' ([(a'',a')]\<bullet>y))" using d3 d5 |
|
107 |
by (simp add: at_calc[OF at_name_inst] pt_fun_app_eq[OF pt_name_inst, OF at_name_inst]) |
|
108 |
hence "a''\<sharp>(f3 a'' ([(a'',a')]\<bullet>((rev [(a'',a')])\<bullet>(y (pi1@[(a,pi2\<bullet>a'')])))))" by force |
|
109 |
thus ?thesis by (simp only: pt_pi_rev[OF pt_name_inst, OF at_name_inst]) |
|
110 |
qed |
|
111 |
have d6: "a''\<sharp>(\<lambda>a'. f3 a' (y (pi1@[(a,pi2\<bullet>a')])))" |
|
112 |
proof - |
|
113 |
from a b have d7: "finite ((supp (f3,a,pi1,pi2,y))::name set)" by (simp add: supp_prod fs_name1) |
|
114 |
have e: "((supp (f3,a,pi1,pi2,y))::name set) supports (\<lambda>a'. f3 a' (y (pi1@[(a,pi2\<bullet>a')])))" |
|
115 |
by (supports_simp add: perm_append) |
|
116 |
from e d7 d3c show ?thesis by (rule supports_fresh) |
|
117 |
qed |
|
118 |
from d6 d4 show ?thesis by force |
|
119 |
qed |
|
120 |
||
121 |
lemma f3_freshness_conditions_simple: |
|
122 |
fixes f3::"('a::pt_name) f3_ty" |
|
123 |
and y ::"name prm \<Rightarrow> 'a::pt_name" |
|
124 |
and a ::"name" |
|
125 |
and pi::"name prm" |
|
126 |
assumes a: "finite ((supp f3)::name set)" |
|
127 |
and b: "finite ((supp y)::name set)" |
|
128 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
129 |
shows "\<exists>(a''::name). a''\<sharp>(\<lambda>a'. f3 a' (y (pi@[(a,a')]))) \<and> a''\<sharp>(\<lambda>a'. f3 a' (y (pi@[(a,a')]))) a''" |
|
130 |
proof - |
|
131 |
from c obtain a' where d0: "a'\<sharp>f3" and d1: "\<forall>(y::'a::pt_name). a'\<sharp>f3 a' y" by force |
|
132 |
have "\<exists>(a''::name). a''\<sharp>(f3,a,a',pi,y)" |
|
133 |
by (rule at_exists_fresh[OF at_name_inst], simp add: supp_prod fs_name1 a b) |
|
134 |
then obtain a'' where d2: "a''\<sharp>f3" and d3: "a''\<noteq>a'" and d3b: "a''\<sharp>(f3,a,pi,y)" |
|
135 |
by (auto simp add: fresh_prod at_fresh[OF at_name_inst]) |
|
136 |
have d3c: "a''\<notin>((supp (f3,a,pi,y))::name set)" using d3b by (simp add: fresh_def) |
|
137 |
have d4: "a''\<sharp>f3 a'' (y (pi@[(a,a'')]))" |
|
138 |
proof - |
|
139 |
have d5: "[(a'',a')]\<bullet>f3 = f3" |
|
140 |
by (rule pt_fresh_fresh[OF pt_name_inst, OF at_name_inst, OF d2, OF d0]) |
|
141 |
from d1 have "\<forall>(y::'a::pt_name). ([(a'',a')]\<bullet>a')\<sharp>([(a'',a')]\<bullet>(f3 a' y))" |
|
142 |
by (simp add: pt_fresh_bij[OF pt_name_inst, OF at_name_inst]) |
|
143 |
hence "\<forall>(y::'a::pt_name). a''\<sharp>(f3 a'' ([(a'',a')]\<bullet>y))" using d3 d5 |
|
144 |
by (simp add: at_calc[OF at_name_inst] pt_fun_app_eq[OF pt_name_inst, OF at_name_inst]) |
|
145 |
hence "a''\<sharp>(f3 a'' ([(a'',a')]\<bullet>((rev [(a'',a')])\<bullet>(y (pi@[(a,a'')])))))" by force |
|
146 |
thus ?thesis by (simp only: pt_pi_rev[OF pt_name_inst, OF at_name_inst]) |
|
147 |
qed |
|
148 |
have d6: "a''\<sharp>(\<lambda>a'. f3 a' (y (pi@[(a,a')])))" |
|
149 |
proof - |
|
150 |
from a b have d7: "finite ((supp (f3,a,pi,y))::name set)" by (simp add: supp_prod fs_name1) |
|
151 |
have "((supp (f3,a,pi,y))::name set) supports (\<lambda>a'. f3 a' (y (pi@[(a,a')])))" |
|
152 |
by (supports_simp add: perm_append) |
|
153 |
with d7 d3c show ?thesis by (simp add: supports_fresh) |
|
154 |
qed |
|
155 |
from d6 d4 show ?thesis by force |
|
156 |
qed |
|
157 |
||
158 |
lemma f3_fresh_fun_supports: |
|
159 |
fixes f3::"('a::pt_name) f3_ty" |
|
160 |
and a ::"name" |
|
161 |
and pi1::"name prm" |
|
162 |
and y ::"name prm \<Rightarrow> 'a::pt_name" |
|
163 |
assumes a: "finite ((supp f3)::name set)" |
|
164 |
and b: "finite ((supp y)::name set)" |
|
165 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
166 |
shows "((supp (f3,a,y))::name set) supports (\<lambda>pi. fresh_fun (\<lambda>a'. f3 a' (y (pi@[(a,a')]))))" |
|
167 |
proof (auto simp add: "op supports_def" perm_fun_def expand_fun_eq fresh_def[symmetric]) |
|
168 |
fix b::"name" and c::"name" and pi::"name prm" |
|
169 |
assume b1: "b\<sharp>(f3,a,y)" |
|
170 |
and b2: "c\<sharp>(f3,a,y)" |
|
171 |
from b1 b2 have b3: "[(b,c)]\<bullet>f3=f3" and t4: "[(b,c)]\<bullet>a=a" and t5: "[(b,c)]\<bullet>y=y" |
|
172 |
by (simp_all add: pt_fresh_fresh[OF pt_name_inst, OF at_name_inst] fresh_prod) |
|
173 |
let ?g = "\<lambda>a'. f3 a' (y (([(b,c)]\<bullet>pi)@[(a,a')]))" |
|
174 |
and ?h = "\<lambda>a'. f3 a' (y (pi@[(a,a')]))" |
|
175 |
have a0: "finite ((supp (f3,a,[(b,c)]\<bullet>pi,y))::name set)" using a b |
|
176 |
by (simp add: supp_prod fs_name1) |
|
177 |
have a1: "((supp (f3,a,[(b,c)]\<bullet>pi,y))::name set) supports ?g" by (supports_simp add: perm_append) |
|
178 |
hence a2: "finite ((supp ?g)::name set)" using a0 by (rule supports_finite) |
|
179 |
have a3: "\<exists>(a''::name). a''\<sharp>?g \<and> a''\<sharp>(?g a'')" |
|
180 |
by (rule f3_freshness_conditions_simple[OF a, OF b, OF c]) |
|
181 |
have "((supp (f3,a,y))::name set) \<subseteq> (supp (f3,a,[(b,c)]\<bullet>pi,y))" by (force simp add: supp_prod) |
|
182 |
have a4: "[(b,c)]\<bullet>?g = ?h" using b1 b2 |
|
183 |
by (simp add: fresh_prod, perm_simp add: perm_append) |
|
184 |
have "[(b,c)]\<bullet>(fresh_fun ?g) = fresh_fun ([(b,c)]\<bullet>?g)" |
|
185 |
by (simp add: fresh_fun_equiv[OF pt_name_inst, OF at_name_inst, OF a2, OF a3]) |
|
186 |
also have "\<dots> = fresh_fun ?h" using a4 by simp |
|
187 |
finally show "[(b,c)]\<bullet>(fresh_fun ?g) = fresh_fun ?h" . |
|
188 |
qed |
|
189 |
||
190 |
lemma f3_fresh_fun_supp_finite: |
|
191 |
fixes f3::"('a::pt_name) f3_ty" |
|
192 |
and a ::"name" |
|
193 |
and pi1::"name prm" |
|
194 |
and y ::"name prm \<Rightarrow> 'a::pt_name" |
|
195 |
assumes a: "finite ((supp f3)::name set)" |
|
196 |
and b: "finite ((supp y)::name set)" |
|
197 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
198 |
shows "finite ((supp (\<lambda>pi. fresh_fun (\<lambda>a'. f3 a' (y (pi@[(a,a')])))))::name set)" |
|
199 |
proof - |
|
200 |
have "((supp (f3,a,y))::name set) supports (\<lambda>pi. fresh_fun (\<lambda>a'. f3 a' (y (pi@[(a,a')]))))" |
|
201 |
using a b c by (rule f3_fresh_fun_supports) |
|
202 |
moreover |
|
203 |
have "finite ((supp (f3,a,y))::name set)" using a b by (simp add: supp_prod fs_name1) |
|
204 |
ultimately show ?thesis by (rule supports_finite) |
|
205 |
qed |
|
206 |
||
207 |
types 'a recT = "'a f1_ty \<Rightarrow> 'a f2_ty \<Rightarrow> 'a f3_ty \<Rightarrow> (lam\<times>(name prm \<Rightarrow> ('a::pt_name))) set" |
|
208 |
||
209 |
consts |
|
210 |
rec :: "('a::pt_name) recT" |
|
211 |
||
212 |
inductive "rec f1 f2 f3" |
|
213 |
intros |
|
214 |
r1: "(Var a,\<lambda>pi. f1 (pi\<bullet>a))\<in>rec f1 f2 f3" |
|
215 |
r2: "\<lbrakk>finite ((supp y1)::name set);(t1,y1)\<in>rec f1 f2 f3; |
|
216 |
finite ((supp y2)::name set);(t2,y2)\<in>rec f1 f2 f3\<rbrakk> |
|
217 |
\<Longrightarrow> (App t1 t2,\<lambda>pi. f2 (y1 pi) (y2 pi))\<in>rec f1 f2 f3" |
|
218 |
r3: "\<lbrakk>finite ((supp y)::name set);(t,y)\<in>rec f1 f2 f3\<rbrakk> |
|
219 |
\<Longrightarrow> (Lam [a].t,\<lambda>pi. fresh_fun (\<lambda>a'. f3 a' (y (pi@[(a,a')]))))\<in>rec f1 f2 f3" |
|
220 |
||
221 |
constdefs |
|
222 |
rfun' :: "'a f1_ty \<Rightarrow> 'a f2_ty \<Rightarrow> 'a f3_ty \<Rightarrow> lam \<Rightarrow> name prm \<Rightarrow> ('a::pt_name)" |
|
223 |
"rfun' f1 f2 f3 t \<equiv> (THE y. (t,y)\<in>rec f1 f2 f3)" |
|
224 |
||
225 |
rfun :: "'a f1_ty \<Rightarrow> 'a f2_ty \<Rightarrow> 'a f3_ty \<Rightarrow> lam \<Rightarrow> ('a::pt_name)" |
|
226 |
"rfun f1 f2 f3 t \<equiv> rfun' f1 f2 f3 t ([]::name prm)" |
|
227 |
||
228 |
lemma rec_prm_eq[rule_format]: |
|
229 |
fixes f1 ::"('a::pt_name) f1_ty" |
|
230 |
and f2 ::"('a::pt_name) f2_ty" |
|
231 |
and f3 ::"('a::pt_name) f3_ty" |
|
232 |
and t ::"lam" |
|
233 |
and y ::"name prm \<Rightarrow> ('a::pt_name)" |
|
234 |
shows "(t,y)\<in>rec f1 f2 f3 \<Longrightarrow> (\<forall>(pi1::name prm) (pi2::name prm). pi1 \<sim> pi2 \<longrightarrow> (y pi1 = y pi2))" |
|
235 |
apply(erule rec.induct) |
|
236 |
apply(auto simp add: pt3[OF pt_name_inst]) |
|
237 |
apply(rule_tac f="fresh_fun" in arg_cong) |
|
238 |
apply(auto simp add: expand_fun_eq) |
|
239 |
apply(drule_tac x="pi1@[(a,x)]" in spec) |
|
240 |
apply(drule_tac x="pi2@[(a,x)]" in spec) |
|
241 |
apply(force simp add: prm_eq_def pt2[OF pt_name_inst]) |
|
242 |
done |
|
243 |
||
244 |
(* silly helper lemma *) |
|
245 |
lemma rec_trans: |
|
246 |
fixes f1 ::"('a::pt_name) f1_ty" |
|
247 |
and f2 ::"('a::pt_name) f2_ty" |
|
248 |
and f3 ::"('a::pt_name) f3_ty" |
|
249 |
and t ::"lam" |
|
250 |
and y ::"name prm \<Rightarrow> ('a::pt_name)" |
|
251 |
assumes a: "(t,y)\<in>rec f1 f2 f3" |
|
252 |
and b: "y=y'" |
|
253 |
shows "(t,y')\<in>rec f1 f2 f3" |
|
254 |
using a b by simp |
|
255 |
||
256 |
||
257 |
lemma rec_prm_equiv: |
|
258 |
fixes f1 ::"('a::pt_name) f1_ty" |
|
259 |
and f2 ::"('a::pt_name) f2_ty" |
|
260 |
and f3 ::"('a::pt_name) f3_ty" |
|
261 |
and t ::"lam" |
|
262 |
and y ::"name prm \<Rightarrow> ('a::pt_name)" |
|
263 |
and pi ::"name prm" |
|
264 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
265 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
266 |
and a: "(t,y)\<in>rec f1 f2 f3" |
|
267 |
shows "(pi\<bullet>t,pi\<bullet>y)\<in>rec (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3)" |
|
268 |
using a |
|
269 |
proof (induct) |
|
270 |
case (r1 c) |
|
271 |
let ?g ="pi\<bullet>(\<lambda>(pi'::name prm). f1 (pi'\<bullet>c))" |
|
272 |
and ?g'="\<lambda>(pi'::name prm). (pi\<bullet>f1) (pi'\<bullet>(pi\<bullet>c))" |
|
273 |
have "?g'=?g" |
|
274 |
proof (auto simp only: expand_fun_eq perm_fun_def) |
|
275 |
fix pi'::"name prm" |
|
276 |
let ?h = "((rev pi)\<bullet>(pi'\<bullet>(pi\<bullet>c)))" |
|
277 |
and ?h'= "(((rev pi)\<bullet>pi')\<bullet>c)" |
|
278 |
have "?h' = ((rev pi)\<bullet>pi')\<bullet>((rev pi)\<bullet>(pi\<bullet>c))" |
|
279 |
by (simp add: pt_rev_pi[OF pt_name_inst, OF at_name_inst]) |
|
280 |
also have "\<dots> = ?h" |
|
281 |
by (simp add: pt_perm_compose[OF pt_name_inst, OF at_name_inst,symmetric]) |
|
282 |
finally show "pi\<bullet>(f1 ?h) = pi\<bullet>(f1 ?h')" by simp |
|
283 |
qed |
|
284 |
thus ?case by (force intro: rec_trans rec.r1) |
|
285 |
next |
|
286 |
case (r2 t1 t2 y1 y2) |
|
287 |
assume a1: "finite ((supp y1)::name set)" |
|
288 |
and a2: "finite ((supp y2)::name set)" |
|
289 |
and a3: "(pi\<bullet>t1,pi\<bullet>y1) \<in> rec (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3)" |
|
290 |
and a4: "(pi\<bullet>t2,pi\<bullet>y2) \<in> rec (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3)" |
|
291 |
from a1 a2 have a1': "finite ((supp (pi\<bullet>y1))::name set)" and a2': "finite ((supp (pi\<bullet>y2))::name set)" |
|
292 |
by (simp_all add: pt_supp_finite_pi[OF pt_name_inst, OF at_name_inst]) |
|
293 |
let ?g ="pi\<bullet>(\<lambda>(pi'::name prm). f2 (y1 pi') (y2 pi'))" |
|
294 |
and ?g'="\<lambda>(pi'::name prm). (pi\<bullet>f2) ((pi\<bullet>y1) pi') ((pi\<bullet>y2) pi')" |
|
295 |
have "?g'=?g" by (simp add: expand_fun_eq perm_fun_def pt_rev_pi[OF pt_name_inst, OF at_name_inst]) |
|
296 |
thus ?case using a1' a2' a3 a4 by (force intro: rec.r2 rec_trans) |
|
297 |
next |
|
298 |
case (r3 a t y) |
|
299 |
assume a1: "finite ((supp y)::name set)" |
|
300 |
and a2: "(pi\<bullet>t,pi\<bullet>y) \<in> rec (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3)" |
|
301 |
from a1 have a1': "finite ((supp (pi\<bullet>y))::name set)" |
|
302 |
by (simp add: pt_supp_finite_pi[OF pt_name_inst, OF at_name_inst]) |
|
303 |
let ?g ="pi\<bullet>(\<lambda>(pi'::name prm). fresh_fun (\<lambda>a'. f3 a' (y (pi'@[(a,a')]))))" |
|
304 |
and ?g'="(\<lambda>(pi'::name prm). fresh_fun (\<lambda>a'. (pi\<bullet>f3) a' ((pi\<bullet>y) (pi'@[((pi\<bullet>a),a')]))))" |
|
305 |
have "?g'=?g" |
|
306 |
proof (auto simp add: expand_fun_eq perm_fun_def pt_rev_pi[OF pt_name_inst, OF at_name_inst] |
|
307 |
perm_append) |
|
308 |
fix pi'::"name prm" |
|
309 |
let ?h = "\<lambda>a'. pi\<bullet>(f3 ((rev pi)\<bullet>a') (y (((rev pi)\<bullet>pi')@[(a,(rev pi)\<bullet>a')])))" |
|
310 |
and ?h' = "\<lambda>a'. f3 a' (y (((rev pi)\<bullet>pi')@[(a,a')]))" |
|
311 |
have fs_f3: "finite ((supp f3)::name set)" using f by (simp add: supp_prod) |
|
312 |
have fs_h': "finite ((supp ?h')::name set)" |
|
313 |
proof - |
|
314 |
have "((supp (f3,a,(rev pi)\<bullet>pi',y))::name set) supports ?h'" |
|
315 |
by (supports_simp add: perm_append) |
|
316 |
moreover |
|
317 |
have "finite ((supp (f3,a,(rev pi)\<bullet>pi',y))::name set)" using a1 fs_f3 |
|
318 |
by (simp add: supp_prod fs_name1) |
|
319 |
ultimately show ?thesis by (rule supports_finite) |
|
320 |
qed |
|
321 |
have fcond: "\<exists>(a''::name). a''\<sharp>?h' \<and> a''\<sharp>(?h' a'')" |
|
322 |
by (rule f3_freshness_conditions_simple[OF fs_f3, OF a1, OF c]) |
|
323 |
have "fresh_fun ?h = fresh_fun (pi\<bullet>?h')" |
|
324 |
by (simp add: perm_fun_def pt_rev_pi[OF pt_name_inst, OF at_name_inst]) |
|
325 |
also have "\<dots> = pi\<bullet>(fresh_fun ?h')" |
|
326 |
by (simp add: fresh_fun_equiv[OF pt_name_inst, OF at_name_inst, OF fs_h', OF fcond]) |
|
327 |
finally show "fresh_fun ?h = pi\<bullet>(fresh_fun ?h')" . |
|
328 |
qed |
|
329 |
thus ?case using a1' a2 by (force intro: rec.r3 rec_trans) |
|
330 |
qed |
|
331 |
||
332 |
lemma rec_perm: |
|
333 |
fixes f1 ::"('a::pt_name) f1_ty" |
|
334 |
and f2 ::"('a::pt_name) f2_ty" |
|
335 |
and f3 ::"('a::pt_name) f3_ty" |
|
336 |
and pi1::"name prm" |
|
337 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
338 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
339 |
and a: "(t,y)\<in>rec f1 f2 f3" |
|
340 |
shows "(pi1\<bullet>t, \<lambda>pi2. y (pi2@pi1))\<in>rec f1 f2 f3" |
|
341 |
proof - |
|
342 |
have lem: "\<forall>(y::name prm\<Rightarrow>('a::pt_name))(pi::name prm). |
|
343 |
finite ((supp y)::name set) \<longrightarrow> finite ((supp (\<lambda>pi'. y (pi'@pi)))::name set)" |
|
344 |
proof (intro strip) |
|
345 |
fix y::"name prm\<Rightarrow>('a::pt_name)" and pi::"name prm" |
|
346 |
assume "finite ((supp y)::name set)" |
|
347 |
hence "finite ((supp (y,pi))::name set)" by (simp add: supp_prod fs_name1) |
|
348 |
moreover |
|
349 |
have "((supp (y,pi))::name set) supports (\<lambda>pi'. y (pi'@pi))" |
|
350 |
by (supports_simp add: perm_append) |
|
351 |
ultimately show "finite ((supp (\<lambda>pi'. y (pi'@pi)))::name set)" by (simp add: supports_finite) |
|
352 |
qed |
|
353 |
from a |
|
354 |
show ?thesis |
|
355 |
proof (induct) |
|
356 |
case (r1 c) |
|
357 |
show ?case |
|
358 |
by (auto simp add: pt2[OF pt_name_inst], rule rec.r1) |
|
359 |
next |
|
360 |
case (r2 t1 t2 y1 y2) |
|
361 |
thus ?case using lem by (auto intro!: rec.r2) |
|
362 |
next |
|
363 |
case (r3 c t y) |
|
364 |
assume a0: "(t,y)\<in>rec f1 f2 f3" |
|
365 |
and a1: "finite ((supp y)::name set)" |
|
366 |
and a2: "(pi1\<bullet>t,\<lambda>pi2. y (pi2@pi1))\<in>rec f1 f2 f3" |
|
367 |
from f have f': "finite ((supp f3)::name set)" by (simp add: supp_prod) |
|
368 |
show ?case |
|
369 |
proof(simp) |
|
370 |
have a3: "finite ((supp (\<lambda>pi2. y (pi2@pi1)))::name set)" using lem a1 by force |
|
371 |
let ?g' = "\<lambda>(pi::name prm). fresh_fun (\<lambda>a'. f3 a' ((\<lambda>pi2. y (pi2@pi1)) (pi@[(pi1\<bullet>c,a')])))" |
|
372 |
and ?g = "\<lambda>(pi::name prm). fresh_fun (\<lambda>a'. f3 a' (y (pi@[(pi1\<bullet>c,a')]@pi1)))" |
|
373 |
and ?h = "\<lambda>(pi::name prm). fresh_fun (\<lambda>a'. f3 a' (y (pi@pi1@[(c,a')])))" |
|
374 |
have eq1: "?g = ?g'" by simp |
|
375 |
have eq2: "?g'= ?h" |
|
376 |
proof (auto simp only: expand_fun_eq) |
|
377 |
fix pi::"name prm" |
|
378 |
let ?q = "\<lambda>a'. f3 a' (y ((pi@[(pi1\<bullet>c,a')])@pi1))" |
|
379 |
and ?q' = "\<lambda>a'. f3 a' (y (((pi@pi1)@[(c,(rev pi1)\<bullet>a')])))" |
|
380 |
and ?r = "\<lambda>a'. f3 a' (y ((pi@pi1)@[(c,a')]))" |
|
381 |
and ?r' = "\<lambda>a'. f3 a' (y (pi@(pi1@[(c,a')])))" |
|
382 |
have eq3a: "?r = ?r'" by simp |
|
383 |
have eq3: "?q = ?q'" |
|
384 |
proof (auto simp only: expand_fun_eq) |
|
385 |
fix a'::"name" |
|
386 |
have "(y ((pi@[(pi1\<bullet>c,a')])@pi1)) = (y (((pi@pi1)@[(c,(rev pi1)\<bullet>a')])))" |
|
387 |
proof - |
|
388 |
have "((pi@[(pi1\<bullet>c,a')])@pi1) \<sim> ((pi@pi1)@[(c,(rev pi1)\<bullet>a')])" |
|
389 |
by (force simp add: prm_eq_def at_append[OF at_name_inst] |
|
390 |
at_calc[OF at_name_inst] at_bij[OF at_name_inst] |
|
391 |
at_pi_rev[OF at_name_inst] at_rev_pi[OF at_name_inst]) |
|
392 |
with a0 show ?thesis by (rule rec_prm_eq) |
|
393 |
qed |
|
394 |
thus "f3 a' (y ((pi@[(pi1\<bullet>c,a')])@pi1)) = f3 a' (y (((pi@pi1)@[(c,(rev pi1)\<bullet>a')])))" by simp |
|
395 |
qed |
|
396 |
have fs_a: "finite ((supp ?q')::name set)" |
|
397 |
proof - |
|
398 |
have "((supp (f3,c,(pi@pi1),(rev pi1),y))::name set) supports ?q'" |
|
399 |
by (supports_simp add: perm_append fresh_list_append fresh_list_rev) |
|
400 |
moreover |
|
401 |
have "finite ((supp (f3,c,(pi@pi1),(rev pi1),y))::name set)" using f' a1 |
|
402 |
by (simp add: supp_prod fs_name1) |
|
403 |
ultimately show ?thesis by (rule supports_finite) |
|
404 |
qed |
|
405 |
have fs_b: "finite ((supp ?r)::name set)" |
|
406 |
proof - |
|
407 |
have "((supp (f3,c,(pi@pi1),y))::name set) supports ?r" |
|
408 |
by (supports_simp add: perm_append fresh_list_append) |
|
409 |
moreover |
|
410 |
have "finite ((supp (f3,c,(pi@pi1),y))::name set)" using f' a1 |
|
411 |
by (simp add: supp_prod fs_name1) |
|
412 |
ultimately show ?thesis by (rule supports_finite) |
|
413 |
qed |
|
414 |
have c1: "\<exists>(a''::name). a''\<sharp>?q' \<and> a''\<sharp>(?q' a'')" |
|
415 |
by (rule f3_freshness_conditions[OF f', OF a1, OF c]) |
|
416 |
have c2: "\<exists>(a''::name). a''\<sharp>?r \<and> a''\<sharp>(?r a'')" |
|
417 |
by (rule f3_freshness_conditions_simple[OF f', OF a1, OF c]) |
|
418 |
have c3: "\<exists>(d::name). d\<sharp>(?q',?r,(rev pi1))" |
|
419 |
by (rule at_exists_fresh[OF at_name_inst], |
|
420 |
simp only: finite_Un supp_prod fs_a fs_b fs_name1, simp) |
|
421 |
then obtain d::"name" where d1: "d\<sharp>?q'" and d2: "d\<sharp>?r" and d3: "d\<sharp>(rev pi1)" |
|
422 |
by (auto simp only: fresh_prod) |
|
423 |
have eq4: "(rev pi1)\<bullet>d = d" using d3 by (simp add: at_prm_fresh[OF at_name_inst]) |
|
424 |
have "fresh_fun ?q = fresh_fun ?q'" using eq3 by simp |
|
425 |
also have "\<dots> = ?q' d" using fs_a c1 d1 |
|
426 |
by (simp add: fresh_fun_app[OF pt_name_inst, OF at_name_inst]) |
|
427 |
also have "\<dots> = ?r d" using fs_b c2 d2 eq4 |
|
428 |
by (simp add: fresh_fun_app[OF pt_name_inst, OF at_name_inst]) |
|
429 |
also have "\<dots> = fresh_fun ?r" using fs_b c2 d2 |
|
430 |
by (simp add: fresh_fun_app[OF pt_name_inst, OF at_name_inst]) |
|
431 |
finally show "fresh_fun ?q = fresh_fun ?r'" by simp |
|
432 |
qed |
|
433 |
from a3 a2 have "(Lam [(pi1\<bullet>c)].(pi1\<bullet>t), ?g')\<in>rec f1 f2 f3" by (rule rec.r3) |
|
434 |
thus "(Lam [(pi1\<bullet>c)].(pi1\<bullet>t), ?h)\<in>rec f1 f2 f3" using eq2 by simp |
|
435 |
qed |
|
436 |
qed |
|
437 |
qed |
|
438 |
||
439 |
lemma rec_perm_rev: |
|
440 |
fixes f1::"('a::pt_name) f1_ty" |
|
441 |
and f2::"('a::pt_name) f2_ty" |
|
442 |
and f3::"('a::pt_name) f3_ty" |
|
443 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
444 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
445 |
and a: "(pi\<bullet>t,y)\<in>rec f1 f2 f3" |
|
446 |
shows "(t, \<lambda>pi2. y (pi2@(rev pi)))\<in>rec f1 f2 f3" |
|
447 |
proof - |
|
448 |
from a have "((rev pi)\<bullet>(pi\<bullet>t),\<lambda>pi2. y (pi2@(rev pi)))\<in>rec f1 f2 f3" |
|
449 |
by (rule rec_perm[OF f, OF c]) |
|
450 |
thus ?thesis by (simp add: pt_rev_pi[OF pt_name_inst, OF at_name_inst]) |
|
451 |
qed |
|
452 |
||
453 |
||
454 |
lemma rec_unique: |
|
455 |
fixes f1::"('a::pt_name) f1_ty" |
|
456 |
and f2::"('a::pt_name) f2_ty" |
|
457 |
and f3::"('a::pt_name) f3_ty" |
|
458 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
459 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
460 |
and a: "(t,y)\<in>rec f1 f2 f3" |
|
461 |
shows "\<forall>(y'::name prm\<Rightarrow>('a::pt_name))(pi::name prm). |
|
462 |
(t,y')\<in>rec f1 f2 f3 \<longrightarrow> y pi = y' pi" |
|
463 |
using a |
|
464 |
proof (induct) |
|
465 |
case (r1 c) |
|
466 |
show ?case |
|
467 |
apply(auto) |
|
468 |
apply(ind_cases "(Var c, y') \<in> rec f1 f2 f3") |
|
469 |
apply(simp_all add: lam.distinct lam.inject) |
|
470 |
done |
|
471 |
next |
|
472 |
case (r2 t1 t2 y1 y2) |
|
473 |
thus ?case |
|
474 |
apply(clarify) |
|
475 |
apply(ind_cases "(App t1 t2, y') \<in> rec f1 f2 f3") |
|
476 |
apply(simp_all (no_asm_use) only: lam.distinct lam.inject) |
|
477 |
apply(clarify) |
|
478 |
apply(drule_tac x="y1" in spec) |
|
479 |
apply(drule_tac x="y2" in spec) |
|
480 |
apply(auto) |
|
481 |
done |
|
482 |
next |
|
483 |
case (r3 c t y) |
|
484 |
assume i1: "finite ((supp y)::name set)" |
|
485 |
and i2: "(t,y)\<in>rec f1 f2 f3" |
|
486 |
and i3: "\<forall>(y'::name prm\<Rightarrow>('a::pt_name))(pi::name prm). |
|
487 |
(t,y')\<in>rec f1 f2 f3 \<longrightarrow> y pi = y' pi" |
|
488 |
from f have f': "finite ((supp f3)::name set)" by (simp add: supp_prod) |
|
489 |
show ?case |
|
490 |
proof (auto) |
|
491 |
fix y'::"name prm\<Rightarrow>('a::pt_name)" and pi::"name prm" |
|
492 |
assume i4: "(Lam [c].t, y') \<in> rec f1 f2 f3" |
|
493 |
from i4 show "fresh_fun (\<lambda>a'. f3 a' (y (pi@[(c,a')]))) = y' pi" |
|
494 |
proof (cases, simp_all add: lam.distinct lam.inject, auto) |
|
495 |
fix a::"name" and t'::"lam" and y''::"name prm\<Rightarrow>('a::pt_name)" |
|
496 |
assume i5: "[c].t = [a].t'" |
|
497 |
and i6: "(t',y'')\<in>rec f1 f2 f3" |
|
498 |
and i6':"finite ((supp y'')::name set)" |
|
499 |
let ?g = "\<lambda>a'. f3 a' (y (pi@[(c,a')]))" |
|
500 |
and ?h = "\<lambda>a'. f3 a' (y'' (pi@[(a,a')]))" |
|
501 |
show "fresh_fun ?g = fresh_fun ?h" using i5 |
|
502 |
proof (cases "a=c") |
|
503 |
case True |
|
504 |
assume i7: "a=c" |
|
505 |
with i5 have i8: "t=t'" by (simp add: alpha) |
|
506 |
show "fresh_fun ?g = fresh_fun ?h" using i3 i6 i7 i8 by simp |
|
507 |
next |
|
508 |
case False |
|
509 |
assume i9: "a\<noteq>c" |
|
510 |
with i5[symmetric] have i10: "t'=[(a,c)]\<bullet>t" and i11: "a\<sharp>t" by (simp_all add: alpha) |
|
511 |
have r1: "finite ((supp ?g)::name set)" |
|
512 |
proof - |
|
513 |
have "((supp (f3,c,pi,y))::name set) supports ?g" |
|
514 |
by (supports_simp add: perm_append) |
|
515 |
moreover |
|
516 |
have "finite ((supp (f3,c,pi,y))::name set)" using f' i1 |
|
517 |
by (simp add: supp_prod fs_name1) |
|
518 |
ultimately show ?thesis by (rule supports_finite) |
|
519 |
qed |
|
520 |
have r2: "finite ((supp ?h)::name set)" |
|
521 |
proof - |
|
522 |
have "((supp (f3,a,pi,y''))::name set) supports ?h" |
|
523 |
by (supports_simp add: perm_append) |
|
524 |
moreover |
|
525 |
have "finite ((supp (f3,a,pi,y''))::name set)" using f' i6' |
|
526 |
by (simp add: supp_prod fs_name1) |
|
527 |
ultimately show ?thesis by (rule supports_finite) |
|
528 |
qed |
|
529 |
have c1: "\<exists>(a''::name). a''\<sharp>?g \<and> a''\<sharp>(?g a'')" |
|
530 |
by (rule f3_freshness_conditions_simple[OF f', OF i1, OF c]) |
|
531 |
have c2: "\<exists>(a''::name). a''\<sharp>?h \<and> a''\<sharp>(?h a'')" |
|
532 |
by (rule f3_freshness_conditions_simple[OF f', OF i6', OF c]) |
|
533 |
have "\<exists>(d::name). d\<sharp>(?g,?h,t,a,c)" |
|
534 |
by (rule at_exists_fresh[OF at_name_inst], |
|
535 |
simp only: finite_Un supp_prod r1 r2 fs_name1, simp) |
|
536 |
then obtain d::"name" |
|
537 |
where f1: "d\<sharp>?g" and f2: "d\<sharp>?h" and f3: "d\<sharp>t" and f4: "d\<noteq>a" and f5: "d\<noteq>c" |
|
538 |
by (force simp add: fresh_prod at_fresh[OF at_name_inst] at_fresh[OF at_name_inst]) |
|
539 |
have g1: "[(a,d)]\<bullet>t = t" |
|
540 |
by (rule pt_fresh_fresh[OF pt_name_inst, OF at_name_inst, OF i11, OF f3]) |
|
541 |
from i6 have "(([(a,c)]@[(a,d)])\<bullet>t,y'')\<in>rec f1 f2 f3" using g1 i10 by (simp only: pt_name2) |
|
542 |
hence "(t, \<lambda>pi2. y'' (pi2@(rev ([(a,c)]@[(a,d)]))))\<in>rec f1 f2 f3" |
|
543 |
by (simp only: rec_perm_rev[OF f, OF c]) |
|
544 |
hence g2: "(t, \<lambda>pi2. y'' (pi2@([(a,d)]@[(a,c)])))\<in>rec f1 f2 f3" by simp |
|
545 |
have "distinct [a,c,d]" using i9 f4 f5 by force |
|
546 |
hence g3: "(pi@[(c,d)]@[(a,d)]@[(a,c)]) \<sim> (pi@[(a,d)])" |
|
547 |
by (force simp add: prm_eq_def at_calc[OF at_name_inst] at_append[OF at_name_inst]) |
|
548 |
have "fresh_fun ?g = ?g d" using r1 c1 f1 |
|
549 |
by (simp add: fresh_fun_app[OF pt_name_inst, OF at_name_inst]) |
|
550 |
also have "\<dots> = f3 d ((\<lambda>pi2. y'' (pi2@([(a,d)]@[(a,c)]))) (pi@[(c,d)]))" using i3 g2 by simp |
|
551 |
also have "\<dots> = f3 d (y'' (pi@[(c,d)]@[(a,d)]@[(a,c)]))" by simp |
|
552 |
also have "\<dots> = f3 d (y'' (pi@[(a,d)]))" using i6 g3 by (simp add: rec_prm_eq) |
|
553 |
also have "\<dots> = fresh_fun ?h" using r2 c2 f2 |
|
554 |
by (simp add: fresh_fun_app[OF pt_name_inst, OF at_name_inst]) |
|
555 |
finally show "fresh_fun ?g = fresh_fun ?h" . |
|
556 |
qed |
|
557 |
qed |
|
558 |
qed |
|
559 |
qed |
|
560 |
||
561 |
lemma rec_total_aux: |
|
562 |
fixes f1::"('a::pt_name) f1_ty" |
|
563 |
and f2::"('a::pt_name) f2_ty" |
|
564 |
and f3::"('a::pt_name) f3_ty" |
|
565 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
566 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
567 |
shows "\<exists>(y::name prm\<Rightarrow>('a::pt_name)). ((t,y)\<in>rec f1 f2 f3) \<and> (finite ((supp y)::name set))" |
|
568 |
proof (induct t rule: lam.induct_weak) |
|
569 |
case (Var c) |
|
570 |
have a1: "(Var c,\<lambda>(pi::name prm). f1 (pi\<bullet>c))\<in>rec f1 f2 f3" by (rule rec.r1) |
|
571 |
have a2: "finite ((supp (\<lambda>(pi::name prm). f1 (pi\<bullet>c)))::name set)" |
|
572 |
proof - |
|
573 |
have "((supp (f1,c))::name set) supports (\<lambda>(pi::name prm). f1 (pi\<bullet>c))" by (supports_simp) |
|
574 |
moreover have "finite ((supp (f1,c))::name set)" using f by (simp add: supp_prod fs_name1) |
|
575 |
ultimately show ?thesis by (rule supports_finite) |
|
576 |
qed |
|
577 |
from a1 a2 show ?case by force |
|
578 |
next |
|
579 |
case (App t1 t2) |
|
580 |
assume "\<exists>y1. (t1,y1)\<in>rec f1 f2 f3 \<and> finite ((supp y1)::name set)" |
|
581 |
then obtain y1::"name prm \<Rightarrow> ('a::pt_name)" |
|
582 |
where a11: "(t1,y1)\<in>rec f1 f2 f3" and a12: "finite ((supp y1)::name set)" by force |
|
583 |
assume "\<exists>y2. (t2,y2)\<in>rec f1 f2 f3 \<and> finite ((supp y2)::name set)" |
|
584 |
then obtain y2::"name prm \<Rightarrow> ('a::pt_name)" |
|
585 |
where a21: "(t2,y2)\<in>rec f1 f2 f3" and a22: "finite ((supp y2)::name set)" by force |
|
586 |
||
587 |
have a1: "(App t1 t2,\<lambda>(pi::name prm). f2 (y1 pi) (y2 pi))\<in>rec f1 f2 f3" |
|
588 |
using a12 a11 a22 a21 by (rule rec.r2) |
|
589 |
have a2: "finite ((supp (\<lambda>(pi::name prm). f2 (y1 pi) (y2 pi)))::name set)" |
|
590 |
proof - |
|
591 |
have "((supp (f2,y1,y2))::name set) supports (\<lambda>(pi::name prm). f2 (y1 pi) (y2 pi))" |
|
592 |
by (supports_simp) |
|
593 |
moreover have "finite ((supp (f2,y1,y2))::name set)" using f a21 a22 |
|
594 |
by (simp add: supp_prod fs_name1) |
|
595 |
ultimately show ?thesis by (rule supports_finite) |
|
596 |
qed |
|
597 |
from a1 a2 show ?case by force |
|
598 |
next |
|
599 |
case (Lam a t) |
|
600 |
assume "\<exists>y. (t,y)\<in>rec f1 f2 f3 \<and> finite ((supp y)::name set)" |
|
601 |
then obtain y::"name prm \<Rightarrow> ('a::pt_name)" |
|
602 |
where a11: "(t,y)\<in>rec f1 f2 f3" and a12: "finite ((supp y)::name set)" by force |
|
603 |
from f have f': "finite ((supp f3)::name set)" by (simp add: supp_prod) |
|
604 |
have a1: "(Lam [a].t,\<lambda>(pi::name prm). fresh_fun (\<lambda>a'. f3 a' (y (pi@[(a,a')]))))\<in>rec f1 f2 f3" |
|
605 |
using a12 a11 by (rule rec.r3) |
|
606 |
have a2: "finite ((supp (\<lambda>pi. fresh_fun (\<lambda>a'. f3 a' (y (pi@[(a,a')])))))::name set)" |
|
607 |
using f' a12 c by (rule f3_fresh_fun_supp_finite) |
|
608 |
from a1 a2 show ?case by force |
|
609 |
qed |
|
610 |
||
611 |
lemma rec_total: |
|
612 |
fixes f1::"('a::pt_name) f1_ty" |
|
613 |
and f2::"('a::pt_name) f2_ty" |
|
614 |
and f3::"('a::pt_name) f3_ty" |
|
615 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
616 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
617 |
shows "\<exists>(y::name prm\<Rightarrow>('a::pt_name)). ((t,y)\<in>rec f1 f2 f3)" |
|
618 |
proof - |
|
619 |
have "\<exists>y. ((t,y)\<in>rec f1 f2 f3) \<and> (finite ((supp y)::name set))" |
|
620 |
by (rule rec_total_aux[OF f, OF c]) |
|
621 |
thus ?thesis by force |
|
622 |
qed |
|
623 |
||
624 |
lemma rec_function: |
|
625 |
fixes f1::"('a::pt_name) f1_ty" |
|
626 |
and f2::"('a::pt_name) f2_ty" |
|
627 |
and f3::"('a::pt_name) f3_ty" |
|
628 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
629 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
630 |
shows "\<exists>!y. (t,y)\<in>rec f1 f2 f3" |
|
631 |
proof |
|
632 |
case goal1 |
|
633 |
show ?case by (rule rec_total[OF f, OF c]) |
|
634 |
next |
|
635 |
case (goal2 y1 y2) |
|
636 |
assume a1: "(t,y1)\<in>rec f1 f2 f3" and a2: "(t,y2)\<in>rec f1 f2 f3" |
|
637 |
hence "\<forall>pi. y1 pi = y2 pi" using rec_unique[OF f, OF c] by force |
|
638 |
thus ?case by (force simp add: expand_fun_eq) |
|
639 |
qed |
|
640 |
||
641 |
lemma theI2': |
|
642 |
assumes a1: "P a" |
|
643 |
and a2: "\<exists>!x. P x" |
|
644 |
and a3: "P a \<Longrightarrow> Q a" |
|
645 |
shows "Q (THE x. P x)" |
|
646 |
apply(rule theI2) |
|
647 |
apply(rule a1) |
|
648 |
apply(subgoal_tac "\<exists>!x. P x") |
|
649 |
apply(auto intro: a1 simp add: Ex1_def) |
|
650 |
apply(fold Ex1_def) |
|
651 |
apply(rule a2) |
|
652 |
apply(subgoal_tac "x=a") |
|
653 |
apply(simp) |
|
654 |
apply(rule a3) |
|
655 |
apply(assumption) |
|
656 |
apply(subgoal_tac "\<exists>!x. P x") |
|
657 |
apply(auto intro: a1 simp add: Ex1_def) |
|
658 |
apply(fold Ex1_def) |
|
659 |
apply(rule a2) |
|
660 |
done |
|
661 |
||
662 |
lemma rfun'_equiv: |
|
663 |
fixes f1::"('a::pt_name) f1_ty" |
|
664 |
and f2::"('a::pt_name) f2_ty" |
|
665 |
and f3::"('a::pt_name) f3_ty" |
|
666 |
and pi::"name prm" |
|
667 |
and t ::"lam" |
|
668 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
669 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
670 |
shows "pi\<bullet>(rfun' f1 f2 f3 t) = rfun' (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3) (pi\<bullet>t)" |
|
671 |
apply(auto simp add: rfun'_def) |
|
672 |
apply(subgoal_tac "\<exists>y. (t,y)\<in>rec f1 f2 f3 \<and> finite ((supp y)::name set)") |
|
673 |
apply(auto) |
|
674 |
apply(rule sym) |
|
675 |
apply(rule_tac a="y" in theI2') |
|
676 |
apply(assumption) |
|
677 |
apply(rule rec_function[OF f, OF c]) |
|
678 |
apply(rule the1_equality) |
|
679 |
apply(rule rec_function) |
|
680 |
apply(subgoal_tac "finite ((supp (f1,f2,f3))::name set)") |
|
681 |
apply(simp add: supp_prod) |
|
682 |
apply(simp add: pt_supp_finite_pi[OF pt_name_inst, OF at_name_inst]) |
|
683 |
apply(rule f) |
|
684 |
apply(subgoal_tac "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)") |
|
685 |
apply(auto) |
|
686 |
apply(rule_tac x="pi\<bullet>a" in exI) |
|
687 |
apply(auto) |
|
688 |
apply(simp add: pt_fresh_bij[OF pt_name_inst, OF at_name_inst]) |
|
689 |
apply(drule_tac x="(rev pi)\<bullet>x" in spec) |
|
690 |
apply(subgoal_tac "(pi\<bullet>f3) (pi\<bullet>a) x = pi\<bullet>(f3 a ((rev pi)\<bullet>x))") |
|
691 |
apply(simp add: pt_fresh_bij[OF pt_name_inst, OF at_name_inst]) |
|
692 |
apply(subgoal_tac "pi\<bullet>(f3 a ((rev pi)\<bullet>x)) = (pi\<bullet>f3) (pi\<bullet>a) (pi\<bullet>((rev pi)\<bullet>x))") |
|
693 |
apply(simp) |
|
694 |
apply(simp add: pt_pi_rev[OF pt_name_inst, OF at_name_inst]) |
|
695 |
apply(simp add: pt_fun_app_eq[OF pt_name_inst, OF at_name_inst]) |
|
696 |
apply(rule c) |
|
697 |
apply(rule rec_prm_equiv) |
|
698 |
apply(rule f, rule c, assumption) |
|
699 |
apply(rule rec_total_aux) |
|
700 |
apply(rule f) |
|
701 |
apply(rule c) |
|
702 |
done |
|
703 |
||
704 |
lemma rfun'_supports: |
|
705 |
fixes f1::"('a::pt_name) f1_ty" |
|
706 |
and f2::"('a::pt_name) f2_ty" |
|
707 |
and f3::"('a::pt_name) f3_ty" |
|
708 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
709 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
710 |
shows "((supp (f1,f2,f3,t))::name set) supports (rfun' f1 f2 f3 t)" |
|
711 |
proof (auto simp add: "op supports_def" fresh_def[symmetric]) |
|
712 |
fix a::"name" and b::"name" |
|
713 |
assume a1: "a\<sharp>(f1,f2,f3,t)" |
|
714 |
and a2: "b\<sharp>(f1,f2,f3,t)" |
|
715 |
from a1 a2 have "[(a,b)]\<bullet>f1=f1" and "[(a,b)]\<bullet>f2=f2" and "[(a,b)]\<bullet>f3=f3" and "[(a,b)]\<bullet>t=t" |
|
716 |
by (simp_all add: pt_fresh_fresh[OF pt_name_inst, OF at_name_inst] fresh_prod) |
|
717 |
thus "[(a,b)]\<bullet>(rfun' f1 f2 f3 t) = rfun' f1 f2 f3 t" |
|
718 |
by (simp add: rfun'_equiv[OF f, OF c]) |
|
719 |
qed |
|
720 |
||
721 |
lemma rfun'_finite_supp: |
|
722 |
fixes f1::"('a::pt_name) f1_ty" |
|
723 |
and f2::"('a::pt_name) f2_ty" |
|
724 |
and f3::"('a::pt_name) f3_ty" |
|
725 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
726 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
727 |
shows "finite ((supp (rfun' f1 f2 f3 t))::name set)" |
|
728 |
apply(rule supports_finite) |
|
729 |
apply(rule rfun'_supports[OF f, OF c]) |
|
730 |
apply(subgoal_tac "finite ((supp (f1,f2,f3))::name set)") |
|
731 |
apply(simp add: supp_prod fs_name1) |
|
732 |
apply(rule f) |
|
733 |
done |
|
734 |
||
735 |
lemma rfun'_prm: |
|
736 |
fixes f1::"('a::pt_name) f1_ty" |
|
737 |
and f2::"('a::pt_name) f2_ty" |
|
738 |
and f3::"('a::pt_name) f3_ty" |
|
739 |
and pi1::"name prm" |
|
740 |
and pi2::"name prm" |
|
741 |
and t ::"lam" |
|
742 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
743 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
744 |
shows "rfun' f1 f2 f3 (pi1\<bullet>t) pi2 = rfun' f1 f2 f3 t (pi2@pi1)" |
|
745 |
apply(auto simp add: rfun'_def) |
|
746 |
apply(subgoal_tac "\<exists>y. (t,y)\<in>rec f1 f2 f3 \<and> finite ((supp y)::name set)") |
|
747 |
apply(auto) |
|
748 |
apply(rule_tac a="y" in theI2') |
|
749 |
apply(assumption) |
|
750 |
apply(rule rec_function[OF f, OF c]) |
|
751 |
apply(rule_tac a="\<lambda>pi2. y (pi2@pi1)" in theI2') |
|
752 |
apply(rule rec_perm) |
|
753 |
apply(rule f, rule c) |
|
754 |
apply(assumption) |
|
755 |
apply(rule rec_function) |
|
756 |
apply(rule f) |
|
757 |
apply(rule c) |
|
758 |
apply(simp) |
|
759 |
apply(rule rec_total_aux) |
|
760 |
apply(rule f) |
|
761 |
apply(rule c) |
|
762 |
done |
|
763 |
||
764 |
lemma rfun_Var: |
|
765 |
fixes f1::"('a::pt_name) f1_ty" |
|
766 |
and f2::"('a::pt_name) f2_ty" |
|
767 |
and f3::"('a::pt_name) f3_ty" |
|
768 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
769 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
770 |
shows "rfun f1 f2 f3 (Var c) = (f1 c)" |
|
771 |
apply(auto simp add: rfun_def rfun'_def) |
|
772 |
apply(subgoal_tac "(THE y. (Var c, y) \<in> rec f1 f2 f3) = (\<lambda>(pi::name prm). f1 (pi\<bullet>c))")(*A*) |
|
773 |
apply(simp) |
|
774 |
apply(rule the1_equality) |
|
775 |
apply(rule rec_function) |
|
776 |
apply(rule f) |
|
777 |
apply(rule c) |
|
778 |
apply(rule rec.r1) |
|
779 |
done |
|
780 |
||
781 |
lemma rfun_App: |
|
782 |
fixes f1::"('a::pt_name) f1_ty" |
|
783 |
and f2::"('a::pt_name) f2_ty" |
|
784 |
and f3::"('a::pt_name) f3_ty" |
|
785 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
786 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
787 |
shows "rfun f1 f2 f3 (App t1 t2) = (f2 (rfun f1 f2 f3 t1) (rfun f1 f2 f3 t2))" |
|
788 |
apply(auto simp add: rfun_def rfun'_def) |
|
789 |
apply(subgoal_tac "(THE y. (App t1 t2, y)\<in>rec f1 f2 f3) = |
|
790 |
(\<lambda>(pi::name prm). f2 ((rfun' f1 f2 f3 t1) pi) ((rfun' f1 f2 f3 t2) pi))")(*A*) |
|
791 |
apply(simp add: rfun'_def) |
|
792 |
apply(rule the1_equality) |
|
793 |
apply(rule rec_function[OF f, OF c]) |
|
794 |
apply(rule rec.r2) |
|
795 |
apply(rule rfun'_finite_supp[OF f, OF c]) |
|
796 |
apply(subgoal_tac "\<exists>y. (t1,y)\<in>rec f1 f2 f3") |
|
797 |
apply(erule exE, simp add: rfun'_def) |
|
798 |
apply(rule_tac a="y" in theI2') |
|
799 |
apply(assumption) |
|
800 |
apply(rule rec_function[OF f, OF c]) |
|
801 |
apply(assumption) |
|
802 |
apply(rule rec_total[OF f, OF c]) |
|
803 |
apply(rule rfun'_finite_supp[OF f, OF c]) |
|
804 |
apply(subgoal_tac "\<exists>y. (t2,y)\<in>rec f1 f2 f3") |
|
805 |
apply(auto simp add: rfun'_def) |
|
806 |
apply(rule_tac a="y" in theI2') |
|
807 |
apply(assumption) |
|
808 |
apply(rule rec_function[OF f, OF c]) |
|
809 |
apply(assumption) |
|
810 |
apply(rule rec_total[OF f, OF c]) |
|
811 |
done |
|
812 |
||
813 |
lemma rfun_Lam_aux1: |
|
814 |
fixes f1::"('a::pt_name) f1_ty" |
|
815 |
and f2::"('a::pt_name) f2_ty" |
|
816 |
and f3::"('a::pt_name) f3_ty" |
|
817 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
818 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
819 |
shows "rfun f1 f2 f3 (Lam [a].t) = fresh_fun (\<lambda>a'. f3 a' (rfun' f1 f2 f3 t ([]@[(a,a')])))" |
|
820 |
apply(simp add: rfun_def rfun'_def) |
|
821 |
apply(subgoal_tac "(THE y. (Lam [a].t, y)\<in>rec f1 f2 f3) = |
|
822 |
(\<lambda>(pi::name prm). fresh_fun(\<lambda>a'. f3 a' ((rfun' f1 f2 f3 t) (pi@[(a,a')]))))")(*A*) |
|
823 |
apply(simp add: rfun'_def[symmetric]) |
|
824 |
apply(rule the1_equality) |
|
825 |
apply(rule rec_function[OF f, OF c]) |
|
826 |
apply(rule rec.r3) |
|
827 |
apply(rule rfun'_finite_supp[OF f, OF c]) |
|
828 |
apply(subgoal_tac "\<exists>y. (t,y)\<in>rec f1 f2 f3") |
|
829 |
apply(erule exE, simp add: rfun'_def) |
|
830 |
apply(rule_tac a="y" in theI2') |
|
831 |
apply(assumption) |
|
832 |
apply(rule rec_function[OF f, OF c]) |
|
833 |
apply(assumption) |
|
834 |
apply(rule rec_total[OF f, OF c]) |
|
835 |
done |
|
836 |
||
837 |
lemma rfun_Lam_aux2: |
|
838 |
fixes f1::"('a::pt_name) f1_ty" |
|
839 |
and f2::"('a::pt_name) f2_ty" |
|
840 |
and f3::"('a::pt_name) f3_ty" |
|
841 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
842 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
843 |
and a: "b\<sharp>(a,t,f1,f2,f3)" |
|
844 |
shows "rfun f1 f2 f3 (Lam [b].([(a,b)]\<bullet>t)) = f3 b (rfun f1 f2 f3 ([(a,b)]\<bullet>t))" |
|
845 |
proof - |
|
846 |
from f have f': "finite ((supp f3)::name set)" by (simp add: supp_prod) |
|
847 |
have eq1: "rfun f1 f2 f3 (Lam [b].([(a,b)]\<bullet>t)) = rfun f1 f2 f3 (Lam [a].t)" |
|
848 |
proof - |
|
849 |
have "Lam [a].t = Lam [b].([(a,b)]\<bullet>t)" using a |
|
850 |
by (force simp add: lam.inject alpha fresh_prod at_fresh[OF at_name_inst] |
|
851 |
pt_swap_bij[OF pt_name_inst, OF at_name_inst] |
|
852 |
pt_fresh_left[OF pt_name_inst, OF at_name_inst] at_calc[OF at_name_inst]) |
|
853 |
thus ?thesis by simp |
|
854 |
qed |
|
855 |
let ?g = "(\<lambda>a'. f3 a' (rfun' f1 f2 f3 t ([]@[(a,a')])))" |
|
856 |
have a0: "((supp (f3,a,([]::name prm),rfun' f1 f2 f3 t))::name set) supports ?g" |
|
857 |
by (supports_simp add: perm_append) |
|
858 |
have a1: "finite ((supp (f3,a,([]::name prm),rfun' f1 f2 f3 t))::name set)" |
|
859 |
using f' by (simp add: supp_prod fs_name1 rfun'_finite_supp[OF f, OF c]) |
|
860 |
from a0 a1 have a2: "finite ((supp ?g)::name set)" |
|
861 |
by (rule supports_finite) |
|
862 |
have c0: "finite ((supp (rfun' f1 f2 f3 t))::name set)" |
|
863 |
by (rule rfun'_finite_supp[OF f, OF c]) |
|
864 |
have c1: "\<exists>(a''::name). a''\<sharp>?g \<and> a''\<sharp>(?g a'')" |
|
865 |
by (rule f3_freshness_conditions_simple[OF f', OF c0, OF c]) |
|
866 |
have c2: "b\<sharp>?g" |
|
867 |
proof - |
|
868 |
have fs_g: "finite ((supp (f1,f2,f3,t))::name set)" using f |
|
869 |
by (simp add: supp_prod fs_name1) |
|
870 |
have "((supp (f1,f2,f3,t))::name set) supports (rfun' f1 f2 f3 t)" |
|
871 |
by (simp add: rfun'_supports[OF f, OF c]) |
|
872 |
hence c3: "b\<sharp>(rfun' f1 f2 f3 t)" using fs_g |
|
873 |
proof(rule supports_fresh, simp add: fresh_def[symmetric]) |
|
874 |
show "b\<sharp>(f1,f2,f3,t)" using a by (simp add: fresh_prod) |
|
875 |
qed |
|
876 |
show ?thesis |
|
877 |
proof(rule supports_fresh[OF a0, OF a1], simp add: fresh_def[symmetric]) |
|
878 |
show "b\<sharp>(f3,a,([]::name prm),rfun' f1 f2 f3 t)" using a c3 |
|
879 |
by (simp add: fresh_prod fresh_list_nil) |
|
880 |
qed |
|
881 |
qed |
|
882 |
(* main proof *) |
|
883 |
have "rfun f1 f2 f3 (Lam [b].([(a,b)]\<bullet>t)) = rfun f1 f2 f3 (Lam [a].t)" by (simp add: eq1) |
|
884 |
also have "\<dots> = fresh_fun ?g" by (rule rfun_Lam_aux1[OF f, OF c]) |
|
885 |
also have "\<dots> = ?g b" using c2 |
|
886 |
by (rule fresh_fun_app[OF pt_name_inst, OF at_name_inst, OF a2, OF c1]) |
|
887 |
also have "\<dots> = f3 b (rfun f1 f2 f3 ([(a,b)]\<bullet>t))" |
|
888 |
by (simp add: rfun_def rfun'_prm[OF f, OF c]) |
|
889 |
finally show "rfun f1 f2 f3 (Lam [b].([(a,b)]\<bullet>t)) = f3 b (rfun f1 f2 f3 ([(a,b)]\<bullet>t))" . |
|
890 |
qed |
|
891 |
||
892 |
||
893 |
lemma rfun_Lam: |
|
894 |
fixes f1::"('a::pt_name) f1_ty" |
|
895 |
and f2::"('a::pt_name) f2_ty" |
|
896 |
and f3::"('a::pt_name) f3_ty" |
|
897 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
898 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
899 |
and a: "b\<sharp>(f1,f2,f3)" |
|
900 |
shows "rfun f1 f2 f3 (Lam [b].t) = f3 b (rfun f1 f2 f3 t)" |
|
901 |
proof - |
|
902 |
have "\<exists>(a::name). a\<sharp>(b,t)" |
|
903 |
by (rule at_exists_fresh[OF at_name_inst], simp add: supp_prod fs_name1) |
|
904 |
then obtain a::"name" where a1: "a\<sharp>b" and a2: "a\<sharp>t" by (force simp add: fresh_prod) |
|
905 |
have "rfun f1 f2 f3 (Lam [b].t) = rfun f1 f2 f3 (Lam [b].(([(a,b)])\<bullet>([(a,b)]\<bullet>t)))" |
|
906 |
by (simp add: pt_swap_bij[OF pt_name_inst, OF at_name_inst]) |
|
907 |
also have "\<dots> = f3 b (rfun f1 f2 f3 (([(a,b)])\<bullet>([(a,b)]\<bullet>t)))" |
|
908 |
proof(rule rfun_Lam_aux2[OF f, OF c]) |
|
909 |
have "b\<sharp>([(a,b)]\<bullet>t)" using a1 a2 |
|
910 |
by (simp add: pt_fresh_left[OF pt_name_inst, OF at_name_inst] at_calc[OF at_name_inst] |
|
911 |
at_fresh[OF at_name_inst]) |
|
912 |
thus "b\<sharp>(a,[(a,b)]\<bullet>t,f1,f2,f3)" using a a1 by (force simp add: fresh_prod at_fresh[OF at_name_inst]) |
|
913 |
qed |
|
914 |
also have "\<dots> = f3 b (rfun f1 f2 f3 t)" by (simp add: pt_swap_bij[OF pt_name_inst, OF at_name_inst]) |
|
915 |
finally show ?thesis . |
|
916 |
qed |
|
917 |
||
918 |
lemma rec_unique: |
|
919 |
fixes fun::"lam \<Rightarrow> ('a::pt_name)" |
|
920 |
and f1::"('a::pt_name) f1_ty" |
|
921 |
and f2::"('a::pt_name) f2_ty" |
|
922 |
and f3::"('a::pt_name) f3_ty" |
|
923 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
924 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
925 |
and a1: "\<forall>c. fun (Var c) = f1 c" |
|
926 |
and a2: "\<forall>t1 t2. fun (App t1 t2) = f2 (fun t1) (fun t2)" |
|
927 |
and a3: "\<forall>a t. a\<sharp>(f1,f2,f3) \<longrightarrow> fun (Lam [a].t) = f3 a (fun t)" |
|
928 |
shows "fun t = rfun f1 f2 f3 t" |
|
929 |
(*apply(nominal_induct t rule: lam_induct')*) |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
930 |
apply (rule lam_induct'[of "\<lambda>_. (f1,f2,f3)" "\<lambda>_ t. fun t = rfun f1 f2 f3 t"]) |
18106 | 931 |
(* finite support *) |
932 |
apply(rule f) |
|
933 |
(* VAR *) |
|
934 |
apply(simp add: a1 rfun_Var[OF f, OF c, symmetric]) |
|
935 |
(* APP *) |
|
936 |
apply(simp add: a2 rfun_App[OF f, OF c, symmetric]) |
|
937 |
(* LAM *) |
|
938 |
apply(simp add: a3 rfun_Lam[OF f, OF c, symmetric]) |
|
939 |
done |
|
940 |
||
941 |
lemma rec_function: |
|
942 |
fixes f1::"('a::pt_name) f1_ty" |
|
943 |
and f2::"('a::pt_name) f2_ty" |
|
944 |
and f3::"('a::pt_name) f3_ty" |
|
945 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
946 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)" |
|
947 |
shows "(\<exists>!(fun::lam \<Rightarrow> ('a::pt_name)). |
|
948 |
(\<forall>c. fun (Var c) = f1 c) \<and> |
|
949 |
(\<forall>t1 t2. fun (App t1 t2) = f2 (fun t1) (fun t2)) \<and> |
|
950 |
(\<forall>a t. a\<sharp>(f1,f2,f3) \<longrightarrow> fun (Lam [a].t) = f3 a (fun t)))" |
|
951 |
apply(rule_tac a="\<lambda>t. rfun f1 f2 f3 t" in ex1I) |
|
952 |
(* existence *) |
|
953 |
apply(simp add: rfun_Var[OF f, OF c]) |
|
954 |
apply(simp add: rfun_App[OF f, OF c]) |
|
955 |
apply(simp add: rfun_Lam[OF f, OF c]) |
|
956 |
(* uniqueness *) |
|
957 |
apply(auto simp add: expand_fun_eq) |
|
958 |
apply(rule rec_unique[OF f, OF c]) |
|
959 |
apply(force)+ |
|
960 |
done |
|
961 |
||
962 |
(* "real" recursion *) |
|
963 |
||
964 |
types 'a f1_ty' = "name\<Rightarrow>('a::pt_name)" |
|
965 |
'a f2_ty' = "lam\<Rightarrow>lam\<Rightarrow>'a\<Rightarrow>'a\<Rightarrow>('a::pt_name)" |
|
966 |
'a f3_ty' = "lam\<Rightarrow>name\<Rightarrow>'a\<Rightarrow>('a::pt_name)" |
|
967 |
||
968 |
constdefs |
|
969 |
rfun_gen' :: "'a f1_ty' \<Rightarrow> 'a f2_ty' \<Rightarrow> 'a f3_ty' \<Rightarrow> lam \<Rightarrow> (lam\<times>'a::pt_name)" |
|
970 |
"rfun_gen' f1 f2 f3 t \<equiv> (rfun |
|
971 |
(\<lambda>(a::name). (Var a,f1 a)) |
|
972 |
(\<lambda>r1 r2. (App (fst r1) (fst r2), f2 (fst r1) (fst r2) (snd r1) (snd r2))) |
|
973 |
(\<lambda>(a::name) r. (Lam [a].(fst r),f3 (fst r) a (snd r))) |
|
974 |
t)" |
|
975 |
||
976 |
rfun_gen :: "'a f1_ty' \<Rightarrow> 'a f2_ty' \<Rightarrow> 'a f3_ty' \<Rightarrow> lam \<Rightarrow> 'a::pt_name" |
|
977 |
"rfun_gen f1 f2 f3 t \<equiv> snd(rfun_gen' f1 f2 f3 t)" |
|
978 |
||
979 |
||
980 |
||
981 |
lemma f1'_supports: |
|
982 |
fixes f1::"('a::pt_name) f1_ty'" |
|
983 |
shows "((supp f1)::name set) supports (\<lambda>(a::name). (Var a,f1 a))" |
|
984 |
by (supports_simp) |
|
985 |
||
986 |
lemma f2'_supports: |
|
987 |
fixes f2::"('a::pt_name) f2_ty'" |
|
988 |
shows "((supp f2)::name set) supports |
|
989 |
(\<lambda>r1 r2. (App (fst r1) (fst r2), f2 (fst r1) (fst r2) (snd r1) (snd r2)))" |
|
990 |
by (supports_simp add: perm_fst perm_snd) |
|
991 |
||
992 |
lemma f3'_supports: |
|
993 |
fixes f3::"('a::pt_name) f3_ty'" |
|
994 |
shows "((supp f3)::name set) supports (\<lambda>(a::name) r. (Lam [a].(fst r),f3 (fst r) a (snd r)))" |
|
995 |
by (supports_simp add: perm_fst perm_snd) |
|
996 |
||
997 |
lemma fcb': |
|
998 |
fixes f3::"('a::pt_name) f3_ty'" |
|
999 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1000 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1001 |
shows "\<exists>a. a \<sharp> (\<lambda>a r. (Lam [a].fst r, f3 (fst r) a (snd r))) \<and> |
|
1002 |
(\<forall>y. a \<sharp> (Lam [a].fst y, f3 (fst y) a (snd y)))" |
|
1003 |
using c f |
|
1004 |
apply(auto) |
|
1005 |
apply(rule_tac x="a" in exI) |
|
1006 |
apply(auto simp add: abs_fresh fresh_prod) |
|
1007 |
apply(rule supports_fresh) |
|
1008 |
apply(rule f3'_supports) |
|
1009 |
apply(simp add: supp_prod) |
|
1010 |
apply(simp add: fresh_def) |
|
1011 |
done |
|
1012 |
||
1013 |
lemma fsupp': |
|
1014 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1015 |
and f2::"('a::pt_name) f2_ty'" |
|
1016 |
and f3::"('a::pt_name) f3_ty'" |
|
1017 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1018 |
shows "finite((supp |
|
1019 |
(\<lambda>a. (Var a, f1 a), |
|
1020 |
\<lambda>r1 r2. |
|
1021 |
(App (fst r1) (fst r2), |
|
1022 |
f2 (fst r1) (fst r2) (snd r1) (snd r2)), |
|
1023 |
\<lambda>a r. (Lam [a].fst r, f3 (fst r) a (snd r))))::name set)" |
|
1024 |
using f |
|
1025 |
apply(auto simp add: supp_prod) |
|
1026 |
apply(rule supports_finite) |
|
1027 |
apply(rule f1'_supports) |
|
1028 |
apply(assumption) |
|
1029 |
apply(rule supports_finite) |
|
1030 |
apply(rule f2'_supports) |
|
1031 |
apply(assumption) |
|
1032 |
apply(rule supports_finite) |
|
1033 |
apply(rule f3'_supports) |
|
1034 |
apply(assumption) |
|
1035 |
done |
|
1036 |
||
1037 |
lemma rfun_gen'_fst: |
|
1038 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1039 |
and f2::"('a::pt_name) f2_ty'" |
|
1040 |
and f3::"('a::pt_name) f3_ty'" |
|
1041 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1042 |
and c: "(\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y))" |
|
1043 |
shows "fst (rfun_gen' f1 f2 f3 t) = t" |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
1044 |
apply(rule lam_induct'[of "\<lambda>_. (f1,f2,f3)" "\<lambda>_ t. fst (rfun_gen' f1 f2 f3 t) = t"]) |
18106 | 1045 |
apply(simp add: f) |
1046 |
apply(unfold rfun_gen'_def) |
|
1047 |
apply(simp only: rfun_Var[OF fsupp'[OF f],OF fcb'[OF f, OF c]]) |
|
1048 |
apply(simp) |
|
1049 |
apply(simp only: rfun_App[OF fsupp'[OF f],OF fcb'[OF f, OF c]]) |
|
1050 |
apply(simp) |
|
1051 |
apply(auto) |
|
1052 |
apply(rule trans) |
|
1053 |
apply(rule_tac f="fst" in arg_cong) |
|
1054 |
apply(rule rfun_Lam[OF fsupp'[OF f],OF fcb'[OF f, OF c]]) |
|
1055 |
apply(auto simp add: fresh_prod) |
|
1056 |
apply(rule supports_fresh) |
|
1057 |
apply(rule f1'_supports) |
|
1058 |
apply(subgoal_tac "finite ((supp (f1,f2,f3))::name set)") |
|
1059 |
apply(simp add: supp_prod) |
|
1060 |
apply(rule f) |
|
1061 |
apply(simp add: fresh_def) |
|
1062 |
apply(rule supports_fresh) |
|
1063 |
apply(rule f2'_supports) |
|
1064 |
apply(subgoal_tac "finite ((supp (f1,f2,f3))::name set)") |
|
1065 |
apply(simp add: supp_prod) |
|
1066 |
apply(rule f) |
|
1067 |
apply(simp add: fresh_def) |
|
1068 |
apply(rule supports_fresh) |
|
1069 |
apply(rule f3'_supports) |
|
1070 |
apply(subgoal_tac "finite ((supp (f1,f2,f3))::name set)") |
|
1071 |
apply(simp add: supp_prod) |
|
1072 |
apply(rule f) |
|
1073 |
apply(simp add: fresh_def) |
|
1074 |
done |
|
1075 |
||
1076 |
lemma rfun_gen'_Var: |
|
1077 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1078 |
and f2::"('a::pt_name) f2_ty'" |
|
1079 |
and f3::"('a::pt_name) f3_ty'" |
|
1080 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1081 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1082 |
shows "rfun_gen' f1 f2 f3 (Var c) = (Var c, f1 c)" |
|
1083 |
apply(simp add: rfun_gen'_def) |
|
1084 |
apply(simp add: rfun_Var[OF fsupp'[OF f],OF fcb'[OF f, OF c]]) |
|
1085 |
done |
|
1086 |
||
1087 |
lemma rfun_gen'_App: |
|
1088 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1089 |
and f2::"('a::pt_name) f2_ty'" |
|
1090 |
and f3::"('a::pt_name) f3_ty'" |
|
1091 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1092 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1093 |
shows "rfun_gen' f1 f2 f3 (App t1 t2) = |
|
1094 |
(App t1 t2, f2 t1 t2 (rfun_gen f1 f2 f3 t1) (rfun_gen f1 f2 f3 t2))" |
|
1095 |
apply(simp add: rfun_gen'_def) |
|
1096 |
apply(rule trans) |
|
1097 |
apply(rule rfun_App[OF fsupp'[OF f],OF fcb'[OF f, OF c]]) |
|
1098 |
apply(fold rfun_gen'_def) |
|
1099 |
apply(simp_all add: rfun_gen'_fst[OF f, OF c]) |
|
1100 |
apply(simp_all add: rfun_gen_def) |
|
1101 |
done |
|
1102 |
||
1103 |
lemma rfun_gen'_Lam: |
|
1104 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1105 |
and f2::"('a::pt_name) f2_ty'" |
|
1106 |
and f3::"('a::pt_name) f3_ty'" |
|
1107 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1108 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1109 |
and a: "b\<sharp>(f1,f2,f3)" |
|
1110 |
shows "rfun_gen' f1 f2 f3 (Lam [b].t) = (Lam [b].t, f3 t b (rfun_gen f1 f2 f3 t))" |
|
1111 |
using a f |
|
1112 |
apply(simp add: rfun_gen'_def) |
|
1113 |
apply(rule trans) |
|
1114 |
apply(rule rfun_Lam[OF fsupp'[OF f],OF fcb'[OF f, OF c]]) |
|
1115 |
apply(auto simp add: fresh_prod) |
|
1116 |
apply(rule supports_fresh) |
|
1117 |
apply(rule f1'_supports) |
|
1118 |
apply(simp add: supp_prod) |
|
1119 |
apply(simp add: fresh_def) |
|
1120 |
apply(rule supports_fresh) |
|
1121 |
apply(rule f2'_supports) |
|
1122 |
apply(simp add: supp_prod) |
|
1123 |
apply(simp add: fresh_def) |
|
1124 |
apply(rule supports_fresh) |
|
1125 |
apply(rule f3'_supports) |
|
1126 |
apply(simp add: supp_prod) |
|
1127 |
apply(simp add: fresh_def) |
|
1128 |
apply(fold rfun_gen'_def) |
|
1129 |
apply(simp_all add: rfun_gen'_fst[OF f, OF c]) |
|
1130 |
apply(simp_all add: rfun_gen_def) |
|
1131 |
done |
|
1132 |
||
1133 |
lemma rfun_gen_Var: |
|
1134 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1135 |
and f2::"('a::pt_name) f2_ty'" |
|
1136 |
and f3::"('a::pt_name) f3_ty'" |
|
1137 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1138 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1139 |
shows "rfun_gen f1 f2 f3 (Var c) = f1 c" |
|
1140 |
apply(unfold rfun_gen_def) |
|
1141 |
apply(simp add: rfun_gen'_Var[OF f, OF c]) |
|
1142 |
done |
|
1143 |
||
1144 |
lemma rfun_gen_App: |
|
1145 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1146 |
and f2::"('a::pt_name) f2_ty'" |
|
1147 |
and f3::"('a::pt_name) f3_ty'" |
|
1148 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1149 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1150 |
shows "rfun_gen f1 f2 f3 (App t1 t2) = f2 t1 t2 (rfun_gen f1 f2 f3 t1) (rfun_gen f1 f2 f3 t2)" |
|
1151 |
apply(unfold rfun_gen_def) |
|
1152 |
apply(simp add: rfun_gen'_App[OF f, OF c]) |
|
1153 |
apply(simp add: rfun_gen_def) |
|
1154 |
done |
|
1155 |
||
1156 |
lemma rfun_gen_Lam: |
|
1157 |
fixes f1::"('a::pt_name) f1_ty'" |
|
1158 |
and f2::"('a::pt_name) f2_ty'" |
|
1159 |
and f3::"('a::pt_name) f3_ty'" |
|
1160 |
assumes f: "finite ((supp (f1,f2,f3))::name set)" |
|
1161 |
and c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name) t. a\<sharp>f3 t a y)" |
|
1162 |
and a: "b\<sharp>(f1,f2,f3)" |
|
1163 |
shows "rfun_gen f1 f2 f3 (Lam [b].t) = f3 t b (rfun_gen f1 f2 f3 t)" |
|
1164 |
using a |
|
1165 |
apply(unfold rfun_gen_def) |
|
1166 |
apply(simp add: rfun_gen'_Lam[OF f, OF c]) |
|
1167 |
apply(simp add: rfun_gen_def) |
|
1168 |
done |
|
1169 |
||
18269 | 1170 |
(* FIXME: this should be automatically proved in nominal_atoms *) |
1171 |
||
18106 | 1172 |
instance nat :: pt_name |
1173 |
apply(intro_classes) |
|
1174 |
apply(simp_all add: perm_nat_def) |
|
1175 |
done |
|
1176 |
||
1177 |
constdefs |
|
1178 |
depth_Var :: "name \<Rightarrow> nat" |
|
1179 |
"depth_Var \<equiv> \<lambda>(a::name). 1" |
|
1180 |
||
1181 |
depth_App :: "nat \<Rightarrow> nat \<Rightarrow> nat" |
|
1182 |
"depth_App \<equiv> \<lambda>n1 n2. (max n1 n2)+1" |
|
1183 |
||
1184 |
depth_Lam :: "name \<Rightarrow> nat \<Rightarrow> nat" |
|
1185 |
"depth_Lam \<equiv> \<lambda>(a::name) n. n+1" |
|
1186 |
||
1187 |
depth_lam :: "lam \<Rightarrow> nat" |
|
1188 |
"depth_lam \<equiv> rfun depth_Var depth_App depth_Lam" |
|
1189 |
||
1190 |
lemma supp_depth_Var: |
|
1191 |
shows "((supp depth_Var)::name set)={}" |
|
1192 |
apply(simp add: depth_Var_def) |
|
1193 |
apply(simp add: supp_def) |
|
1194 |
apply(simp add: perm_fun_def) |
|
1195 |
apply(simp add: perm_nat_def) |
|
1196 |
done |
|
1197 |
||
1198 |
lemma supp_depth_App: |
|
1199 |
shows "((supp depth_App)::name set)={}" |
|
1200 |
apply(simp add: depth_App_def) |
|
1201 |
apply(simp add: supp_def) |
|
1202 |
apply(simp add: perm_fun_def) |
|
1203 |
apply(simp add: perm_nat_def) |
|
1204 |
done |
|
1205 |
||
1206 |
lemma supp_depth_Lam: |
|
1207 |
shows "((supp depth_Lam)::name set)={}" |
|
1208 |
apply(simp add: depth_Lam_def) |
|
1209 |
apply(simp add: supp_def) |
|
1210 |
apply(simp add: perm_fun_def) |
|
1211 |
apply(simp add: perm_nat_def) |
|
1212 |
done |
|
1213 |
||
1214 |
||
1215 |
lemma fin_supp_depth: |
|
1216 |
shows "finite ((supp (depth_Var,depth_App,depth_Lam))::name set)" |
|
1217 |
using supp_depth_Var supp_depth_Lam supp_depth_App |
|
1218 |
by (simp add: supp_prod) |
|
1219 |
||
1220 |
lemma fresh_depth_Lam: |
|
1221 |
shows "\<exists>(a::name). a\<sharp>depth_Lam \<and> (\<forall>n. a\<sharp>depth_Lam a n)" |
|
1222 |
apply(rule exI) |
|
1223 |
apply(rule conjI) |
|
1224 |
apply(simp add: fresh_def supp_depth_Lam) |
|
1225 |
apply(auto simp add: depth_Lam_def) |
|
1226 |
apply(unfold fresh_def) |
|
1227 |
apply(simp add: supp_def) |
|
1228 |
apply(simp add: perm_nat_def) |
|
1229 |
done |
|
1230 |
||
1231 |
lemma depth_Var: |
|
1232 |
shows "depth_lam (Var c) = 1" |
|
1233 |
apply(simp add: depth_lam_def) |
|
1234 |
apply(simp add: rfun_Var[OF fin_supp_depth, OF fresh_depth_Lam]) |
|
1235 |
apply(simp add: depth_Var_def) |
|
1236 |
done |
|
1237 |
||
1238 |
lemma depth_App: |
|
1239 |
shows "depth_lam (App t1 t2) = (max (depth_lam t1) (depth_lam t2))+1" |
|
1240 |
apply(simp add: depth_lam_def) |
|
1241 |
apply(simp add: rfun_App[OF fin_supp_depth, OF fresh_depth_Lam]) |
|
1242 |
apply(simp add: depth_App_def) |
|
1243 |
done |
|
1244 |
||
1245 |
lemma depth_Lam: |
|
1246 |
shows "depth_lam (Lam [a].t) = (depth_lam t)+1" |
|
1247 |
apply(simp add: depth_lam_def) |
|
1248 |
apply(rule trans) |
|
1249 |
apply(rule rfun_Lam[OF fin_supp_depth, OF fresh_depth_Lam]) |
|
1250 |
apply(simp add: fresh_def supp_prod supp_depth_Var supp_depth_App supp_depth_Lam) |
|
1251 |
apply(simp add: depth_Lam_def) |
|
1252 |
done |
|
1253 |
||
1254 |
||
1255 |
(* substitution *) |
|
1256 |
||
1257 |
constdefs |
|
1258 |
subst_Var :: "name \<Rightarrow>lam \<Rightarrow> name \<Rightarrow> lam" |
|
1259 |
"subst_Var b t \<equiv> \<lambda>a. (if a=b then t else (Var a))" |
|
1260 |
||
1261 |
subst_App :: "name \<Rightarrow> lam \<Rightarrow> lam \<Rightarrow> lam \<Rightarrow> lam" |
|
1262 |
"subst_App b t \<equiv> \<lambda>r1 r2. App r1 r2" |
|
1263 |
||
1264 |
subst_Lam :: "name \<Rightarrow> lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" |
|
1265 |
"subst_Lam b t \<equiv> \<lambda>a r. Lam [a].r" |
|
1266 |
||
1267 |
subst_lam :: "name \<Rightarrow> lam \<Rightarrow> lam \<Rightarrow> lam" |
|
1268 |
"subst_lam b t \<equiv> rfun (subst_Var b t) (subst_App b t) (subst_Lam b t)" |
|
1269 |
||
1270 |
||
1271 |
lemma supports_subst_Var: |
|
1272 |
shows "((supp (b,t))::name set) supports (subst_Var b t)" |
|
1273 |
apply(supports_simp add: subst_Var_def) |
|
1274 |
apply(rule impI) |
|
1275 |
apply(drule pt_bij1[OF pt_name_inst, OF at_name_inst]) |
|
1276 |
apply(simp add: pt_fresh_fresh[OF pt_name_inst, OF at_name_inst]) |
|
1277 |
done |
|
1278 |
||
1279 |
lemma supports_subst_App: |
|
1280 |
shows "((supp (b,t))::name set) supports subst_App b t" |
|
1281 |
by (supports_simp add: subst_App_def) |
|
1282 |
||
1283 |
lemma supports_subst_Lam: |
|
1284 |
shows "((supp (b,t))::name set) supports subst_Lam b t" |
|
1285 |
by (supports_simp add: subst_Lam_def) |
|
1286 |
||
1287 |
||
1288 |
lemma fin_supp_subst: |
|
1289 |
shows "finite ((supp (subst_Var b t,subst_App b t,subst_Lam b t))::name set)" |
|
1290 |
apply(auto simp add: supp_prod) |
|
1291 |
apply(rule supports_finite) |
|
1292 |
apply(rule supports_subst_Var) |
|
1293 |
apply(simp add: fs_name1) |
|
1294 |
apply(rule supports_finite) |
|
1295 |
apply(rule supports_subst_App) |
|
1296 |
apply(simp add: fs_name1) |
|
1297 |
apply(rule supports_finite) |
|
1298 |
apply(rule supports_subst_Lam) |
|
1299 |
apply(simp add: fs_name1) |
|
1300 |
done |
|
1301 |
||
1302 |
lemma fresh_subst_Lam: |
|
1303 |
shows "\<exists>(a::name). a\<sharp>(subst_Lam b t)\<and> (\<forall>y. a\<sharp>(subst_Lam b t) a y)" |
|
1304 |
apply(subgoal_tac "\<exists>(c::name). c\<sharp>(b,t)") |
|
1305 |
apply(auto) |
|
1306 |
apply(rule_tac x="c" in exI) |
|
1307 |
apply(auto) |
|
1308 |
apply(rule supports_fresh) |
|
1309 |
apply(rule supports_subst_Lam) |
|
1310 |
apply(simp_all add: fresh_def[symmetric] fs_name1) |
|
1311 |
apply(simp add: subst_Lam_def) |
|
1312 |
apply(simp add: abs_fresh) |
|
1313 |
apply(rule at_exists_fresh[OF at_name_inst]) |
|
1314 |
apply(simp add: fs_name1) |
|
1315 |
done |
|
1316 |
||
1317 |
lemma subst_Var: |
|
1318 |
shows "subst_lam b t (Var a) = (if a=b then t else (Var a))" |
|
1319 |
apply(simp add: subst_lam_def) |
|
1320 |
apply(auto simp add: rfun_Var[OF fin_supp_subst, OF fresh_subst_Lam]) |
|
1321 |
apply(auto simp add: subst_Var_def) |
|
1322 |
done |
|
1323 |
||
1324 |
lemma subst_App: |
|
1325 |
shows "subst_lam b t (App t1 t2) = App (subst_lam b t t1) (subst_lam b t t2)" |
|
1326 |
apply(simp add: subst_lam_def) |
|
1327 |
apply(auto simp add: rfun_App[OF fin_supp_subst, OF fresh_subst_Lam]) |
|
1328 |
apply(auto simp add: subst_App_def) |
|
1329 |
done |
|
1330 |
||
1331 |
lemma subst_Lam: |
|
1332 |
assumes a: "a\<sharp>(b,t)" |
|
1333 |
shows "subst_lam b t (Lam [a].t1) = Lam [a].(subst_lam b t t1)" |
|
1334 |
using a |
|
1335 |
apply(simp add: subst_lam_def) |
|
1336 |
apply(subgoal_tac "a\<sharp>(subst_Var b t,subst_App b t,subst_Lam b t)") |
|
1337 |
apply(auto simp add: rfun_Lam[OF fin_supp_subst, OF fresh_subst_Lam]) |
|
1338 |
apply(simp (no_asm) add: subst_Lam_def) |
|
1339 |
apply(auto simp add: fresh_prod) |
|
1340 |
apply(rule supports_fresh) |
|
1341 |
apply(rule supports_subst_Var) |
|
1342 |
apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) |
|
1343 |
apply(rule supports_fresh) |
|
1344 |
apply(rule supports_subst_App) |
|
1345 |
apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) |
|
1346 |
apply(rule supports_fresh) |
|
1347 |
apply(rule supports_subst_Lam) |
|
1348 |
apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) |
|
1349 |
done |
|
1350 |
||
1351 |
lemma subst_Lam': |
|
1352 |
assumes a: "a\<noteq>b" |
|
1353 |
and b: "a\<sharp>t" |
|
1354 |
shows "subst_lam b t (Lam [a].t1) = Lam [a].(subst_lam b t t1)" |
|
1355 |
apply(rule subst_Lam) |
|
1356 |
apply(simp add: fresh_prod a b fresh_atm) |
|
1357 |
done |
|
1358 |
||
1359 |
consts |
|
1360 |
subst_syn :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_[_::=_]" [100,100,100] 900) |
|
1361 |
translations |
|
1362 |
"t1[a::=t2]" \<rightleftharpoons> "subst_lam a t2 t1" |
|
1363 |
||
1364 |
declare subst_Var[simp] |
|
1365 |
declare subst_App[simp] |
|
1366 |
declare subst_Lam[simp] |
|
1367 |
declare subst_Lam'[simp] |
|
1368 |
||
1369 |
lemma subst_eqvt[simp]: |
|
1370 |
fixes pi:: "name prm" |
|
1371 |
and t1:: "lam" |
|
1372 |
and t2:: "lam" |
|
1373 |
and a :: "name" |
|
1374 |
shows "pi\<bullet>(t1[a::=t2]) = (pi\<bullet>t1)[(pi\<bullet>a)::=(pi\<bullet>t2)]" |
|
18284
cd217d16c90d
changed the order of the induction variable and the context
urbanc
parents:
18269
diff
changeset
|
1375 |
thm lam_induct |
18106 | 1376 |
apply(nominal_induct t1 rule: lam_induct) |
1377 |
apply(auto) |
|
1378 |
apply(auto simp add: perm_bij fresh_prod fresh_atm) |
|
1379 |
apply(subgoal_tac "(aa\<bullet>ab)\<sharp>(aa\<bullet>a,aa\<bullet>b)")(*A*) |
|
1380 |
apply(simp) |
|
1381 |
apply(simp add: perm_bij fresh_prod fresh_atm pt_fresh_bij[OF pt_name_inst, OF at_name_inst]) |
|
1382 |
done |
|
1383 |
||
1384 |
lemma subst_supp: "supp(t1[a::=t2])\<subseteq>(((supp(t1)-{a})\<union>supp(t2))::name set)" |
|
1385 |
apply(nominal_induct t1 rule: lam_induct) |
|
1386 |
apply(auto simp add: lam.supp supp_atm fresh_prod abs_supp) |
|
1387 |
apply(blast) |
|
1388 |
apply(blast) |
|
1389 |
done |
|
1390 |
||
1391 |
(* parallel substitution *) |
|
1392 |
||
1393 |
consts |
|
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1394 |
"domain" :: "(name\<times>lam) list \<Rightarrow> (name list)" |
18106 | 1395 |
primrec |
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1396 |
"domain [] = []" |
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1397 |
"domain (x#\<theta>) = (fst x)#(domain \<theta>)" |
18106 | 1398 |
|
1399 |
consts |
|
1400 |
"apply_sss" :: "(name\<times>lam) list \<Rightarrow> name \<Rightarrow> lam" (" _ < _ >" [80,80] 80) |
|
1401 |
primrec |
|
1402 |
"(x#\<theta>)<a> = (if (a = fst x) then (snd x) else \<theta><a>)" |
|
1403 |
||
1404 |
||
1405 |
lemma apply_sss_eqvt[rule_format]: |
|
1406 |
fixes pi::"name prm" |
|
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1407 |
shows "a\<in>set (domain \<theta>) \<longrightarrow> pi\<bullet>(\<theta><a>) = (pi\<bullet>\<theta>)<pi\<bullet>a>" |
18106 | 1408 |
apply(induct_tac \<theta>) |
1409 |
apply(auto) |
|
1410 |
apply(simp add: pt_bij[OF pt_name_inst, OF at_name_inst]) |
|
1411 |
done |
|
1412 |
||
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1413 |
lemma domain_eqvt[rule_format]: |
18106 | 1414 |
fixes pi::"name prm" |
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1415 |
shows "((pi\<bullet>a)\<in>set (domain \<theta>)) = (a\<in>set (domain ((rev pi)\<bullet>\<theta>)))" |
18106 | 1416 |
apply(induct_tac \<theta>) |
1417 |
apply(auto) |
|
1418 |
apply(simp_all add: pt_rev_pi[OF pt_name_inst, OF at_name_inst]) |
|
1419 |
apply(simp_all add: pt_pi_rev[OF pt_name_inst, OF at_name_inst]) |
|
1420 |
done |
|
1421 |
||
1422 |
constdefs |
|
1423 |
psubst_Var :: "(name\<times>lam) list \<Rightarrow> name \<Rightarrow> lam" |
|
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1424 |
"psubst_Var \<theta> \<equiv> \<lambda>a. (if a\<in>set (domain \<theta>) then \<theta><a> else (Var a))" |
18106 | 1425 |
|
1426 |
psubst_App :: "(name\<times>lam) list \<Rightarrow> lam \<Rightarrow> lam \<Rightarrow> lam" |
|
1427 |
"psubst_App \<theta> \<equiv> \<lambda>r1 r2. App r1 r2" |
|
1428 |
||
1429 |
psubst_Lam :: "(name\<times>lam) list \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" |
|
1430 |
"psubst_Lam \<theta> \<equiv> \<lambda>a r. Lam [a].r" |
|
1431 |
||
1432 |
psubst_lam :: "(name\<times>lam) list \<Rightarrow> lam \<Rightarrow> lam" |
|
1433 |
"psubst_lam \<theta> \<equiv> rfun (psubst_Var \<theta>) (psubst_App \<theta>) (psubst_Lam \<theta>)" |
|
1434 |
||
1435 |
lemma supports_psubst_Var: |
|
1436 |
shows "((supp \<theta>)::name set) supports (psubst_Var \<theta>)" |
|
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1437 |
by (supports_simp add: psubst_Var_def apply_sss_eqvt domain_eqvt) |
18106 | 1438 |
|
1439 |
lemma supports_psubst_App: |
|
1440 |
shows "((supp \<theta>)::name set) supports psubst_App \<theta>" |
|
1441 |
by (supports_simp add: psubst_App_def) |
|
1442 |
||
1443 |
lemma supports_psubst_Lam: |
|
1444 |
shows "((supp \<theta>)::name set) supports psubst_Lam \<theta>" |
|
1445 |
by (supports_simp add: psubst_Lam_def) |
|
1446 |
||
1447 |
lemma fin_supp_psubst: |
|
1448 |
shows "finite ((supp (psubst_Var \<theta>,psubst_App \<theta>,psubst_Lam \<theta>))::name set)" |
|
1449 |
apply(auto simp add: supp_prod) |
|
1450 |
apply(rule supports_finite) |
|
1451 |
apply(rule supports_psubst_Var) |
|
1452 |
apply(simp add: fs_name1) |
|
1453 |
apply(rule supports_finite) |
|
1454 |
apply(rule supports_psubst_App) |
|
1455 |
apply(simp add: fs_name1) |
|
1456 |
apply(rule supports_finite) |
|
1457 |
apply(rule supports_psubst_Lam) |
|
1458 |
apply(simp add: fs_name1) |
|
1459 |
done |
|
1460 |
||
1461 |
lemma fresh_psubst_Lam: |
|
1462 |
shows "\<exists>(a::name). a\<sharp>(psubst_Lam \<theta>)\<and> (\<forall>y. a\<sharp>(psubst_Lam \<theta>) a y)" |
|
1463 |
apply(subgoal_tac "\<exists>(c::name). c\<sharp>\<theta>") |
|
1464 |
apply(auto) |
|
1465 |
apply(rule_tac x="c" in exI) |
|
1466 |
apply(auto) |
|
1467 |
apply(rule supports_fresh) |
|
1468 |
apply(rule supports_psubst_Lam) |
|
1469 |
apply(simp_all add: fresh_def[symmetric] fs_name1) |
|
1470 |
apply(simp add: psubst_Lam_def) |
|
1471 |
apply(simp add: abs_fresh) |
|
1472 |
apply(rule at_exists_fresh[OF at_name_inst]) |
|
1473 |
apply(simp add: fs_name1) |
|
1474 |
done |
|
1475 |
||
1476 |
lemma psubst_Var: |
|
18263
7f75925498da
cleaned up all examples so that they work with the
urbanc
parents:
18106
diff
changeset
|
1477 |
shows "psubst_lam \<theta> (Var a) = (if a\<in>set (domain \<theta>) then \<theta><a> else (Var a))" |
18106 | 1478 |
apply(simp add: psubst_lam_def) |
1479 |
apply(auto simp add: rfun_Var[OF fin_supp_psubst, OF fresh_psubst_Lam]) |
|
1480 |
apply(auto simp add: psubst_Var_def) |
|
1481 |
done |
|
1482 |
||
1483 |
lemma psubst_App: |
|
1484 |
shows "psubst_lam \<theta> (App t1 t2) = App (psubst_lam \<theta> t1) (psubst_lam \<theta> t2)" |
|
1485 |
apply(simp add: psubst_lam_def) |
|
1486 |
apply(auto simp add: rfun_App[OF fin_supp_psubst, OF fresh_psubst_Lam]) |
|
1487 |
apply(auto simp add: psubst_App_def) |
|
1488 |
done |
|
1489 |
||
1490 |
lemma psubst_Lam: |
|
1491 |
assumes a: "a\<sharp>\<theta>" |
|
1492 |
shows "psubst_lam \<theta> (Lam [a].t1) = Lam [a].(psubst_lam \<theta> t1)" |
|
1493 |
using a |
|
1494 |
apply(simp add: psubst_lam_def) |
|
1495 |
apply(subgoal_tac "a\<sharp>(psubst_Var \<theta>,psubst_App \<theta>,psubst_Lam \<theta>)") |
|
1496 |
apply(auto simp add: rfun_Lam[OF fin_supp_psubst, OF fresh_psubst_Lam]) |
|
1497 |
apply(simp (no_asm) add: psubst_Lam_def) |
|
1498 |
apply(auto simp add: fresh_prod) |
|
1499 |
apply(rule supports_fresh) |
|
1500 |
apply(rule supports_psubst_Var) |
|
1501 |
apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) |
|
1502 |
apply(rule supports_fresh) |
|
1503 |
apply(rule supports_psubst_App) |
|
1504 |
apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) |
|
1505 |
apply(rule supports_fresh) |
|
1506 |
apply(rule supports_psubst_Lam) |
|
1507 |
apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) |
|
1508 |
done |
|
1509 |
||
1510 |
declare psubst_Var[simp] |
|
1511 |
declare psubst_App[simp] |
|
1512 |
declare psubst_Lam[simp] |
|
1513 |
||
1514 |
consts |
|
1515 |
psubst_syn :: "lam \<Rightarrow> (name\<times>lam) list \<Rightarrow> lam" ("_[<_>]" [100,100] 900) |
|
1516 |
translations |
|
1517 |
"t[<\<theta>>]" \<rightleftharpoons> "psubst_lam \<theta> t" |
|
1518 |
||
1519 |
end |