author | Christian Urban <urbanc@in.tum.de> |
Tue, 13 Apr 2010 00:47:57 +0200 | |
changeset 1815 | 4135198bbb8a |
parent 1811 | ae176476b525 |
child 1827 | eef70e8fa9ee |
permissions | -rw-r--r-- |
1062 | 1 |
(* Title: Nominal2_Eqvt |
1810
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents:
1803
diff
changeset
|
2 |
Author: Brian Huffman, |
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents:
1803
diff
changeset
|
3 |
Author: Christian Urban |
1062 | 4 |
|
5 |
Equivariance, Supp and Fresh Lemmas for Operators. |
|
1810
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents:
1803
diff
changeset
|
6 |
(Contains many, but not all such lemmas.) |
1062 | 7 |
*) |
8 |
theory Nominal2_Eqvt |
|
1315
43d6e3730353
Add image_eqvt and atom_eqvt to eqvt bases.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1258
diff
changeset
|
9 |
imports Nominal2_Base Nominal2_Atoms |
1062 | 10 |
uses ("nominal_thmdecls.ML") |
11 |
("nominal_permeq.ML") |
|
12 |
begin |
|
13 |
||
1810
894930834ca8
fixed bug in thmdecls with destructing Trueprop; some initial infrastructure for eqvt-theorems of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents:
1803
diff
changeset
|
14 |
|
1062 | 15 |
section {* Logical Operators *} |
16 |
||
17 |
lemma eq_eqvt: |
|
18 |
shows "p \<bullet> (x = y) \<longleftrightarrow> (p \<bullet> x) = (p \<bullet> y)" |
|
19 |
unfolding permute_eq_iff permute_bool_def .. |
|
20 |
||
21 |
lemma if_eqvt: |
|
22 |
shows "p \<bullet> (if b then x else y) = (if p \<bullet> b then p \<bullet> x else p \<bullet> y)" |
|
23 |
by (simp add: permute_fun_def permute_bool_def) |
|
24 |
||
25 |
lemma True_eqvt: |
|
26 |
shows "p \<bullet> True = True" |
|
27 |
unfolding permute_bool_def .. |
|
28 |
||
29 |
lemma False_eqvt: |
|
30 |
shows "p \<bullet> False = False" |
|
31 |
unfolding permute_bool_def .. |
|
32 |
||
33 |
lemma imp_eqvt: |
|
34 |
shows "p \<bullet> (A \<longrightarrow> B) = ((p \<bullet> A) \<longrightarrow> (p \<bullet> B))" |
|
35 |
by (simp add: permute_bool_def) |
|
36 |
||
37 |
lemma conj_eqvt: |
|
38 |
shows "p \<bullet> (A \<and> B) = ((p \<bullet> A) \<and> (p \<bullet> B))" |
|
39 |
by (simp add: permute_bool_def) |
|
40 |
||
41 |
lemma disj_eqvt: |
|
42 |
shows "p \<bullet> (A \<or> B) = ((p \<bullet> A) \<or> (p \<bullet> B))" |
|
43 |
by (simp add: permute_bool_def) |
|
44 |
||
45 |
lemma Not_eqvt: |
|
46 |
shows "p \<bullet> (\<not> A) = (\<not> (p \<bullet> A))" |
|
47 |
by (simp add: permute_bool_def) |
|
48 |
||
49 |
lemma all_eqvt: |
|
50 |
shows "p \<bullet> (\<forall>x. P x) = (\<forall>x. (p \<bullet> P) x)" |
|
51 |
unfolding permute_fun_def permute_bool_def |
|
52 |
by (auto, drule_tac x="p \<bullet> x" in spec, simp) |
|
53 |
||
54 |
lemma all_eqvt2: |
|
55 |
shows "p \<bullet> (\<forall>x. P x) = (\<forall>x. p \<bullet> P (- p \<bullet> x))" |
|
56 |
unfolding permute_fun_def permute_bool_def |
|
57 |
by (auto, drule_tac x="p \<bullet> x" in spec, simp) |
|
58 |
||
59 |
lemma ex_eqvt: |
|
60 |
shows "p \<bullet> (\<exists>x. P x) = (\<exists>x. (p \<bullet> P) x)" |
|
61 |
unfolding permute_fun_def permute_bool_def |
|
62 |
by (auto, rule_tac x="p \<bullet> x" in exI, simp) |
|
63 |
||
64 |
lemma ex_eqvt2: |
|
65 |
shows "p \<bullet> (\<exists>x. P x) = (\<exists>x. p \<bullet> P (- p \<bullet> x))" |
|
66 |
unfolding permute_fun_def permute_bool_def |
|
67 |
by (auto, rule_tac x="p \<bullet> x" in exI, simp) |
|
68 |
||
69 |
lemma ex1_eqvt: |
|
70 |
shows "p \<bullet> (\<exists>!x. P x) = (\<exists>!x. (p \<bullet> P) x)" |
|
71 |
unfolding Ex1_def |
|
72 |
by (simp add: ex_eqvt permute_fun_def conj_eqvt all_eqvt imp_eqvt eq_eqvt) |
|
73 |
||
74 |
lemma ex1_eqvt2: |
|
75 |
shows "p \<bullet> (\<exists>!x. P x) = (\<exists>!x. p \<bullet> P (- p \<bullet> x))" |
|
76 |
unfolding Ex1_def ex_eqvt2 conj_eqvt all_eqvt2 imp_eqvt eq_eqvt |
|
77 |
by simp |
|
78 |
||
79 |
lemma the_eqvt: |
|
80 |
assumes unique: "\<exists>!x. P x" |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
81 |
shows "(p \<bullet> (THE x. P x)) = (THE x. p \<bullet> P (- p \<bullet> x))" |
1062 | 82 |
apply(rule the1_equality [symmetric]) |
83 |
apply(simp add: ex1_eqvt2[symmetric]) |
|
84 |
apply(simp add: permute_bool_def unique) |
|
85 |
apply(simp add: permute_bool_def) |
|
86 |
apply(rule theI'[OF unique]) |
|
87 |
done |
|
88 |
||
89 |
section {* Set Operations *} |
|
90 |
||
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
91 |
lemma mem_permute_iff: |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
92 |
shows "(p \<bullet> x) \<in> (p \<bullet> X) \<longleftrightarrow> x \<in> X" |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
93 |
unfolding mem_def permute_fun_def permute_bool_def |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
94 |
by simp |
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
95 |
|
1062 | 96 |
lemma mem_eqvt: |
97 |
shows "p \<bullet> (x \<in> A) \<longleftrightarrow> (p \<bullet> x) \<in> (p \<bullet> A)" |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
98 |
unfolding mem_permute_iff permute_bool_def by simp |
1062 | 99 |
|
100 |
lemma not_mem_eqvt: |
|
101 |
shows "p \<bullet> (x \<notin> A) \<longleftrightarrow> (p \<bullet> x) \<notin> (p \<bullet> A)" |
|
102 |
unfolding mem_def permute_fun_def by (simp add: Not_eqvt) |
|
103 |
||
104 |
lemma Collect_eqvt: |
|
105 |
shows "p \<bullet> {x. P x} = {x. (p \<bullet> P) x}" |
|
106 |
unfolding Collect_def permute_fun_def .. |
|
107 |
||
108 |
lemma Collect_eqvt2: |
|
109 |
shows "p \<bullet> {x. P x} = {x. p \<bullet> (P (-p \<bullet> x))}" |
|
110 |
unfolding Collect_def permute_fun_def .. |
|
111 |
||
112 |
lemma empty_eqvt: |
|
113 |
shows "p \<bullet> {} = {}" |
|
114 |
unfolding empty_def Collect_eqvt2 False_eqvt .. |
|
115 |
||
116 |
lemma supp_set_empty: |
|
117 |
shows "supp {} = {}" |
|
118 |
by (simp add: supp_def empty_eqvt) |
|
119 |
||
120 |
lemma fresh_set_empty: |
|
121 |
shows "a \<sharp> {}" |
|
122 |
by (simp add: fresh_def supp_set_empty) |
|
123 |
||
124 |
lemma UNIV_eqvt: |
|
125 |
shows "p \<bullet> UNIV = UNIV" |
|
126 |
unfolding UNIV_def Collect_eqvt2 True_eqvt .. |
|
127 |
||
128 |
lemma union_eqvt: |
|
129 |
shows "p \<bullet> (A \<union> B) = (p \<bullet> A) \<union> (p \<bullet> B)" |
|
130 |
unfolding Un_def Collect_eqvt2 disj_eqvt mem_eqvt by simp |
|
131 |
||
132 |
lemma inter_eqvt: |
|
133 |
shows "p \<bullet> (A \<inter> B) = (p \<bullet> A) \<inter> (p \<bullet> B)" |
|
134 |
unfolding Int_def Collect_eqvt2 conj_eqvt mem_eqvt by simp |
|
135 |
||
136 |
lemma Diff_eqvt: |
|
137 |
fixes A B :: "'a::pt set" |
|
138 |
shows "p \<bullet> (A - B) = p \<bullet> A - p \<bullet> B" |
|
139 |
unfolding set_diff_eq Collect_eqvt2 conj_eqvt Not_eqvt mem_eqvt by simp |
|
140 |
||
141 |
lemma Compl_eqvt: |
|
142 |
fixes A :: "'a::pt set" |
|
143 |
shows "p \<bullet> (- A) = - (p \<bullet> A)" |
|
144 |
unfolding Compl_eq_Diff_UNIV Diff_eqvt UNIV_eqvt .. |
|
145 |
||
146 |
lemma insert_eqvt: |
|
147 |
shows "p \<bullet> (insert x A) = insert (p \<bullet> x) (p \<bullet> A)" |
|
148 |
unfolding permute_set_eq_image image_insert .. |
|
149 |
||
150 |
lemma vimage_eqvt: |
|
151 |
shows "p \<bullet> (f -` A) = (p \<bullet> f) -` (p \<bullet> A)" |
|
152 |
unfolding vimage_def permute_fun_def [where f=f] |
|
153 |
unfolding Collect_eqvt2 mem_eqvt .. |
|
154 |
||
155 |
lemma image_eqvt: |
|
156 |
shows "p \<bullet> (f ` A) = (p \<bullet> f) ` (p \<bullet> A)" |
|
157 |
unfolding permute_set_eq_image |
|
158 |
unfolding permute_fun_def [where f=f] |
|
159 |
by (simp add: image_image) |
|
160 |
||
161 |
lemma finite_permute_iff: |
|
162 |
shows "finite (p \<bullet> A) \<longleftrightarrow> finite A" |
|
163 |
unfolding permute_set_eq_vimage |
|
164 |
using bij_permute by (rule finite_vimage_iff) |
|
165 |
||
166 |
lemma finite_eqvt: |
|
167 |
shows "p \<bullet> finite A = finite (p \<bullet> A)" |
|
168 |
unfolding finite_permute_iff permute_bool_def .. |
|
169 |
||
170 |
||
171 |
section {* List Operations *} |
|
172 |
||
173 |
lemma append_eqvt: |
|
174 |
shows "p \<bullet> (xs @ ys) = (p \<bullet> xs) @ (p \<bullet> ys)" |
|
175 |
by (induct xs) auto |
|
176 |
||
177 |
lemma supp_append: |
|
178 |
shows "supp (xs @ ys) = supp xs \<union> supp ys" |
|
179 |
by (induct xs) (auto simp add: supp_Nil supp_Cons) |
|
180 |
||
181 |
lemma fresh_append: |
|
182 |
shows "a \<sharp> (xs @ ys) \<longleftrightarrow> a \<sharp> xs \<and> a \<sharp> ys" |
|
183 |
by (induct xs) (simp_all add: fresh_Nil fresh_Cons) |
|
184 |
||
185 |
lemma rev_eqvt: |
|
186 |
shows "p \<bullet> (rev xs) = rev (p \<bullet> xs)" |
|
187 |
by (induct xs) (simp_all add: append_eqvt) |
|
188 |
||
189 |
lemma supp_rev: |
|
190 |
shows "supp (rev xs) = supp xs" |
|
191 |
by (induct xs) (auto simp add: supp_append supp_Cons supp_Nil) |
|
192 |
||
193 |
lemma fresh_rev: |
|
194 |
shows "a \<sharp> rev xs \<longleftrightarrow> a \<sharp> xs" |
|
195 |
by (induct xs) (auto simp add: fresh_append fresh_Cons fresh_Nil) |
|
196 |
||
197 |
lemma set_eqvt: |
|
198 |
shows "p \<bullet> (set xs) = set (p \<bullet> xs)" |
|
199 |
by (induct xs) (simp_all add: empty_eqvt insert_eqvt) |
|
200 |
||
201 |
(* needs finite support premise |
|
202 |
lemma supp_set: |
|
203 |
fixes x :: "'a::pt" |
|
204 |
shows "supp (set xs) = supp xs" |
|
205 |
*) |
|
206 |
||
1815
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
207 |
lemma map_eqvt: |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
208 |
shows "p \<bullet> (map f xs) = map (p \<bullet> f) (p \<bullet> xs)" |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
209 |
by (induct xs) (simp_all, simp only: permute_fun_app_eq) |
1062 | 210 |
|
211 |
section {* Product Operations *} |
|
212 |
||
213 |
lemma fst_eqvt: |
|
214 |
"p \<bullet> (fst x) = fst (p \<bullet> x)" |
|
215 |
by (cases x) simp |
|
216 |
||
217 |
lemma snd_eqvt: |
|
218 |
"p \<bullet> (snd x) = snd (p \<bullet> x)" |
|
219 |
by (cases x) simp |
|
220 |
||
221 |
section {* Units *} |
|
222 |
||
223 |
lemma supp_unit: |
|
224 |
shows "supp () = {}" |
|
225 |
by (simp add: supp_def) |
|
226 |
||
227 |
lemma fresh_unit: |
|
228 |
shows "a \<sharp> ()" |
|
229 |
by (simp add: fresh_def supp_unit) |
|
230 |
||
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
231 |
lemma permute_eqvt_raw: |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
232 |
shows "p \<bullet> permute = permute" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
233 |
apply(simp add: expand_fun_eq permute_fun_def) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
234 |
apply(subst permute_eqvt) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
235 |
apply(simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
236 |
done |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
237 |
|
1062 | 238 |
section {* Equivariance automation *} |
239 |
||
240 |
text {* Setup of the theorem attributes @{text eqvt} and @{text eqvt_force} *} |
|
241 |
||
242 |
use "nominal_thmdecls.ML" |
|
243 |
setup "Nominal_ThmDecls.setup" |
|
244 |
||
245 |
lemmas [eqvt] = |
|
246 |
(* connectives *) |
|
247 |
eq_eqvt if_eqvt imp_eqvt disj_eqvt conj_eqvt Not_eqvt |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
248 |
True_eqvt False_eqvt ex_eqvt all_eqvt ex1_eqvt |
1062 | 249 |
imp_eqvt [folded induct_implies_def] |
250 |
||
251 |
(* nominal *) |
|
1326 | 252 |
supp_eqvt fresh_eqvt |
1062 | 253 |
|
254 |
(* datatypes *) |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
255 |
permute_prod.simps append_eqvt rev_eqvt set_eqvt |
1815
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
256 |
map_eqvt fst_eqvt snd_eqvt Pair_eqvt permute_list.simps |
1062 | 257 |
|
258 |
(* sets *) |
|
1087
bb7f4457091a
moved some lemmas to Nominal; updated all files
Christian Urban <urbanc@in.tum.de>
parents:
1079
diff
changeset
|
259 |
empty_eqvt UNIV_eqvt union_eqvt inter_eqvt mem_eqvt |
1315
43d6e3730353
Add image_eqvt and atom_eqvt to eqvt bases.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1258
diff
changeset
|
260 |
Diff_eqvt Compl_eqvt insert_eqvt Collect_eqvt image_eqvt |
43d6e3730353
Add image_eqvt and atom_eqvt to eqvt bases.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1258
diff
changeset
|
261 |
|
1331
0f329449e304
Fix eqvt for multiple quantifiers.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1326
diff
changeset
|
262 |
atom_eqvt add_perm_eqvt |
1062 | 263 |
|
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
264 |
lemmas [eqvt_raw] = |
1811
ae176476b525
implemented in thmdecls the case where eqvt-lemmas are of the form _ ==> _
Christian Urban <urbanc@in.tum.de>
parents:
1810
diff
changeset
|
265 |
permute_eqvt_raw[THEN eq_reflection] (* the normal version of this lemma loops *) |
1062 | 266 |
|
267 |
text {* helper lemmas for the eqvt_tac *} |
|
268 |
||
269 |
definition |
|
270 |
"unpermute p = permute (- p)" |
|
271 |
||
272 |
lemma eqvt_apply: |
|
273 |
fixes f :: "'a::pt \<Rightarrow> 'b::pt" |
|
274 |
and x :: "'a::pt" |
|
275 |
shows "p \<bullet> (f x) \<equiv> (p \<bullet> f) (p \<bullet> x)" |
|
276 |
unfolding permute_fun_def by simp |
|
277 |
||
278 |
lemma eqvt_lambda: |
|
279 |
fixes f :: "'a::pt \<Rightarrow> 'b::pt" |
|
280 |
shows "p \<bullet> (\<lambda>x. f x) \<equiv> (\<lambda>x. p \<bullet> (f (unpermute p x)))" |
|
281 |
unfolding permute_fun_def unpermute_def by simp |
|
282 |
||
283 |
lemma eqvt_bound: |
|
284 |
shows "p \<bullet> unpermute p x \<equiv> x" |
|
285 |
unfolding unpermute_def by simp |
|
286 |
||
287 |
use "nominal_permeq.ML" |
|
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
288 |
setup Nominal_Permeq.setup |
1062 | 289 |
|
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
290 |
method_setup perm_simp = |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
291 |
{* Attrib.thms >> |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
292 |
(fn thms => fn ctxt => SIMPLE_METHOD (HEADGOAL (Nominal_Permeq.eqvt_tac ctxt thms ["The"]))) *} |
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
293 |
{* pushes permutations inside *} |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
294 |
|
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
295 |
method_setup perm_strict_simp = |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
296 |
{* Attrib.thms >> |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
297 |
(fn thms => fn ctxt => SIMPLE_METHOD (HEADGOAL (Nominal_Permeq.eqvt_strict_tac ctxt thms ["The"]))) *} |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
298 |
{* pushes permutations inside, raises an error if it cannot solve all permutations *} |
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
299 |
|
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
300 |
declare [[trace_eqvt = true]] |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
301 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
302 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
303 |
fixes B::"'a::pt" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
304 |
shows "p \<bullet> (B = C)" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
305 |
apply(perm_simp) |
1062 | 306 |
oops |
307 |
||
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
308 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
309 |
fixes B::"bool" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
310 |
shows "p \<bullet> (B = C)" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
311 |
apply(perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
312 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
313 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
314 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
315 |
fixes B::"bool" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
316 |
shows "p \<bullet> (A \<longrightarrow> B = C)" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
317 |
apply (perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
318 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
319 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
320 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
321 |
shows "p \<bullet> (\<lambda>(x::'a::pt). A \<longrightarrow> (B::'a \<Rightarrow> bool) x = C) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
322 |
apply(perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
323 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
324 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
325 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
326 |
shows "p \<bullet> (\<lambda>B::bool. A \<longrightarrow> (B = C)) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
327 |
apply (perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
328 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
329 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
330 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
331 |
shows "p \<bullet> (\<lambda>x y. \<exists>z. x = z \<and> x = y \<longrightarrow> z \<noteq> x) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
332 |
apply (perm_simp) |
1062 | 333 |
oops |
334 |
||
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
335 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
336 |
shows "p \<bullet> (\<lambda>f x. f (g (f x))) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
337 |
apply (perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
338 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
339 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
340 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
341 |
fixes p q::"perm" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
342 |
and x::"'a::pt" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
343 |
shows "p \<bullet> (q \<bullet> x) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
344 |
apply(perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
345 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
346 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
347 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
348 |
fixes p q r::"perm" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
349 |
and x::"'a::pt" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
350 |
shows "p \<bullet> (q \<bullet> r \<bullet> x) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
351 |
apply(perm_simp) |
1062 | 352 |
oops |
353 |
||
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
354 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
355 |
fixes p r::"perm" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
356 |
shows "p \<bullet> (\<lambda>q::perm. q \<bullet> (r \<bullet> x)) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
357 |
apply (perm_simp) |
1062 | 358 |
oops |
359 |
||
1800
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
360 |
lemma |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
361 |
fixes C D::"bool" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
362 |
shows "B (p \<bullet> (C = D))" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
363 |
apply(perm_simp) |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
364 |
oops |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
365 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
366 |
declare [[trace_eqvt = false]] |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
367 |
|
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
368 |
text {* Problem: there is no raw eqvt-rule for The *} |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
369 |
lemma "p \<bullet> (THE x. P x) = foo" |
78fdc6b36a1c
changed the eqvt-tac to move only outermost permutations inside; added tracing infrastructure for the eqvt-tac
Christian Urban <urbanc@in.tum.de>
parents:
1774
diff
changeset
|
370 |
apply(perm_simp) |
1801
6d2a39db3862
added more robust tracing infrastructure; a strict version of the eqvt_tac raises an error if not all permutations cannot be analysed
Christian Urban <urbanc@in.tum.de>
parents:
1800
diff
changeset
|
371 |
(* apply(perm_strict_simp) *) |
1062 | 372 |
oops |
373 |
||
1815
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
374 |
atom_decl var |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
375 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
376 |
ML {* |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
377 |
val inductive_atomize = @{thms induct_atomize}; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
378 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
379 |
val atomize_conv = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
380 |
MetaSimplifier.rewrite_cterm (true, false, false) (K (K NONE)) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
381 |
(HOL_basic_ss addsimps inductive_atomize); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
382 |
val atomize_intr = Conv.fconv_rule (Conv.prems_conv ~1 atomize_conv); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
383 |
fun atomize_induct ctxt = Conv.fconv_rule (Conv.prems_conv ~1 |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
384 |
(Conv.params_conv ~1 (K (Conv.prems_conv ~1 atomize_conv)) ctxt)); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
385 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
386 |
fun map_term f t u = (case f t u of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
387 |
NONE => map_term' f t u | x => x) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
388 |
and map_term' f (t $ u) (t' $ u') = (case (map_term f t t', map_term f u u') of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
389 |
(NONE, NONE) => NONE |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
390 |
| (SOME t'', NONE) => SOME (t'' $ u) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
391 |
| (NONE, SOME u'') => SOME (t $ u'') |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
392 |
| (SOME t'', SOME u'') => SOME (t'' $ u'')) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
393 |
| map_term' f (Abs (s, T, t)) (Abs (s', T', t')) = (case map_term f t t' of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
394 |
NONE => NONE |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
395 |
| SOME t'' => SOME (Abs (s, T, t''))) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
396 |
| map_term' _ _ _ = NONE; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
397 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
398 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
399 |
fun map_thm ctxt f tac monos opt th = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
400 |
let |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
401 |
val prop = prop_of th; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
402 |
fun prove t = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
403 |
Goal.prove ctxt [] [] t (fn _ => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
404 |
EVERY [cut_facts_tac [th] 1, etac rev_mp 1, |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
405 |
REPEAT_DETERM (FIRSTGOAL (resolve_tac monos)), |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
406 |
REPEAT_DETERM (rtac impI 1 THEN (atac 1 ORELSE tac))]) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
407 |
in Option.map prove (map_term f prop (the_default prop opt)) end; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
408 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
409 |
fun split_conj f names (Const ("op &", _) $ p $ q) _ = (case head_of p of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
410 |
Const (name, _) => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
411 |
if name mem names then SOME (f p q) else NONE |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
412 |
| _ => NONE) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
413 |
| split_conj _ _ _ _ = NONE; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
414 |
*} |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
415 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
416 |
ML {* |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
417 |
val perm_bool = @{thm "permute_bool_def"}; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
418 |
val perm_boolI = @{thm "permute_boolI"}; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
419 |
val (_, [perm_boolI_pi, _]) = Drule.strip_comb (snd (Thm.dest_comb |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
420 |
(Drule.strip_imp_concl (cprop_of perm_boolI)))); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
421 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
422 |
fun mk_perm_bool pi th = th RS Drule.cterm_instantiate |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
423 |
[(perm_boolI_pi, pi)] perm_boolI; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
424 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
425 |
*} |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
426 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
427 |
ML {* |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
428 |
fun transp ([] :: _) = [] |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
429 |
| transp xs = map hd xs :: transp (map tl xs); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
430 |
|
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
431 |
fun prove_eqvt s xatoms ctxt = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
432 |
let |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
433 |
val thy = ProofContext.theory_of ctxt; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
434 |
val ({names, ...}, {raw_induct, intrs, elims, ...}) = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
435 |
Inductive.the_inductive ctxt (Sign.intern_const thy s); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
436 |
val raw_induct = atomize_induct ctxt raw_induct; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
437 |
val elims = map (atomize_induct ctxt) elims; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
438 |
val intrs = map atomize_intr intrs; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
439 |
val monos = Inductive.get_monos ctxt; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
440 |
val intrs' = Inductive.unpartition_rules intrs |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
441 |
(map (fn (((s, ths), (_, k)), th) => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
442 |
(s, ths ~~ Inductive.infer_intro_vars th k ths)) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
443 |
(Inductive.partition_rules raw_induct intrs ~~ |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
444 |
Inductive.arities_of raw_induct ~~ elims)); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
445 |
val k = length (Inductive.params_of raw_induct); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
446 |
val atoms' = ["var"]; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
447 |
val atoms = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
448 |
if null xatoms then atoms' else |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
449 |
let val atoms = map (Sign.intern_type thy) xatoms |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
450 |
in |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
451 |
(case duplicates op = atoms of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
452 |
[] => () |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
453 |
| xs => error ("Duplicate atoms: " ^ commas xs); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
454 |
case subtract (op =) atoms' atoms of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
455 |
[] => () |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
456 |
| xs => error ("No such atoms: " ^ commas xs); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
457 |
atoms) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
458 |
end; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
459 |
val perm_pi_simp = PureThy.get_thms thy "perm_pi_simp"; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
460 |
val eqvt_ss = Simplifier.global_context thy HOL_basic_ss addsimps |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
461 |
(Nominal_ThmDecls.get_eqvts_thms ctxt @ perm_pi_simp); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
462 |
val (([t], [pi]), ctxt') = ctxt |> |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
463 |
Variable.import_terms false [concl_of raw_induct] ||>> |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
464 |
Variable.variant_fixes ["pi"]; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
465 |
val ps = map (fst o HOLogic.dest_imp) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
466 |
(HOLogic.dest_conj (HOLogic.dest_Trueprop t)); |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
467 |
fun eqvt_tac ctxt'' pi (intr, vs) st = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
468 |
let |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
469 |
fun eqvt_err s = |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
470 |
let val ([t], ctxt''') = Variable.import_terms true [prop_of intr] ctxt |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
471 |
in error ("Could not prove equivariance for introduction rule\n" ^ |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
472 |
Syntax.string_of_term ctxt''' t ^ "\n" ^ s) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
473 |
end; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
474 |
val res = SUBPROOF (fn {prems, params, ...} => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
475 |
let |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
476 |
val prems' = map (fn th => the_default th (map_thm ctxt' |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
477 |
(split_conj (K I) names) (etac conjunct2 1) monos NONE th)) prems; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
478 |
val prems'' = map (fn th => Simplifier.simplify eqvt_ss |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
479 |
(mk_perm_bool (cterm_of thy pi) th)) prems'; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
480 |
val intr' = intr |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
481 |
in (rtac intr' THEN_ALL_NEW (TRY o resolve_tac prems'')) 1 |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
482 |
end) ctxt' 1 st |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
483 |
in |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
484 |
case (Seq.pull res handle THM (s, _, _) => eqvt_err s) of |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
485 |
NONE => eqvt_err ("Rule does not match goal\n" ^ |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
486 |
Syntax.string_of_term ctxt'' (hd (prems_of st))) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
487 |
| SOME (th, _) => Seq.single th |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
488 |
end; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
489 |
val thss = map (fn atom => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
490 |
let val pi' = Free (pi, @{typ perm}) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
491 |
in map (fn th => zero_var_indexes (th RS mp)) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
492 |
(Datatype_Aux.split_conj_thm (Goal.prove ctxt' [] [] |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
493 |
(HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj (map (fn p => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
494 |
let |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
495 |
val (h, ts) = strip_comb p; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
496 |
val (ts1, ts2) = chop k ts |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
497 |
in |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
498 |
HOLogic.mk_imp (p, list_comb (h, ts1)) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
499 |
end) ps))) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
500 |
(fn {context, ...} => EVERY (rtac raw_induct 1 :: map (fn intr_vs => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
501 |
full_simp_tac eqvt_ss 1 THEN |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
502 |
eqvt_tac context pi' intr_vs) intrs')) |> |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
503 |
singleton (ProofContext.export ctxt' ctxt))) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
504 |
end) atoms |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
505 |
in |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
506 |
ctxt |> |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
507 |
Local_Theory.notes (map (fn (name, ths) => |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
508 |
((Binding.qualified_name (Long_Name.qualify (Long_Name.base_name name) "eqvt"), |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
509 |
[Attrib.internal (K Nominal_ThmDecls.eqvt_add)]), [(ths, [])])) |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
510 |
(names ~~ transp thss)) |> snd |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
511 |
end; |
4135198bbb8a
moved equivariance of map into Nominal2_Eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
1811
diff
changeset
|
512 |
*} |
1062 | 513 |
|
1315
43d6e3730353
Add image_eqvt and atom_eqvt to eqvt bases.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1258
diff
changeset
|
514 |
end |