author | Christian Urban <urbanc@in.tum.de> |
Wed, 10 Mar 2010 12:48:55 +0100 | |
changeset 1393 | 4eaae533efc3 |
parent 1363 | f00761b5957e |
child 1499 | 21dda372fb11 |
permissions | -rw-r--r-- |
1062 | 1 |
(* Title: Nominal2_Atoms |
2 |
Authors: Brian Huffman, Christian Urban |
|
3 |
||
4 |
Definitions for concrete atom types. |
|
5 |
*) |
|
6 |
theory Nominal2_Atoms |
|
7 |
imports Nominal2_Base |
|
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
8 |
uses ("nominal_atoms.ML") |
1062 | 9 |
begin |
10 |
||
11 |
section {* Concrete atom types *} |
|
12 |
||
13 |
text {* |
|
14 |
Class @{text at_base} allows types containing multiple sorts of atoms. |
|
15 |
Class @{text at} only allows types with a single sort. |
|
16 |
*} |
|
17 |
||
18 |
class at_base = pt + |
|
19 |
fixes atom :: "'a \<Rightarrow> atom" |
|
20 |
assumes atom_eq_iff [simp]: "atom a = atom b \<longleftrightarrow> a = b" |
|
21 |
assumes atom_eqvt: "p \<bullet> (atom a) = atom (p \<bullet> a)" |
|
22 |
||
23 |
class at = at_base + |
|
24 |
assumes sort_of_atom_eq [simp]: "sort_of (atom a) = sort_of (atom b)" |
|
25 |
||
26 |
instance at < at_base .. |
|
27 |
||
28 |
lemma supp_at_base: |
|
29 |
fixes a::"'a::at_base" |
|
30 |
shows "supp a = {atom a}" |
|
31 |
by (simp add: supp_atom [symmetric] supp_def atom_eqvt) |
|
32 |
||
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
33 |
lemma fresh_at_base: |
1062 | 34 |
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> atom b" |
35 |
unfolding fresh_def by (simp add: supp_at_base) |
|
36 |
||
37 |
instance at_base < fs |
|
38 |
proof qed (simp add: supp_at_base) |
|
39 |
||
40 |
lemma at_base_infinite [simp]: |
|
41 |
shows "infinite (UNIV :: 'a::at_base set)" (is "infinite ?U") |
|
42 |
proof |
|
43 |
obtain a :: 'a where "True" by auto |
|
44 |
assume "finite ?U" |
|
45 |
hence "finite (atom ` ?U)" |
|
46 |
by (rule finite_imageI) |
|
47 |
then obtain b where b: "b \<notin> atom ` ?U" "sort_of b = sort_of (atom a)" |
|
48 |
by (rule obtain_atom) |
|
49 |
from b(2) have "b = atom ((atom a \<rightleftharpoons> b) \<bullet> a)" |
|
50 |
unfolding atom_eqvt [symmetric] |
|
51 |
by (simp add: swap_atom) |
|
52 |
hence "b \<in> atom ` ?U" by simp |
|
53 |
with b(1) show "False" by simp |
|
54 |
qed |
|
55 |
||
56 |
lemma swap_at_base_simps [simp]: |
|
57 |
fixes x y::"'a::at_base" |
|
58 |
shows "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> x = y" |
|
59 |
and "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> y = x" |
|
60 |
and "atom x \<noteq> a \<Longrightarrow> atom x \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" |
|
61 |
unfolding atom_eq_iff [symmetric] |
|
62 |
unfolding atom_eqvt [symmetric] |
|
63 |
by simp_all |
|
64 |
||
65 |
lemma obtain_at_base: |
|
66 |
assumes X: "finite X" |
|
67 |
obtains a::"'a::at_base" where "atom a \<notin> X" |
|
68 |
proof - |
|
69 |
have "inj (atom :: 'a \<Rightarrow> atom)" |
|
70 |
by (simp add: inj_on_def) |
|
71 |
with X have "finite (atom -` X :: 'a set)" |
|
72 |
by (rule finite_vimageI) |
|
73 |
with at_base_infinite have "atom -` X \<noteq> (UNIV :: 'a set)" |
|
74 |
by auto |
|
75 |
then obtain a :: 'a where "atom a \<notin> X" |
|
76 |
by auto |
|
77 |
thus ?thesis .. |
|
78 |
qed |
|
79 |
||
80 |
||
81 |
section {* A swapping operation for concrete atoms *} |
|
82 |
||
83 |
definition |
|
84 |
flip :: "'a::at_base \<Rightarrow> 'a \<Rightarrow> perm" ("'(_ \<leftrightarrow> _')") |
|
85 |
where |
|
86 |
"(a \<leftrightarrow> b) = (atom a \<rightleftharpoons> atom b)" |
|
87 |
||
88 |
lemma flip_self [simp]: "(a \<leftrightarrow> a) = 0" |
|
89 |
unfolding flip_def by (rule swap_self) |
|
90 |
||
91 |
lemma flip_commute: "(a \<leftrightarrow> b) = (b \<leftrightarrow> a)" |
|
92 |
unfolding flip_def by (rule swap_commute) |
|
93 |
||
94 |
lemma minus_flip [simp]: "- (a \<leftrightarrow> b) = (a \<leftrightarrow> b)" |
|
95 |
unfolding flip_def by (rule minus_swap) |
|
96 |
||
97 |
lemma add_flip_cancel: "(a \<leftrightarrow> b) + (a \<leftrightarrow> b) = 0" |
|
98 |
unfolding flip_def by (rule swap_cancel) |
|
99 |
||
100 |
lemma permute_flip_cancel [simp]: "(a \<leftrightarrow> b) \<bullet> (a \<leftrightarrow> b) \<bullet> x = x" |
|
101 |
unfolding permute_plus [symmetric] add_flip_cancel by simp |
|
102 |
||
103 |
lemma permute_flip_cancel2 [simp]: "(a \<leftrightarrow> b) \<bullet> (b \<leftrightarrow> a) \<bullet> x = x" |
|
104 |
by (simp add: flip_commute) |
|
105 |
||
106 |
lemma flip_eqvt: |
|
107 |
fixes a b c::"'a::at_base" |
|
108 |
shows "p \<bullet> (a \<leftrightarrow> b) = (p \<bullet> a \<leftrightarrow> p \<bullet> b)" |
|
109 |
unfolding flip_def |
|
110 |
by (simp add: swap_eqvt atom_eqvt) |
|
111 |
||
112 |
lemma flip_at_base_simps [simp]: |
|
113 |
shows "sort_of (atom a) = sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> a = b" |
|
114 |
and "sort_of (atom a) = sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> b = a" |
|
115 |
and "\<lbrakk>a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> c = c" |
|
116 |
and "sort_of (atom a) \<noteq> sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> x = x" |
|
117 |
unfolding flip_def |
|
118 |
unfolding atom_eq_iff [symmetric] |
|
119 |
unfolding atom_eqvt [symmetric] |
|
120 |
by simp_all |
|
121 |
||
122 |
text {* the following two lemmas do not hold for at_base, |
|
123 |
only for single sort atoms from at *} |
|
124 |
||
125 |
lemma permute_flip_at: |
|
126 |
fixes a b c::"'a::at" |
|
127 |
shows "(a \<leftrightarrow> b) \<bullet> c = (if c = a then b else if c = b then a else c)" |
|
128 |
unfolding flip_def |
|
129 |
apply (rule atom_eq_iff [THEN iffD1]) |
|
130 |
apply (subst atom_eqvt [symmetric]) |
|
131 |
apply (simp add: swap_atom) |
|
132 |
done |
|
133 |
||
134 |
lemma flip_at_simps [simp]: |
|
135 |
fixes a b::"'a::at" |
|
136 |
shows "(a \<leftrightarrow> b) \<bullet> a = b" |
|
137 |
and "(a \<leftrightarrow> b) \<bullet> b = a" |
|
138 |
unfolding permute_flip_at by simp_all |
|
139 |
||
140 |
||
141 |
subsection {* Syntax for coercing at-elements to the atom-type *} |
|
142 |
||
1363
f00761b5957e
updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
143 |
(* |
1062 | 144 |
syntax |
145 |
"_atom_constrain" :: "logic \<Rightarrow> type \<Rightarrow> logic" ("_:::_" [4, 0] 3) |
|
146 |
||
147 |
translations |
|
148 |
"_atom_constrain a t" => "atom (_constrain a t)" |
|
1363
f00761b5957e
updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents:
1258
diff
changeset
|
149 |
*) |
1062 | 150 |
|
151 |
subsection {* A lemma for proving instances of class @{text at}. *} |
|
152 |
||
153 |
setup {* Sign.add_const_constraint (@{const_name "permute"}, NONE) *} |
|
154 |
setup {* Sign.add_const_constraint (@{const_name "atom"}, NONE) *} |
|
155 |
||
156 |
text {* |
|
157 |
New atom types are defined as subtypes of @{typ atom}. |
|
158 |
*} |
|
159 |
||
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
160 |
lemma exists_eq_simple_sort: |
1062 | 161 |
shows "\<exists>a. a \<in> {a. sort_of a = s}" |
162 |
by (rule_tac x="Atom s 0" in exI, simp) |
|
163 |
||
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
164 |
lemma exists_eq_sort: |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
165 |
shows "\<exists>a. a \<in> {a. sort_of a \<in> range sort_fun}" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
166 |
by (rule_tac x="Atom (sort_fun x) y" in exI, simp) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
167 |
|
1062 | 168 |
lemma at_base_class: |
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
169 |
fixes sort_fun :: "'b \<Rightarrow>atom_sort" |
1062 | 170 |
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a" |
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
171 |
assumes type: "type_definition Rep Abs {a. sort_of a \<in> range sort_fun}" |
1062 | 172 |
assumes atom_def: "\<And>a. atom a = Rep a" |
173 |
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)" |
|
174 |
shows "OFCLASS('a, at_base_class)" |
|
175 |
proof |
|
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
176 |
interpret type_definition Rep Abs "{a. sort_of a \<in> range sort_fun}" by (rule type) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
177 |
have sort_of_Rep: "\<And>a. sort_of (Rep a) \<in> range sort_fun" using Rep by simp |
1062 | 178 |
fix a b :: 'a and p p1 p2 :: perm |
179 |
show "0 \<bullet> a = a" |
|
180 |
unfolding permute_def by (simp add: Rep_inverse) |
|
181 |
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a" |
|
182 |
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep) |
|
183 |
show "atom a = atom b \<longleftrightarrow> a = b" |
|
184 |
unfolding atom_def by (simp add: Rep_inject) |
|
185 |
show "p \<bullet> atom a = atom (p \<bullet> a)" |
|
186 |
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep) |
|
187 |
qed |
|
188 |
||
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
189 |
(* |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
190 |
lemma at_class: |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
191 |
fixes s :: atom_sort |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
192 |
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
193 |
assumes type: "type_definition Rep Abs {a. sort_of a \<in> range (\<lambda>x::unit. s)}" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
194 |
assumes atom_def: "\<And>a. atom a = Rep a" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
195 |
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
196 |
shows "OFCLASS('a, at_class)" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
197 |
proof |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
198 |
interpret type_definition Rep Abs "{a. sort_of a \<in> range (\<lambda>x::unit. s)}" by (rule type) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
199 |
have sort_of_Rep: "\<And>a. sort_of (Rep a) = s" using Rep by (simp add: image_def) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
200 |
fix a b :: 'a and p p1 p2 :: perm |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
201 |
show "0 \<bullet> a = a" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
202 |
unfolding permute_def by (simp add: Rep_inverse) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
203 |
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
204 |
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
205 |
show "sort_of (atom a) = sort_of (atom b)" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
206 |
unfolding atom_def by (simp add: sort_of_Rep) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
207 |
show "atom a = atom b \<longleftrightarrow> a = b" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
208 |
unfolding atom_def by (simp add: Rep_inject) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
209 |
show "p \<bullet> atom a = atom (p \<bullet> a)" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
210 |
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
211 |
qed |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
212 |
*) |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
213 |
|
1062 | 214 |
lemma at_class: |
215 |
fixes s :: atom_sort |
|
216 |
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a" |
|
217 |
assumes type: "type_definition Rep Abs {a. sort_of a = s}" |
|
218 |
assumes atom_def: "\<And>a. atom a = Rep a" |
|
219 |
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)" |
|
220 |
shows "OFCLASS('a, at_class)" |
|
221 |
proof |
|
222 |
interpret type_definition Rep Abs "{a. sort_of a = s}" by (rule type) |
|
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
223 |
have sort_of_Rep: "\<And>a. sort_of (Rep a) = s" using Rep by (simp add: image_def) |
1062 | 224 |
fix a b :: 'a and p p1 p2 :: perm |
225 |
show "0 \<bullet> a = a" |
|
226 |
unfolding permute_def by (simp add: Rep_inverse) |
|
227 |
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a" |
|
228 |
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep) |
|
229 |
show "sort_of (atom a) = sort_of (atom b)" |
|
230 |
unfolding atom_def by (simp add: sort_of_Rep) |
|
231 |
show "atom a = atom b \<longleftrightarrow> a = b" |
|
232 |
unfolding atom_def by (simp add: Rep_inject) |
|
233 |
show "p \<bullet> atom a = atom (p \<bullet> a)" |
|
234 |
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep) |
|
235 |
qed |
|
236 |
||
237 |
setup {* Sign.add_const_constraint |
|
238 |
(@{const_name "permute"}, SOME @{typ "perm \<Rightarrow> 'a::pt \<Rightarrow> 'a"}) *} |
|
239 |
setup {* Sign.add_const_constraint |
|
240 |
(@{const_name "atom"}, SOME @{typ "'a::at_base \<Rightarrow> atom"}) *} |
|
241 |
||
242 |
||
243 |
section {* Automation for creating concrete atom types *} |
|
244 |
||
245 |
text {* at the moment only single-sort concrete atoms are supported *} |
|
246 |
||
1079
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
247 |
use "nominal_atoms.ML" |
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
248 |
|
c70e7545b738
updated to latest Nominal2
Christian Urban <urbanc@in.tum.de>
parents:
1062
diff
changeset
|
249 |
|
1062 | 250 |
|
251 |
||
252 |
end |