2494
|
1 |
theory Foo1
|
|
2 |
imports "../Nominal2"
|
|
3 |
begin
|
|
4 |
|
|
5 |
(*
|
|
6 |
Contrived example that has more than one
|
|
7 |
binding function for a datatype
|
|
8 |
*)
|
|
9 |
|
|
10 |
atom_decl name
|
|
11 |
|
|
12 |
nominal_datatype foo: trm =
|
|
13 |
Var "name"
|
|
14 |
| App "trm" "trm"
|
|
15 |
| Lam x::"name" t::"trm" bind x in t
|
|
16 |
| Let1 a::"assg" t::"trm" bind "bn1 a" in t
|
|
17 |
| Let2 a::"assg" t::"trm" bind "bn2 a" in t
|
|
18 |
| Let3 a::"assg" t::"trm" bind "bn3 a" in t
|
|
19 |
and assg =
|
|
20 |
As "name" "name" "trm"
|
|
21 |
binder
|
|
22 |
bn1::"assg \<Rightarrow> atom list" and
|
|
23 |
bn2::"assg \<Rightarrow> atom list" and
|
|
24 |
bn3::"assg \<Rightarrow> atom list"
|
|
25 |
where
|
|
26 |
"bn1 (As x y t) = [atom x]"
|
|
27 |
| "bn2 (As x y t) = [atom y]"
|
|
28 |
| "bn3 (As x y t) = [atom x, atom y]"
|
|
29 |
|
|
30 |
thm foo.distinct
|
|
31 |
thm foo.induct
|
|
32 |
thm foo.inducts
|
|
33 |
thm foo.exhaust
|
|
34 |
thm foo.fv_defs
|
|
35 |
thm foo.bn_defs
|
|
36 |
thm foo.perm_simps
|
|
37 |
thm foo.eq_iff
|
|
38 |
thm foo.fv_bn_eqvt
|
|
39 |
thm foo.size_eqvt
|
|
40 |
thm foo.supports
|
|
41 |
thm foo.fsupp
|
|
42 |
thm foo.supp
|
|
43 |
thm foo.fresh
|
|
44 |
|
2500
|
45 |
primrec
|
|
46 |
permute_bn1_raw
|
|
47 |
where
|
|
48 |
"permute_bn1_raw p (As_raw x y t) = As_raw (p \<bullet> x) y t"
|
|
49 |
|
|
50 |
primrec
|
|
51 |
permute_bn2_raw
|
|
52 |
where
|
|
53 |
"permute_bn2_raw p (As_raw x y t) = As_raw x (p \<bullet> y) t"
|
|
54 |
|
|
55 |
primrec
|
|
56 |
permute_bn3_raw
|
|
57 |
where
|
|
58 |
"permute_bn3_raw p (As_raw x y t) = As_raw (p \<bullet> x) (p \<bullet> y) t"
|
|
59 |
|
|
60 |
quotient_definition
|
|
61 |
"permute_bn1 :: perm \<Rightarrow> assg \<Rightarrow> assg"
|
|
62 |
is
|
|
63 |
"permute_bn1_raw"
|
|
64 |
|
|
65 |
quotient_definition
|
|
66 |
"permute_bn2 :: perm \<Rightarrow> assg \<Rightarrow> assg"
|
|
67 |
is
|
|
68 |
"permute_bn2_raw"
|
|
69 |
|
|
70 |
quotient_definition
|
|
71 |
"permute_bn3 :: perm \<Rightarrow> assg \<Rightarrow> assg"
|
|
72 |
is
|
|
73 |
"permute_bn3_raw"
|
|
74 |
|
|
75 |
lemma [quot_respect]:
|
|
76 |
shows "((op =) ===> alpha_assg_raw ===> alpha_assg_raw) permute_bn1_raw permute_bn1_raw"
|
|
77 |
apply simp
|
|
78 |
apply clarify
|
|
79 |
apply (erule alpha_assg_raw.cases)
|
|
80 |
apply simp_all
|
|
81 |
apply (rule foo.raw_alpha)
|
|
82 |
apply simp_all
|
|
83 |
done
|
|
84 |
|
|
85 |
lemma [quot_respect]:
|
|
86 |
shows "((op =) ===> alpha_assg_raw ===> alpha_assg_raw) permute_bn2_raw permute_bn2_raw"
|
|
87 |
apply simp
|
|
88 |
apply clarify
|
|
89 |
apply (erule alpha_assg_raw.cases)
|
|
90 |
apply simp_all
|
|
91 |
apply (rule foo.raw_alpha)
|
|
92 |
apply simp_all
|
|
93 |
done
|
|
94 |
|
|
95 |
lemma [quot_respect]:
|
|
96 |
shows "((op =) ===> alpha_assg_raw ===> alpha_assg_raw) permute_bn3_raw permute_bn3_raw"
|
|
97 |
apply simp
|
|
98 |
apply clarify
|
|
99 |
apply (erule alpha_assg_raw.cases)
|
|
100 |
apply simp_all
|
|
101 |
apply (rule foo.raw_alpha)
|
|
102 |
apply simp_all
|
|
103 |
done
|
|
104 |
|
|
105 |
lemmas permute_bn1 = permute_bn1_raw.simps[quot_lifted]
|
|
106 |
lemmas permute_bn2 = permute_bn2_raw.simps[quot_lifted]
|
|
107 |
lemmas permute_bn3 = permute_bn3_raw.simps[quot_lifted]
|
|
108 |
|
|
109 |
lemma uu1:
|
|
110 |
shows "alpha_bn1 as (permute_bn1 p as)"
|
|
111 |
apply(induct as rule: foo.inducts(2))
|
|
112 |
apply(auto)[6]
|
|
113 |
apply(simp add: permute_bn1)
|
|
114 |
apply(simp add: foo.eq_iff)
|
|
115 |
done
|
|
116 |
|
|
117 |
lemma uu2:
|
|
118 |
shows "alpha_bn2 as (permute_bn2 p as)"
|
|
119 |
apply(induct as rule: foo.inducts(2))
|
|
120 |
apply(auto)[6]
|
|
121 |
apply(simp add: permute_bn2)
|
|
122 |
apply(simp add: foo.eq_iff)
|
|
123 |
done
|
|
124 |
|
|
125 |
lemma uu3:
|
|
126 |
shows "alpha_bn3 as (permute_bn3 p as)"
|
|
127 |
apply(induct as rule: foo.inducts(2))
|
|
128 |
apply(auto)[6]
|
|
129 |
apply(simp add: permute_bn3)
|
|
130 |
apply(simp add: foo.eq_iff)
|
|
131 |
done
|
|
132 |
|
|
133 |
lemma tt1:
|
|
134 |
shows "(p \<bullet> bn1 as) = bn1 (permute_bn1 p as)"
|
|
135 |
apply(induct as rule: foo.inducts(2))
|
|
136 |
apply(auto)[6]
|
|
137 |
apply(simp add: permute_bn1 foo.bn_defs)
|
|
138 |
apply(simp add: atom_eqvt)
|
|
139 |
done
|
|
140 |
|
|
141 |
lemma tt2:
|
|
142 |
shows "(p \<bullet> bn2 as) = bn2 (permute_bn2 p as)"
|
|
143 |
apply(induct as rule: foo.inducts(2))
|
|
144 |
apply(auto)[6]
|
|
145 |
apply(simp add: permute_bn2 foo.bn_defs)
|
|
146 |
apply(simp add: atom_eqvt)
|
|
147 |
done
|
|
148 |
|
|
149 |
lemma tt3:
|
|
150 |
shows "(p \<bullet> bn3 as) = bn3 (permute_bn3 p as)"
|
|
151 |
apply(induct as rule: foo.inducts(2))
|
|
152 |
apply(auto)[6]
|
|
153 |
apply(simp add: permute_bn3 foo.bn_defs)
|
|
154 |
apply(simp add: atom_eqvt)
|
|
155 |
done
|
|
156 |
|
|
157 |
|
|
158 |
lemma strong_exhaust1:
|
|
159 |
fixes c::"'a::fs"
|
2503
|
160 |
assumes "\<And>name. y = Var name \<Longrightarrow> P"
|
|
161 |
and "\<And>trm1 trm2. y = App trm1 trm2 \<Longrightarrow> P"
|
|
162 |
and "\<And>name trm. \<lbrakk>{atom name} \<sharp>* c; y = Lam name trm\<rbrakk> \<Longrightarrow> P"
|
|
163 |
and "\<And>assn trm. \<lbrakk>set (bn1 assn) \<sharp>* c; y = Let1 assn trm\<rbrakk> \<Longrightarrow> P"
|
|
164 |
and "\<And>assn trm. \<lbrakk>set (bn2 assn) \<sharp>* c; y = Let2 assn trm\<rbrakk> \<Longrightarrow> P"
|
|
165 |
and "\<And>assn trm. \<lbrakk>set (bn3 assn) \<sharp>* c; y = Let3 assn trm\<rbrakk> \<Longrightarrow> P"
|
2500
|
166 |
shows "P"
|
|
167 |
apply(rule_tac y="y" in foo.exhaust(1))
|
|
168 |
apply(rule assms(1))
|
2503
|
169 |
apply(assumption)
|
2500
|
170 |
apply(rule assms(2))
|
2503
|
171 |
apply(assumption)
|
2500
|
172 |
apply(subgoal_tac "\<exists>q. (q \<bullet> {atom name}) \<sharp>* c \<and> supp (Lam name trm) \<sharp>* q")
|
|
173 |
apply(erule exE)
|
|
174 |
apply(erule conjE)
|
|
175 |
apply(rule assms(3))
|
|
176 |
apply(perm_simp)
|
|
177 |
apply(assumption)
|
|
178 |
apply(drule supp_perm_eq[symmetric])
|
2503
|
179 |
apply(perm_simp)
|
2500
|
180 |
apply(simp)
|
|
181 |
apply(rule at_set_avoiding2)
|
|
182 |
apply(simp add: finite_supp)
|
|
183 |
apply(simp add: finite_supp)
|
|
184 |
apply(simp add: finite_supp)
|
|
185 |
apply(simp add: foo.fresh fresh_star_def)
|
|
186 |
apply(subgoal_tac "\<exists>q. (q \<bullet> (set (bn1 assg))) \<sharp>* c \<and> supp ([bn1 assg]lst.trm) \<sharp>* q")
|
|
187 |
apply(erule exE)
|
|
188 |
apply(erule conjE)
|
|
189 |
apply(rule assms(4))
|
2503
|
190 |
apply(perm_simp add: tt1)
|
|
191 |
apply(assumption)
|
|
192 |
apply(drule supp_perm_eq[symmetric])
|
2500
|
193 |
apply(simp add: foo.eq_iff)
|
|
194 |
apply(simp add: tt1 uu1)
|
|
195 |
apply(rule at_set_avoiding2)
|
|
196 |
apply(simp add: finite_supp)
|
|
197 |
apply(simp add: finite_supp)
|
|
198 |
apply(simp add: finite_supp)
|
|
199 |
apply(simp add: Abs_fresh_star)
|
|
200 |
apply(subgoal_tac "\<exists>q. (q \<bullet> (set (bn2 assg))) \<sharp>* c \<and> supp ([bn2 assg]lst.trm) \<sharp>* q")
|
|
201 |
apply(erule exE)
|
|
202 |
apply(erule conjE)
|
|
203 |
apply(rule assms(5))
|
|
204 |
apply(simp add: set_eqvt)
|
|
205 |
apply(simp add: tt2)
|
|
206 |
apply(simp add: foo.eq_iff)
|
|
207 |
apply(drule supp_perm_eq[symmetric])
|
|
208 |
apply(simp)
|
|
209 |
apply(simp add: tt2 uu2)
|
|
210 |
apply(rule at_set_avoiding2)
|
|
211 |
apply(simp add: finite_supp)
|
|
212 |
apply(simp add: finite_supp)
|
|
213 |
apply(simp add: finite_supp)
|
|
214 |
apply(simp add: Abs_fresh_star)
|
|
215 |
apply(subgoal_tac "\<exists>q. (q \<bullet> (set (bn3 assg))) \<sharp>* c \<and> supp ([bn3 assg]lst.trm) \<sharp>* q")
|
|
216 |
apply(erule exE)
|
|
217 |
apply(erule conjE)
|
|
218 |
apply(rule assms(6))
|
|
219 |
apply(simp add: set_eqvt)
|
|
220 |
apply(simp add: tt3)
|
|
221 |
apply(simp add: foo.eq_iff)
|
|
222 |
apply(drule supp_perm_eq[symmetric])
|
|
223 |
apply(simp)
|
|
224 |
apply(simp add: tt3 uu3)
|
|
225 |
apply(rule at_set_avoiding2)
|
|
226 |
apply(simp add: finite_supp)
|
|
227 |
apply(simp add: finite_supp)
|
|
228 |
apply(simp add: finite_supp)
|
|
229 |
apply(simp add: Abs_fresh_star)
|
|
230 |
done
|
|
231 |
|
|
232 |
lemma strong_exhaust2:
|
2503
|
233 |
assumes "\<And>x y t. as = As x y t \<Longrightarrow> P"
|
2500
|
234 |
shows "P"
|
|
235 |
apply(rule_tac y="as" in foo.exhaust(2))
|
|
236 |
apply(rule assms(1))
|
2503
|
237 |
apply(assumption)
|
2500
|
238 |
done
|
|
239 |
|
|
240 |
|
|
241 |
lemma
|
|
242 |
fixes t::trm
|
|
243 |
and as::assg
|
|
244 |
and c::"'a::fs"
|
|
245 |
assumes a1: "\<And>x c. P1 c (Var x)"
|
|
246 |
and a2: "\<And>t1 t2 c. \<lbrakk>\<And>d. P1 d t1; \<And>d. P1 d t2\<rbrakk> \<Longrightarrow> P1 c (App t1 t2)"
|
|
247 |
and a3: "\<And>x t c. \<lbrakk>{atom x} \<sharp>* c; \<And>d. P1 d t\<rbrakk> \<Longrightarrow> P1 c (Lam x t)"
|
|
248 |
and a4: "\<And>as t c. \<lbrakk>set (bn1 as) \<sharp>* c; \<And>d. P2 d as; \<And>d. P1 d t\<rbrakk> \<Longrightarrow> P1 c (Let1 as t)"
|
|
249 |
and a5: "\<And>as t c. \<lbrakk>set (bn2 as) \<sharp>* c; \<And>d. P2 d as; \<And>d. P1 d t\<rbrakk> \<Longrightarrow> P1 c (Let2 as t)"
|
|
250 |
and a6: "\<And>as t c. \<lbrakk>set (bn3 as) \<sharp>* c; \<And>d. P2 d as; \<And>d. P1 d t\<rbrakk> \<Longrightarrow> P1 c (Let3 as t)"
|
|
251 |
and a7: "\<And>x y t c. \<And>d. P1 d t \<Longrightarrow> P2 c (As x y t)"
|
|
252 |
shows "P1 c t" "P2 c as"
|
|
253 |
using assms
|
|
254 |
apply(induction_schema)
|
2503
|
255 |
apply(rule_tac y="t" and c="c" in strong_exhaust1)
|
|
256 |
apply(simp_all)[6]
|
2500
|
257 |
apply(rule_tac as="as" in strong_exhaust2)
|
2503
|
258 |
apply(simp)
|
2500
|
259 |
apply(relation "measure (sum_case (\<lambda>y. size (snd y)) (\<lambda>z. size (snd z)))")
|
|
260 |
apply(simp_all add: foo.size)
|
|
261 |
done
|
2494
|
262 |
|
|
263 |
end
|
|
264 |
|
|
265 |
|
|
266 |
|