author | Christian Urban <urbanc@in.tum.de> |
Wed, 02 Dec 2009 16:12:41 +0100 | |
changeset 484 | 123aeffbd65e |
parent 482 | 767baada01dc |
child 486 | 7c26b31d2371 |
permissions | -rw-r--r-- |
0 | 1 |
theory QuotMain |
6 | 2 |
imports QuotScript QuotList Prove |
264
d0581fbc096c
split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
263
diff
changeset
|
3 |
uses ("quotient_info.ML") |
d0581fbc096c
split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
263
diff
changeset
|
4 |
("quotient.ML") |
277
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
5 |
("quotient_def.ML") |
0 | 6 |
begin |
7 |
||
471 | 8 |
ML {* |
9 |
let |
|
10 |
val parser = Args.context -- Scan.lift Args.name_source |
|
11 |
fun term_pat (ctxt, str) = |
|
12 |
str |> ProofContext.read_term_pattern ctxt |
|
13 |
|> ML_Syntax.print_term |
|
14 |
|> ML_Syntax.atomic |
|
15 |
in |
|
16 |
ML_Antiquote.inline "term_pat" (parser >> term_pat) |
|
17 |
end |
|
18 |
*} |
|
19 |
||
20 |
ML {* |
|
21 |
fun make_inst lhs t = |
|
22 |
let |
|
23 |
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs; |
|
24 |
val _ $ (Abs (_, _, g)) = t; |
|
484 | 25 |
|
26 |
fun mk_abs i t = |
|
471 | 27 |
if incr_boundvars i u aconv t then Bound i |
28 |
else (case t of |
|
29 |
t1 $ t2 => mk_abs i t1 $ mk_abs i t2 |
|
30 |
| Abs (s, T, t') => Abs (s, T, mk_abs (i + 1) t') |
|
31 |
| Bound j => if i = j then error "make_inst" else t |
|
32 |
| _ => t); |
|
484 | 33 |
|
471 | 34 |
in (f, Abs ("x", T, mk_abs 0 g)) end; |
35 |
*} |
|
36 |
||
37 |
ML {* |
|
38 |
val trm1 = @{term_pat "(P::(nat\<Rightarrow>bool)\<Rightarrow>bool) (\<lambda>(x::nat). (?f ((g::nat\<Rightarrow>nat) x)))"}; |
|
39 |
val trm2 = @{term_pat "(P::(nat\<Rightarrow>bool)\<Rightarrow>bool) (\<lambda>(x::nat). (h (g x) ((g::nat\<Rightarrow>nat) x)))"} |
|
40 |
*} |
|
41 |
||
42 |
ML {* |
|
43 |
fun test trm = |
|
44 |
case trm of |
|
45 |
(_ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u))) => (1,f) |
|
46 |
| (_ $ (Abs (_, _, (f as (Var (_, _)) $ u)))) => (2,f) |
|
47 |
| (_ $ (Abs (_, _, (f $ u)))) => (3,f) |
|
48 |
*} |
|
49 |
||
50 |
ML {* test trm1 *} |
|
51 |
||
52 |
ML {* |
|
53 |
make_inst trm1 trm2 |
|
54 |
|> pairself (Syntax.string_of_term @{context}) |
|
55 |
|> pairself writeln |
|
56 |
*} |
|
57 |
||
58 |
||
59 |
||
60 |
||
0 | 61 |
locale QUOT_TYPE = |
62 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
63 |
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b" |
|
64 |
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)" |
|
65 |
assumes equiv: "EQUIV R" |
|
66 |
and rep_prop: "\<And>y. \<exists>x. Rep y = R x" |
|
67 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
|
68 |
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)" |
|
69 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
|
15 | 70 |
begin |
0 | 71 |
|
72 |
definition |
|
200
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
73 |
ABS::"'a \<Rightarrow> 'b" |
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
74 |
where |
0 | 75 |
"ABS x \<equiv> Abs (R x)" |
76 |
||
77 |
definition |
|
200
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
78 |
REP::"'b \<Rightarrow> 'a" |
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
79 |
where |
0 | 80 |
"REP a = Eps (Rep a)" |
81 |
||
15 | 82 |
lemma lem9: |
0 | 83 |
shows "R (Eps (R x)) = R x" |
84 |
proof - |
|
85 |
have a: "R x x" using equiv by (simp add: EQUIV_REFL_SYM_TRANS REFL_def) |
|
86 |
then have "R x (Eps (R x))" by (rule someI) |
|
15 | 87 |
then show "R (Eps (R x)) = R x" |
0 | 88 |
using equiv unfolding EQUIV_def by simp |
89 |
qed |
|
90 |
||
91 |
theorem thm10: |
|
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
92 |
shows "ABS (REP a) \<equiv> a" |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
93 |
apply (rule eq_reflection) |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
94 |
unfolding ABS_def REP_def |
0 | 95 |
proof - |
15 | 96 |
from rep_prop |
0 | 97 |
obtain x where eq: "Rep a = R x" by auto |
98 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
|
99 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
|
100 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
|
101 |
also have "\<dots> = a" using rep_inverse by simp |
|
102 |
finally |
|
103 |
show "Abs (R (Eps (Rep a))) = a" by simp |
|
104 |
qed |
|
105 |
||
15 | 106 |
lemma REP_refl: |
0 | 107 |
shows "R (REP a) (REP a)" |
108 |
unfolding REP_def |
|
109 |
by (simp add: equiv[simplified EQUIV_def]) |
|
110 |
||
111 |
lemma lem7: |
|
22 | 112 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
0 | 113 |
apply(rule iffI) |
114 |
apply(simp) |
|
115 |
apply(drule rep_inject[THEN iffD2]) |
|
116 |
apply(simp add: abs_inverse) |
|
117 |
done |
|
15 | 118 |
|
0 | 119 |
theorem thm11: |
120 |
shows "R r r' = (ABS r = ABS r')" |
|
121 |
unfolding ABS_def |
|
122 |
by (simp only: equiv[simplified EQUIV_def] lem7) |
|
123 |
||
4 | 124 |
|
2 | 125 |
lemma REP_ABS_rsp: |
4 | 126 |
shows "R f (REP (ABS g)) = R f g" |
127 |
and "R (REP (ABS g)) f = R g f" |
|
23 | 128 |
by (simp_all add: thm10 thm11) |
4 | 129 |
|
0 | 130 |
lemma QUOTIENT: |
131 |
"QUOTIENT R ABS REP" |
|
132 |
apply(unfold QUOTIENT_def) |
|
133 |
apply(simp add: thm10) |
|
134 |
apply(simp add: REP_refl) |
|
135 |
apply(subst thm11[symmetric]) |
|
136 |
apply(simp add: equiv[simplified EQUIV_def]) |
|
137 |
done |
|
138 |
||
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
139 |
lemma R_trans: |
49 | 140 |
assumes ab: "R a b" |
141 |
and bc: "R b c" |
|
22 | 142 |
shows "R a c" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
143 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
144 |
have tr: "TRANS R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
145 |
moreover have ab: "R a b" by fact |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
146 |
moreover have bc: "R b c" by fact |
22 | 147 |
ultimately show "R a c" unfolding TRANS_def by blast |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
148 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
149 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
150 |
lemma R_sym: |
49 | 151 |
assumes ab: "R a b" |
22 | 152 |
shows "R b a" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
153 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
154 |
have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
22 | 155 |
then show "R b a" using ab unfolding SYM_def by blast |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
156 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
157 |
|
49 | 158 |
lemma R_trans2: |
159 |
assumes ac: "R a c" |
|
22 | 160 |
and bd: "R b d" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
161 |
shows "R a b = R c d" |
200
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
162 |
using ac bd |
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
163 |
by (blast intro: R_trans R_sym) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
164 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
165 |
lemma REPS_same: |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
166 |
shows "R (REP a) (REP b) \<equiv> (a = b)" |
38 | 167 |
proof - |
168 |
have "R (REP a) (REP b) = (a = b)" |
|
169 |
proof |
|
170 |
assume as: "R (REP a) (REP b)" |
|
171 |
from rep_prop |
|
172 |
obtain x y |
|
173 |
where eqs: "Rep a = R x" "Rep b = R y" by blast |
|
174 |
from eqs have "R (Eps (R x)) (Eps (R y))" using as unfolding REP_def by simp |
|
175 |
then have "R x (Eps (R y))" using lem9 by simp |
|
176 |
then have "R (Eps (R y)) x" using R_sym by blast |
|
177 |
then have "R y x" using lem9 by simp |
|
178 |
then have "R x y" using R_sym by blast |
|
179 |
then have "ABS x = ABS y" using thm11 by simp |
|
180 |
then have "Abs (Rep a) = Abs (Rep b)" using eqs unfolding ABS_def by simp |
|
181 |
then show "a = b" using rep_inverse by simp |
|
182 |
next |
|
183 |
assume ab: "a = b" |
|
184 |
have "REFL R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
|
185 |
then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto |
|
186 |
qed |
|
187 |
then show "R (REP a) (REP b) \<equiv> (a = b)" by simp |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
188 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
189 |
|
0 | 190 |
end |
191 |
||
458 | 192 |
(* EQUALS_RSP is stronger *) |
419
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
193 |
lemma equiv_trans2: |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
194 |
assumes e: "EQUIV R" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
195 |
and ac: "R a c" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
196 |
and bd: "R b d" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
197 |
shows "R a b = R c d" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
198 |
using ac bd e |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
199 |
unfolding EQUIV_REFL_SYM_TRANS TRANS_def SYM_def |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
200 |
by (blast) |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
201 |
|
0 | 202 |
section {* type definition for the quotient type *} |
203 |
||
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
204 |
(* the auxiliary data for the quotient types *) |
264
d0581fbc096c
split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
263
diff
changeset
|
205 |
use "quotient_info.ML" |
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
206 |
|
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
207 |
declare [[map list = (map, LIST_REL)]] |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
208 |
declare [[map * = (prod_fun, prod_rel)]] |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
209 |
declare [[map "fun" = (fun_map, FUN_REL)]] |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
210 |
|
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
211 |
ML {* maps_lookup @{theory} "List.list" *} |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
212 |
ML {* maps_lookup @{theory} "*" *} |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
213 |
ML {* maps_lookup @{theory} "fun" *} |
174
09048a951dca
moved the map_funs setup into QuotMain
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
214 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
215 |
|
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
216 |
(* definition of the quotient types *) |
277
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
217 |
(* FIXME: should be called quotient_typ.ML *) |
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
218 |
use "quotient.ML" |
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
219 |
|
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents:
267
diff
changeset
|
220 |
|
277
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
221 |
(* lifting of constants *) |
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
222 |
use "quotient_def.ML" |
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
223 |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
224 |
(* TODO: Consider defining it with an "if"; sth like: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
225 |
Babs p m = \<lambda>x. if x \<in> p then m x else undefined |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
226 |
*) |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
227 |
definition |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
228 |
Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
229 |
where |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
230 |
"(x \<in> p) \<Longrightarrow> (Babs p m x = m x)" |
310
fec6301a1989
added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents:
307
diff
changeset
|
231 |
|
139 | 232 |
section {* ATOMIZE *} |
233 |
||
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
234 |
lemma atomize_eqv[atomize]: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
235 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
139 | 236 |
proof |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
237 |
assume "A \<equiv> B" |
139 | 238 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
239 |
next |
|
240 |
assume *: "Trueprop A \<equiv> Trueprop B" |
|
241 |
have "A = B" |
|
242 |
proof (cases A) |
|
243 |
case True |
|
244 |
have "A" by fact |
|
245 |
then show "A = B" using * by simp |
|
246 |
next |
|
247 |
case False |
|
248 |
have "\<not>A" by fact |
|
249 |
then show "A = B" using * by auto |
|
250 |
qed |
|
251 |
then show "A \<equiv> B" by (rule eq_reflection) |
|
252 |
qed |
|
253 |
||
254 |
ML {* |
|
255 |
fun atomize_thm thm = |
|
256 |
let |
|
221 | 257 |
val thm' = Thm.freezeT (forall_intr_vars thm) |
139 | 258 |
val thm'' = ObjectLogic.atomize (cprop_of thm') |
259 |
in |
|
404 | 260 |
@{thm equal_elim_rule1} OF [thm'', thm'] |
139 | 261 |
end |
262 |
*} |
|
263 |
||
387 | 264 |
section {* infrastructure about id *} |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
265 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
266 |
lemma prod_fun_id: "prod_fun id id \<equiv> id" |
415
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
267 |
by (rule eq_reflection) (simp add: prod_fun_def) |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
268 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
269 |
lemma map_id: "map id \<equiv> id" |
415
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
270 |
apply (rule eq_reflection) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
271 |
apply (rule ext) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
272 |
apply (rule_tac list="x" in list.induct) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
273 |
apply (simp_all) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
274 |
done |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
275 |
|
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
276 |
lemmas id_simps = |
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
277 |
FUN_MAP_I[THEN eq_reflection] |
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
278 |
id_apply[THEN eq_reflection] |
415
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
279 |
id_def[THEN eq_reflection,symmetric] |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
280 |
prod_fun_id map_id |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
281 |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
282 |
ML {* |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
283 |
fun simp_ids thm = |
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
284 |
MetaSimplifier.rewrite_rule @{thms id_simps} thm |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
285 |
*} |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
286 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
287 |
section {* Debugging infrastructure for testing tactics *} |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
288 |
|
447
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
parents:
446
diff
changeset
|
289 |
ML {* |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
290 |
fun my_print_tac ctxt s i thm = |
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
291 |
let |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
292 |
val prem_str = nth (prems_of thm) (i - 1) |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
293 |
|> Syntax.string_of_term ctxt |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
294 |
handle Subscript => "no subgoal" |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
295 |
val _ = tracing (s ^ "\n" ^ prem_str) |
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
296 |
in |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
297 |
Seq.single thm |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
298 |
end *} |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
299 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
300 |
|
447
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
parents:
446
diff
changeset
|
301 |
ML {* |
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
parents:
446
diff
changeset
|
302 |
fun DT ctxt s tac i thm = |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
303 |
let |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
304 |
val before_goal = nth (prems_of thm) (i - 1) |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
305 |
|> Syntax.string_of_term ctxt |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
306 |
val before_msg = ["before: " ^ s, before_goal, "after: " ^ s] |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
307 |
|> cat_lines |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
308 |
in |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
309 |
EVERY [tac i, my_print_tac ctxt before_msg i] thm |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
310 |
end |
444 | 311 |
|
447
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
parents:
446
diff
changeset
|
312 |
fun NDT ctxt s tac thm = tac thm |
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
313 |
*} |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
314 |
|
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
parents:
452
diff
changeset
|
315 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
316 |
section {* Infrastructure for collecting theorems for starting the lifting *} |
267
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
264
diff
changeset
|
317 |
|
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
264
diff
changeset
|
318 |
ML {* |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
319 |
fun lookup_quot_data lthy qty = |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
320 |
let |
311
77fc6f3c0343
changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents:
310
diff
changeset
|
321 |
val qty_name = fst (dest_Type qty) |
314 | 322 |
val SOME quotdata = quotdata_lookup lthy qty_name |
311
77fc6f3c0343
changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents:
310
diff
changeset
|
323 |
(* cu: Changed the lookup\<dots>not sure whether this works *) |
303
991b0e53f9dc
More code cleaning and commenting
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
302
diff
changeset
|
324 |
(* TODO: Should no longer be needed *) |
257
68bd5c2a1b96
Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
255
diff
changeset
|
325 |
val rty = Logic.unvarifyT (#rtyp quotdata) |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
326 |
val rel = #rel quotdata |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
327 |
val rel_eqv = #equiv_thm quotdata |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
328 |
val rel_refl = @{thm EQUIV_REFL} OF [rel_eqv] |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
329 |
in |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
330 |
(rty, rel, rel_refl, rel_eqv) |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
331 |
end |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
332 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
333 |
|
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
334 |
ML {* |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
335 |
fun lookup_quot_thms lthy qty_name = |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
336 |
let |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
337 |
val thy = ProofContext.theory_of lthy; |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
338 |
val trans2 = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".R_trans2") |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
339 |
val reps_same = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".REPS_same") |
269 | 340 |
val absrep = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".thm10") |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
341 |
val quot = PureThy.get_thm thy ("QUOTIENT_" ^ qty_name) |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
342 |
in |
269 | 343 |
(trans2, reps_same, absrep, quot) |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
344 |
end |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
345 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
346 |
|
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
347 |
ML {* |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
348 |
fun lookup_quot_consts defs = |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
349 |
let |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
350 |
fun dest_term (a $ b) = (a, b); |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
351 |
val def_terms = map (snd o Logic.dest_equals o concl_of) defs; |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
352 |
in |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
353 |
map (fst o dest_Const o snd o dest_term) def_terms |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
354 |
end |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
355 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
356 |
|
402
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
357 |
section {* Regularization *} |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
358 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
359 |
(* |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
360 |
Regularizing an rtrm means: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
361 |
- quantifiers over a type that needs lifting are replaced by |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
362 |
bounded quantifiers, for example: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
363 |
\<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
364 |
|
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
365 |
the relation R is given by the rty and qty; |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
366 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
367 |
- abstractions over a type that needs lifting are replaced |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
368 |
by bounded abstractions: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
369 |
\<lambda>x. P \<Longrightarrow> Ball (Respects R) (\<lambda>x. P) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
370 |
|
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
371 |
- equalities over the type being lifted are replaced by |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
372 |
corresponding relations: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
373 |
A = B \<Longrightarrow> A \<approx> B |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
374 |
|
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
375 |
example with more complicated types of A, B: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
376 |
A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
377 |
*) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
378 |
|
404 | 379 |
ML {* |
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
380 |
(* builds the relation that is the argument of respects *) |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
381 |
fun mk_resp_arg lthy (rty, qty) = |
319 | 382 |
let |
383 |
val thy = ProofContext.theory_of lthy |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
384 |
in |
334 | 385 |
if rty = qty |
386 |
then HOLogic.eq_const rty |
|
387 |
else |
|
388 |
case (rty, qty) of |
|
389 |
(Type (s, tys), Type (s', tys')) => |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
390 |
if s = s' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
391 |
then let |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
392 |
val SOME map_info = maps_lookup thy s |
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
393 |
val args = map (mk_resp_arg lthy) (tys ~~ tys') |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
394 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
395 |
list_comb (Const (#relfun map_info, dummyT), args) |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
396 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
397 |
else let |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
398 |
val SOME qinfo = quotdata_lookup_thy thy s' |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
399 |
(* FIXME: check in this case that the rty and qty *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
400 |
(* FIXME: correspond to each other *) |
353
9a0e8ab42ee8
fixed the error by a temporary fix (the data of the eqivalence relation should be only its name)
Christian Urban <urbanc@in.tum.de>
parents:
351
diff
changeset
|
401 |
val (s, _) = dest_Const (#rel qinfo) |
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
402 |
(* FIXME: the relation should only be the string *) |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
403 |
(* FIXME: and the type needs to be calculated as below; *) |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
404 |
(* FIXME: maybe one should actually have a term *) |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
405 |
(* FIXME: and one needs to force it to have this type *) |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
406 |
in |
353
9a0e8ab42ee8
fixed the error by a temporary fix (the data of the eqivalence relation should be only its name)
Christian Urban <urbanc@in.tum.de>
parents:
351
diff
changeset
|
407 |
Const (s, rty --> rty --> @{typ bool}) |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
408 |
end |
334 | 409 |
| _ => HOLogic.eq_const dummyT |
351 | 410 |
(* FIXME: check that the types correspond to each other? *) |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
411 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
412 |
*} |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
413 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
414 |
ML {* |
467 | 415 |
val mk_babs = Const (@{const_name Babs}, dummyT) |
416 |
val mk_ball = Const (@{const_name Ball}, dummyT) |
|
417 |
val mk_bex = Const (@{const_name Bex}, dummyT) |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
418 |
val mk_resp = Const (@{const_name Respects}, dummyT) |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
419 |
*} |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
420 |
|
323 | 421 |
ML {* |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
422 |
(* - applies f to the subterm of an abstraction, *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
423 |
(* otherwise to the given term, *) |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
424 |
(* - used by regularize, therefore abstracted *) |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
425 |
(* variables do not have to be treated specially *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
426 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
427 |
fun apply_subt f trm1 trm2 = |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
428 |
case (trm1, trm2) of |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
429 |
(Abs (x, T, t), Abs (x', T', t')) => Abs (x, T, f t t') |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
430 |
| _ => f trm1 trm2 |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
431 |
|
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
432 |
(* the major type of All and Ex quantifiers *) |
334 | 433 |
fun qnt_typ ty = domain_type (domain_type ty) |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
434 |
*} |
319 | 435 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
436 |
ML {* |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
437 |
(* produces a regularized version of rtm *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
438 |
(* - the result is still not completely typed *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
439 |
(* - does not need any special treatment of *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
440 |
(* bound variables *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
441 |
|
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
442 |
fun regularize_trm lthy rtrm qtrm = |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
443 |
case (rtrm, qtrm) of |
325 | 444 |
(Abs (x, ty, t), Abs (x', ty', t')) => |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
445 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
446 |
val subtrm = regularize_trm lthy t t' |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
447 |
in |
325 | 448 |
if ty = ty' |
449 |
then Abs (x, ty, subtrm) |
|
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
325
diff
changeset
|
450 |
else mk_babs $ (mk_resp $ mk_resp_arg lthy (ty, ty')) $ subtrm |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
451 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
452 |
| (Const (@{const_name "All"}, ty) $ t, Const (@{const_name "All"}, ty') $ t') => |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
453 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
454 |
val subtrm = apply_subt (regularize_trm lthy) t t' |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
455 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
456 |
if ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
457 |
then Const (@{const_name "All"}, ty) $ subtrm |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
458 |
else mk_ball $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
459 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
460 |
| (Const (@{const_name "Ex"}, ty) $ t, Const (@{const_name "Ex"}, ty') $ t') => |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
461 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
462 |
val subtrm = apply_subt (regularize_trm lthy) t t' |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
463 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
464 |
if ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
465 |
then Const (@{const_name "Ex"}, ty) $ subtrm |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
466 |
else mk_bex $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
467 |
end |
351 | 468 |
(* FIXME: Should = only be replaced, when fully applied? *) |
469 |
(* Then there must be a 2nd argument *) |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
470 |
| (Const (@{const_name "op ="}, ty) $ t, Const (@{const_name "op ="}, ty') $ t') => |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
471 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
472 |
val subtrm = regularize_trm lthy t t' |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
473 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
474 |
if ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
475 |
then Const (@{const_name "op ="}, ty) $ subtrm |
349
f507f088de73
domain_type in regularizing equality
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
348
diff
changeset
|
476 |
else mk_resp_arg lthy (domain_type ty, domain_type ty') $ subtrm |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
477 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
478 |
| (t1 $ t2, t1' $ t2') => |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
479 |
(regularize_trm lthy t1 t1') $ (regularize_trm lthy t2 t2') |
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
parents:
452
diff
changeset
|
480 |
| (Free (x, ty), Free (x', ty')) => |
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
parents:
452
diff
changeset
|
481 |
(* this case cannot arrise as we start with two fully atomized terms *) |
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
parents:
452
diff
changeset
|
482 |
raise (LIFT_MATCH "regularize (frees)") |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
483 |
| (Bound i, Bound i') => |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
484 |
if i = i' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
485 |
then rtrm |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
486 |
else raise (LIFT_MATCH "regularize (bounds)") |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
487 |
| (Const (s, ty), Const (s', ty')) => |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
488 |
if s = s' andalso ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
489 |
then rtrm |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
490 |
else rtrm (* FIXME: check correspondence according to definitions *) |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
491 |
| (rt, qt) => |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
492 |
raise (LIFT_MATCH "regularize (default)") |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
493 |
*} |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
494 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
495 |
(* |
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
496 |
FIXME / TODO: needs to be adapted |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
497 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
498 |
To prove that the raw theorem implies the regularised one, |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
499 |
we try in order: |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
500 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
501 |
- Reflexivity of the relation |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
502 |
- Assumption |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
503 |
- Elimnating quantifiers on both sides of toplevel implication |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
504 |
- Simplifying implications on both sides of toplevel implication |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
505 |
- Ball (Respects ?E) ?P = All ?P |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
506 |
- (\<And>x. ?R x \<Longrightarrow> ?P x \<longrightarrow> ?Q x) \<Longrightarrow> All ?P \<longrightarrow> Ball ?R ?Q |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
507 |
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
508 |
*) |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
509 |
|
442
7beed9b75ea2
renamed LAMBDA_RES_TAC and WEAK_LAMBDA_RES_TAC to lower case names
Christian Urban <urbanc@in.tum.de>
parents:
440
diff
changeset
|
510 |
(* FIXME: they should be in in the new Isabelle *) |
404 | 511 |
lemma [mono]: |
512 |
"(\<And>x. P x \<longrightarrow> Q x) \<Longrightarrow> (Ex P) \<longrightarrow> (Ex Q)" |
|
400 | 513 |
by blast |
514 |
||
515 |
lemma [mono]: "P \<longrightarrow> Q \<Longrightarrow> \<not>Q \<longrightarrow> \<not>P" |
|
516 |
by auto |
|
517 |
||
518 |
(* FIXME: OPTION_EQUIV, PAIR_EQUIV, ... *) |
|
519 |
ML {* |
|
520 |
fun equiv_tac rel_eqvs = |
|
420
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
521 |
REPEAT_ALL_NEW (FIRST' |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
522 |
[resolve_tac rel_eqvs, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
523 |
rtac @{thm IDENTITY_EQUIV}, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
524 |
rtac @{thm LIST_EQUIV}]) |
400 | 525 |
*} |
526 |
||
527 |
ML {* |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
528 |
fun ball_reg_eqv_simproc rel_eqvs ss redex = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
529 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
530 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
531 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
532 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
533 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
534 |
(ogl as ((Const (@{const_name "Ball"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
535 |
((Const (@{const_name "Respects"}, _)) $ R) $ P1)) => |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
536 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
537 |
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
538 |
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
539 |
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
540 |
val thm = (@{thm eq_reflection} OF [@{thm ball_reg_eqv} OF [eqv]]); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
541 |
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thm)); *) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
542 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
543 |
SOME thm |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
544 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
545 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
546 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
547 |
| _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
548 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
549 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
550 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
551 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
552 |
fun bex_reg_eqv_simproc rel_eqvs ss redex = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
553 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
554 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
555 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
556 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
557 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
558 |
(ogl as ((Const (@{const_name "Bex"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
559 |
((Const (@{const_name "Respects"}, _)) $ R) $ P1)) => |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
560 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
561 |
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
562 |
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
563 |
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
564 |
val thm = (@{thm eq_reflection} OF [@{thm bex_reg_eqv} OF [eqv]]); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
565 |
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thm)); *) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
566 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
567 |
SOME thm |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
568 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
569 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
570 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
571 |
| _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
572 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
573 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
574 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
575 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
576 |
fun prep_trm thy (x, (T, t)) = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
577 |
(cterm_of thy (Var (x, T)), cterm_of thy t) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
578 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
579 |
fun prep_ty thy (x, (S, ty)) = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
580 |
(ctyp_of thy (TVar (x, S)), ctyp_of thy ty) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
581 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
582 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
583 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
584 |
fun matching_prs thy pat trm = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
585 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
586 |
val univ = Unify.matchers thy [(pat, trm)] |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
587 |
val SOME (env, _) = Seq.pull univ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
588 |
val tenv = Vartab.dest (Envir.term_env env) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
589 |
val tyenv = Vartab.dest (Envir.type_env env) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
590 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
591 |
(map (prep_ty thy) tyenv, map (prep_trm thy) tenv) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
592 |
end |
400 | 593 |
*} |
594 |
||
595 |
ML {* |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
596 |
fun ball_reg_eqv_range_simproc rel_eqvs ss redex = |
400 | 597 |
let |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
598 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
599 |
val thy = ProofContext.theory_of ctxt |
400 | 600 |
in |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
601 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
602 |
(ogl as ((Const (@{const_name "Ball"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
603 |
((Const (@{const_name "Respects"}, _)) $ ((Const (@{const_name "FUN_REL"}, _)) $ R1 $ R2)) $ _)) => |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
604 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
605 |
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R2; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
606 |
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
607 |
val _ = tracing (Syntax.string_of_term ctxt glc); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
608 |
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
609 |
val thm = (@{thm eq_reflection} OF [@{thm ball_reg_eqv_range} OF [eqv]]); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
610 |
val R1c = cterm_of thy R1; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
611 |
val thmi = Drule.instantiate' [] [SOME R1c] thm; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
612 |
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thmi)); *) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
613 |
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) ogl |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
614 |
val _ = tracing "AAA"; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
615 |
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
616 |
val _ = tracing (Syntax.string_of_term ctxt (prop_of thm2)); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
617 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
618 |
SOME thm2 |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
619 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
620 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
621 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
622 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
623 |
| _ => NONE |
400 | 624 |
end |
625 |
*} |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
626 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
627 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
628 |
fun bex_reg_eqv_range_simproc rel_eqvs ss redex = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
629 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
630 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
631 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
632 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
633 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
634 |
(ogl as ((Const (@{const_name "Bex"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
635 |
((Const (@{const_name "Respects"}, _)) $ ((Const (@{const_name "FUN_REL"}, _)) $ R1 $ R2)) $ _)) => |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
636 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
637 |
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R2; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
638 |
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
639 |
val _ = tracing (Syntax.string_of_term ctxt glc); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
640 |
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
641 |
val thm = (@{thm eq_reflection} OF [@{thm bex_reg_eqv_range} OF [eqv]]); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
642 |
val R1c = cterm_of thy R1; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
643 |
val thmi = Drule.instantiate' [] [SOME R1c] thm; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
644 |
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thmi)); *) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
645 |
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) ogl |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
646 |
val _ = tracing "AAA"; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
647 |
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
648 |
val _ = tracing (Syntax.string_of_term ctxt (prop_of thm2)); |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
649 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
650 |
SOME thm2 |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
651 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
652 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
653 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
654 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
655 |
| _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
656 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
657 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
658 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
659 |
lemma eq_imp_rel: "EQUIV R \<Longrightarrow> a = b \<longrightarrow> R a b" |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
660 |
by (simp add: EQUIV_REFL) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
661 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
662 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
663 |
fun regularize_tac ctxt rel_eqvs = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
664 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
665 |
val pat1 = [@{term "Ball (Respects R) P"}]; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
666 |
val pat2 = [@{term "Bex (Respects R) P"}]; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
667 |
val pat3 = [@{term "Ball (Respects (R1 ===> R2)) P"}]; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
668 |
val pat4 = [@{term "Bex (Respects (R1 ===> R2)) P"}]; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
669 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
670 |
val simproc1 = Simplifier.simproc_i thy "" pat1 (K (ball_reg_eqv_simproc rel_eqvs)) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
671 |
val simproc2 = Simplifier.simproc_i thy "" pat2 (K (bex_reg_eqv_simproc rel_eqvs)) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
672 |
val simproc3 = Simplifier.simproc_i thy "" pat3 (K (ball_reg_eqv_range_simproc rel_eqvs)) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
673 |
val simproc4 = Simplifier.simproc_i thy "" pat4 (K (bex_reg_eqv_range_simproc rel_eqvs)) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
674 |
val simp_ctxt = (Simplifier.context ctxt empty_ss) addsimprocs [simproc1, simproc2, simproc3, simproc4] |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
675 |
(* TODO: Make sure that there are no LIST_REL, PAIR_REL etc involved *) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
676 |
val eq_eqvs = map (fn x => @{thm eq_imp_rel} OF [x]) rel_eqvs |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
677 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
678 |
ObjectLogic.full_atomize_tac THEN' |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
679 |
simp_tac simp_ctxt THEN' |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
680 |
REPEAT_ALL_NEW (FIRST' [ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
681 |
rtac @{thm ball_reg_right}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
682 |
rtac @{thm bex_reg_left}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
683 |
resolve_tac (Inductive.get_monos ctxt), |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
684 |
rtac @{thm ball_all_comm}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
685 |
rtac @{thm bex_ex_comm}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
686 |
resolve_tac eq_eqvs, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
687 |
simp_tac simp_ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
688 |
]) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
689 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
690 |
*} |
390 | 691 |
|
692 |
section {* Injections of REP and ABSes *} |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
693 |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
694 |
(* |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
695 |
Injecting REPABS means: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
696 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
697 |
For abstractions: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
698 |
* If the type of the abstraction doesn't need lifting we recurse. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
699 |
* If it does we add RepAbs around the whole term and check if the |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
700 |
variable needs lifting. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
701 |
* If it doesn't then we recurse |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
702 |
* If it does we recurse and put 'RepAbs' around all occurences |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
703 |
of the variable in the obtained subterm. This in combination |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
704 |
with the RepAbs above will let us change the type of the |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
705 |
abstraction with rewriting. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
706 |
For applications: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
707 |
* If the term is 'Respects' applied to anything we leave it unchanged |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
708 |
* If the term needs lifting and the head is a constant that we know |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
709 |
how to lift, we put a RepAbs and recurse |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
710 |
* If the term needs lifting and the head is a free applied to subterms |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
711 |
(if it is not applied we treated it in Abs branch) then we |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
712 |
put RepAbs and recurse |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
713 |
* Otherwise just recurse. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
714 |
*) |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
715 |
|
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
716 |
ML {* |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
717 |
fun mk_repabs lthy (T, T') trm = |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
718 |
Quotient_Def.get_fun repF lthy (T, T') |
354
2eb6d527dfe4
addded a tactic, which sets up the three goals of the `algorithm'
Christian Urban <urbanc@in.tum.de>
parents:
353
diff
changeset
|
719 |
$ (Quotient_Def.get_fun absF lthy (T, T') $ trm) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
720 |
*} |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
721 |
|
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
722 |
ML {* |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
723 |
(* bound variables need to be treated properly, *) |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
724 |
(* as the type of subterms need to be calculated *) |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
725 |
|
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
726 |
fun inj_repabs_trm lthy (rtrm, qtrm) = |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
727 |
let |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
728 |
val rty = fastype_of rtrm |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
729 |
val qty = fastype_of qtrm |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
730 |
in |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
731 |
case (rtrm, qtrm) of |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
732 |
(Const (@{const_name "Ball"}, T) $ r $ t, Const (@{const_name "All"}, _) $ t') => |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
733 |
Const (@{const_name "Ball"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
734 |
| (Const (@{const_name "Bex"}, T) $ r $ t, Const (@{const_name "Ex"}, _) $ t') => |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
735 |
Const (@{const_name "Bex"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
736 |
| (Const (@{const_name "Babs"}, T) $ r $ t, t') => |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
737 |
Const (@{const_name "Babs"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
738 |
| (Abs (x, T, t), Abs (x', T', t')) => |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
739 |
let |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
740 |
val (y, s) = Term.dest_abs (x, T, t) |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
741 |
val (_, s') = Term.dest_abs (x', T', t') |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
742 |
val yvar = Free (y, T) |
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
parents:
452
diff
changeset
|
743 |
val result = Term.lambda_name (y, yvar) (inj_repabs_trm lthy (s, s')) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
744 |
in |
345
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
745 |
if rty = qty |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
746 |
then result |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
747 |
else mk_repabs lthy (rty, qty) result |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
748 |
end |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
749 |
| _ => |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
750 |
let |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
751 |
val (rhead, rargs) = strip_comb rtrm |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
752 |
val (qhead, qargs) = strip_comb qtrm |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
753 |
val rargs' = map (inj_repabs_trm lthy) (rargs ~~ qargs) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
754 |
in |
464 | 755 |
case (rhead, qhead) of |
756 |
(Const _, Const _) => |
|
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
757 |
if rty = qty |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
758 |
then list_comb (rhead, rargs') |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
759 |
else mk_repabs lthy (rty, qty) (list_comb (rhead, rargs')) |
464 | 760 |
| (Free (x, T), Free (x', T')) => |
761 |
if T = T' |
|
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
762 |
then list_comb (rhead, rargs') |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
763 |
else list_comb (mk_repabs lthy (T, T') rhead, rargs') |
464 | 764 |
| (Abs _, Abs _) => |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
765 |
list_comb (inj_repabs_trm lthy (rhead, qhead), rargs') |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
766 |
| _ => raise (LIFT_MATCH "injection") |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
453
diff
changeset
|
767 |
end |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
768 |
end |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
769 |
*} |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
770 |
|
404 | 771 |
section {* RepAbs Injection Tactic *} |
387 | 772 |
|
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
773 |
(* TODO: check if it still works with first_order_match *) |
387 | 774 |
ML {* |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
775 |
fun instantiate_tac thm = |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
776 |
Subgoal.FOCUS (fn {concl, ...} => |
387 | 777 |
let |
778 |
val pat = Drule.strip_imp_concl (cprop_of thm) |
|
481
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
779 |
val insts = Thm.first_order_match (pat, concl) |
387 | 780 |
in |
781 |
rtac (Drule.instantiate insts thm) 1 |
|
782 |
end |
|
783 |
handle _ => no_tac) |
|
784 |
*} |
|
785 |
||
786 |
ML {* |
|
468 | 787 |
fun quotient_tac ctxt quot_thms = |
788 |
REPEAT_ALL_NEW (FIRST' |
|
420
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
789 |
[rtac @{thm FUN_QUOTIENT}, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
790 |
resolve_tac quot_thms, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
791 |
rtac @{thm IDENTITY_QUOTIENT}, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
792 |
(* For functional identity quotients, (op = ---> op =) *) |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
793 |
(* TODO: think about the other way around, if we need to shorten the relation *) |
468 | 794 |
CHANGED o (simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms id_simps}))]) |
387 | 795 |
*} |
796 |
||
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
797 |
lemma FUN_REL_I: |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
798 |
assumes a: "\<And>x y. R1 x y \<Longrightarrow> R2 (f x) (g y)" |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
799 |
shows "(R1 ===> R2) f g" |
466 | 800 |
using a by simp |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
801 |
|
387 | 802 |
ML {* |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
803 |
val lambda_rsp_tac = |
472
cb03d4b3f059
fixed problems with FOCUS
Christian Urban <urbanc@in.tum.de>
parents:
471
diff
changeset
|
804 |
SUBGOAL (fn (goal, i) => |
475 | 805 |
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of |
472
cb03d4b3f059
fixed problems with FOCUS
Christian Urban <urbanc@in.tum.de>
parents:
471
diff
changeset
|
806 |
(_ $ (Abs _) $ (Abs _)) => rtac @{thm FUN_REL_I} i |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
807 |
| _ => no_tac) |
387 | 808 |
*} |
809 |
||
810 |
ML {* |
|
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
811 |
val weak_lambda_rsp_tac = |
472
cb03d4b3f059
fixed problems with FOCUS
Christian Urban <urbanc@in.tum.de>
parents:
471
diff
changeset
|
812 |
SUBGOAL (fn (goal, i) => |
475 | 813 |
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of |
473 | 814 |
(_ $ _ $ (Abs _)) => rtac @{thm FUN_REL_I} i |
815 |
| (_ $ (Abs _) $ _) => rtac @{thm FUN_REL_I} i |
|
428 | 816 |
| _ => no_tac) |
387 | 817 |
*} |
818 |
||
434 | 819 |
ML {* |
820 |
val ball_rsp_tac = |
|
472
cb03d4b3f059
fixed problems with FOCUS
Christian Urban <urbanc@in.tum.de>
parents:
471
diff
changeset
|
821 |
SUBGOAL (fn (goal, i) => |
475 | 822 |
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
823 |
(_ $ (Const (@{const_name Ball}, _) $ _) |
473 | 824 |
$ (Const (@{const_name Ball}, _) $ _)) => rtac @{thm FUN_REL_I} i |
434 | 825 |
|_ => no_tac) |
826 |
*} |
|
827 |
||
828 |
ML {* |
|
829 |
val bex_rsp_tac = |
|
472
cb03d4b3f059
fixed problems with FOCUS
Christian Urban <urbanc@in.tum.de>
parents:
471
diff
changeset
|
830 |
SUBGOAL (fn (goal, i) => |
475 | 831 |
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
832 |
(_ $ (Const (@{const_name Bex}, _) $ _) |
473 | 833 |
$ (Const (@{const_name Bex}, _) $ _)) => rtac @{thm FUN_REL_I} i |
434 | 834 |
| _ => no_tac) |
835 |
*} |
|
836 |
||
387 | 837 |
ML {* (* Legacy *) |
838 |
fun needs_lift (rty as Type (rty_s, _)) ty = |
|
839 |
case ty of |
|
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
840 |
Type (s, tys) => (s = rty_s) orelse (exists (needs_lift rty) tys) |
387 | 841 |
| _ => false |
842 |
||
843 |
*} |
|
844 |
||
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
845 |
definition |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
846 |
"QUOT_TRUE x \<equiv> True" |
472
cb03d4b3f059
fixed problems with FOCUS
Christian Urban <urbanc@in.tum.de>
parents:
471
diff
changeset
|
847 |
|
387 | 848 |
ML {* |
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
849 |
fun find_qt_asm asms = |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
850 |
let |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
851 |
fun find_fun trm = |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
852 |
case trm of |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
853 |
(Const(@{const_name Trueprop}, _) $ (Const (@{const_name QUOT_TRUE}, _) $ _)) => true |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
854 |
| _ => false |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
855 |
in |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
856 |
case find_first find_fun asms of |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
857 |
SOME (_ $ (_ $ (f $ a))) => (f, a) |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
858 |
| _ => error "find_qt_asm" |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
859 |
end |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
860 |
*} |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
861 |
|
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
862 |
ML {* |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
863 |
fun APPLY_RSP_TAC rty = |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
864 |
Subgoal.FOCUS (fn {concl, asms, ...} => |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
865 |
case ((HOLogic.dest_Trueprop (term_of concl))) of |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
866 |
((_ $ (f $ _) $ (_ $ _))) => |
431
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
867 |
let |
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
868 |
val (asmf, asma) = find_qt_asm (map term_of asms); |
431
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
869 |
val pat = Drule.strip_imp_concl (cprop_of @{thm APPLY_RSP}); |
481
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
870 |
val insts = Thm.first_order_match (pat, concl) |
431
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
871 |
in |
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
872 |
if (fastype_of asmf) = (fastype_of f) |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
873 |
then no_tac |
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
874 |
else rtac (Drule.instantiate insts @{thm APPLY_RSP}) 1 |
431
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
875 |
end |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
876 |
| _ => no_tac) |
387 | 877 |
*} |
878 |
||
879 |
ML {* |
|
482
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
880 |
val APPLY_RSP_TAC' = |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
881 |
Subgoal.FOCUS (fn {concl, asms, context,...} => |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
882 |
case ((HOLogic.dest_Trueprop (term_of concl))) of |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
883 |
((R2 $ (f $ x) $ (g $ y))) => |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
884 |
let |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
885 |
val (asmf, asma) = find_qt_asm (map term_of asms); |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
886 |
in |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
887 |
if (fastype_of asmf) = (fastype_of f) then no_tac else let |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
888 |
val ty_a = fastype_of x; |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
889 |
val ty_b = fastype_of asma; |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
890 |
val ty_c = range_type (type_of f); |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
891 |
val ty_d = range_type (type_of asmf); |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
892 |
val thy = ProofContext.theory_of context; |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
893 |
val ty_inst = map (fn x => SOME (ctyp_of thy x)) [ty_a, ty_b, ty_c, ty_d]; |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
894 |
val [R2, f, g, x, y] = map (cterm_of thy) [R2, f, g, x, y]; |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
895 |
val t_inst = [NONE, NONE, NONE, SOME R2, NONE, NONE, SOME f, SOME g, SOME x, SOME y]; |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
896 |
val thm = Drule.instantiate' ty_inst t_inst @{thm APPLY_RSP} |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
897 |
(*val _ = tracing (Syntax.string_of_term @{context} (prop_of thm))*) |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
898 |
in |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
899 |
rtac thm 1 |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
900 |
end |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
901 |
end |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
902 |
| _ => no_tac) |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
903 |
*} |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
904 |
|
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
905 |
|
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
906 |
ML {* |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
907 |
fun SOLVES' tac = tac THEN_ALL_NEW (fn _ => no_tac) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
908 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
909 |
|
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
910 |
(* |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
911 |
To prove that the regularised theorem implies the abs/rep injected, |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
912 |
we try: |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
913 |
|
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
914 |
1) theorems 'trans2' from the appropriate QUOT_TYPE |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
915 |
2) remove lambdas from both sides: lambda_rsp_tac |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
916 |
3) remove Ball/Bex from the right hand side |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
917 |
4) use user-supplied RSP theorems |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
918 |
5) remove rep_abs from the right side |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
919 |
6) reflexivity of equality |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
920 |
7) split applications of lifted type (apply_rsp) |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
921 |
8) split applications of non-lifted type (cong_tac) |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
922 |
9) apply extentionality |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
923 |
A) reflexivity of the relation |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
924 |
B) assumption |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
925 |
(Lambdas under respects may have left us some assumptions) |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
926 |
C) proving obvious higher order equalities by simplifying fun_rel |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
927 |
(not sure if it is still needed?) |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
928 |
D) unfolding lambda on one side |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
929 |
E) simplifying (= ===> =) for simpler respectfulness |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
930 |
|
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
931 |
*) |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
932 |
|
469 | 933 |
lemma quot_true_dests: |
934 |
shows QT_all: "QUOT_TRUE (All P) \<Longrightarrow> QUOT_TRUE P" |
|
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
935 |
and QT_ex: "QUOT_TRUE (Ex P) \<Longrightarrow> QUOT_TRUE P" |
469 | 936 |
and QT_lam: "QUOT_TRUE (\<lambda>x. P x) \<Longrightarrow> (\<And>x. QUOT_TRUE (P x))" |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
937 |
and QT_ext: "(\<And>x. QUOT_TRUE (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (QUOT_TRUE a \<Longrightarrow> f = g)" |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
938 |
apply(simp_all add: QUOT_TRUE_def ext) |
469 | 939 |
done |
940 |
||
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
941 |
lemma QUOT_TRUE_i: "(QUOT_TRUE (a :: bool) \<Longrightarrow> P) \<Longrightarrow> P" |
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
942 |
by (simp add: QUOT_TRUE_def) |
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
943 |
|
479
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
944 |
lemma QUOT_TRUE_imp: "QUOT_TRUE a \<equiv> QUOT_TRUE b" |
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
945 |
by (simp add: QUOT_TRUE_def) |
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
946 |
|
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
947 |
ML {* |
479
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
948 |
fun quot_true_conv1 ctxt fnctn ctrm = |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
949 |
case (term_of ctrm) of |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
950 |
(Const (@{const_name QUOT_TRUE}, _) $ x) => |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
951 |
let |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
952 |
val fx = fnctn x; |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
953 |
val thy = ProofContext.theory_of ctxt; |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
954 |
val cx = cterm_of thy x; |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
955 |
val cfx = cterm_of thy fx; |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
956 |
val cxt = ctyp_of thy (fastype_of x); |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
957 |
val cfxt = ctyp_of thy (fastype_of fx); |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
958 |
val thm = Drule.instantiate' [SOME cxt, SOME cfxt] [SOME cx, SOME cfx] @{thm QUOT_TRUE_imp} |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
959 |
in |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
960 |
Conv.rewr_conv thm ctrm |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
961 |
end |
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
469
diff
changeset
|
962 |
*} |
469 | 963 |
|
479
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
964 |
ML {* |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
965 |
fun quot_true_conv ctxt fnctn ctrm = |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
966 |
case (term_of ctrm) of |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
967 |
(Const (@{const_name QUOT_TRUE}, _) $ _) => |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
968 |
quot_true_conv1 ctxt fnctn ctrm |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
969 |
| _ $ _ => Conv.comb_conv (quot_true_conv ctxt fnctn) ctrm |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
970 |
| Abs _ => Conv.abs_conv (fn (_, ctxt) => quot_true_conv ctxt fnctn) ctxt ctrm |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
971 |
| _ => Conv.all_conv ctrm |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
972 |
*} |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
973 |
|
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
974 |
ML {* |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
975 |
fun quot_true_tac ctxt fnctn = CSUBGOAL (fn (goal, i) => |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
976 |
CONVERSION |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
977 |
(Conv.params_conv ~1 (fn ctxt => |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
978 |
(Conv.prems_conv ~1 (quot_true_conv ctxt fnctn))) ctxt) i) |
24799397a3ce
The conversion approach works.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
476
diff
changeset
|
979 |
*} |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
980 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
981 |
ML {* fun dest_comb (f $ a) = (f, a) *} |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
982 |
ML {* fun dest_bcomb ((_ $ l) $ r) = (l, r) *} |
481
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
983 |
(* TODO: Can this be done easier? *) |
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
984 |
ML {* |
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
985 |
fun unlam t = |
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
986 |
case t of |
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
987 |
(Abs a) => snd (Term.dest_abs a) |
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
480
diff
changeset
|
988 |
| _ => unlam (Abs("", domain_type (fastype_of t), (incr_boundvars 1 t) $ (Bound 0))) *} |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
989 |
|
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
990 |
ML {* |
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
991 |
fun inj_repabs_tac_old ctxt rty quot_thms rel_refl trans2 = |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
992 |
(FIRST' [ |
449 | 993 |
(* "cong" rule of the of the relation / transitivity*) |
994 |
(* (op =) (R a b) (R c d) ----> \<lbrakk>R a c; R b d\<rbrakk> *) |
|
469 | 995 |
DT ctxt "1" (resolve_tac trans2), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
996 |
|
443 | 997 |
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *) |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
998 |
NDT ctxt "2" (lambda_rsp_tac), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
999 |
|
443 | 1000 |
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
458 | 1001 |
NDT ctxt "3" (rtac @{thm ball_rsp}), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1002 |
|
443 | 1003 |
(* (R1 ===> R2) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Ball\<dots>x) (Ball\<dots>y) *) |
473 | 1004 |
NDT ctxt "4" (ball_rsp_tac), |
434 | 1005 |
|
443 | 1006 |
(* (op =) (Bex\<dots>) (Bex\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
458 | 1007 |
NDT ctxt "5" (rtac @{thm bex_rsp}), |
434 | 1008 |
|
443 | 1009 |
(* (R1 ===> R2) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Bex\<dots>x) (Bex\<dots>y) *) |
473 | 1010 |
NDT ctxt "6" (bex_rsp_tac), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1011 |
|
442
7beed9b75ea2
renamed LAMBDA_RES_TAC and WEAK_LAMBDA_RES_TAC to lower case names
Christian Urban <urbanc@in.tum.de>
parents:
440
diff
changeset
|
1012 |
(* respectfulness of constants *) |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
1013 |
NDT ctxt "7" (resolve_tac (rsp_rules_get ctxt)), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1014 |
|
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1015 |
(* reflexivity of operators arising from Cong_tac *) |
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
parents:
445
diff
changeset
|
1016 |
NDT ctxt "8" (rtac @{thm refl}), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1017 |
|
443 | 1018 |
(* R (\<dots>) (Rep (Abs \<dots>)) ----> R (\<dots>) (\<dots>) *) |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1019 |
(* observe ---> *) |
459 | 1020 |
NDT ctxt "9" ((instantiate_tac @{thm REP_ABS_RSP} ctxt |
468 | 1021 |
THEN' (RANGE [SOLVES' (quotient_tac ctxt quot_thms)]))), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1022 |
|
449 | 1023 |
(* R (t $ \<dots>) (t' $ \<dots>) ----> APPLY_RSP provided type of t needs lifting *) |
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
parents:
445
diff
changeset
|
1024 |
NDT ctxt "A" ((APPLY_RSP_TAC rty ctxt THEN' |
468 | 1025 |
(RANGE [SOLVES' (quotient_tac ctxt quot_thms), SOLVES' (quotient_tac ctxt quot_thms)]))), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1026 |
|
449 | 1027 |
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *) |
444 | 1028 |
(* merge with previous tactic *) |
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
parents:
445
diff
changeset
|
1029 |
NDT ctxt "B" (Cong_Tac.cong_tac @{thm cong}), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1030 |
|
443 | 1031 |
(* (op =) (\<lambda>x\<dots>) (\<lambda>x\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
parents:
445
diff
changeset
|
1032 |
NDT ctxt "C" (rtac @{thm ext}), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1033 |
|
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1034 |
(* reflexivity of the basic relations *) |
449 | 1035 |
(* R \<dots> \<dots> *) |
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
parents:
445
diff
changeset
|
1036 |
NDT ctxt "D" (resolve_tac rel_refl), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1037 |
|
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1038 |
(* resolving with R x y assumptions *) |
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
parents:
445
diff
changeset
|
1039 |
NDT ctxt "E" (atac), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1040 |
|
443 | 1041 |
(* (op =) ===> (op =) \<Longrightarrow> (op =), needed in order to apply respectfulness theorems *) |
1042 |
(* global simplification *) |
|
452
7ba2c16fe0c8
Removed unnecessary HOL_ss which proved one of the subgoals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
451
diff
changeset
|
1043 |
NDT ctxt "H" (CHANGED o (asm_full_simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms eq_reflection[OF FUN_REL_EQ]})))]) |
443 | 1044 |
*} |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
1045 |
|
443 | 1046 |
ML {* |
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
479
diff
changeset
|
1047 |
fun inj_repabs_tac ctxt rty quot_thms rel_refl trans2 = |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1048 |
(FIRST' [ |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1049 |
(* "cong" rule of the of the relation / transitivity*) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1050 |
(* (op =) (R a b) (R c d) ----> \<lbrakk>R a c; R b d\<rbrakk> *) |
482
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
1051 |
NDT ctxt "1" (resolve_tac trans2 THEN' RANGE [ |
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
1052 |
quot_true_tac ctxt (fst o dest_bcomb), quot_true_tac ctxt (snd o dest_bcomb)]), |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1053 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1054 |
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1055 |
NDT ctxt "2" (lambda_rsp_tac THEN' quot_true_tac ctxt unlam), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1056 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1057 |
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1058 |
NDT ctxt "3" (rtac @{thm ball_rsp} THEN' dtac @{thm QT_all}), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1059 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1060 |
(* R2 is always equality *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1061 |
(* (R1 ===> R2) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Ball\<dots>x) (Ball\<dots>y) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1062 |
NDT ctxt "4" (ball_rsp_tac THEN' quot_true_tac ctxt unlam), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1063 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1064 |
(* (op =) (Bex\<dots>) (Bex\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1065 |
NDT ctxt "5" (rtac @{thm bex_rsp} THEN' dtac @{thm QT_ex}), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1066 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1067 |
(* (R1 ===> R2) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Bex\<dots>x) (Bex\<dots>y) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1068 |
NDT ctxt "6" (bex_rsp_tac THEN' dtac @{thm QT_ext}), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1069 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1070 |
(* respectfulness of constants *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1071 |
NDT ctxt "7" (resolve_tac (rsp_rules_get ctxt)), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1072 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1073 |
(* reflexivity of operators arising from Cong_tac *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1074 |
NDT ctxt "8" (rtac @{thm refl}), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1075 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1076 |
(* R (\<dots>) (Rep (Abs \<dots>)) ----> R (\<dots>) (\<dots>) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1077 |
(* observe ---> *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1078 |
NDT ctxt "9" ((instantiate_tac @{thm REP_ABS_RSP} ctxt |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1079 |
THEN' (RANGE [SOLVES' (quotient_tac ctxt quot_thms)]))), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1080 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1081 |
(* R (t $ \<dots>) (t' $ \<dots>) ----> APPLY_RSP provided type of t needs lifting *) |
482
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
481
diff
changeset
|
1082 |
NDT ctxt "A" (APPLY_RSP_TAC' ctxt THEN' |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1083 |
(RANGE [SOLVES' (quotient_tac ctxt quot_thms), SOLVES' (quotient_tac ctxt quot_thms), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1084 |
quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)])), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1085 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1086 |
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1087 |
(* merge with previous tactic *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1088 |
NDT ctxt "B" (Cong_Tac.cong_tac @{thm cong} THEN' |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1089 |
(RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)])), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1090 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1091 |
(* (op =) (\<lambda>x\<dots>) (\<lambda>x\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1092 |
NDT ctxt "C" (rtac @{thm ext} THEN' quot_true_tac ctxt unlam), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1093 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1094 |
(* reflexivity of the basic relations *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1095 |
(* R \<dots> \<dots> *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1096 |
NDT ctxt "D" (resolve_tac rel_refl), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1097 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1098 |
(* resolving with R x y assumptions *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1099 |
NDT ctxt "E" (atac), |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1100 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1101 |
(* (op =) ===> (op =) \<Longrightarrow> (op =), needed in order to apply respectfulness theorems *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1102 |
(* global simplification *) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1103 |
NDT ctxt "H" (CHANGED o (asm_full_simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms eq_reflection[OF FUN_REL_EQ]})))]) |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1104 |
*} |
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1105 |
|
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1106 |
ML {* |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
1107 |
fun all_inj_repabs_tac ctxt rty quot_thms rel_refl trans2 = |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
1108 |
REPEAT_ALL_NEW (inj_repabs_tac ctxt rty quot_thms rel_refl trans2) |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
1109 |
*} |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
1110 |
|
399 | 1111 |
section {* Cleaning of the theorem *} |
387 | 1112 |
|
389 | 1113 |
|
462
0911d3aabf47
clean_tac rewrites the definitions the other way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
459
diff
changeset
|
1114 |
(* TODO: This is slow *) |
389 | 1115 |
ML {* |
468 | 1116 |
fun allex_prs_tac ctxt quot = |
1117 |
(EqSubst.eqsubst_tac ctxt [0] @{thms all_prs ex_prs}) THEN' (quotient_tac ctxt quot) |
|
387 | 1118 |
*} |
1119 |
||
426 | 1120 |
(* Rewrites the term with LAMBDA_PRS thm. |
1121 |
||
1122 |
Replaces: (Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) |
|
1123 |
with: f |
|
1124 |
||
1125 |
It proves the QUOTIENT assumptions by calling quotient_tac |
|
1126 |
*) |
|
387 | 1127 |
ML {* |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1128 |
fun make_inst lhs t = |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1129 |
let |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1130 |
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1131 |
val _ $ (Abs (_, _, g)) = t; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1132 |
fun mk_abs i t = |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1133 |
if incr_boundvars i u aconv t then Bound i |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1134 |
else (case t of |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1135 |
t1 $ t2 => mk_abs i t1 $ mk_abs i t2 |
469 | 1136 |
| Abs (s, T, t') => Abs (s, T, mk_abs (i + 1) t') |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1137 |
| Bound j => if i = j then error "make_inst" else t |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1138 |
| _ => t); |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1139 |
in (f, Abs ("x", T, mk_abs 0 g)) end; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1140 |
|
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1141 |
fun lambda_prs_conv1 ctxt quot_thms ctrm = |
387 | 1142 |
case (term_of ctrm) of ((Const (@{const_name "fun_map"}, _) $ r1 $ a2) $ (Abs _)) => |
1143 |
let |
|
1144 |
val (_, [ty_b, ty_a]) = dest_Type (fastype_of r1); |
|
1145 |
val (_, [ty_c, ty_d]) = dest_Type (fastype_of a2); |
|
1146 |
val thy = ProofContext.theory_of ctxt; |
|
1147 |
val [cty_a, cty_b, cty_c, cty_d] = map (ctyp_of thy) [ty_a, ty_b, ty_c, ty_d] |
|
1148 |
val tyinst = [SOME cty_a, SOME cty_b, SOME cty_c, SOME cty_d]; |
|
1149 |
val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)] |
|
1150 |
val lpi = Drule.instantiate' tyinst tinst @{thm LAMBDA_PRS}; |
|
1151 |
val tac = |
|
1152 |
(compose_tac (false, lpi, 2)) THEN_ALL_NEW |
|
468 | 1153 |
(quotient_tac ctxt quot_thms); |
387 | 1154 |
val gc = Drule.strip_imp_concl (cprop_of lpi); |
1155 |
val t = Goal.prove_internal [] gc (fn _ => tac 1) |
|
1156 |
val te = @{thm eq_reflection} OF [t] |
|
415
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
1157 |
val ts = MetaSimplifier.rewrite_rule @{thms id_simps} te |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1158 |
val tl = Thm.lhs_of ts; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1159 |
val (insp, inst) = make_inst (term_of tl) (term_of ctrm); |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1160 |
val ti = Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1161 |
(* val _ = writeln (Syntax.string_of_term @{context} (term_of (cprop_of ti)));*) |
387 | 1162 |
in |
1163 |
Conv.rewr_conv ti ctrm |
|
1164 |
end |
|
1165 |
*} |
|
1166 |
||
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1167 |
(* quot stands for the QUOTIENT theorems: *) |
387 | 1168 |
(* could be potentially all of them *) |
1169 |
ML {* |
|
1170 |
fun lambda_prs_conv ctxt quot ctrm = |
|
1171 |
case (term_of ctrm) of |
|
1172 |
(Const (@{const_name "fun_map"}, _) $ _ $ _) $ (Abs _) => |
|
1173 |
(Conv.arg_conv (Conv.abs_conv (fn (_, ctxt) => lambda_prs_conv ctxt quot) ctxt) |
|
1174 |
then_conv (lambda_prs_conv1 ctxt quot)) ctrm |
|
1175 |
| _ $ _ => Conv.comb_conv (lambda_prs_conv ctxt quot) ctrm |
|
1176 |
| Abs _ => Conv.abs_conv (fn (_, ctxt) => lambda_prs_conv ctxt quot) ctxt ctrm |
|
1177 |
| _ => Conv.all_conv ctrm |
|
1178 |
*} |
|
1179 |
||
1180 |
ML {* |
|
1181 |
fun lambda_prs_tac ctxt quot = CSUBGOAL (fn (goal, i) => |
|
1182 |
CONVERSION |
|
1183 |
(Conv.params_conv ~1 (fn ctxt => |
|
1184 |
(Conv.prems_conv ~1 (lambda_prs_conv ctxt quot) then_conv |
|
1185 |
Conv.concl_conv ~1 (lambda_prs_conv ctxt quot))) ctxt) i) |
|
1186 |
*} |
|
1187 |
||
457 | 1188 |
(* |
465 | 1189 |
Cleaning the theorem consists of 6 kinds of rewrites. |
1190 |
The first two need to be done before fun_map is unfolded |
|
457 | 1191 |
|
1192 |
- LAMBDA_PRS: |
|
469 | 1193 |
(Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) ----> f |
1194 |
||
465 | 1195 |
- FORALL_PRS (and the same for exists: EXISTS_PRS) |
469 | 1196 |
\<forall>x\<in>Respects R. (abs ---> id) f ----> \<forall>x. f |
1197 |
||
457 | 1198 |
- Rewriting with definitions from the argument defs |
469 | 1199 |
NewConst ----> (rep ---> abs) oldConst |
1200 |
||
457 | 1201 |
- QUOTIENT_REL_REP: |
469 | 1202 |
Rel (Rep x) (Rep y) ----> x = y |
1203 |
||
465 | 1204 |
- ABS_REP |
469 | 1205 |
Abs (Rep x) ----> x |
1206 |
||
465 | 1207 |
- id_simps; fun_map.simps |
457 | 1208 |
|
1209 |
The first one is implemented as a conversion (fast). |
|
465 | 1210 |
The second one is an EqSubst (slow). |
1211 |
The rest are a simp_tac and are fast. |
|
457 | 1212 |
*) |
469 | 1213 |
|
1214 |
thm all_prs ex_prs |
|
1215 |
||
1216 |
||
387 | 1217 |
ML {* |
466 | 1218 |
fun clean_tac lthy quot defs = |
387 | 1219 |
let |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1220 |
val absrep = map (fn x => @{thm QUOTIENT_ABS_REP} OF [x]) quot |
462
0911d3aabf47
clean_tac rewrites the definitions the other way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
459
diff
changeset
|
1221 |
val meta_absrep = map (fn x => @{thm eq_reflection} OF [x]) absrep; |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1222 |
val reps_same = map (fn x => @{thm QUOTIENT_REL_REP} OF [x]) quot |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1223 |
val meta_reps_same = map (fn x => @{thm eq_reflection} OF [x]) reps_same |
462
0911d3aabf47
clean_tac rewrites the definitions the other way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
459
diff
changeset
|
1224 |
val simp_ctxt = (Simplifier.context lthy empty_ss) addsimps |
0911d3aabf47
clean_tac rewrites the definitions the other way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
459
diff
changeset
|
1225 |
(@{thm eq_reflection[OF fun_map.simps]} :: @{thms id_simps} @ meta_absrep @ meta_reps_same @ defs) |
387 | 1226 |
in |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1227 |
EVERY' [lambda_prs_tac lthy quot, |
462
0911d3aabf47
clean_tac rewrites the definitions the other way
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
459
diff
changeset
|
1228 |
TRY o REPEAT_ALL_NEW (allex_prs_tac lthy quot), |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1229 |
TRY o simp_tac simp_ctxt, |
451
586e3dc4afdb
Added 'TRY' to refl in clean_tac to get as far as possible. Removed unnecessary [quot_rsp] in FSet. Added necessary [quot_rsp] and one lifted thm in LamEx.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
450
diff
changeset
|
1230 |
TRY o rtac refl] |
387 | 1231 |
end |
1232 |
*} |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
1233 |
|
404 | 1234 |
section {* Genralisation of free variables in a goal *} |
347
7e82493c6253
Finished temporary goal-directed lift_theorem wrapper.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
346
diff
changeset
|
1235 |
|
7e82493c6253
Finished temporary goal-directed lift_theorem wrapper.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
346
diff
changeset
|
1236 |
ML {* |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1237 |
fun inst_spec ctrm = |
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1238 |
Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec} |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1239 |
|
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1240 |
fun inst_spec_tac ctrms = |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1241 |
EVERY' (map (dtac o inst_spec) ctrms) |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1242 |
|
412 | 1243 |
fun all_list xs trm = |
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1244 |
fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm |
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1245 |
|
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1246 |
fun apply_under_Trueprop f = |
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1247 |
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop |
362 | 1248 |
|
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1249 |
fun gen_frees_tac ctxt = |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1250 |
SUBGOAL (fn (concl, i) => |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1251 |
let |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1252 |
val thy = ProofContext.theory_of ctxt |
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1253 |
val vrs = Term.add_frees concl [] |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1254 |
val cvrs = map (cterm_of thy o Free) vrs |
412 | 1255 |
val concl' = apply_under_Trueprop (all_list vrs) concl |
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1256 |
val goal = Logic.mk_implies (concl', concl) |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1257 |
val rule = Goal.prove ctxt [] [] goal |
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1258 |
(K (EVERY1 [inst_spec_tac (rev cvrs), atac])) |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1259 |
in |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1260 |
rtac rule i |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1261 |
end) |
362 | 1262 |
*} |
1263 |
||
402
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
1264 |
section {* General outline of the lifting procedure *} |
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
1265 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1266 |
(* - A is the original raw theorem *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1267 |
(* - B is the regularized theorem *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1268 |
(* - C is the rep/abs injected version of B *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1269 |
(* - D is the lifted theorem *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1270 |
(* *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1271 |
(* - b is the regularization step *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1272 |
(* - c is the rep/abs injection step *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1273 |
(* - d is the cleaning part *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1274 |
|
413 | 1275 |
lemma lifting_procedure: |
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1276 |
assumes a: "A" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1277 |
and b: "A \<Longrightarrow> B" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1278 |
and c: "B = C" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1279 |
and d: "C = D" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1280 |
shows "D" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1281 |
using a b c d |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1282 |
by simp |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1283 |
|
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1284 |
ML {* |
412 | 1285 |
fun lift_match_error ctxt fun_str rtrm qtrm = |
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1286 |
let |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1287 |
val rtrm_str = Syntax.string_of_term ctxt rtrm |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1288 |
val qtrm_str = Syntax.string_of_term ctxt qtrm |
388 | 1289 |
val msg = [enclose "[" "]" fun_str, "The quotient theorem\n", qtrm_str, |
1290 |
"and the lifted theorem\n", rtrm_str, "do not match"] |
|
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1291 |
in |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1292 |
error (space_implode " " msg) |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1293 |
end |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1294 |
*} |
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1295 |
|
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1296 |
ML {* |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1297 |
fun procedure_inst ctxt rtrm qtrm = |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1298 |
let |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1299 |
val thy = ProofContext.theory_of ctxt |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1300 |
val rtrm' = HOLogic.dest_Trueprop rtrm |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1301 |
val qtrm' = HOLogic.dest_Trueprop qtrm |
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1302 |
val reg_goal = |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
1303 |
Syntax.check_term ctxt (regularize_trm ctxt rtrm' qtrm') |
412 | 1304 |
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm |
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1305 |
val inj_goal = |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
1306 |
Syntax.check_term ctxt (inj_repabs_trm ctxt (reg_goal, qtrm')) |
412 | 1307 |
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm |
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1308 |
in |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1309 |
Drule.instantiate' [] |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1310 |
[SOME (cterm_of thy rtrm'), |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1311 |
SOME (cterm_of thy reg_goal), |
413 | 1312 |
SOME (cterm_of thy inj_goal)] @{thm lifting_procedure} |
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1313 |
end |
362 | 1314 |
*} |
389 | 1315 |
|
1316 |
(* Left for debugging *) |
|
362 | 1317 |
ML {* |
389 | 1318 |
fun procedure_tac lthy rthm = |
1319 |
ObjectLogic.full_atomize_tac |
|
1320 |
THEN' gen_frees_tac lthy |
|
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
parents:
372
diff
changeset
|
1321 |
THEN' Subgoal.FOCUS (fn {context, concl, ...} => |
389 | 1322 |
let |
1323 |
val rthm' = atomize_thm rthm |
|
1324 |
val rule = procedure_inst context (prop_of rthm') (term_of concl) |
|
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1325 |
val thm = Drule.instantiate' [] [SOME (snd (Thm.dest_comb concl))] @{thm QUOT_TRUE_i} |
389 | 1326 |
in |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1327 |
EVERY1 [rtac rule, rtac rthm'] THEN RANGE [(fn _ => all_tac), rtac thm] 1 |
412 | 1328 |
end) lthy |
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1329 |
*} |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1330 |
|
361 | 1331 |
ML {* |
413 | 1332 |
(* FIXME/TODO should only get as arguments the rthm like procedure_tac *) |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
1333 |
fun lift_tac lthy rthm rel_eqv rty quot defs = |
389 | 1334 |
ObjectLogic.full_atomize_tac |
1335 |
THEN' gen_frees_tac lthy |
|
1336 |
THEN' Subgoal.FOCUS (fn {context, concl, ...} => |
|
1337 |
let |
|
1338 |
val rthm' = atomize_thm rthm |
|
1339 |
val rule = procedure_inst context (prop_of rthm') (term_of concl) |
|
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1340 |
val rel_refl = map (fn x => @{thm EQUIV_REFL} OF [x]) rel_eqv |
419
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
1341 |
val trans2 = map (fn x => @{thm equiv_trans2} OF [x]) rel_eqv |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1342 |
val thm = Drule.instantiate' [] [SOME (snd (Thm.dest_comb concl))] @{thm QUOT_TRUE_i} |
389 | 1343 |
in |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1344 |
EVERY1 |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1345 |
[rtac rule, |
413 | 1346 |
RANGE [rtac rthm', |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1347 |
regularize_tac lthy rel_eqv, |
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
475
diff
changeset
|
1348 |
rtac thm THEN' all_inj_repabs_tac lthy rty quot rel_refl trans2, |
466 | 1349 |
clean_tac lthy quot defs]] |
412 | 1350 |
end) lthy |
361 | 1351 |
*} |
1352 |
||
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
1353 |
end |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
1354 |