author | Christian Urban <urbanc@in.tum.de> |
Fri, 14 May 2010 17:58:26 +0100 | |
changeset 2137 | 5b007ac41b29 |
parent 2013 | 3078fab2d7a6 |
child 2310 | dd3b9c046c7d |
permissions | -rw-r--r-- |
1062 | 1 |
(* Title: Nominal2_Base |
2 |
Authors: Brian Huffman, Christian Urban |
|
3 |
||
4 |
Basic definitions and lemma infrastructure for |
|
5 |
Nominal Isabelle. |
|
6 |
*) |
|
7 |
theory Nominal2_Base |
|
8 |
imports Main Infinite_Set |
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
9 |
uses ("nominal_library.ML") |
1062 | 10 |
begin |
11 |
||
12 |
section {* Atoms and Sorts *} |
|
13 |
||
14 |
text {* A simple implementation for atom_sorts is strings. *} |
|
15 |
(* types atom_sort = string *) |
|
16 |
||
17 |
text {* To deal with Church-like binding we use trees of |
|
18 |
strings as sorts. *} |
|
19 |
||
20 |
datatype atom_sort = Sort "string" "atom_sort list" |
|
21 |
||
22 |
datatype atom = Atom atom_sort nat |
|
23 |
||
24 |
||
25 |
text {* Basic projection function. *} |
|
26 |
||
27 |
primrec |
|
28 |
sort_of :: "atom \<Rightarrow> atom_sort" |
|
29 |
where |
|
30 |
"sort_of (Atom s i) = s" |
|
31 |
||
1930
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
32 |
primrec |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
33 |
nat_of :: "atom \<Rightarrow> nat" |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
34 |
where |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
35 |
"nat_of (Atom s n) = n" |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
36 |
|
1062 | 37 |
|
38 |
text {* There are infinitely many atoms of each sort. *} |
|
39 |
lemma INFM_sort_of_eq: |
|
40 |
shows "INFM a. sort_of a = s" |
|
41 |
proof - |
|
42 |
have "INFM i. sort_of (Atom s i) = s" by simp |
|
43 |
moreover have "inj (Atom s)" by (simp add: inj_on_def) |
|
44 |
ultimately show "INFM a. sort_of a = s" by (rule INFM_inj) |
|
45 |
qed |
|
46 |
||
47 |
lemma infinite_sort_of_eq: |
|
48 |
shows "infinite {a. sort_of a = s}" |
|
49 |
using INFM_sort_of_eq unfolding INFM_iff_infinite . |
|
50 |
||
51 |
lemma atom_infinite [simp]: |
|
52 |
shows "infinite (UNIV :: atom set)" |
|
53 |
using subset_UNIV infinite_sort_of_eq |
|
54 |
by (rule infinite_super) |
|
55 |
||
56 |
lemma obtain_atom: |
|
57 |
fixes X :: "atom set" |
|
58 |
assumes X: "finite X" |
|
59 |
obtains a where "a \<notin> X" "sort_of a = s" |
|
60 |
proof - |
|
61 |
from X have "MOST a. a \<notin> X" |
|
62 |
unfolding MOST_iff_cofinite by simp |
|
63 |
with INFM_sort_of_eq |
|
64 |
have "INFM a. sort_of a = s \<and> a \<notin> X" |
|
65 |
by (rule INFM_conjI) |
|
66 |
then obtain a where "a \<notin> X" "sort_of a = s" |
|
67 |
by (auto elim: INFM_E) |
|
68 |
then show ?thesis .. |
|
69 |
qed |
|
70 |
||
1930
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
71 |
lemma atom_components_eq_iff: |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
72 |
fixes a b :: atom |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
73 |
shows "a = b \<longleftrightarrow> sort_of a = sort_of b \<and> nat_of a = nat_of b" |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
74 |
by (induct a, induct b, simp) |
f189cf2c0987
moved some lemmas into the right places
Christian Urban <urbanc@in.tum.de>
parents:
1879
diff
changeset
|
75 |
|
1062 | 76 |
section {* Sort-Respecting Permutations *} |
77 |
||
78 |
typedef perm = |
|
79 |
"{f. bij f \<and> finite {a. f a \<noteq> a} \<and> (\<forall>a. sort_of (f a) = sort_of a)}" |
|
80 |
proof |
|
81 |
show "id \<in> ?perm" by simp |
|
82 |
qed |
|
83 |
||
84 |
lemma permI: |
|
85 |
assumes "bij f" and "MOST x. f x = x" and "\<And>a. sort_of (f a) = sort_of a" |
|
86 |
shows "f \<in> perm" |
|
87 |
using assms unfolding perm_def MOST_iff_cofinite by simp |
|
88 |
||
89 |
lemma perm_is_bij: "f \<in> perm \<Longrightarrow> bij f" |
|
90 |
unfolding perm_def by simp |
|
91 |
||
92 |
lemma perm_is_finite: "f \<in> perm \<Longrightarrow> finite {a. f a \<noteq> a}" |
|
93 |
unfolding perm_def by simp |
|
94 |
||
95 |
lemma perm_is_sort_respecting: "f \<in> perm \<Longrightarrow> sort_of (f a) = sort_of a" |
|
96 |
unfolding perm_def by simp |
|
97 |
||
98 |
lemma perm_MOST: "f \<in> perm \<Longrightarrow> MOST x. f x = x" |
|
99 |
unfolding perm_def MOST_iff_cofinite by simp |
|
100 |
||
101 |
lemma perm_id: "id \<in> perm" |
|
102 |
unfolding perm_def by simp |
|
103 |
||
104 |
lemma perm_comp: |
|
105 |
assumes f: "f \<in> perm" and g: "g \<in> perm" |
|
106 |
shows "(f \<circ> g) \<in> perm" |
|
107 |
apply (rule permI) |
|
108 |
apply (rule bij_comp) |
|
109 |
apply (rule perm_is_bij [OF g]) |
|
110 |
apply (rule perm_is_bij [OF f]) |
|
111 |
apply (rule MOST_rev_mp [OF perm_MOST [OF g]]) |
|
112 |
apply (rule MOST_rev_mp [OF perm_MOST [OF f]]) |
|
113 |
apply (simp) |
|
114 |
apply (simp add: perm_is_sort_respecting [OF f]) |
|
115 |
apply (simp add: perm_is_sort_respecting [OF g]) |
|
116 |
done |
|
117 |
||
118 |
lemma perm_inv: |
|
119 |
assumes f: "f \<in> perm" |
|
120 |
shows "(inv f) \<in> perm" |
|
121 |
apply (rule permI) |
|
122 |
apply (rule bij_imp_bij_inv) |
|
123 |
apply (rule perm_is_bij [OF f]) |
|
124 |
apply (rule MOST_mono [OF perm_MOST [OF f]]) |
|
125 |
apply (erule subst, rule inv_f_f) |
|
126 |
apply (rule bij_is_inj [OF perm_is_bij [OF f]]) |
|
127 |
apply (rule perm_is_sort_respecting [OF f, THEN sym, THEN trans]) |
|
128 |
apply (simp add: surj_f_inv_f [OF bij_is_surj [OF perm_is_bij [OF f]]]) |
|
129 |
done |
|
130 |
||
131 |
lemma bij_Rep_perm: "bij (Rep_perm p)" |
|
132 |
using Rep_perm [of p] unfolding perm_def by simp |
|
133 |
||
134 |
lemma finite_Rep_perm: "finite {a. Rep_perm p a \<noteq> a}" |
|
135 |
using Rep_perm [of p] unfolding perm_def by simp |
|
136 |
||
137 |
lemma sort_of_Rep_perm: "sort_of (Rep_perm p a) = sort_of a" |
|
138 |
using Rep_perm [of p] unfolding perm_def by simp |
|
139 |
||
140 |
lemma Rep_perm_ext: |
|
141 |
"Rep_perm p1 = Rep_perm p2 \<Longrightarrow> p1 = p2" |
|
142 |
by (simp add: expand_fun_eq Rep_perm_inject [symmetric]) |
|
143 |
||
144 |
||
145 |
subsection {* Permutations form a group *} |
|
146 |
||
147 |
instantiation perm :: group_add |
|
148 |
begin |
|
149 |
||
150 |
definition |
|
151 |
"0 = Abs_perm id" |
|
152 |
||
153 |
definition |
|
154 |
"- p = Abs_perm (inv (Rep_perm p))" |
|
155 |
||
156 |
definition |
|
157 |
"p + q = Abs_perm (Rep_perm p \<circ> Rep_perm q)" |
|
158 |
||
159 |
definition |
|
160 |
"(p1::perm) - p2 = p1 + - p2" |
|
161 |
||
162 |
lemma Rep_perm_0: "Rep_perm 0 = id" |
|
163 |
unfolding zero_perm_def |
|
164 |
by (simp add: Abs_perm_inverse perm_id) |
|
165 |
||
166 |
lemma Rep_perm_add: |
|
167 |
"Rep_perm (p1 + p2) = Rep_perm p1 \<circ> Rep_perm p2" |
|
168 |
unfolding plus_perm_def |
|
169 |
by (simp add: Abs_perm_inverse perm_comp Rep_perm) |
|
170 |
||
171 |
lemma Rep_perm_uminus: |
|
172 |
"Rep_perm (- p) = inv (Rep_perm p)" |
|
173 |
unfolding uminus_perm_def |
|
174 |
by (simp add: Abs_perm_inverse perm_inv Rep_perm) |
|
175 |
||
176 |
instance |
|
177 |
apply default |
|
178 |
unfolding Rep_perm_inject [symmetric] |
|
179 |
unfolding minus_perm_def |
|
180 |
unfolding Rep_perm_add |
|
181 |
unfolding Rep_perm_uminus |
|
182 |
unfolding Rep_perm_0 |
|
183 |
by (simp_all add: o_assoc inv_o_cancel [OF bij_is_inj [OF bij_Rep_perm]]) |
|
184 |
||
185 |
end |
|
186 |
||
187 |
||
188 |
section {* Implementation of swappings *} |
|
189 |
||
190 |
definition |
|
191 |
swap :: "atom \<Rightarrow> atom \<Rightarrow> perm" ("'(_ \<rightleftharpoons> _')") |
|
192 |
where |
|
193 |
"(a \<rightleftharpoons> b) = |
|
194 |
Abs_perm (if sort_of a = sort_of b |
|
195 |
then (\<lambda>c. if a = c then b else if b = c then a else c) |
|
196 |
else id)" |
|
197 |
||
198 |
lemma Rep_perm_swap: |
|
199 |
"Rep_perm (a \<rightleftharpoons> b) = |
|
200 |
(if sort_of a = sort_of b |
|
201 |
then (\<lambda>c. if a = c then b else if b = c then a else c) |
|
202 |
else id)" |
|
203 |
unfolding swap_def |
|
204 |
apply (rule Abs_perm_inverse) |
|
205 |
apply (rule permI) |
|
206 |
apply (auto simp add: bij_def inj_on_def surj_def)[1] |
|
207 |
apply (rule MOST_rev_mp [OF MOST_neq(1) [of a]]) |
|
208 |
apply (rule MOST_rev_mp [OF MOST_neq(1) [of b]]) |
|
209 |
apply (simp) |
|
210 |
apply (simp) |
|
211 |
done |
|
212 |
||
213 |
lemmas Rep_perm_simps = |
|
214 |
Rep_perm_0 |
|
215 |
Rep_perm_add |
|
216 |
Rep_perm_uminus |
|
217 |
Rep_perm_swap |
|
218 |
||
219 |
lemma swap_different_sorts [simp]: |
|
220 |
"sort_of a \<noteq> sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) = 0" |
|
221 |
by (rule Rep_perm_ext) (simp add: Rep_perm_simps) |
|
222 |
||
223 |
lemma swap_cancel: |
|
224 |
"(a \<rightleftharpoons> b) + (a \<rightleftharpoons> b) = 0" |
|
1879 | 225 |
by (rule Rep_perm_ext) |
226 |
(simp add: Rep_perm_simps expand_fun_eq) |
|
1062 | 227 |
|
228 |
lemma swap_self [simp]: |
|
229 |
"(a \<rightleftharpoons> a) = 0" |
|
230 |
by (rule Rep_perm_ext, simp add: Rep_perm_simps expand_fun_eq) |
|
231 |
||
232 |
lemma minus_swap [simp]: |
|
233 |
"- (a \<rightleftharpoons> b) = (a \<rightleftharpoons> b)" |
|
234 |
by (rule minus_unique [OF swap_cancel]) |
|
235 |
||
236 |
lemma swap_commute: |
|
237 |
"(a \<rightleftharpoons> b) = (b \<rightleftharpoons> a)" |
|
238 |
by (rule Rep_perm_ext) |
|
239 |
(simp add: Rep_perm_swap expand_fun_eq) |
|
240 |
||
241 |
lemma swap_triple: |
|
242 |
assumes "a \<noteq> b" and "c \<noteq> b" |
|
243 |
assumes "sort_of a = sort_of b" "sort_of b = sort_of c" |
|
244 |
shows "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)" |
|
245 |
using assms |
|
246 |
by (rule_tac Rep_perm_ext) |
|
247 |
(auto simp add: Rep_perm_simps expand_fun_eq) |
|
248 |
||
249 |
||
250 |
section {* Permutation Types *} |
|
251 |
||
252 |
text {* |
|
253 |
Infix syntax for @{text permute} has higher precedence than |
|
254 |
addition, but lower than unary minus. |
|
255 |
*} |
|
256 |
||
257 |
class pt = |
|
258 |
fixes permute :: "perm \<Rightarrow> 'a \<Rightarrow> 'a" ("_ \<bullet> _" [76, 75] 75) |
|
259 |
assumes permute_zero [simp]: "0 \<bullet> x = x" |
|
260 |
assumes permute_plus [simp]: "(p + q) \<bullet> x = p \<bullet> (q \<bullet> x)" |
|
261 |
begin |
|
262 |
||
263 |
lemma permute_diff [simp]: |
|
264 |
shows "(p - q) \<bullet> x = p \<bullet> - q \<bullet> x" |
|
265 |
unfolding diff_minus by simp |
|
266 |
||
267 |
lemma permute_minus_cancel [simp]: |
|
268 |
shows "p \<bullet> - p \<bullet> x = x" |
|
269 |
and "- p \<bullet> p \<bullet> x = x" |
|
270 |
unfolding permute_plus [symmetric] by simp_all |
|
271 |
||
272 |
lemma permute_swap_cancel [simp]: |
|
273 |
shows "(a \<rightleftharpoons> b) \<bullet> (a \<rightleftharpoons> b) \<bullet> x = x" |
|
274 |
unfolding permute_plus [symmetric] |
|
275 |
by (simp add: swap_cancel) |
|
276 |
||
277 |
lemma permute_swap_cancel2 [simp]: |
|
278 |
shows "(a \<rightleftharpoons> b) \<bullet> (b \<rightleftharpoons> a) \<bullet> x = x" |
|
279 |
unfolding permute_plus [symmetric] |
|
280 |
by (simp add: swap_commute) |
|
281 |
||
282 |
lemma inj_permute [simp]: |
|
283 |
shows "inj (permute p)" |
|
284 |
by (rule inj_on_inverseI) |
|
285 |
(rule permute_minus_cancel) |
|
286 |
||
287 |
lemma surj_permute [simp]: |
|
288 |
shows "surj (permute p)" |
|
289 |
by (rule surjI, rule permute_minus_cancel) |
|
290 |
||
291 |
lemma bij_permute [simp]: |
|
292 |
shows "bij (permute p)" |
|
293 |
by (rule bijI [OF inj_permute surj_permute]) |
|
294 |
||
295 |
lemma inv_permute: |
|
296 |
shows "inv (permute p) = permute (- p)" |
|
297 |
by (rule inv_equality) (simp_all) |
|
298 |
||
299 |
lemma permute_minus: |
|
300 |
shows "permute (- p) = inv (permute p)" |
|
301 |
by (simp add: inv_permute) |
|
302 |
||
303 |
lemma permute_eq_iff [simp]: |
|
304 |
shows "p \<bullet> x = p \<bullet> y \<longleftrightarrow> x = y" |
|
305 |
by (rule inj_permute [THEN inj_eq]) |
|
306 |
||
307 |
end |
|
308 |
||
309 |
subsection {* Permutations for atoms *} |
|
310 |
||
311 |
instantiation atom :: pt |
|
312 |
begin |
|
313 |
||
314 |
definition |
|
1879 | 315 |
"p \<bullet> a = (Rep_perm p) a" |
1062 | 316 |
|
317 |
instance |
|
318 |
apply(default) |
|
319 |
apply(simp_all add: permute_atom_def Rep_perm_simps) |
|
320 |
done |
|
321 |
||
322 |
end |
|
323 |
||
324 |
lemma sort_of_permute [simp]: |
|
325 |
shows "sort_of (p \<bullet> a) = sort_of a" |
|
326 |
unfolding permute_atom_def by (rule sort_of_Rep_perm) |
|
327 |
||
328 |
lemma swap_atom: |
|
329 |
shows "(a \<rightleftharpoons> b) \<bullet> c = |
|
330 |
(if sort_of a = sort_of b |
|
331 |
then (if c = a then b else if c = b then a else c) else c)" |
|
332 |
unfolding permute_atom_def |
|
333 |
by (simp add: Rep_perm_swap) |
|
334 |
||
335 |
lemma swap_atom_simps [simp]: |
|
336 |
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> a = b" |
|
337 |
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> b = a" |
|
338 |
"c \<noteq> a \<Longrightarrow> c \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> c = c" |
|
339 |
unfolding swap_atom by simp_all |
|
340 |
||
341 |
lemma expand_perm_eq: |
|
342 |
fixes p q :: "perm" |
|
343 |
shows "p = q \<longleftrightarrow> (\<forall>a::atom. p \<bullet> a = q \<bullet> a)" |
|
344 |
unfolding permute_atom_def |
|
345 |
by (metis Rep_perm_ext ext) |
|
346 |
||
347 |
||
348 |
subsection {* Permutations for permutations *} |
|
349 |
||
350 |
instantiation perm :: pt |
|
351 |
begin |
|
352 |
||
353 |
definition |
|
354 |
"p \<bullet> q = p + q - p" |
|
355 |
||
356 |
instance |
|
357 |
apply default |
|
358 |
apply (simp add: permute_perm_def) |
|
359 |
apply (simp add: permute_perm_def diff_minus minus_add add_assoc) |
|
360 |
done |
|
361 |
||
362 |
end |
|
363 |
||
1879 | 364 |
lemma permute_self: |
365 |
shows "p \<bullet> p = p" |
|
366 |
unfolding permute_perm_def |
|
367 |
by (simp add: diff_minus add_assoc) |
|
1062 | 368 |
|
369 |
lemma permute_eqvt: |
|
370 |
shows "p \<bullet> (q \<bullet> x) = (p \<bullet> q) \<bullet> (p \<bullet> x)" |
|
371 |
unfolding permute_perm_def by simp |
|
372 |
||
373 |
lemma zero_perm_eqvt: |
|
374 |
shows "p \<bullet> (0::perm) = 0" |
|
375 |
unfolding permute_perm_def by simp |
|
376 |
||
377 |
lemma add_perm_eqvt: |
|
378 |
fixes p p1 p2 :: perm |
|
379 |
shows "p \<bullet> (p1 + p2) = p \<bullet> p1 + p \<bullet> p2" |
|
380 |
unfolding permute_perm_def |
|
381 |
by (simp add: expand_perm_eq) |
|
382 |
||
383 |
lemma swap_eqvt: |
|
384 |
shows "p \<bullet> (a \<rightleftharpoons> b) = (p \<bullet> a \<rightleftharpoons> p \<bullet> b)" |
|
385 |
unfolding permute_perm_def |
|
386 |
by (auto simp add: swap_atom expand_perm_eq) |
|
387 |
||
388 |
||
389 |
subsection {* Permutations for functions *} |
|
390 |
||
391 |
instantiation "fun" :: (pt, pt) pt |
|
392 |
begin |
|
393 |
||
394 |
definition |
|
395 |
"p \<bullet> f = (\<lambda>x. p \<bullet> (f (- p \<bullet> x)))" |
|
396 |
||
397 |
instance |
|
398 |
apply default |
|
399 |
apply (simp add: permute_fun_def) |
|
400 |
apply (simp add: permute_fun_def minus_add) |
|
401 |
done |
|
402 |
||
403 |
end |
|
404 |
||
405 |
lemma permute_fun_app_eq: |
|
406 |
shows "p \<bullet> (f x) = (p \<bullet> f) (p \<bullet> x)" |
|
1879 | 407 |
unfolding permute_fun_def by simp |
1062 | 408 |
|
409 |
||
410 |
subsection {* Permutations for booleans *} |
|
411 |
||
412 |
instantiation bool :: pt |
|
413 |
begin |
|
414 |
||
415 |
definition "p \<bullet> (b::bool) = b" |
|
416 |
||
417 |
instance |
|
418 |
apply(default) |
|
419 |
apply(simp_all add: permute_bool_def) |
|
420 |
done |
|
421 |
||
422 |
end |
|
423 |
||
424 |
lemma Not_eqvt: |
|
425 |
shows "p \<bullet> (\<not> A) = (\<not> (p \<bullet> A))" |
|
426 |
by (simp add: permute_bool_def) |
|
427 |
||
1557
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
428 |
lemma permute_boolE: |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
429 |
fixes P::"bool" |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
430 |
shows "p \<bullet> P \<Longrightarrow> P" |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
431 |
by (simp add: permute_bool_def) |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
432 |
|
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
433 |
lemma permute_boolI: |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
434 |
fixes P::"bool" |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
435 |
shows "P \<Longrightarrow> p \<bullet> P" |
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
parents:
1305
diff
changeset
|
436 |
by(simp add: permute_bool_def) |
1062 | 437 |
|
438 |
subsection {* Permutations for sets *} |
|
439 |
||
440 |
lemma permute_set_eq: |
|
441 |
fixes x::"'a::pt" |
|
442 |
and p::"perm" |
|
443 |
shows "(p \<bullet> X) = {p \<bullet> x | x. x \<in> X}" |
|
1879 | 444 |
unfolding permute_fun_def |
445 |
unfolding permute_bool_def |
|
446 |
apply(auto simp add: mem_def) |
|
1062 | 447 |
apply(rule_tac x="- p \<bullet> x" in exI) |
448 |
apply(simp) |
|
449 |
done |
|
450 |
||
451 |
lemma permute_set_eq_image: |
|
452 |
shows "p \<bullet> X = permute p ` X" |
|
1879 | 453 |
unfolding permute_set_eq by auto |
1062 | 454 |
|
455 |
lemma permute_set_eq_vimage: |
|
456 |
shows "p \<bullet> X = permute (- p) -` X" |
|
1879 | 457 |
unfolding permute_fun_def permute_bool_def |
458 |
unfolding vimage_def Collect_def mem_def .. |
|
1062 | 459 |
|
460 |
lemma swap_set_not_in: |
|
461 |
assumes a: "a \<notin> S" "b \<notin> S" |
|
462 |
shows "(a \<rightleftharpoons> b) \<bullet> S = S" |
|
1879 | 463 |
unfolding permute_set_eq |
464 |
using a by (auto simp add: swap_atom) |
|
1062 | 465 |
|
466 |
lemma swap_set_in: |
|
467 |
assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b" |
|
468 |
shows "(a \<rightleftharpoons> b) \<bullet> S \<noteq> S" |
|
1879 | 469 |
unfolding permute_set_eq |
470 |
using a by (auto simp add: swap_atom) |
|
1062 | 471 |
|
472 |
subsection {* Permutations for units *} |
|
473 |
||
474 |
instantiation unit :: pt |
|
475 |
begin |
|
476 |
||
477 |
definition "p \<bullet> (u::unit) = u" |
|
478 |
||
1879 | 479 |
instance |
480 |
by (default) (simp_all add: permute_unit_def) |
|
1062 | 481 |
|
482 |
end |
|
483 |
||
484 |
||
485 |
subsection {* Permutations for products *} |
|
486 |
||
487 |
instantiation "*" :: (pt, pt) pt |
|
488 |
begin |
|
489 |
||
490 |
primrec |
|
491 |
permute_prod |
|
492 |
where |
|
493 |
Pair_eqvt: "p \<bullet> (x, y) = (p \<bullet> x, p \<bullet> y)" |
|
494 |
||
495 |
instance |
|
496 |
by default auto |
|
497 |
||
498 |
end |
|
499 |
||
500 |
subsection {* Permutations for sums *} |
|
501 |
||
502 |
instantiation "+" :: (pt, pt) pt |
|
503 |
begin |
|
504 |
||
505 |
primrec |
|
506 |
permute_sum |
|
507 |
where |
|
508 |
"p \<bullet> (Inl x) = Inl (p \<bullet> x)" |
|
509 |
| "p \<bullet> (Inr y) = Inr (p \<bullet> y)" |
|
510 |
||
1879 | 511 |
instance |
512 |
by (default) (case_tac [!] x, simp_all) |
|
1062 | 513 |
|
514 |
end |
|
515 |
||
516 |
subsection {* Permutations for lists *} |
|
517 |
||
518 |
instantiation list :: (pt) pt |
|
519 |
begin |
|
520 |
||
521 |
primrec |
|
522 |
permute_list |
|
523 |
where |
|
524 |
"p \<bullet> [] = []" |
|
525 |
| "p \<bullet> (x # xs) = p \<bullet> x # p \<bullet> xs" |
|
526 |
||
1879 | 527 |
instance |
528 |
by (default) (induct_tac [!] x, simp_all) |
|
1062 | 529 |
|
530 |
end |
|
531 |
||
532 |
subsection {* Permutations for options *} |
|
533 |
||
534 |
instantiation option :: (pt) pt |
|
535 |
begin |
|
536 |
||
537 |
primrec |
|
538 |
permute_option |
|
539 |
where |
|
540 |
"p \<bullet> None = None" |
|
541 |
| "p \<bullet> (Some x) = Some (p \<bullet> x)" |
|
542 |
||
1879 | 543 |
instance |
544 |
by (default) (induct_tac [!] x, simp_all) |
|
1062 | 545 |
|
546 |
end |
|
547 |
||
548 |
subsection {* Permutations for @{typ char}, @{typ nat}, and @{typ int} *} |
|
549 |
||
550 |
instantiation char :: pt |
|
551 |
begin |
|
552 |
||
553 |
definition "p \<bullet> (c::char) = c" |
|
554 |
||
1879 | 555 |
instance |
556 |
by (default) (simp_all add: permute_char_def) |
|
1062 | 557 |
|
558 |
end |
|
559 |
||
560 |
instantiation nat :: pt |
|
561 |
begin |
|
562 |
||
563 |
definition "p \<bullet> (n::nat) = n" |
|
564 |
||
1879 | 565 |
instance |
566 |
by (default) (simp_all add: permute_nat_def) |
|
1062 | 567 |
|
568 |
end |
|
569 |
||
570 |
instantiation int :: pt |
|
571 |
begin |
|
572 |
||
573 |
definition "p \<bullet> (i::int) = i" |
|
574 |
||
1879 | 575 |
instance |
576 |
by (default) (simp_all add: permute_int_def) |
|
1062 | 577 |
|
578 |
end |
|
579 |
||
580 |
||
581 |
section {* Pure types *} |
|
582 |
||
583 |
text {* Pure types will have always empty support. *} |
|
584 |
||
585 |
class pure = pt + |
|
586 |
assumes permute_pure: "p \<bullet> x = x" |
|
587 |
||
588 |
text {* Types @{typ unit} and @{typ bool} are pure. *} |
|
589 |
||
590 |
instance unit :: pure |
|
591 |
proof qed (rule permute_unit_def) |
|
592 |
||
593 |
instance bool :: pure |
|
594 |
proof qed (rule permute_bool_def) |
|
595 |
||
596 |
text {* Other type constructors preserve purity. *} |
|
597 |
||
598 |
instance "fun" :: (pure, pure) pure |
|
599 |
by default (simp add: permute_fun_def permute_pure) |
|
600 |
||
601 |
instance "*" :: (pure, pure) pure |
|
602 |
by default (induct_tac x, simp add: permute_pure) |
|
603 |
||
604 |
instance "+" :: (pure, pure) pure |
|
605 |
by default (induct_tac x, simp_all add: permute_pure) |
|
606 |
||
607 |
instance list :: (pure) pure |
|
608 |
by default (induct_tac x, simp_all add: permute_pure) |
|
609 |
||
610 |
instance option :: (pure) pure |
|
611 |
by default (induct_tac x, simp_all add: permute_pure) |
|
612 |
||
613 |
||
614 |
subsection {* Types @{typ char}, @{typ nat}, and @{typ int} *} |
|
615 |
||
616 |
instance char :: pure |
|
617 |
proof qed (rule permute_char_def) |
|
618 |
||
619 |
instance nat :: pure |
|
620 |
proof qed (rule permute_nat_def) |
|
621 |
||
622 |
instance int :: pure |
|
623 |
proof qed (rule permute_int_def) |
|
624 |
||
625 |
||
626 |
subsection {* Supp, Freshness and Supports *} |
|
627 |
||
628 |
context pt |
|
629 |
begin |
|
630 |
||
631 |
definition |
|
632 |
supp :: "'a \<Rightarrow> atom set" |
|
633 |
where |
|
634 |
"supp x = {a. infinite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}}" |
|
635 |
||
636 |
end |
|
637 |
||
638 |
definition |
|
639 |
fresh :: "atom \<Rightarrow> 'a::pt \<Rightarrow> bool" ("_ \<sharp> _" [55, 55] 55) |
|
640 |
where |
|
641 |
"a \<sharp> x \<equiv> a \<notin> supp x" |
|
642 |
||
643 |
lemma supp_conv_fresh: |
|
644 |
shows "supp x = {a. \<not> a \<sharp> x}" |
|
645 |
unfolding fresh_def by simp |
|
646 |
||
647 |
lemma swap_rel_trans: |
|
648 |
assumes "sort_of a = sort_of b" |
|
649 |
assumes "sort_of b = sort_of c" |
|
650 |
assumes "(a \<rightleftharpoons> c) \<bullet> x = x" |
|
651 |
assumes "(b \<rightleftharpoons> c) \<bullet> x = x" |
|
652 |
shows "(a \<rightleftharpoons> b) \<bullet> x = x" |
|
653 |
proof (cases) |
|
654 |
assume "a = b \<or> c = b" |
|
655 |
with assms show "(a \<rightleftharpoons> b) \<bullet> x = x" by auto |
|
656 |
next |
|
657 |
assume *: "\<not> (a = b \<or> c = b)" |
|
658 |
have "((a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c)) \<bullet> x = x" |
|
659 |
using assms by simp |
|
660 |
also have "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)" |
|
661 |
using assms * by (simp add: swap_triple) |
|
662 |
finally show "(a \<rightleftharpoons> b) \<bullet> x = x" . |
|
663 |
qed |
|
664 |
||
665 |
lemma swap_fresh_fresh: |
|
666 |
assumes a: "a \<sharp> x" |
|
667 |
and b: "b \<sharp> x" |
|
668 |
shows "(a \<rightleftharpoons> b) \<bullet> x = x" |
|
669 |
proof (cases) |
|
670 |
assume asm: "sort_of a = sort_of b" |
|
671 |
have "finite {c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x}" "finite {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x}" |
|
672 |
using a b unfolding fresh_def supp_def by simp_all |
|
673 |
then have "finite ({c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x} \<union> {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x})" by simp |
|
674 |
then obtain c |
|
675 |
where "(a \<rightleftharpoons> c) \<bullet> x = x" "(b \<rightleftharpoons> c) \<bullet> x = x" "sort_of c = sort_of b" |
|
676 |
by (rule obtain_atom) (auto) |
|
677 |
then show "(a \<rightleftharpoons> b) \<bullet> x = x" using asm by (rule_tac swap_rel_trans) (simp_all) |
|
678 |
next |
|
679 |
assume "sort_of a \<noteq> sort_of b" |
|
680 |
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by simp |
|
681 |
qed |
|
682 |
||
683 |
||
684 |
subsection {* supp and fresh are equivariant *} |
|
685 |
||
686 |
lemma finite_Collect_bij: |
|
687 |
assumes a: "bij f" |
|
688 |
shows "finite {x. P (f x)} = finite {x. P x}" |
|
689 |
by (metis a finite_vimage_iff vimage_Collect_eq) |
|
690 |
||
691 |
lemma fresh_permute_iff: |
|
692 |
shows "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x" |
|
693 |
proof - |
|
694 |
have "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}" |
|
695 |
unfolding fresh_def supp_def by simp |
|
696 |
also have "\<dots> \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> p \<bullet> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}" |
|
1879 | 697 |
using bij_permute by (rule finite_Collect_bij[symmetric]) |
1062 | 698 |
also have "\<dots> \<longleftrightarrow> finite {b. p \<bullet> (a \<rightleftharpoons> b) \<bullet> x \<noteq> p \<bullet> x}" |
699 |
by (simp only: permute_eqvt [of p] swap_eqvt) |
|
700 |
also have "\<dots> \<longleftrightarrow> finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}" |
|
701 |
by (simp only: permute_eq_iff) |
|
702 |
also have "\<dots> \<longleftrightarrow> a \<sharp> x" |
|
703 |
unfolding fresh_def supp_def by simp |
|
1879 | 704 |
finally show "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x" . |
1062 | 705 |
qed |
706 |
||
707 |
lemma fresh_eqvt: |
|
708 |
shows "p \<bullet> (a \<sharp> x) = (p \<bullet> a) \<sharp> (p \<bullet> x)" |
|
1879 | 709 |
unfolding permute_bool_def |
710 |
by (simp add: fresh_permute_iff) |
|
1062 | 711 |
|
712 |
lemma supp_eqvt: |
|
713 |
fixes p :: "perm" |
|
714 |
and x :: "'a::pt" |
|
715 |
shows "p \<bullet> (supp x) = supp (p \<bullet> x)" |
|
716 |
unfolding supp_conv_fresh |
|
1879 | 717 |
unfolding Collect_def |
718 |
unfolding permute_fun_def |
|
1062 | 719 |
by (simp add: Not_eqvt fresh_eqvt) |
720 |
||
721 |
subsection {* supports *} |
|
722 |
||
723 |
definition |
|
724 |
supports :: "atom set \<Rightarrow> 'a::pt \<Rightarrow> bool" (infixl "supports" 80) |
|
725 |
where |
|
726 |
"S supports x \<equiv> \<forall>a b. (a \<notin> S \<and> b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x)" |
|
727 |
||
728 |
lemma supp_is_subset: |
|
729 |
fixes S :: "atom set" |
|
730 |
and x :: "'a::pt" |
|
731 |
assumes a1: "S supports x" |
|
732 |
and a2: "finite S" |
|
733 |
shows "(supp x) \<subseteq> S" |
|
734 |
proof (rule ccontr) |
|
1879 | 735 |
assume "\<not> (supp x \<subseteq> S)" |
1062 | 736 |
then obtain a where b1: "a \<in> supp x" and b2: "a \<notin> S" by auto |
1879 | 737 |
from a1 b2 have "\<forall>b. b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" unfolding supports_def by auto |
738 |
then have "{b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x} \<subseteq> S" by auto |
|
1062 | 739 |
with a2 have "finite {b. (a \<rightleftharpoons> b)\<bullet>x \<noteq> x}" by (simp add: finite_subset) |
740 |
then have "a \<notin> (supp x)" unfolding supp_def by simp |
|
741 |
with b1 show False by simp |
|
742 |
qed |
|
743 |
||
744 |
lemma supports_finite: |
|
745 |
fixes S :: "atom set" |
|
746 |
and x :: "'a::pt" |
|
747 |
assumes a1: "S supports x" |
|
748 |
and a2: "finite S" |
|
749 |
shows "finite (supp x)" |
|
750 |
proof - |
|
751 |
have "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset) |
|
752 |
then show "finite (supp x)" using a2 by (simp add: finite_subset) |
|
753 |
qed |
|
754 |
||
755 |
lemma supp_supports: |
|
756 |
fixes x :: "'a::pt" |
|
757 |
shows "(supp x) supports x" |
|
1879 | 758 |
unfolding supports_def |
759 |
proof (intro strip) |
|
1062 | 760 |
fix a b |
761 |
assume "a \<notin> (supp x) \<and> b \<notin> (supp x)" |
|
762 |
then have "a \<sharp> x" and "b \<sharp> x" by (simp_all add: fresh_def) |
|
1879 | 763 |
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh) |
1062 | 764 |
qed |
765 |
||
766 |
lemma supp_is_least_supports: |
|
767 |
fixes S :: "atom set" |
|
768 |
and x :: "'a::pt" |
|
769 |
assumes a1: "S supports x" |
|
770 |
and a2: "finite S" |
|
771 |
and a3: "\<And>S'. finite S' \<Longrightarrow> (S' supports x) \<Longrightarrow> S \<subseteq> S'" |
|
772 |
shows "(supp x) = S" |
|
773 |
proof (rule equalityI) |
|
774 |
show "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset) |
|
775 |
with a2 have fin: "finite (supp x)" by (rule rev_finite_subset) |
|
776 |
have "(supp x) supports x" by (rule supp_supports) |
|
777 |
with fin a3 show "S \<subseteq> supp x" by blast |
|
778 |
qed |
|
779 |
||
780 |
lemma subsetCI: |
|
781 |
shows "(\<And>x. x \<in> A \<Longrightarrow> x \<notin> B \<Longrightarrow> False) \<Longrightarrow> A \<subseteq> B" |
|
782 |
by auto |
|
783 |
||
784 |
lemma finite_supp_unique: |
|
785 |
assumes a1: "S supports x" |
|
786 |
assumes a2: "finite S" |
|
787 |
assumes a3: "\<And>a b. \<lbrakk>a \<in> S; b \<notin> S; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x \<noteq> x" |
|
788 |
shows "(supp x) = S" |
|
789 |
using a1 a2 |
|
790 |
proof (rule supp_is_least_supports) |
|
791 |
fix S' |
|
792 |
assume "finite S'" and "S' supports x" |
|
793 |
show "S \<subseteq> S'" |
|
794 |
proof (rule subsetCI) |
|
795 |
fix a |
|
796 |
assume "a \<in> S" and "a \<notin> S'" |
|
797 |
have "finite (S \<union> S')" |
|
798 |
using `finite S` `finite S'` by simp |
|
799 |
then obtain b where "b \<notin> S \<union> S'" and "sort_of b = sort_of a" |
|
800 |
by (rule obtain_atom) |
|
801 |
then have "b \<notin> S" and "b \<notin> S'" and "sort_of a = sort_of b" |
|
802 |
by simp_all |
|
803 |
then have "(a \<rightleftharpoons> b) \<bullet> x = x" |
|
804 |
using `a \<notin> S'` `S' supports x` by (simp add: supports_def) |
|
805 |
moreover have "(a \<rightleftharpoons> b) \<bullet> x \<noteq> x" |
|
806 |
using `a \<in> S` `b \<notin> S` `sort_of a = sort_of b` |
|
807 |
by (rule a3) |
|
808 |
ultimately show "False" by simp |
|
809 |
qed |
|
810 |
qed |
|
811 |
||
812 |
section {* Finitely-supported types *} |
|
813 |
||
814 |
class fs = pt + |
|
815 |
assumes finite_supp: "finite (supp x)" |
|
816 |
||
817 |
lemma pure_supp: |
|
818 |
shows "supp (x::'a::pure) = {}" |
|
819 |
unfolding supp_def by (simp add: permute_pure) |
|
820 |
||
821 |
lemma pure_fresh: |
|
822 |
fixes x::"'a::pure" |
|
823 |
shows "a \<sharp> x" |
|
824 |
unfolding fresh_def by (simp add: pure_supp) |
|
825 |
||
826 |
instance pure < fs |
|
827 |
by default (simp add: pure_supp) |
|
828 |
||
829 |
||
830 |
subsection {* Type @{typ atom} is finitely-supported. *} |
|
831 |
||
832 |
lemma supp_atom: |
|
833 |
shows "supp a = {a}" |
|
834 |
apply (rule finite_supp_unique) |
|
835 |
apply (clarsimp simp add: supports_def) |
|
836 |
apply simp |
|
837 |
apply simp |
|
838 |
done |
|
839 |
||
840 |
lemma fresh_atom: |
|
841 |
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> b" |
|
842 |
unfolding fresh_def supp_atom by simp |
|
843 |
||
844 |
instance atom :: fs |
|
845 |
by default (simp add: supp_atom) |
|
846 |
||
1933
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
847 |
section {* Support for finite sets of atoms *} |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
848 |
|
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
849 |
lemma supp_finite_atom_set: |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
850 |
fixes S::"atom set" |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
851 |
assumes "finite S" |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
852 |
shows "supp S = S" |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
853 |
apply(rule finite_supp_unique) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
854 |
apply(simp add: supports_def) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
855 |
apply(simp add: swap_set_not_in) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
856 |
apply(rule assms) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
857 |
apply(simp add: swap_set_in) |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
858 |
done |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
859 |
|
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
860 |
lemma supp_atom_insert: |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
861 |
fixes S::"atom set" |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
862 |
assumes a: "finite S" |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
863 |
shows "supp (insert a S) = supp a \<union> supp S" |
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
parents:
1932
diff
changeset
|
864 |
using a by (simp add: supp_finite_atom_set supp_atom) |
1062 | 865 |
|
866 |
section {* Type @{typ perm} is finitely-supported. *} |
|
867 |
||
868 |
lemma perm_swap_eq: |
|
869 |
shows "(a \<rightleftharpoons> b) \<bullet> p = p \<longleftrightarrow> (p \<bullet> (a \<rightleftharpoons> b)) = (a \<rightleftharpoons> b)" |
|
870 |
unfolding permute_perm_def |
|
871 |
by (metis add_diff_cancel minus_perm_def) |
|
872 |
||
873 |
lemma supports_perm: |
|
874 |
shows "{a. p \<bullet> a \<noteq> a} supports p" |
|
875 |
unfolding supports_def |
|
1879 | 876 |
unfolding perm_swap_eq |
877 |
by (simp add: swap_eqvt) |
|
1062 | 878 |
|
879 |
lemma finite_perm_lemma: |
|
880 |
shows "finite {a::atom. p \<bullet> a \<noteq> a}" |
|
881 |
using finite_Rep_perm [of p] |
|
882 |
unfolding permute_atom_def . |
|
883 |
||
884 |
lemma supp_perm: |
|
885 |
shows "supp p = {a. p \<bullet> a \<noteq> a}" |
|
886 |
apply (rule finite_supp_unique) |
|
887 |
apply (rule supports_perm) |
|
888 |
apply (rule finite_perm_lemma) |
|
889 |
apply (simp add: perm_swap_eq swap_eqvt) |
|
890 |
apply (auto simp add: expand_perm_eq swap_atom) |
|
891 |
done |
|
892 |
||
893 |
lemma fresh_perm: |
|
894 |
shows "a \<sharp> p \<longleftrightarrow> p \<bullet> a = a" |
|
1879 | 895 |
unfolding fresh_def |
896 |
by (simp add: supp_perm) |
|
1062 | 897 |
|
898 |
lemma supp_swap: |
|
899 |
shows "supp (a \<rightleftharpoons> b) = (if a = b \<or> sort_of a \<noteq> sort_of b then {} else {a, b})" |
|
900 |
by (auto simp add: supp_perm swap_atom) |
|
901 |
||
902 |
lemma fresh_zero_perm: |
|
903 |
shows "a \<sharp> (0::perm)" |
|
904 |
unfolding fresh_perm by simp |
|
905 |
||
906 |
lemma supp_zero_perm: |
|
907 |
shows "supp (0::perm) = {}" |
|
908 |
unfolding supp_perm by simp |
|
909 |
||
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
910 |
lemma fresh_plus_perm: |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
911 |
fixes p q::perm |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
912 |
assumes "a \<sharp> p" "a \<sharp> q" |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
913 |
shows "a \<sharp> (p + q)" |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
914 |
using assms |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
915 |
unfolding fresh_def |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
916 |
by (auto simp add: supp_perm) |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
917 |
|
1062 | 918 |
lemma supp_plus_perm: |
919 |
fixes p q::perm |
|
920 |
shows "supp (p + q) \<subseteq> supp p \<union> supp q" |
|
921 |
by (auto simp add: supp_perm) |
|
922 |
||
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
923 |
lemma fresh_minus_perm: |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
924 |
fixes p::perm |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
925 |
shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p" |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
926 |
unfolding fresh_def |
1879 | 927 |
unfolding supp_perm |
928 |
apply(simp) |
|
929 |
apply(metis permute_minus_cancel) |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
930 |
done |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
931 |
|
1062 | 932 |
lemma supp_minus_perm: |
933 |
fixes p::perm |
|
934 |
shows "supp (- p) = supp p" |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
935 |
unfolding supp_conv_fresh |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
936 |
by (simp add: fresh_minus_perm) |
1062 | 937 |
|
938 |
instance perm :: fs |
|
939 |
by default (simp add: supp_perm finite_perm_lemma) |
|
940 |
||
1305
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
941 |
lemma plus_perm_eq: |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
942 |
fixes p q::"perm" |
1879 | 943 |
assumes asm: "supp p \<inter> supp q = {}" |
1305
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
944 |
shows "p + q = q + p" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
945 |
unfolding expand_perm_eq |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
946 |
proof |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
947 |
fix a::"atom" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
948 |
show "(p + q) \<bullet> a = (q + p) \<bullet> a" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
949 |
proof - |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
950 |
{ assume "a \<notin> supp p" "a \<notin> supp q" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
951 |
then have "(p + q) \<bullet> a = (q + p) \<bullet> a" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
952 |
by (simp add: supp_perm) |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
953 |
} |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
954 |
moreover |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
955 |
{ assume a: "a \<in> supp p" "a \<notin> supp q" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
956 |
then have "p \<bullet> a \<in> supp p" by (simp add: supp_perm) |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
957 |
then have "p \<bullet> a \<notin> supp q" using asm by auto |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
958 |
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
959 |
by (simp add: supp_perm) |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
960 |
} |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
961 |
moreover |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
962 |
{ assume a: "a \<notin> supp p" "a \<in> supp q" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
963 |
then have "q \<bullet> a \<in> supp q" by (simp add: supp_perm) |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
964 |
then have "q \<bullet> a \<notin> supp p" using asm by auto |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
965 |
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
966 |
by (simp add: supp_perm) |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
967 |
} |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
968 |
ultimately show "(p + q) \<bullet> a = (q + p) \<bullet> a" |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
969 |
using asm by blast |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
970 |
qed |
61319a9af976
updated (added lemma about commuting permutations)
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
971 |
qed |
1062 | 972 |
|
973 |
section {* Finite Support instances for other types *} |
|
974 |
||
975 |
subsection {* Type @{typ "'a \<times> 'b"} is finitely-supported. *} |
|
976 |
||
977 |
lemma supp_Pair: |
|
978 |
shows "supp (x, y) = supp x \<union> supp y" |
|
979 |
by (simp add: supp_def Collect_imp_eq Collect_neg_eq) |
|
980 |
||
981 |
lemma fresh_Pair: |
|
982 |
shows "a \<sharp> (x, y) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> y" |
|
983 |
by (simp add: fresh_def supp_Pair) |
|
984 |
||
985 |
instance "*" :: (fs, fs) fs |
|
986 |
apply default |
|
987 |
apply (induct_tac x) |
|
988 |
apply (simp add: supp_Pair finite_supp) |
|
989 |
done |
|
990 |
||
991 |
subsection {* Type @{typ "'a + 'b"} is finitely supported *} |
|
992 |
||
993 |
lemma supp_Inl: |
|
994 |
shows "supp (Inl x) = supp x" |
|
995 |
by (simp add: supp_def) |
|
996 |
||
997 |
lemma supp_Inr: |
|
998 |
shows "supp (Inr x) = supp x" |
|
999 |
by (simp add: supp_def) |
|
1000 |
||
1001 |
lemma fresh_Inl: |
|
1002 |
shows "a \<sharp> Inl x \<longleftrightarrow> a \<sharp> x" |
|
1003 |
by (simp add: fresh_def supp_Inl) |
|
1004 |
||
1005 |
lemma fresh_Inr: |
|
1006 |
shows "a \<sharp> Inr y \<longleftrightarrow> a \<sharp> y" |
|
1007 |
by (simp add: fresh_def supp_Inr) |
|
1008 |
||
1009 |
instance "+" :: (fs, fs) fs |
|
1010 |
apply default |
|
1011 |
apply (induct_tac x) |
|
1012 |
apply (simp_all add: supp_Inl supp_Inr finite_supp) |
|
1013 |
done |
|
1014 |
||
1015 |
subsection {* Type @{typ "'a option"} is finitely supported *} |
|
1016 |
||
1017 |
lemma supp_None: |
|
1018 |
shows "supp None = {}" |
|
1019 |
by (simp add: supp_def) |
|
1020 |
||
1021 |
lemma supp_Some: |
|
1022 |
shows "supp (Some x) = supp x" |
|
1023 |
by (simp add: supp_def) |
|
1024 |
||
1025 |
lemma fresh_None: |
|
1026 |
shows "a \<sharp> None" |
|
1027 |
by (simp add: fresh_def supp_None) |
|
1028 |
||
1029 |
lemma fresh_Some: |
|
1030 |
shows "a \<sharp> Some x \<longleftrightarrow> a \<sharp> x" |
|
1031 |
by (simp add: fresh_def supp_Some) |
|
1032 |
||
1033 |
instance option :: (fs) fs |
|
1034 |
apply default |
|
1035 |
apply (induct_tac x) |
|
1036 |
apply (simp_all add: supp_None supp_Some finite_supp) |
|
1037 |
done |
|
1038 |
||
1039 |
subsubsection {* Type @{typ "'a list"} is finitely supported *} |
|
1040 |
||
1041 |
lemma supp_Nil: |
|
1042 |
shows "supp [] = {}" |
|
1043 |
by (simp add: supp_def) |
|
1044 |
||
1045 |
lemma supp_Cons: |
|
1046 |
shows "supp (x # xs) = supp x \<union> supp xs" |
|
1047 |
by (simp add: supp_def Collect_imp_eq Collect_neg_eq) |
|
1048 |
||
1049 |
lemma fresh_Nil: |
|
1050 |
shows "a \<sharp> []" |
|
1051 |
by (simp add: fresh_def supp_Nil) |
|
1052 |
||
1053 |
lemma fresh_Cons: |
|
1054 |
shows "a \<sharp> (x # xs) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> xs" |
|
1055 |
by (simp add: fresh_def supp_Cons) |
|
1056 |
||
1057 |
instance list :: (fs) fs |
|
1058 |
apply default |
|
1059 |
apply (induct_tac x) |
|
1060 |
apply (simp_all add: supp_Nil supp_Cons finite_supp) |
|
1061 |
done |
|
1062 |
||
1063 |
section {* Support and freshness for applications *} |
|
1064 |
||
1879 | 1065 |
lemma fresh_conv_MOST: |
1066 |
shows "a \<sharp> x \<longleftrightarrow> (MOST b. (a \<rightleftharpoons> b) \<bullet> x = x)" |
|
1067 |
unfolding fresh_def supp_def |
|
1068 |
unfolding MOST_iff_cofinite by simp |
|
1069 |
||
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1070 |
lemma supp_subset_fresh: |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1071 |
assumes a: "\<And>a. a \<sharp> x \<Longrightarrow> a \<sharp> y" |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1072 |
shows "supp y \<subseteq> supp x" |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1073 |
using a |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1074 |
unfolding fresh_def |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1075 |
by blast |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1076 |
|
1879 | 1077 |
lemma fresh_fun_app: |
1078 |
assumes "a \<sharp> f" and "a \<sharp> x" |
|
1079 |
shows "a \<sharp> f x" |
|
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1080 |
using assms |
1879 | 1081 |
unfolding fresh_conv_MOST |
1082 |
unfolding permute_fun_app_eq |
|
1083 |
by (elim MOST_rev_mp, simp) |
|
1084 |
||
1062 | 1085 |
lemma supp_fun_app: |
1086 |
shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)" |
|
1879 | 1087 |
using fresh_fun_app |
1088 |
unfolding fresh_def |
|
1089 |
by auto |
|
1090 |
||
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1091 |
text {* support of equivariant functions *} |
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1092 |
|
1941 | 1093 |
lemma supp_fun_eqvt: |
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1094 |
assumes a: "\<And>p. p \<bullet> f = f" |
1941 | 1095 |
shows "supp f = {}" |
1096 |
unfolding supp_def |
|
1097 |
using a by simp |
|
1098 |
||
1062 | 1099 |
lemma fresh_fun_eqvt_app: |
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1100 |
assumes a: "\<And>p. p \<bullet> f = f" |
1062 | 1101 |
shows "a \<sharp> x \<Longrightarrow> a \<sharp> f x" |
1102 |
proof - |
|
1941 | 1103 |
from a have "supp f = {}" by (simp add: supp_fun_eqvt) |
1879 | 1104 |
then show "a \<sharp> x \<Longrightarrow> a \<sharp> f x" |
1062 | 1105 |
unfolding fresh_def |
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
parents:
1973
diff
changeset
|
1106 |
using supp_fun_app by auto |
1062 | 1107 |
qed |
1108 |
||
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1109 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1110 |
section {* Concrete atoms types *} |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1111 |
|
1972 | 1112 |
text {* |
1113 |
Class @{text at_base} allows types containing multiple sorts of atoms. |
|
1114 |
Class @{text at} only allows types with a single sort. |
|
1115 |
*} |
|
1116 |
||
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1117 |
class at_base = pt + |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1118 |
fixes atom :: "'a \<Rightarrow> atom" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1119 |
assumes atom_eq_iff [simp]: "atom a = atom b \<longleftrightarrow> a = b" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1120 |
assumes atom_eqvt: "p \<bullet> (atom a) = atom (p \<bullet> a)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1121 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1122 |
class at = at_base + |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1123 |
assumes sort_of_atom_eq [simp]: "sort_of (atom a) = sort_of (atom b)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1124 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1125 |
lemma supp_at_base: |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1126 |
fixes a::"'a::at_base" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1127 |
shows "supp a = {atom a}" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1128 |
by (simp add: supp_atom [symmetric] supp_def atom_eqvt) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1129 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1130 |
lemma fresh_at_base: |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1131 |
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> atom b" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1132 |
unfolding fresh_def by (simp add: supp_at_base) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1133 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1134 |
instance at_base < fs |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1135 |
proof qed (simp add: supp_at_base) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1136 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1137 |
lemma at_base_infinite [simp]: |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1138 |
shows "infinite (UNIV :: 'a::at_base set)" (is "infinite ?U") |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1139 |
proof |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1140 |
obtain a :: 'a where "True" by auto |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1141 |
assume "finite ?U" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1142 |
hence "finite (atom ` ?U)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1143 |
by (rule finite_imageI) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1144 |
then obtain b where b: "b \<notin> atom ` ?U" "sort_of b = sort_of (atom a)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1145 |
by (rule obtain_atom) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1146 |
from b(2) have "b = atom ((atom a \<rightleftharpoons> b) \<bullet> a)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1147 |
unfolding atom_eqvt [symmetric] |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1148 |
by (simp add: swap_atom) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1149 |
hence "b \<in> atom ` ?U" by simp |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1150 |
with b(1) show "False" by simp |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1151 |
qed |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1152 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1153 |
lemma swap_at_base_simps [simp]: |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1154 |
fixes x y::"'a::at_base" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1155 |
shows "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> x = y" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1156 |
and "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> y = x" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1157 |
and "atom x \<noteq> a \<Longrightarrow> atom x \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1158 |
unfolding atom_eq_iff [symmetric] |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1159 |
unfolding atom_eqvt [symmetric] |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1160 |
by simp_all |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1161 |
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1162 |
lemma obtain_at_base: |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1163 |
assumes X: "finite X" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1164 |
obtains a::"'a::at_base" where "atom a \<notin> X" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1165 |
proof - |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1166 |
have "inj (atom :: 'a \<Rightarrow> atom)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1167 |
by (simp add: inj_on_def) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1168 |
with X have "finite (atom -` X :: 'a set)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1169 |
by (rule finite_vimageI) |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1170 |
with at_base_infinite have "atom -` X \<noteq> (UNIV :: 'a set)" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1171 |
by auto |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1172 |
then obtain a :: 'a where "atom a \<notin> X" |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1173 |
by auto |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1174 |
thus ?thesis .. |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1175 |
qed |
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1941
diff
changeset
|
1176 |
|
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1177 |
lemma image_eqvt: |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1178 |
shows "p \<bullet> (f ` A) = (p \<bullet> f) ` (p \<bullet> A)" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1179 |
unfolding permute_set_eq_image |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1180 |
unfolding permute_fun_def [where f=f] |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1181 |
by (simp add: image_image) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1182 |
|
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1183 |
lemma atom_image_cong: |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1184 |
shows "(atom ` X = atom ` Y) = (X = Y)" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1185 |
apply(rule inj_image_eq_iff) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1186 |
apply(simp add: inj_on_def) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1187 |
done |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1188 |
|
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1189 |
lemma atom_image_supp: |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1190 |
shows "supp S = supp (atom ` S)" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1191 |
apply(simp add: supp_def) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1192 |
apply(simp add: image_eqvt) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1193 |
apply(subst (2) permute_fun_def) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1194 |
apply(simp add: atom_eqvt) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1195 |
apply(simp add: atom_image_cong) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1196 |
done |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1197 |
|
1973
fc5ce7f22b74
use the more general type-class at_base
Christian Urban <urbanc@in.tum.de>
parents:
1972
diff
changeset
|
1198 |
lemma supp_finite_set_at_base: |
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1199 |
assumes a: "finite S" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1200 |
shows "supp S = atom ` S" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1201 |
proof - |
2013 | 1202 |
have fin: "finite (atom ` S)" using a by simp |
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1203 |
have "supp S = supp (atom ` S)" by (rule atom_image_supp) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1204 |
also have "\<dots> = atom ` S" using fin by (simp add: supp_finite_atom_set) |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1205 |
finally show "supp S = atom ` S" by simp |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1206 |
qed |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1207 |
|
1973
fc5ce7f22b74
use the more general type-class at_base
Christian Urban <urbanc@in.tum.de>
parents:
1972
diff
changeset
|
1208 |
lemma supp_at_base_insert: |
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1209 |
fixes a::"'a::at_base" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1210 |
assumes a: "finite S" |
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1211 |
shows "supp (insert a S) = supp a \<union> supp S" |
1973
fc5ce7f22b74
use the more general type-class at_base
Christian Urban <urbanc@in.tum.de>
parents:
1972
diff
changeset
|
1212 |
using a by (simp add: supp_finite_set_at_base supp_at_base) |
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
parents:
1962
diff
changeset
|
1213 |
|
1879 | 1214 |
section {* library functions for the nominal infrastructure *} |
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
1215 |
use "nominal_library.ML" |
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
1216 |
|
1062 | 1217 |
end |