author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Mon, 30 Nov 2009 10:16:10 +0100 | |
changeset 457 | 48042bacdce2 |
parent 455 | 9cb45d022524 |
child 458 | 44a70e69ef92 |
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 |
||
8 |
locale QUOT_TYPE = |
|
9 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
10 |
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b" |
|
11 |
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)" |
|
12 |
assumes equiv: "EQUIV R" |
|
13 |
and rep_prop: "\<And>y. \<exists>x. Rep y = R x" |
|
14 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
|
15 |
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)" |
|
16 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
|
15 | 17 |
begin |
0 | 18 |
|
19 |
definition |
|
200
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
20 |
ABS::"'a \<Rightarrow> 'b" |
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
21 |
where |
0 | 22 |
"ABS x \<equiv> Abs (R x)" |
23 |
||
24 |
definition |
|
200
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
25 |
REP::"'b \<Rightarrow> 'a" |
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
26 |
where |
0 | 27 |
"REP a = Eps (Rep a)" |
28 |
||
15 | 29 |
lemma lem9: |
0 | 30 |
shows "R (Eps (R x)) = R x" |
31 |
proof - |
|
32 |
have a: "R x x" using equiv by (simp add: EQUIV_REFL_SYM_TRANS REFL_def) |
|
33 |
then have "R x (Eps (R x))" by (rule someI) |
|
15 | 34 |
then show "R (Eps (R x)) = R x" |
0 | 35 |
using equiv unfolding EQUIV_def by simp |
36 |
qed |
|
37 |
||
38 |
theorem thm10: |
|
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
39 |
shows "ABS (REP a) \<equiv> a" |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
40 |
apply (rule eq_reflection) |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
41 |
unfolding ABS_def REP_def |
0 | 42 |
proof - |
15 | 43 |
from rep_prop |
0 | 44 |
obtain x where eq: "Rep a = R x" by auto |
45 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
|
46 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
|
47 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
|
48 |
also have "\<dots> = a" using rep_inverse by simp |
|
49 |
finally |
|
50 |
show "Abs (R (Eps (Rep a))) = a" by simp |
|
51 |
qed |
|
52 |
||
15 | 53 |
lemma REP_refl: |
0 | 54 |
shows "R (REP a) (REP a)" |
55 |
unfolding REP_def |
|
56 |
by (simp add: equiv[simplified EQUIV_def]) |
|
57 |
||
58 |
lemma lem7: |
|
22 | 59 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
0 | 60 |
apply(rule iffI) |
61 |
apply(simp) |
|
62 |
apply(drule rep_inject[THEN iffD2]) |
|
63 |
apply(simp add: abs_inverse) |
|
64 |
done |
|
15 | 65 |
|
0 | 66 |
theorem thm11: |
67 |
shows "R r r' = (ABS r = ABS r')" |
|
68 |
unfolding ABS_def |
|
69 |
by (simp only: equiv[simplified EQUIV_def] lem7) |
|
70 |
||
4 | 71 |
|
2 | 72 |
lemma REP_ABS_rsp: |
4 | 73 |
shows "R f (REP (ABS g)) = R f g" |
74 |
and "R (REP (ABS g)) f = R g f" |
|
23 | 75 |
by (simp_all add: thm10 thm11) |
4 | 76 |
|
0 | 77 |
lemma QUOTIENT: |
78 |
"QUOTIENT R ABS REP" |
|
79 |
apply(unfold QUOTIENT_def) |
|
80 |
apply(simp add: thm10) |
|
81 |
apply(simp add: REP_refl) |
|
82 |
apply(subst thm11[symmetric]) |
|
83 |
apply(simp add: equiv[simplified EQUIV_def]) |
|
84 |
done |
|
85 |
||
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
86 |
lemma R_trans: |
49 | 87 |
assumes ab: "R a b" |
88 |
and bc: "R b c" |
|
22 | 89 |
shows "R a c" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
90 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
91 |
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
|
92 |
moreover have ab: "R a b" by fact |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
93 |
moreover have bc: "R b c" by fact |
22 | 94 |
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
|
95 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
96 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
97 |
lemma R_sym: |
49 | 98 |
assumes ab: "R a b" |
22 | 99 |
shows "R b a" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
100 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
101 |
have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
22 | 102 |
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
|
103 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
104 |
|
49 | 105 |
lemma R_trans2: |
106 |
assumes ac: "R a c" |
|
22 | 107 |
and bd: "R b d" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
108 |
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
|
109 |
using ac bd |
d6a24dad5882
made quotients compatiple with Nominal; updated keyword file
Christian Urban <urbanc@in.tum.de>
parents:
198
diff
changeset
|
110 |
by (blast intro: R_trans R_sym) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
111 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
112 |
lemma REPS_same: |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
113 |
shows "R (REP a) (REP b) \<equiv> (a = b)" |
38 | 114 |
proof - |
115 |
have "R (REP a) (REP b) = (a = b)" |
|
116 |
proof |
|
117 |
assume as: "R (REP a) (REP b)" |
|
118 |
from rep_prop |
|
119 |
obtain x y |
|
120 |
where eqs: "Rep a = R x" "Rep b = R y" by blast |
|
121 |
from eqs have "R (Eps (R x)) (Eps (R y))" using as unfolding REP_def by simp |
|
122 |
then have "R x (Eps (R y))" using lem9 by simp |
|
123 |
then have "R (Eps (R y)) x" using R_sym by blast |
|
124 |
then have "R y x" using lem9 by simp |
|
125 |
then have "R x y" using R_sym by blast |
|
126 |
then have "ABS x = ABS y" using thm11 by simp |
|
127 |
then have "Abs (Rep a) = Abs (Rep b)" using eqs unfolding ABS_def by simp |
|
128 |
then show "a = b" using rep_inverse by simp |
|
129 |
next |
|
130 |
assume ab: "a = b" |
|
131 |
have "REFL R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
|
132 |
then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto |
|
133 |
qed |
|
134 |
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
|
135 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
136 |
|
0 | 137 |
end |
138 |
||
419
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
139 |
lemma equiv_trans2: |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
140 |
assumes e: "EQUIV R" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
141 |
and ac: "R a c" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
142 |
and bd: "R b d" |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
143 |
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
|
144 |
using ac bd e |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
145 |
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
|
146 |
by (blast) |
b1cd040ff5f7
Simplifying arguments; got rid of trans2_thm.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
416
diff
changeset
|
147 |
|
0 | 148 |
section {* type definition for the quotient type *} |
149 |
||
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
|
150 |
(* 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
|
151 |
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
|
152 |
|
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
153 |
declare [[map list = (map, LIST_REL)]] |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
154 |
declare [[map * = (prod_fun, prod_rel)]] |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
155 |
declare [[map "fun" = (fun_map, FUN_REL)]] |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
156 |
|
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
157 |
ML {* maps_lookup @{theory} "List.list" *} |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
158 |
ML {* maps_lookup @{theory} "*" *} |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
159 |
ML {* maps_lookup @{theory} "fun" *} |
174
09048a951dca
moved the map_funs setup into QuotMain
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
160 |
|
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
|
161 |
|
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
|
162 |
(* 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
|
163 |
(* 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
|
164 |
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
|
165 |
|
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
|
166 |
|
277
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
167 |
(* lifting of constants *) |
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
168 |
use "quotient_def.ML" |
37636f2b1c19
separated the quotient_def into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
275
diff
changeset
|
169 |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
170 |
(* 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
|
171 |
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
|
172 |
*) |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
173 |
definition |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
174 |
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
|
175 |
where |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
176 |
"(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
|
177 |
|
139 | 178 |
section {* ATOMIZE *} |
179 |
||
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
180 |
lemma atomize_eqv[atomize]: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
181 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
139 | 182 |
proof |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
183 |
assume "A \<equiv> B" |
139 | 184 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
185 |
next |
|
186 |
assume *: "Trueprop A \<equiv> Trueprop B" |
|
187 |
have "A = B" |
|
188 |
proof (cases A) |
|
189 |
case True |
|
190 |
have "A" by fact |
|
191 |
then show "A = B" using * by simp |
|
192 |
next |
|
193 |
case False |
|
194 |
have "\<not>A" by fact |
|
195 |
then show "A = B" using * by auto |
|
196 |
qed |
|
197 |
then show "A \<equiv> B" by (rule eq_reflection) |
|
198 |
qed |
|
199 |
||
200 |
ML {* |
|
201 |
fun atomize_thm thm = |
|
202 |
let |
|
221 | 203 |
val thm' = Thm.freezeT (forall_intr_vars thm) |
139 | 204 |
val thm'' = ObjectLogic.atomize (cprop_of thm') |
205 |
in |
|
404 | 206 |
@{thm equal_elim_rule1} OF [thm'', thm'] |
139 | 207 |
end |
208 |
*} |
|
209 |
||
387 | 210 |
section {* infrastructure about id *} |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
211 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
212 |
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
|
213 |
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
|
214 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
215 |
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
|
216 |
apply (rule eq_reflection) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
217 |
apply (rule ext) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
218 |
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
|
219 |
apply (simp_all) |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
220 |
done |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
221 |
|
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
222 |
lemmas id_simps = |
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
223 |
FUN_MAP_I[THEN eq_reflection] |
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
224 |
id_apply[THEN eq_reflection] |
415
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
225 |
id_def[THEN eq_reflection,symmetric] |
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
226 |
prod_fun_id map_id |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
227 |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
228 |
ML {* |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
229 |
fun simp_ids thm = |
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
230 |
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
|
231 |
*} |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
232 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
233 |
section {* Debugging infrastructure for testing tactics *} |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
234 |
|
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
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
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
|
239 |
|> 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
|
240 |
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
|
241 |
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
|
242 |
in |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
243 |
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
|
244 |
end *} |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
245 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
246 |
|
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
|
247 |
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
|
248 |
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
|
249 |
let |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
250 |
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
|
251 |
|> 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
|
252 |
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
|
253 |
|> 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
|
254 |
in |
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
255 |
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
|
256 |
end |
444 | 257 |
|
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
|
258 |
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
|
259 |
*} |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
260 |
|
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
parents:
452
diff
changeset
|
261 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
262 |
section {* Infrastructure about definitions *} |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
263 |
|
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
264 |
(* Does the same as 'subst' in a given theorem *) |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
265 |
ML {* |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
266 |
fun eqsubst_thm ctxt thms thm = |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
267 |
let |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
268 |
val goalstate = Goal.init (Thm.cprop_of thm) |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
269 |
val a' = case (SINGLE (EqSubst.eqsubst_tac ctxt [0] thms 1) goalstate) of |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
270 |
NONE => error "eqsubst_thm" |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
271 |
| SOME th => cprem_of th 1 |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
272 |
val tac = (EqSubst.eqsubst_tac ctxt [0] thms 1) THEN simp_tac HOL_ss 1 |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
273 |
val goal = Logic.mk_equals (term_of (Thm.cprop_of thm), term_of a'); |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
274 |
val cgoal = cterm_of (ProofContext.theory_of ctxt) goal |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
275 |
val rt = Goal.prove_internal [] cgoal (fn _ => tac); |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
276 |
in |
402
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
277 |
@{thm equal_elim_rule1} OF [rt, thm] |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
278 |
end |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
279 |
*} |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
280 |
|
404 | 281 |
(* expects atomized definitions *) |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
282 |
ML {* |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
283 |
fun add_lower_defs_aux lthy thm = |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
284 |
let |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
285 |
val e1 = @{thm fun_cong} OF [thm]; |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
286 |
val f = eqsubst_thm lthy @{thms fun_map.simps} e1; |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
287 |
val g = simp_ids f |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
288 |
in |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
289 |
(simp_ids thm) :: (add_lower_defs_aux lthy g) |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
290 |
end |
409
6b59a3844055
introduced a separate lemma for id_simps
Christian Urban <urbanc@in.tum.de>
parents:
408
diff
changeset
|
291 |
handle _ => [simp_ids thm] |
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
292 |
*} |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
293 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
294 |
ML {* |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
295 |
fun add_lower_defs lthy def = |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
296 |
let |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
297 |
val def_pre_sym = symmetric def |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
298 |
val def_atom = atomize_thm def_pre_sym |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
299 |
val defs_all = add_lower_defs_aux lthy def_atom |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
300 |
in |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
301 |
map Thm.varifyT defs_all |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
302 |
end |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
303 |
*} |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
304 |
|
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
305 |
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
|
306 |
|
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
264
diff
changeset
|
307 |
ML {* |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
308 |
fun lookup_quot_data lthy qty = |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
309 |
let |
311
77fc6f3c0343
changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents:
310
diff
changeset
|
310 |
val qty_name = fst (dest_Type qty) |
314 | 311 |
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
|
312 |
(* 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
|
313 |
(* TODO: Should no longer be needed *) |
257
68bd5c2a1b96
Fixed quotdata_lookup.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
255
diff
changeset
|
314 |
val rty = Logic.unvarifyT (#rtyp quotdata) |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
315 |
val rel = #rel quotdata |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
316 |
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
|
317 |
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
|
318 |
in |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
319 |
(rty, rel, rel_refl, rel_eqv) |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
320 |
end |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
321 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
322 |
|
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
323 |
ML {* |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
324 |
fun lookup_quot_thms lthy qty_name = |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
325 |
let |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
326 |
val thy = ProofContext.theory_of lthy; |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
327 |
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
|
328 |
val reps_same = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".REPS_same") |
269 | 329 |
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
|
330 |
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
|
331 |
in |
269 | 332 |
(trans2, reps_same, absrep, quot) |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
333 |
end |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
334 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
335 |
|
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
336 |
ML {* |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
337 |
fun lookup_quot_consts defs = |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
338 |
let |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
339 |
fun dest_term (a $ b) = (a, b); |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
340 |
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
|
341 |
in |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
342 |
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
|
343 |
end |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
344 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
345 |
|
402
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
346 |
section {* Regularization *} |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
347 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
348 |
(* |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
349 |
Regularizing an rtrm means: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
350 |
- 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
|
351 |
bounded quantifiers, for example: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
352 |
\<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
|
353 |
|
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
354 |
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
|
355 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
356 |
- 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
|
357 |
by bounded abstractions: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
358 |
\<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
|
359 |
|
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
360 |
- 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
|
361 |
corresponding relations: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
362 |
A = B \<Longrightarrow> A \<approx> B |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
363 |
|
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
364 |
example with more complicated types of A, B: |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
365 |
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
|
366 |
*) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
367 |
|
404 | 368 |
ML {* |
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
369 |
(* 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
|
370 |
fun mk_resp_arg lthy (rty, qty) = |
319 | 371 |
let |
372 |
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
|
373 |
in |
334 | 374 |
if rty = qty |
375 |
then HOLogic.eq_const rty |
|
376 |
else |
|
377 |
case (rty, qty) of |
|
378 |
(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
|
379 |
if s = s' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
380 |
then let |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
384 |
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
|
385 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
386 |
else let |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
387 |
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
|
388 |
(* 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
|
389 |
(* 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
|
390 |
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
|
391 |
(* 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
|
392 |
(* 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
|
393 |
(* 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
|
394 |
(* 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
|
395 |
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
|
396 |
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
|
397 |
end |
334 | 398 |
| _ => HOLogic.eq_const dummyT |
351 | 399 |
(* 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
|
400 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
401 |
*} |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
402 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
403 |
ML {* |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
404 |
val mk_babs = Const (@{const_name "Babs"}, dummyT) |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
405 |
val mk_ball = Const (@{const_name "Ball"}, dummyT) |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
406 |
val mk_bex = Const (@{const_name "Bex"}, dummyT) |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
407 |
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
|
408 |
*} |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
409 |
|
323 | 410 |
ML {* |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
411 |
(* - applies f to the subterm of an abstraction, *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
412 |
(* otherwise to the given term, *) |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
413 |
(* - used by regularize, therefore abstracted *) |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
414 |
(* variables do not have to be treated specially *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
415 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
416 |
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
|
417 |
case (trm1, trm2) of |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
418 |
(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
|
419 |
| _ => f trm1 trm2 |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
420 |
|
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
421 |
(* the major type of All and Ex quantifiers *) |
334 | 422 |
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
|
423 |
*} |
319 | 424 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
425 |
ML {* |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
426 |
(* produces a regularized version of rtm *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
427 |
(* - the result is still not completely typed *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
428 |
(* - does not need any special treatment of *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
429 |
(* bound variables *) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
430 |
|
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
431 |
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
|
432 |
case (rtrm, qtrm) of |
325 | 433 |
(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
|
434 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
435 |
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
|
436 |
in |
325 | 437 |
if ty = ty' |
438 |
then Abs (x, ty, subtrm) |
|
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
325
diff
changeset
|
439 |
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
|
440 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
441 |
| (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
|
442 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
443 |
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
|
444 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
445 |
if ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
446 |
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
|
447 |
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
|
448 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
449 |
| (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
|
450 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
451 |
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
|
452 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
453 |
if ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
454 |
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
|
455 |
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
|
456 |
end |
351 | 457 |
(* FIXME: Should = only be replaced, when fully applied? *) |
458 |
(* 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
|
459 |
| (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
|
460 |
let |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
461 |
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
|
462 |
in |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
463 |
if ty = ty' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
464 |
then Const (@{const_name "op ="}, ty) $ subtrm |
349
f507f088de73
domain_type in regularizing equality
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
348
diff
changeset
|
465 |
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
|
466 |
end |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
467 |
| (t1 $ t2, t1' $ t2') => |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
468 |
(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
|
469 |
| (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
|
470 |
(* 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
|
471 |
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
|
472 |
| (Bound i, Bound i') => |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
473 |
if i = i' |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
474 |
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
|
475 |
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
|
476 |
| (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
|
477 |
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
|
478 |
then rtrm |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
479 |
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
|
480 |
| (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
|
481 |
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
|
482 |
*} |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
483 |
|
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
|
484 |
(* |
407
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
485 |
FIXME / TODO: needs to be adapted |
d387743f022b
tuned comments and moved slightly some code
Christian Urban <urbanc@in.tum.de>
parents:
405
diff
changeset
|
486 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
487 |
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
|
488 |
we try in order: |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
489 |
|
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
|
490 |
- 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
|
491 |
- 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
|
492 |
- 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
|
493 |
- 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
|
494 |
- 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
|
495 |
- (\<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
|
496 |
|
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
|
497 |
*) |
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
|
498 |
|
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
|
499 |
(* FIXME: they should be in in the new Isabelle *) |
404 | 500 |
lemma [mono]: |
501 |
"(\<And>x. P x \<longrightarrow> Q x) \<Longrightarrow> (Ex P) \<longrightarrow> (Ex Q)" |
|
400 | 502 |
by blast |
503 |
||
504 |
lemma [mono]: "P \<longrightarrow> Q \<Longrightarrow> \<not>Q \<longrightarrow> \<not>P" |
|
505 |
by auto |
|
506 |
||
507 |
(* FIXME: OPTION_EQUIV, PAIR_EQUIV, ... *) |
|
508 |
ML {* |
|
509 |
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
|
510 |
REPEAT_ALL_NEW (FIRST' |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
511 |
[resolve_tac rel_eqvs, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
512 |
rtac @{thm IDENTITY_EQUIV}, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
513 |
rtac @{thm LIST_EQUIV}]) |
400 | 514 |
*} |
515 |
||
516 |
ML {* |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
517 |
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
|
518 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
519 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
520 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
521 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
522 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
523 |
(ogl as ((Const (@{const_name "Ball"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
524 |
((Const (@{const_name "Respects"}, _)) $ R) $ P1)) => |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
525 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
526 |
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
|
527 |
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
|
528 |
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
|
529 |
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
|
530 |
(* 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
|
531 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
532 |
SOME thm |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
533 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
534 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
535 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
536 |
| _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
537 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
538 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
539 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
540 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
541 |
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
|
542 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
543 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
544 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
545 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
546 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
547 |
(ogl as ((Const (@{const_name "Bex"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
548 |
((Const (@{const_name "Respects"}, _)) $ R) $ P1)) => |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
549 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
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
|
554 |
(* 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
|
555 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
556 |
SOME thm |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
557 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
558 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
559 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
560 |
| _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
561 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
562 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
563 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
564 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
565 |
fun prep_trm thy (x, (T, t)) = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
566 |
(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
|
567 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
568 |
fun prep_ty thy (x, (S, ty)) = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
569 |
(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
|
570 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
571 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
572 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
573 |
fun matching_prs thy pat trm = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
574 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
575 |
val univ = Unify.matchers thy [(pat, trm)] |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
576 |
val SOME (env, _) = Seq.pull univ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
577 |
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
|
578 |
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
|
579 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
580 |
(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
|
581 |
end |
400 | 582 |
*} |
583 |
||
584 |
ML {* |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
585 |
fun ball_reg_eqv_range_simproc rel_eqvs ss redex = |
400 | 586 |
let |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
587 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
588 |
val thy = ProofContext.theory_of ctxt |
400 | 589 |
in |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
590 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
591 |
(ogl as ((Const (@{const_name "Ball"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
592 |
((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
|
593 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
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
|
598 |
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
|
599 |
val R1c = cterm_of thy R1; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
600 |
val thmi = Drule.instantiate' [] [SOME R1c] thm; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
601 |
(* 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
|
602 |
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
|
603 |
val _ = tracing "AAA"; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
604 |
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
|
605 |
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
|
606 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
607 |
SOME thm2 |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
608 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
609 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
610 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
611 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
612 |
| _ => NONE |
400 | 613 |
end |
614 |
*} |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
615 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
616 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
617 |
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
|
618 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
619 |
val ctxt = Simplifier.the_context ss |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
620 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
621 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
622 |
case redex of |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
623 |
(ogl as ((Const (@{const_name "Bex"}, _)) $ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
624 |
((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
|
625 |
(let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
626 |
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
|
627 |
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
|
628 |
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
|
629 |
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
|
630 |
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
|
631 |
val R1c = cterm_of thy R1; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
632 |
val thmi = Drule.instantiate' [] [SOME R1c] thm; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
633 |
(* 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
|
634 |
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
|
635 |
val _ = tracing "AAA"; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
636 |
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
|
637 |
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
|
638 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
639 |
SOME thm2 |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
640 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
641 |
handle _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
642 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
643 |
) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
644 |
| _ => NONE |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
645 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
646 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
647 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
648 |
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
|
649 |
by (simp add: EQUIV_REFL) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
650 |
|
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
651 |
ML {* |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
652 |
fun regularize_tac ctxt rel_eqvs = |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
653 |
let |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
654 |
val pat1 = [@{term "Ball (Respects R) P"}]; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
655 |
val pat2 = [@{term "Bex (Respects R) P"}]; |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
656 |
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
|
657 |
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
|
658 |
val thy = ProofContext.theory_of ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
659 |
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
|
660 |
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
|
661 |
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
|
662 |
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
|
663 |
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
|
664 |
(* 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
|
665 |
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
|
666 |
in |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
667 |
ObjectLogic.full_atomize_tac THEN' |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
668 |
simp_tac simp_ctxt THEN' |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
669 |
REPEAT_ALL_NEW (FIRST' [ |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
670 |
rtac @{thm ball_reg_right}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
671 |
rtac @{thm bex_reg_left}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
672 |
resolve_tac (Inductive.get_monos ctxt), |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
673 |
rtac @{thm ball_all_comm}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
674 |
rtac @{thm bex_ex_comm}, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
675 |
resolve_tac eq_eqvs, |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
676 |
simp_tac simp_ctxt |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
677 |
]) |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
678 |
end |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
679 |
*} |
390 | 680 |
|
681 |
section {* Injections of REP and ABSes *} |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
682 |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
683 |
(* |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
684 |
Injecting REPABS means: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
685 |
|
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
686 |
For abstractions: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
687 |
* 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
|
688 |
* 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
|
689 |
variable needs lifting. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
690 |
* If it doesn't then we recurse |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
691 |
* 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
|
692 |
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
|
693 |
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
|
694 |
abstraction with rewriting. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
695 |
For applications: |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
696 |
* 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
|
697 |
* 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
|
698 |
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
|
699 |
* 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
|
700 |
(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
|
701 |
put RepAbs and recurse |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
702 |
* Otherwise just recurse. |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
703 |
*) |
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
704 |
|
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
705 |
ML {* |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
706 |
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
|
707 |
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
|
708 |
$ (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
|
709 |
*} |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
710 |
|
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
711 |
ML {* |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
712 |
(* 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
|
713 |
(* 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
|
714 |
|
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
715 |
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
|
716 |
let |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
717 |
val rty = fastype_of rtrm |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
718 |
val qty = fastype_of qtrm |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
719 |
in |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
720 |
case (rtrm, qtrm) of |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
721 |
(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
|
722 |
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
|
723 |
| (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
|
724 |
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
|
725 |
| (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
|
726 |
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
|
727 |
| (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
|
728 |
let |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
729 |
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
|
730 |
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
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
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
|
735 |
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
|
736 |
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
|
737 |
end |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
738 |
| _ => |
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
|
739 |
(**************************************************) |
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
|
740 |
(* new |
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
|
741 |
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
|
742 |
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
|
743 |
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
|
744 |
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
|
745 |
in |
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
|
746 |
case (rhead, qhead, length rargs') of |
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
|
747 |
(Const (_, T), Const (_, T'), 0) => |
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
|
748 |
if T = T' |
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
|
749 |
then rhead |
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 |
else mk_repabs lthy (T, T') rhead |
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 |
| (Free (_, T), Free (_, T'), 0) => |
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 |
if T = T' |
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 |
then rhead |
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 |
else mk_repabs lthy (T, T') rhead |
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
|
755 |
| (Const (_, T), Const (_, T'), _) => (* FIXME/TODO: check this case exactly*) |
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
|
756 |
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
|
757 |
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
|
758 |
else mk_repabs lthy (rty, qty) (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 |
| (Free (x, T), Free (x', T'), _) => |
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
|
760 |
if T = T' |
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
|
761 |
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
|
762 |
else list_comb (mk_repabs lthy (T, T') 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 |
| (Abs _, Abs _, _ ) => |
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
|
764 |
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
|
765 |
| _ => 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
|
766 |
end |
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 |
*) |
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
|
768 |
|
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
|
769 |
(*************************************************) |
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
|
770 |
(* old *) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
771 |
let |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
772 |
val (rhead, rargs) = strip_comb rtrm |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
773 |
val (qhead, qargs) = strip_comb qtrm |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
774 |
val rargs' = map (inj_repabs_trm lthy) (rargs ~~ qargs) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
775 |
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
|
776 |
if rty = qty |
355
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
777 |
then |
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
778 |
case (rhead, qhead) of |
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
779 |
(Free (_, T), Free (_, T')) => |
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
780 |
if T = T' then list_comb (rhead, rargs') |
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
781 |
else list_comb (mk_repabs lthy (T, T') rhead, rargs') |
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
782 |
| _ => list_comb (rhead, rargs') |
345
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
783 |
else |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
784 |
case (rhead, qhead, length rargs') of |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
785 |
(Const _, Const _, 0) => mk_repabs lthy (rty, qty) rhead |
355
abc6bfd0576e
More fixes for inj_REPABS
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
354
diff
changeset
|
786 |
| (Free (_, T), Free (_, T'), 0) => mk_repabs lthy (T, T') rhead |
345
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
787 |
| (Const _, Const _, _) => mk_repabs lthy (rty, qty) (list_comb (rhead, rargs')) |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
788 |
| (Free (x, T), Free (x', T'), _) => |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
789 |
mk_repabs lthy (rty, qty) (list_comb (mk_repabs lthy (T, T') rhead, rargs')) |
573e2b625e8e
a version of inj_REPABS (needs to be looked at again later)
Christian Urban <urbanc@in.tum.de>
parents:
341
diff
changeset
|
790 |
| (Abs _, Abs _, _ ) => |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
791 |
mk_repabs lthy (rty, qty) (list_comb (inj_repabs_trm lthy (rhead, qhead), rargs')) |
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
|
792 |
| _ => raise (LIFT_MATCH "injection") |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
793 |
end |
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
|
794 |
(**) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
795 |
end |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
796 |
*} |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
334
diff
changeset
|
797 |
|
404 | 798 |
section {* RepAbs Injection Tactic *} |
387 | 799 |
|
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
800 |
ML {* |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
801 |
fun stripped_term_of ct = |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
802 |
ct |> term_of |> HOLogic.dest_Trueprop |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
803 |
*} |
387 | 804 |
|
805 |
ML {* |
|
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
806 |
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
|
807 |
Subgoal.FOCUS (fn {concl, ...} => |
387 | 808 |
let |
809 |
val pat = Drule.strip_imp_concl (cprop_of thm) |
|
810 |
val insts = Thm.match (pat, concl) |
|
811 |
in |
|
812 |
rtac (Drule.instantiate insts thm) 1 |
|
813 |
end |
|
814 |
handle _ => no_tac) |
|
815 |
*} |
|
816 |
||
817 |
ML {* |
|
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
818 |
fun quotient_tac quot_thms = |
420
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
819 |
REPEAT_ALL_NEW (FIRST' |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
820 |
[rtac @{thm FUN_QUOTIENT}, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
821 |
resolve_tac quot_thms, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
822 |
rtac @{thm IDENTITY_QUOTIENT}, |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
823 |
(* 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
|
824 |
(* TODO: think about the other way around, if we need to shorten the relation *) |
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
825 |
CHANGED o (simp_tac (HOL_ss addsimps @{thms id_simps}))]) |
387 | 826 |
*} |
827 |
||
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
828 |
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
|
829 |
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
|
830 |
shows "(R1 ===> R2) f g" |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
831 |
using a by (simp add: FUN_REL.simps) |
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
832 |
|
387 | 833 |
ML {* |
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
|
834 |
val lambda_res_tac = |
428 | 835 |
Subgoal.FOCUS (fn {concl, ...} => |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
836 |
case (stripped_term_of concl) of |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
837 |
(_ $ (Abs _) $ (Abs _)) => rtac @{thm FUN_REL_I} 1 |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
838 |
| _ => no_tac) |
387 | 839 |
*} |
840 |
||
841 |
ML {* |
|
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
|
842 |
val weak_lambda_res_tac = |
428 | 843 |
Subgoal.FOCUS (fn {concl, ...} => |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
844 |
case (stripped_term_of concl) of |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
845 |
(_ $ _ $ (Abs _)) => rtac @{thm FUN_REL_I} 1 |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
846 |
| (_ $ (Abs _) $ _) => rtac @{thm FUN_REL_I} 1 |
428 | 847 |
| _ => no_tac) |
387 | 848 |
*} |
849 |
||
434 | 850 |
ML {* |
851 |
val ball_rsp_tac = |
|
852 |
Subgoal.FOCUS (fn {concl, ...} => |
|
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
853 |
case (stripped_term_of concl) of |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
854 |
(_ $ (Const (@{const_name Ball}, _) $ _) |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
855 |
$ (Const (@{const_name Ball}, _) $ _)) => rtac @{thm FUN_REL_I} 1 |
434 | 856 |
|_ => no_tac) |
857 |
*} |
|
858 |
||
859 |
ML {* |
|
860 |
val bex_rsp_tac = |
|
861 |
Subgoal.FOCUS (fn {concl, context = ctxt, ...} => |
|
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
862 |
case (stripped_term_of concl) of |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
863 |
(_ $ (Const (@{const_name Bex}, _) $ _) |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
864 |
$ (Const (@{const_name Bex}, _) $ _)) => rtac @{thm FUN_REL_I} 1 |
434 | 865 |
| _ => no_tac) |
866 |
*} |
|
867 |
||
387 | 868 |
ML {* (* Legacy *) |
869 |
fun needs_lift (rty as Type (rty_s, _)) ty = |
|
870 |
case ty of |
|
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
871 |
Type (s, tys) => (s = rty_s) orelse (exists (needs_lift rty) tys) |
387 | 872 |
| _ => false |
873 |
||
874 |
*} |
|
875 |
||
876 |
ML {* |
|
424
ab6ddf2ec00c
some slight tuning of the apply-tactic
Christian Urban <urbanc@in.tum.de>
parents:
423
diff
changeset
|
877 |
fun APPLY_RSP_TAC rty = |
428 | 878 |
Subgoal.FOCUS (fn {concl, ...} => |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
879 |
case (stripped_term_of concl) of |
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
880 |
(_ $ (f $ _) $ (_ $ _)) => |
431
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
881 |
let |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
882 |
val pat = Drule.strip_imp_concl (cprop_of @{thm APPLY_RSP}); |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
883 |
val insts = Thm.match (pat, concl) |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
884 |
in |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
885 |
if needs_lift rty (fastype_of f) |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
886 |
then rtac (Drule.instantiate insts @{thm APPLY_RSP}) 1 |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
887 |
else no_tac |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
888 |
end |
5b298c42f6c8
more tuning of the repabs-tactics
Christian Urban <urbanc@in.tum.de>
parents:
429
diff
changeset
|
889 |
| _ => no_tac) |
387 | 890 |
*} |
891 |
||
892 |
ML {* |
|
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
893 |
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
|
894 |
*} |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
895 |
|
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
896 |
(* |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
897 |
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
|
898 |
we try: |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
899 |
|
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
900 |
1) theorems 'trans2' from the appropriate QUOT_TYPE |
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
|
901 |
2) remove lambdas from both sides: lambda_res_tac |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
902 |
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
|
903 |
4) use user-supplied RSP theorems |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
904 |
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
|
905 |
6) reflexivity of equality |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
906 |
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
|
907 |
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
|
908 |
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
|
909 |
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
|
910 |
B) assumption |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
911 |
(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
|
912 |
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
|
913 |
(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
|
914 |
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
|
915 |
E) simplifying (= ===> =) for simpler respectfulness |
398
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
916 |
|
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
917 |
*) |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
918 |
|
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
919 |
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
|
920 |
fun inj_repabs_tac 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
|
921 |
(FIRST' [ |
449 | 922 |
(* "cong" rule of the of the relation / transitivity*) |
923 |
(* (op =) (R a b) (R c d) ----> \<lbrakk>R a c; R b d\<rbrakk> *) |
|
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
|
924 |
NDT 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
|
925 |
|
443 | 926 |
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *) |
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
|
927 |
NDT ctxt "2" (lambda_res_tac ctxt), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
928 |
|
443 | 929 |
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
930 |
NDT ctxt "3" (rtac @{thm RES_FORALL_RSP}), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
931 |
|
443 | 932 |
(* (R1 ===> R2) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Ball\<dots>x) (Ball\<dots>y) *) |
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
933 |
NDT ctxt "4" (ball_rsp_tac ctxt), |
434 | 934 |
|
443 | 935 |
(* (op =) (Bex\<dots>) (Bex\<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
|
936 |
NDT ctxt "5" (rtac @{thm RES_EXISTS_RSP}), |
434 | 937 |
|
443 | 938 |
(* (R1 ===> R2) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Bex\<dots>x) (Bex\<dots>y) *) |
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
|
939 |
NDT ctxt "6" (bex_rsp_tac ctxt), |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
940 |
|
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
|
941 |
(* 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
|
942 |
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
|
943 |
|
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
944 |
(* 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
|
945 |
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
|
946 |
|
443 | 947 |
(* 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
|
948 |
(* observe ---> *) |
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
|
949 |
NDT ctxt "9" ((instantiate_tac @{thm REP_ABS_RSP(1)} ctxt |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
950 |
THEN' (RANGE [SOLVES' (quotient_tac 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
|
951 |
|
449 | 952 |
(* 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
|
953 |
NDT ctxt "A" ((APPLY_RSP_TAC rty ctxt THEN' |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
954 |
(RANGE [SOLVES' (quotient_tac quot_thms), SOLVES' (quotient_tac 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
|
955 |
|
449 | 956 |
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *) |
444 | 957 |
(* 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
|
958 |
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
|
959 |
|
443 | 960 |
(* (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
|
961 |
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
|
962 |
|
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
963 |
(* reflexivity of the basic relations *) |
449 | 964 |
(* 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
|
965 |
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
|
966 |
|
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
967 |
(* 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
|
968 |
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
|
969 |
|
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
|
970 |
(* seems not necessay:: NDT ctxt "F" (SOLVES' (simp_tac (HOL_ss addsimps @{thms FUN_REL.simps}))),*) |
443 | 971 |
|
972 |
(* (R1 ===> R2) (\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *) |
|
973 |
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *) |
|
448
24fa145fc2e3
improved pattern matching inside the inj_repabs_tacs
Christian Urban <urbanc@in.tum.de>
parents:
447
diff
changeset
|
974 |
(*NDT ctxt "G" (weak_lambda_res_tac ctxt),*) |
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
|
975 |
|
443 | 976 |
(* (op =) ===> (op =) \<Longrightarrow> (op =), needed in order to apply respectfulness theorems *) |
977 |
(* global simplification *) |
|
452
7ba2c16fe0c8
Removed unnecessary HOL_ss which proved one of the subgoals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
451
diff
changeset
|
978 |
NDT ctxt "H" (CHANGED o (asm_full_simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms eq_reflection[OF FUN_REL_EQ]})))]) |
443 | 979 |
*} |
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
parents:
420
diff
changeset
|
980 |
|
443 | 981 |
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
|
982 |
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
|
983 |
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
|
984 |
*} |
fafcc54e531d
some diagnostic code for r_mk_comb
Christian Urban <urbanc@in.tum.de>
parents:
391
diff
changeset
|
985 |
|
387 | 986 |
|
399 | 987 |
section {* Cleaning of the theorem *} |
387 | 988 |
|
389 | 989 |
ML {* |
990 |
fun applic_prs lthy absrep (rty, qty) = |
|
991 |
let |
|
992 |
fun mk_rep (T, T') tm = (Quotient_Def.get_fun repF lthy (T, T')) $ tm; |
|
993 |
fun mk_abs (T, T') tm = (Quotient_Def.get_fun absF lthy (T, T')) $ tm; |
|
994 |
val (raty, rgty) = Term.strip_type rty; |
|
995 |
val (qaty, qgty) = Term.strip_type qty; |
|
996 |
val vs = map (fn _ => "x") qaty; |
|
997 |
val ((fname :: vfs), lthy') = Variable.variant_fixes ("f" :: vs) lthy; |
|
998 |
val f = Free (fname, qaty ---> qgty); |
|
999 |
val args = map Free (vfs ~~ qaty); |
|
1000 |
val rhs = list_comb(f, args); |
|
1001 |
val largs = map2 mk_rep (raty ~~ qaty) args; |
|
1002 |
val lhs = mk_abs (rgty, qgty) (list_comb((mk_rep (raty ---> rgty, qaty ---> qgty) f), largs)); |
|
1003 |
val llhs = Syntax.check_term lthy lhs; |
|
1004 |
val eq = Logic.mk_equals (llhs, rhs); |
|
1005 |
val ceq = cterm_of (ProofContext.theory_of lthy') eq; |
|
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1006 |
val sctxt = HOL_ss addsimps (@{thms fun_map.simps id_simps} @ absrep); |
389 | 1007 |
val t = Goal.prove_internal [] ceq (fn _ => simp_tac sctxt 1) |
415
5a9bdf81672d
More cleaning in QuotMain, identity handling.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
413
diff
changeset
|
1008 |
val t_id = MetaSimplifier.rewrite_rule @{thms id_simps} t; |
389 | 1009 |
in |
1010 |
singleton (ProofContext.export lthy' lthy) t_id |
|
1011 |
end |
|
1012 |
*} |
|
387 | 1013 |
|
1014 |
ML {* |
|
389 | 1015 |
fun find_aps_all rtm qtm = |
1016 |
case (rtm, qtm) of |
|
1017 |
(Abs(_, T1, s1), Abs(_, T2, s2)) => |
|
1018 |
find_aps_all (subst_bound ((Free ("x", T1)), s1)) (subst_bound ((Free ("x", T2)), s2)) |
|
1019 |
| (((f1 as (Free (_, T1))) $ a1), ((f2 as (Free (_, T2))) $ a2)) => |
|
1020 |
let |
|
1021 |
val sub = (find_aps_all f1 f2) @ (find_aps_all a1 a2) |
|
1022 |
in |
|
1023 |
if T1 = T2 then sub else (T1, T2) :: sub |
|
1024 |
end |
|
1025 |
| ((f1 $ a1), (f2 $ a2)) => (find_aps_all f1 f2) @ (find_aps_all a1 a2) |
|
1026 |
| _ => []; |
|
1027 |
||
1028 |
fun find_aps rtm qtm = distinct (op =) (find_aps_all rtm qtm) |
|
1029 |
*} |
|
1030 |
||
1031 |
ML {* |
|
387 | 1032 |
fun allex_prs_tac lthy quot = |
1033 |
(EqSubst.eqsubst_tac lthy [0] @{thms FORALL_PRS[symmetric] EXISTS_PRS[symmetric]}) |
|
420
dcfe009c98aa
replaced FIRST' (map rtac list) with resolve_tac list
Christian Urban <urbanc@in.tum.de>
parents:
419
diff
changeset
|
1034 |
THEN' (quotient_tac quot) |
387 | 1035 |
*} |
1036 |
||
426 | 1037 |
(* Rewrites the term with LAMBDA_PRS thm. |
1038 |
||
1039 |
Replaces: (Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) |
|
1040 |
with: f |
|
1041 |
||
1042 |
It proves the QUOTIENT assumptions by calling quotient_tac |
|
1043 |
*) |
|
387 | 1044 |
ML {* |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1045 |
fun make_inst lhs t = |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1046 |
let |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1047 |
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
|
1048 |
val _ $ (Abs (_, _, g)) = t; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1049 |
fun mk_abs i t = |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1050 |
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
|
1051 |
else (case t of |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1052 |
t1 $ t2 => mk_abs i t1 $ mk_abs i t2 |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1053 |
| Abs (s, T, t') => Abs (s, T, mk_abs (i+1) t') |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1054 |
| 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
|
1055 |
| _ => t); |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1056 |
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
|
1057 |
|
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1058 |
fun lambda_prs_conv1 ctxt quot_thms ctrm = |
387 | 1059 |
case (term_of ctrm) of ((Const (@{const_name "fun_map"}, _) $ r1 $ a2) $ (Abs _)) => |
1060 |
let |
|
1061 |
val (_, [ty_b, ty_a]) = dest_Type (fastype_of r1); |
|
1062 |
val (_, [ty_c, ty_d]) = dest_Type (fastype_of a2); |
|
1063 |
val thy = ProofContext.theory_of ctxt; |
|
1064 |
val [cty_a, cty_b, cty_c, cty_d] = map (ctyp_of thy) [ty_a, ty_b, ty_c, ty_d] |
|
1065 |
val tyinst = [SOME cty_a, SOME cty_b, SOME cty_c, SOME cty_d]; |
|
1066 |
val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)] |
|
1067 |
val lpi = Drule.instantiate' tyinst tinst @{thm LAMBDA_PRS}; |
|
1068 |
val tac = |
|
1069 |
(compose_tac (false, lpi, 2)) THEN_ALL_NEW |
|
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1070 |
(quotient_tac quot_thms); |
387 | 1071 |
val gc = Drule.strip_imp_concl (cprop_of lpi); |
1072 |
val t = Goal.prove_internal [] gc (fn _ => tac 1) |
|
1073 |
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
|
1074 |
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
|
1075 |
val tl = Thm.lhs_of ts; |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1076 |
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
|
1077 |
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
|
1078 |
(* val _ = writeln (Syntax.string_of_term @{context} (term_of (cprop_of ti)));*) |
387 | 1079 |
in |
1080 |
Conv.rewr_conv ti ctrm |
|
1081 |
end |
|
1082 |
*} |
|
1083 |
||
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1084 |
(* quot stands for the QUOTIENT theorems: *) |
387 | 1085 |
(* could be potentially all of them *) |
1086 |
ML {* |
|
1087 |
fun lambda_prs_conv ctxt quot ctrm = |
|
1088 |
case (term_of ctrm) of |
|
1089 |
(Const (@{const_name "fun_map"}, _) $ _ $ _) $ (Abs _) => |
|
1090 |
(Conv.arg_conv (Conv.abs_conv (fn (_, ctxt) => lambda_prs_conv ctxt quot) ctxt) |
|
1091 |
then_conv (lambda_prs_conv1 ctxt quot)) ctrm |
|
1092 |
| _ $ _ => Conv.comb_conv (lambda_prs_conv ctxt quot) ctrm |
|
1093 |
| Abs _ => Conv.abs_conv (fn (_, ctxt) => lambda_prs_conv ctxt quot) ctxt ctrm |
|
1094 |
| _ => Conv.all_conv ctrm |
|
1095 |
*} |
|
1096 |
||
1097 |
ML {* |
|
1098 |
fun lambda_prs_tac ctxt quot = CSUBGOAL (fn (goal, i) => |
|
1099 |
CONVERSION |
|
1100 |
(Conv.params_conv ~1 (fn ctxt => |
|
1101 |
(Conv.prems_conv ~1 (lambda_prs_conv ctxt quot) then_conv |
|
1102 |
Conv.concl_conv ~1 (lambda_prs_conv ctxt quot))) ctxt) i) |
|
1103 |
*} |
|
1104 |
||
457 | 1105 |
(* |
1106 |
Cleaning the theorem consists of 5 kinds of rewrites. |
|
1107 |
These rewrites can be done independently and in any order. |
|
1108 |
||
1109 |
- LAMBDA_PRS: |
|
1110 |
(Rep1 ---> Abs2) (\<lambda>x. Rep2 (?f (Abs1 x))) \<equiv> ?f |
|
1111 |
- Rewriting with definitions from the argument defs |
|
1112 |
(Abs) OldConst (Rep Args) \<equiv> NewConst Args |
|
1113 |
- QUOTIENT_REL_REP: |
|
1114 |
Rel (Rep x) (Rep y) \<equiv> x = y |
|
1115 |
- FORALL_PRS (and the same for exists: EXISTS_PRS) |
|
1116 |
\<forall>x\<in>Respects R. (abs ---> id) ?f \<equiv> \<forall>x. ?f |
|
1117 |
- applic_prs |
|
1118 |
Abs1 ((Abs2 --> Rep1) f (Rep2 args)) \<equiv> f args |
|
1119 |
||
1120 |
The first one is implemented as a conversion (fast). |
|
1121 |
The second and third one are a simp_tac (fast). |
|
1122 |
The last two are EqSubst (slow). |
|
1123 |
*) |
|
387 | 1124 |
ML {* |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1125 |
fun clean_tac lthy quot defs aps = |
387 | 1126 |
let |
1127 |
val lower = flat (map (add_lower_defs lthy) defs) |
|
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1128 |
val meta_lower = map (fn x => @{thm eq_reflection} OF [x]) lower |
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1129 |
val absrep = map (fn x => @{thm QUOTIENT_ABS_REP} OF [x]) quot |
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
415
diff
changeset
|
1130 |
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
|
1131 |
val meta_reps_same = map (fn x => @{thm eq_reflection} OF [x]) reps_same |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1132 |
val simp_ctxt = (Simplifier.context lthy empty_ss) addsimps (meta_reps_same @ meta_lower) |
389 | 1133 |
val aps_thms = map (applic_prs lthy absrep) aps |
387 | 1134 |
in |
440
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1135 |
EVERY' [lambda_prs_tac lthy quot, |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1136 |
TRY o simp_tac simp_ctxt, |
0af649448a11
Moved fast instantiation to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
436
diff
changeset
|
1137 |
TRY o REPEAT_ALL_NEW (allex_prs_tac lthy quot), |
389 | 1138 |
TRY o REPEAT_ALL_NEW (EqSubst.eqsubst_tac lthy [0] aps_thms), |
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
|
1139 |
TRY o rtac refl] |
387 | 1140 |
end |
1141 |
*} |
|
381
991db758a72d
More moving from QuotMain to UnusedQuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
379
diff
changeset
|
1142 |
|
404 | 1143 |
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
|
1144 |
|
7e82493c6253
Finished temporary goal-directed lift_theorem wrapper.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
346
diff
changeset
|
1145 |
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
|
1146 |
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
|
1147 |
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
|
1148 |
|
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
|
1149 |
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
|
1150 |
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
|
1151 |
|
412 | 1152 |
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
|
1153 |
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
|
1154 |
|
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
parents:
410
diff
changeset
|
1155 |
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
|
1156 |
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop |
362 | 1157 |
|
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
|
1158 |
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
|
1159 |
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
|
1160 |
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
|
1161 |
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
|
1162 |
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
|
1163 |
val cvrs = map (cterm_of thy o Free) vrs |
412 | 1164 |
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
|
1165 |
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
|
1166 |
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
|
1167 |
(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
|
1168 |
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
|
1169 |
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
|
1170 |
end) |
362 | 1171 |
*} |
1172 |
||
402
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
1173 |
section {* General outline of the lifting procedure *} |
dd64cca9265c
recommited changes of comments
Christian Urban <urbanc@in.tum.de>
parents:
401
diff
changeset
|
1174 |
|
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1175 |
(* - A is the original raw theorem *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1176 |
(* - B is the regularized theorem *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1177 |
(* - 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
|
1178 |
(* - D is the lifted theorem *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1179 |
(* *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1180 |
(* - b is the regularization step *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1181 |
(* - c is the rep/abs injection step *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1182 |
(* - d is the cleaning part *) |
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1183 |
|
413 | 1184 |
lemma lifting_procedure: |
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1185 |
assumes a: "A" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1186 |
and b: "A \<Longrightarrow> B" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1187 |
and c: "B = C" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1188 |
and d: "C = D" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1189 |
shows "D" |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1190 |
using a b c d |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1191 |
by simp |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1192 |
|
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
|
1193 |
ML {* |
412 | 1194 |
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
|
1195 |
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
|
1196 |
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
|
1197 |
val qtrm_str = Syntax.string_of_term ctxt qtrm |
388 | 1198 |
val msg = [enclose "[" "]" fun_str, "The quotient theorem\n", qtrm_str, |
1199 |
"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
|
1200 |
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
|
1201 |
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
|
1202 |
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
|
1203 |
*} |
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
|
1204 |
|
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1205 |
ML {* |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1206 |
fun procedure_inst ctxt rtrm qtrm = |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1207 |
let |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1208 |
val thy = ProofContext.theory_of ctxt |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1209 |
val rtrm' = HOLogic.dest_Trueprop rtrm |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1210 |
val qtrm' = HOLogic.dest_Trueprop qtrm |
383
73a3670fb00e
comments tuning and slight reordering
Christian Urban <urbanc@in.tum.de>
parents:
382
diff
changeset
|
1211 |
val reg_goal = |
405
8bc7428745ad
renamed REGULARIZE to be regularize
Christian Urban <urbanc@in.tum.de>
parents:
404
diff
changeset
|
1212 |
Syntax.check_term ctxt (regularize_trm ctxt rtrm' qtrm') |
412 | 1213 |
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
|
1214 |
val inj_goal = |
408
1056861b562c
renamed inj_REPABS to inj_repabs_trm
Christian Urban <urbanc@in.tum.de>
parents:
407
diff
changeset
|
1215 |
Syntax.check_term ctxt (inj_repabs_trm ctxt (reg_goal, qtrm')) |
412 | 1216 |
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
|
1217 |
in |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1218 |
Drule.instantiate' [] |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1219 |
[SOME (cterm_of thy rtrm'), |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1220 |
SOME (cterm_of thy reg_goal), |
413 | 1221 |
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
|
1222 |
end |
362 | 1223 |
*} |
389 | 1224 |
|
1225 |
(* Left for debugging *) |
|
362 | 1226 |
ML {* |
389 | 1227 |
fun procedure_tac lthy rthm = |
1228 |
ObjectLogic.full_atomize_tac |
|
1229 |
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
|
1230 |
THEN' Subgoal.FOCUS (fn {context, concl, ...} => |
389 | 1231 |
let |
1232 |
val rthm' = atomize_thm rthm |
|
1233 |
val rule = procedure_inst context (prop_of rthm') (term_of concl) |
|
1234 |
in |
|
412 | 1235 |
EVERY1 [rtac rule, rtac rthm'] |
1236 |
end) lthy |
|
360
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1237 |
*} |
07fb696efa3d
Moved cleaning to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
359
diff
changeset
|
1238 |
|
361 | 1239 |
ML {* |
413 | 1240 |
(* 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
|
1241 |
fun lift_tac lthy rthm rel_eqv rty quot defs = |
389 | 1242 |
ObjectLogic.full_atomize_tac |
1243 |
THEN' gen_frees_tac lthy |
|
1244 |
THEN' Subgoal.FOCUS (fn {context, concl, ...} => |
|
1245 |
let |
|
1246 |
val rthm' = atomize_thm rthm |
|
1247 |
val rule = procedure_inst context (prop_of rthm') (term_of concl) |
|
1248 |
val aps = find_aps (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
|
1249 |
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
|
1250 |
val trans2 = map (fn x => @{thm equiv_trans2} OF [x]) rel_eqv |
389 | 1251 |
in |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1252 |
EVERY1 |
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1253 |
[rtac rule, |
413 | 1254 |
RANGE [rtac rthm', |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1255 |
regularize_tac lthy rel_eqv, |
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
parents:
449
diff
changeset
|
1256 |
all_inj_repabs_tac lthy rty quot rel_refl trans2, |
432
9c33c0809733
Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
427
diff
changeset
|
1257 |
clean_tac lthy quot defs aps]] |
412 | 1258 |
end) lthy |
361 | 1259 |
*} |
1260 |
||
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
1261 |
end |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
236
diff
changeset
|
1262 |
|
347
7e82493c6253
Finished temporary goal-directed lift_theorem wrapper.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
346
diff
changeset
|
1263 |