author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Fri, 11 Dec 2009 17:19:38 +0100 | |
changeset 719 | a9e55e1ef64c |
parent 715 | 3d7a9d4d2bb6 |
child 720 | e68f501f76d0 |
permissions | -rw-r--r-- |
597 | 1 |
theory QuotMain |
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
2 |
imports QuotScript Prove |
597 | 3 |
uses ("quotient_info.ML") |
4 |
("quotient.ML") |
|
5 |
("quotient_def.ML") |
|
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 equivp: "equivp 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)" |
|
17 |
begin |
|
18 |
||
19 |
definition |
|
719 | 20 |
abs::"'a \<Rightarrow> 'b" |
597 | 21 |
where |
719 | 22 |
"abs x \<equiv> Abs (R x)" |
597 | 23 |
|
24 |
definition |
|
719 | 25 |
rep::"'b \<Rightarrow> 'a" |
597 | 26 |
where |
719 | 27 |
"rep a = Eps (Rep a)" |
597 | 28 |
|
29 |
lemma lem9: |
|
30 |
shows "R (Eps (R x)) = R x" |
|
31 |
proof - |
|
32 |
have a: "R x x" using equivp by (simp add: equivp_reflp_symp_transp reflp_def) |
|
33 |
then have "R x (Eps (R x))" by (rule someI) |
|
34 |
then show "R (Eps (R x)) = R x" |
|
35 |
using equivp unfolding equivp_def by simp |
|
36 |
qed |
|
37 |
||
38 |
theorem thm10: |
|
719 | 39 |
shows "abs (rep a) \<equiv> a" |
597 | 40 |
apply (rule eq_reflection) |
719 | 41 |
unfolding abs_def rep_def |
597 | 42 |
proof - |
43 |
from rep_prop |
|
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 |
||
719 | 53 |
lemma rep_refl: |
54 |
shows "R (rep a) (rep a)" |
|
55 |
unfolding rep_def |
|
597 | 56 |
by (simp add: equivp[simplified equivp_def]) |
57 |
||
58 |
lemma lem7: |
|
59 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
|
60 |
apply(rule iffI) |
|
61 |
apply(simp) |
|
62 |
apply(drule rep_inject[THEN iffD2]) |
|
63 |
apply(simp add: abs_inverse) |
|
64 |
done |
|
65 |
||
66 |
theorem thm11: |
|
719 | 67 |
shows "R r r' = (abs r = abs r')" |
68 |
unfolding abs_def |
|
597 | 69 |
by (simp only: equivp[simplified equivp_def] lem7) |
70 |
||
71 |
||
719 | 72 |
lemma rep_abs_rsp: |
73 |
shows "R f (rep (abs g)) = R f g" |
|
74 |
and "R (rep (abs g)) f = R g f" |
|
597 | 75 |
by (simp_all add: thm10 thm11) |
76 |
||
77 |
lemma Quotient: |
|
719 | 78 |
"Quotient R abs rep" |
597 | 79 |
apply(unfold Quotient_def) |
80 |
apply(simp add: thm10) |
|
719 | 81 |
apply(simp add: rep_refl) |
597 | 82 |
apply(subst thm11[symmetric]) |
83 |
apply(simp add: equivp[simplified equivp_def]) |
|
84 |
done |
|
85 |
||
86 |
end |
|
87 |
||
88 |
section {* type definition for the quotient type *} |
|
89 |
||
90 |
(* the auxiliary data for the quotient types *) |
|
91 |
use "quotient_info.ML" |
|
92 |
||
699
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
93 |
ML {* print_mapsinfo @{context} *} |
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
94 |
|
597 | 95 |
declare [[map "fun" = (fun_map, fun_rel)]] |
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
96 |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
97 |
lemmas [quot_thm] = fun_quotient |
597 | 98 |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
99 |
lemmas [quot_respect] = quot_rel_rsp |
597 | 100 |
|
101 |
(* fun_map is not here since equivp is not true *) |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
102 |
lemmas [quot_equiv] = identity_equivp |
597 | 103 |
|
104 |
(* definition of the quotient types *) |
|
105 |
(* FIXME: should be called quotient_typ.ML *) |
|
106 |
use "quotient.ML" |
|
107 |
||
108 |
(* lifting of constants *) |
|
109 |
use "quotient_def.ML" |
|
110 |
||
111 |
section {* Simset setup *} |
|
112 |
||
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
113 |
(* Since HOL_basic_ss is too "big" for us, *) |
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
114 |
(* we set up our own minimal simpset. *) |
597 | 115 |
ML {* |
116 |
fun mk_minimal_ss ctxt = |
|
117 |
Simplifier.context ctxt empty_ss |
|
118 |
setsubgoaler asm_simp_tac |
|
119 |
setmksimps (mksimps []) |
|
120 |
*} |
|
121 |
||
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
122 |
ML {* |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
123 |
fun OF1 thm1 thm2 = thm2 RS thm1 |
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
124 |
*} |
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
125 |
|
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
126 |
section {* Atomize Infrastructure *} |
597 | 127 |
|
128 |
lemma atomize_eqv[atomize]: |
|
129 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
|
130 |
proof |
|
131 |
assume "A \<equiv> B" |
|
132 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
|
133 |
next |
|
134 |
assume *: "Trueprop A \<equiv> Trueprop B" |
|
135 |
have "A = B" |
|
136 |
proof (cases A) |
|
137 |
case True |
|
138 |
have "A" by fact |
|
139 |
then show "A = B" using * by simp |
|
140 |
next |
|
141 |
case False |
|
142 |
have "\<not>A" by fact |
|
143 |
then show "A = B" using * by auto |
|
144 |
qed |
|
145 |
then show "A \<equiv> B" by (rule eq_reflection) |
|
146 |
qed |
|
147 |
||
148 |
ML {* |
|
149 |
fun atomize_thm thm = |
|
150 |
let |
|
151 |
val thm' = Thm.freezeT (forall_intr_vars thm) |
|
152 |
val thm'' = ObjectLogic.atomize (cprop_of thm') |
|
153 |
in |
|
154 |
@{thm equal_elim_rule1} OF [thm'', thm'] |
|
155 |
end |
|
156 |
*} |
|
157 |
||
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
158 |
section {* Infrastructure about id *} |
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
159 |
|
668 | 160 |
lemmas [id_simps] = |
597 | 161 |
fun_map_id[THEN eq_reflection] |
162 |
id_apply[THEN eq_reflection] |
|
163 |
id_def[THEN eq_reflection,symmetric] |
|
164 |
||
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
165 |
section {* Matching of Terms and Types *} |
597 | 166 |
|
167 |
ML {* |
|
665 | 168 |
fun struct_match_typ (ty, ty') = |
597 | 169 |
case (ty, ty') of |
170 |
(_, TVar _) => true |
|
171 |
| (TFree x, TFree x') => x = x' |
|
172 |
| (Type (s, tys), Type (s', tys')) => |
|
173 |
s = s' andalso |
|
174 |
if (length tys = length tys') |
|
665 | 175 |
then (List.all struct_match_typ (tys ~~ tys')) |
597 | 176 |
else false |
177 |
| _ => false |
|
178 |
||
665 | 179 |
fun struct_match_term (trm, trm') = |
597 | 180 |
case (trm, trm') of |
181 |
(_, Var _) => true |
|
665 | 182 |
| (Const (s, ty), Const (s', ty')) => s = s' andalso struct_match_typ (ty, ty') |
183 |
| (Free (x, ty), Free (x', ty')) => x = x' andalso struct_match_typ (ty, ty') |
|
597 | 184 |
| (Bound i, Bound j) => i = j |
665 | 185 |
| (Abs (_, T, t), Abs (_, T', t')) => struct_match_typ (T, T') andalso struct_match_term (t, t') |
186 |
| (t $ s, t' $ s') => struct_match_term (t, t') andalso struct_match_term (s, s') |
|
597 | 187 |
| _ => false |
188 |
*} |
|
189 |
||
612 | 190 |
section {* Computation of the Regularize Goal *} |
597 | 191 |
|
192 |
(* |
|
193 |
Regularizing an rtrm means: |
|
194 |
- quantifiers over a type that needs lifting are replaced by |
|
195 |
bounded quantifiers, for example: |
|
196 |
\<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P |
|
197 |
||
198 |
the relation R is given by the rty and qty; |
|
199 |
||
200 |
- abstractions over a type that needs lifting are replaced |
|
201 |
by bounded abstractions: |
|
202 |
\<lambda>x. P \<Longrightarrow> Ball (Respects R) (\<lambda>x. P) |
|
203 |
||
204 |
- equalities over the type being lifted are replaced by |
|
205 |
corresponding relations: |
|
206 |
A = B \<Longrightarrow> A \<approx> B |
|
207 |
||
208 |
example with more complicated types of A, B: |
|
209 |
A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B |
|
210 |
*) |
|
211 |
||
212 |
ML {* |
|
213 |
(* builds the relation that is the argument of respects *) |
|
214 |
fun mk_resp_arg lthy (rty, qty) = |
|
215 |
let |
|
216 |
val thy = ProofContext.theory_of lthy |
|
217 |
in |
|
218 |
if rty = qty |
|
219 |
then HOLogic.eq_const rty |
|
220 |
else |
|
221 |
case (rty, qty) of |
|
222 |
(Type (s, tys), Type (s', tys')) => |
|
223 |
if s = s' |
|
224 |
then let |
|
225 |
val SOME map_info = maps_lookup thy s |
|
226 |
val args = map (mk_resp_arg lthy) (tys ~~ tys') |
|
227 |
in |
|
228 |
list_comb (Const (#relfun map_info, dummyT), args) |
|
229 |
end |
|
230 |
else let |
|
231 |
val SOME qinfo = quotdata_lookup_thy thy s' |
|
232 |
(* FIXME: check in this case that the rty and qty *) |
|
233 |
(* FIXME: correspond to each other *) |
|
234 |
val (s, _) = dest_Const (#rel qinfo) |
|
235 |
(* FIXME: the relation should only be the string *) |
|
236 |
(* FIXME: and the type needs to be calculated as below; *) |
|
237 |
(* FIXME: maybe one should actually have a term *) |
|
238 |
(* FIXME: and one needs to force it to have this type *) |
|
239 |
in |
|
240 |
Const (s, rty --> rty --> @{typ bool}) |
|
241 |
end |
|
242 |
| _ => HOLogic.eq_const dummyT |
|
243 |
(* FIXME: check that the types correspond to each other? *) |
|
244 |
end |
|
245 |
*} |
|
246 |
||
247 |
ML {* |
|
248 |
val mk_babs = Const (@{const_name Babs}, dummyT) |
|
249 |
val mk_ball = Const (@{const_name Ball}, dummyT) |
|
250 |
val mk_bex = Const (@{const_name Bex}, dummyT) |
|
251 |
val mk_resp = Const (@{const_name Respects}, dummyT) |
|
252 |
*} |
|
253 |
||
254 |
ML {* |
|
255 |
(* - applies f to the subterm of an abstraction, *) |
|
256 |
(* otherwise to the given term, *) |
|
257 |
(* - used by regularize, therefore abstracted *) |
|
258 |
(* variables do not have to be treated specially *) |
|
259 |
||
260 |
fun apply_subt f trm1 trm2 = |
|
261 |
case (trm1, trm2) of |
|
262 |
(Abs (x, T, t), Abs (x', T', t')) => Abs (x, T, f t t') |
|
263 |
| _ => f trm1 trm2 |
|
264 |
||
265 |
(* the major type of All and Ex quantifiers *) |
|
266 |
fun qnt_typ ty = domain_type (domain_type ty) |
|
267 |
*} |
|
268 |
||
269 |
ML {* |
|
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
270 |
(* produces a regularized version of rtrm *) |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
271 |
(* - the result is contains dummyT *) |
597 | 272 |
(* - does not need any special treatment of *) |
273 |
(* bound variables *) |
|
274 |
||
275 |
fun regularize_trm lthy rtrm qtrm = |
|
276 |
case (rtrm, qtrm) of |
|
277 |
(Abs (x, ty, t), Abs (x', ty', t')) => |
|
278 |
let |
|
279 |
val subtrm = Abs(x, ty, regularize_trm lthy t t') |
|
280 |
in |
|
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
281 |
if ty = ty' then subtrm |
597 | 282 |
else mk_babs $ (mk_resp $ mk_resp_arg lthy (ty, ty')) $ subtrm |
283 |
end |
|
284 |
||
285 |
| (Const (@{const_name "All"}, ty) $ t, Const (@{const_name "All"}, ty') $ t') => |
|
286 |
let |
|
287 |
val subtrm = apply_subt (regularize_trm lthy) t t' |
|
288 |
in |
|
655 | 289 |
if ty = ty' then Const (@{const_name "All"}, ty) $ subtrm |
597 | 290 |
else mk_ball $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm |
291 |
end |
|
292 |
||
293 |
| (Const (@{const_name "Ex"}, ty) $ t, Const (@{const_name "Ex"}, ty') $ t') => |
|
294 |
let |
|
295 |
val subtrm = apply_subt (regularize_trm lthy) t t' |
|
296 |
in |
|
655 | 297 |
if ty = ty' then Const (@{const_name "Ex"}, ty) $ subtrm |
597 | 298 |
else mk_bex $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm |
299 |
end |
|
300 |
||
301 |
| (* equalities need to be replaced by appropriate equivalence relations *) |
|
302 |
(Const (@{const_name "op ="}, ty), Const (@{const_name "op ="}, ty')) => |
|
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
303 |
if ty = ty' then rtrm |
597 | 304 |
else mk_resp_arg lthy (domain_type ty, domain_type ty') |
305 |
||
306 |
| (* in this case we check whether the given equivalence relation is correct *) |
|
307 |
(rel, Const (@{const_name "op ="}, ty')) => |
|
308 |
let |
|
309 |
val exc = LIFT_MATCH "regularise (relation mismatch)" |
|
310 |
val rel_ty = (fastype_of rel) handle TERM _ => raise exc |
|
311 |
val rel' = mk_resp_arg lthy (domain_type rel_ty, domain_type ty') |
|
312 |
in |
|
655 | 313 |
if rel' = rel then rtrm else raise exc |
597 | 314 |
end |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
315 |
| (_, Const (s, Type(st, _))) => |
597 | 316 |
let |
317 |
fun same_name (Const (s, _)) (Const (s', _)) = (s = s') |
|
318 |
| same_name _ _ = false |
|
319 |
in |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
320 |
(* TODO/FIXME: This test is not enough *) |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
321 |
if same_name rtrm qtrm then rtrm |
597 | 322 |
else |
323 |
let |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
324 |
val exc1 = LIFT_MATCH ("regularize (constant " ^ s ^ "(" ^ st ^ ") not found)") |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
325 |
val exc2 = LIFT_MATCH ("regularize (constant " ^ s ^ "(" ^ st ^ ") mismatch)") |
597 | 326 |
val thy = ProofContext.theory_of lthy |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
327 |
val rtrm' = (#rconst (qconsts_lookup thy qtrm)) handle NotFound => raise exc1 |
597 | 328 |
in |
665 | 329 |
if struct_match_term (rtrm, rtrm') then rtrm else |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
330 |
let |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
331 |
val _ = tracing (Syntax.string_of_term @{context} rtrm); |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
332 |
val _ = tracing (Syntax.string_of_term @{context} rtrm'); |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
333 |
in raise exc2 end |
597 | 334 |
end |
335 |
end |
|
336 |
||
337 |
| (t1 $ t2, t1' $ t2') => |
|
338 |
(regularize_trm lthy t1 t1') $ (regularize_trm lthy t2 t2') |
|
339 |
||
340 |
| (Free (x, ty), Free (x', ty')) => |
|
341 |
(* this case cannot arrise as we start with two fully atomized terms *) |
|
342 |
raise (LIFT_MATCH "regularize (frees)") |
|
343 |
||
344 |
| (Bound i, Bound i') => |
|
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
345 |
if i = i' then rtrm |
597 | 346 |
else raise (LIFT_MATCH "regularize (bounds mismatch)") |
347 |
||
348 |
| (rt, qt) => |
|
695
2eba169533b5
Found the problem with ttt3.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
694
diff
changeset
|
349 |
let val (rts, qts) = (Syntax.string_of_term lthy rt, Syntax.string_of_term lthy qt) in |
2eba169533b5
Found the problem with ttt3.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
694
diff
changeset
|
350 |
raise (LIFT_MATCH ("regularize failed (default: " ^ rts ^ "," ^ qts ^ ")")) |
2eba169533b5
Found the problem with ttt3.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
694
diff
changeset
|
351 |
end |
597 | 352 |
*} |
353 |
||
612 | 354 |
section {* Regularize Tactic *} |
355 |
||
597 | 356 |
ML {* |
357 |
fun equiv_tac ctxt = |
|
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
358 |
REPEAT_ALL_NEW (resolve_tac (equiv_rules_get ctxt)) |
597 | 359 |
|
360 |
fun equiv_solver_tac ss = equiv_tac (Simplifier.the_context ss) |
|
361 |
val equiv_solver = Simplifier.mk_solver' "Equivalence goal solver" equiv_solver_tac |
|
362 |
*} |
|
363 |
||
364 |
ML {* |
|
365 |
fun prep_trm thy (x, (T, t)) = |
|
366 |
(cterm_of thy (Var (x, T)), cterm_of thy t) |
|
367 |
||
368 |
fun prep_ty thy (x, (S, ty)) = |
|
369 |
(ctyp_of thy (TVar (x, S)), ctyp_of thy ty) |
|
370 |
*} |
|
371 |
||
372 |
ML {* |
|
373 |
fun matching_prs thy pat trm = |
|
374 |
let |
|
375 |
val univ = Unify.matchers thy [(pat, trm)] |
|
376 |
val SOME (env, _) = Seq.pull univ |
|
377 |
val tenv = Vartab.dest (Envir.term_env env) |
|
378 |
val tyenv = Vartab.dest (Envir.type_env env) |
|
379 |
in |
|
380 |
(map (prep_ty thy) tyenv, map (prep_trm thy) tenv) |
|
381 |
end |
|
382 |
*} |
|
383 |
||
384 |
ML {* |
|
385 |
fun calculate_instance ctxt thm redex R1 R2 = |
|
386 |
let |
|
387 |
val thy = ProofContext.theory_of ctxt |
|
388 |
val goal = Const (@{const_name "equivp"}, dummyT) $ R2 |
|
389 |
|> Syntax.check_term ctxt |
|
390 |
|> HOLogic.mk_Trueprop |
|
391 |
val eqv_prem = Goal.prove ctxt [] [] goal (fn {context,...} => equiv_tac context 1) |
|
392 |
val thm = (@{thm eq_reflection} OF [thm OF [eqv_prem]]) |
|
393 |
val R1c = cterm_of thy R1 |
|
394 |
val thmi = Drule.instantiate' [] [SOME R1c] thm |
|
395 |
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) redex |
|
396 |
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi) |
|
397 |
in |
|
398 |
SOME thm2 |
|
399 |
end |
|
400 |
handle _ => NONE |
|
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
401 |
(* FIXME/TODO: what is the place where the exception is raised: matching_prs? *) |
597 | 402 |
*} |
403 |
||
404 |
ML {* |
|
405 |
fun ball_bex_range_simproc ss redex = |
|
406 |
let |
|
407 |
val ctxt = Simplifier.the_context ss |
|
408 |
in |
|
409 |
case redex of |
|
410 |
(Const (@{const_name "Ball"}, _) $ (Const (@{const_name "Respects"}, _) $ |
|
411 |
(Const (@{const_name "fun_rel"}, _) $ R1 $ R2)) $ _) => |
|
412 |
calculate_instance ctxt @{thm ball_reg_eqv_range} redex R1 R2 |
|
413 |
| (Const (@{const_name "Bex"}, _) $ (Const (@{const_name "Respects"}, _) $ |
|
414 |
(Const (@{const_name "fun_rel"}, _) $ R1 $ R2)) $ _) => |
|
415 |
calculate_instance ctxt @{thm bex_reg_eqv_range} redex R1 R2 |
|
416 |
| _ => NONE |
|
417 |
end |
|
418 |
*} |
|
419 |
||
420 |
lemma eq_imp_rel: |
|
421 |
shows "equivp R \<Longrightarrow> a = b \<longrightarrow> R a b" |
|
422 |
by (simp add: equivp_reflp) |
|
423 |
||
612 | 424 |
(* Regularize Tactic *) |
597 | 425 |
|
612 | 426 |
(* 0. preliminary simplification step according to *) |
427 |
thm ball_reg_eqv bex_reg_eqv babs_reg_eqv (* the latter of no use *) |
|
428 |
ball_reg_eqv_range bex_reg_eqv_range |
|
429 |
(* 1. eliminating simple Ball/Bex instances*) |
|
430 |
thm ball_reg_right bex_reg_left |
|
431 |
(* 2. monos *) |
|
432 |
(* 3. commutation rules for ball and bex *) |
|
433 |
thm ball_all_comm bex_ex_comm |
|
434 |
(* 4. then rel-equality (which need to be instantiated to avoid loops *) |
|
435 |
thm eq_imp_rel |
|
436 |
(* 5. then simplification like 0 *) |
|
437 |
(* finally jump back to 1 *) |
|
597 | 438 |
|
697
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
439 |
ML {* |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
440 |
fun quotient_tac ctxt = |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
441 |
REPEAT_ALL_NEW (FIRST' |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
442 |
[rtac @{thm identity_quotient}, |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
443 |
resolve_tac (quotient_rules_get ctxt)]) |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
444 |
|
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
445 |
fun quotient_solver_tac ss = quotient_tac (Simplifier.the_context ss) |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
446 |
val quotient_solver = Simplifier.mk_solver' "Quotient goal solver" quotient_solver_tac |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
447 |
*} |
612 | 448 |
|
597 | 449 |
ML {* |
450 |
fun regularize_tac ctxt = |
|
451 |
let |
|
452 |
val thy = ProofContext.theory_of ctxt |
|
453 |
val pat_ball = @{term "Ball (Respects (R1 ===> R2)) P"} |
|
454 |
val pat_bex = @{term "Bex (Respects (R1 ===> R2)) P"} |
|
455 |
val simproc = Simplifier.simproc_i thy "" [pat_ball, pat_bex] (K (ball_bex_range_simproc)) |
|
456 |
val simpset = (mk_minimal_ss ctxt) |
|
697
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
457 |
addsimps @{thms ball_reg_eqv bex_reg_eqv babs_reg_eqv babs_simp} |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
458 |
addsimprocs [simproc] addSolver equiv_solver addSolver quotient_solver |
597 | 459 |
(* TODO: Make sure that there are no list_rel, pair_rel etc involved *) |
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
460 |
(* can this cause loops in equiv_tac ? *) |
612 | 461 |
val eq_eqvs = map (OF1 @{thm eq_imp_rel}) (equiv_rules_get ctxt) |
597 | 462 |
in |
463 |
simp_tac simpset THEN' |
|
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
464 |
REPEAT_ALL_NEW (CHANGED o FIRST' [ |
612 | 465 |
resolve_tac @{thms ball_reg_right bex_reg_left}, |
597 | 466 |
resolve_tac (Inductive.get_monos ctxt), |
612 | 467 |
resolve_tac @{thms ball_all_comm bex_ex_comm}, |
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
468 |
resolve_tac eq_eqvs, |
597 | 469 |
simp_tac simpset]) |
470 |
end |
|
471 |
*} |
|
472 |
||
612 | 473 |
section {* Calculation of the Injected Goal *} |
597 | 474 |
|
475 |
(* |
|
476 |
Injecting repabs means: |
|
477 |
||
478 |
For abstractions: |
|
479 |
* If the type of the abstraction doesn't need lifting we recurse. |
|
480 |
* If it does we add RepAbs around the whole term and check if the |
|
481 |
variable needs lifting. |
|
482 |
* If it doesn't then we recurse |
|
483 |
* If it does we recurse and put 'RepAbs' around all occurences |
|
484 |
of the variable in the obtained subterm. This in combination |
|
485 |
with the RepAbs above will let us change the type of the |
|
486 |
abstraction with rewriting. |
|
487 |
For applications: |
|
488 |
* If the term is 'Respects' applied to anything we leave it unchanged |
|
489 |
* If the term needs lifting and the head is a constant that we know |
|
490 |
how to lift, we put a RepAbs and recurse |
|
491 |
* If the term needs lifting and the head is a free applied to subterms |
|
492 |
(if it is not applied we treated it in Abs branch) then we |
|
493 |
put RepAbs and recurse |
|
494 |
* Otherwise just recurse. |
|
495 |
*) |
|
496 |
||
497 |
ML {* |
|
498 |
fun mk_repabs lthy (T, T') trm = |
|
499 |
Quotient_Def.get_fun repF lthy (T, T') |
|
500 |
$ (Quotient_Def.get_fun absF lthy (T, T') $ trm) |
|
501 |
*} |
|
502 |
||
503 |
ML {* |
|
504 |
(* bound variables need to be treated properly, *) |
|
505 |
(* as the type of subterms need to be calculated *) |
|
506 |
(* in the abstraction case *) |
|
507 |
||
508 |
fun inj_repabs_trm lthy (rtrm, qtrm) = |
|
509 |
case (rtrm, qtrm) of |
|
510 |
(Const (@{const_name "Ball"}, T) $ r $ t, Const (@{const_name "All"}, _) $ t') => |
|
511 |
Const (@{const_name "Ball"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
|
512 |
||
513 |
| (Const (@{const_name "Bex"}, T) $ r $ t, Const (@{const_name "Ex"}, _) $ t') => |
|
514 |
Const (@{const_name "Bex"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
|
515 |
||
516 |
| (Const (@{const_name "Babs"}, T) $ r $ t, t' as (Abs _)) => |
|
621
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
616
diff
changeset
|
517 |
let |
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
616
diff
changeset
|
518 |
val rty = fastype_of rtrm |
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
616
diff
changeset
|
519 |
val qty = fastype_of qtrm |
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
616
diff
changeset
|
520 |
in |
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
616
diff
changeset
|
521 |
mk_repabs lthy (rty, qty) (Const (@{const_name "Babs"}, T) $ r $ (inj_repabs_trm lthy (t, t'))) |
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
616
diff
changeset
|
522 |
end |
597 | 523 |
|
524 |
| (Abs (x, T, t), Abs (x', T', t')) => |
|
525 |
let |
|
526 |
val rty = fastype_of rtrm |
|
527 |
val qty = fastype_of qtrm |
|
528 |
val (y, s) = Term.dest_abs (x, T, t) |
|
529 |
val (_, s') = Term.dest_abs (x', T', t') |
|
530 |
val yvar = Free (y, T) |
|
531 |
val result = Term.lambda_name (y, yvar) (inj_repabs_trm lthy (s, s')) |
|
532 |
in |
|
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
533 |
if rty = qty then result |
597 | 534 |
else mk_repabs lthy (rty, qty) result |
535 |
end |
|
536 |
||
537 |
| (t $ s, t' $ s') => |
|
538 |
(inj_repabs_trm lthy (t, t')) $ (inj_repabs_trm lthy (s, s')) |
|
539 |
||
540 |
| (Free (_, T), Free (_, T')) => |
|
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
541 |
if T = T' then rtrm |
597 | 542 |
else mk_repabs lthy (T, T') rtrm |
543 |
||
544 |
| (_, Const (@{const_name "op ="}, _)) => rtrm |
|
545 |
||
546 |
(* FIXME: check here that rtrm is the corresponding definition for the const *) |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
657
diff
changeset
|
547 |
(* Hasn't it already been checked in regularize? *) |
597 | 548 |
| (_, Const (_, T')) => |
549 |
let |
|
550 |
val rty = fastype_of rtrm |
|
551 |
in |
|
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
552 |
if rty = T' then rtrm |
597 | 553 |
else mk_repabs lthy (rty, T') rtrm |
554 |
end |
|
555 |
||
556 |
| _ => raise (LIFT_MATCH "injection") |
|
557 |
*} |
|
558 |
||
612 | 559 |
section {* Injection Tactic *} |
597 | 560 |
|
561 |
ML {* |
|
562 |
fun solve_quotient_assums ctxt thm = |
|
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
563 |
let |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
564 |
val goal = hd (Drule.strip_imp_prems (cprop_of thm)) |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
565 |
in |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
566 |
thm OF [Goal.prove_internal [] goal (fn _ => quotient_tac ctxt 1)] |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
567 |
end |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
568 |
handle _ => error "solve_quotient_assums failed. Maybe a quotient_thm is missing" |
597 | 569 |
*} |
570 |
||
571 |
definition |
|
572 |
"QUOT_TRUE x \<equiv> True" |
|
573 |
||
574 |
ML {* |
|
575 |
fun find_qt_asm asms = |
|
576 |
let |
|
577 |
fun find_fun trm = |
|
578 |
case trm of |
|
579 |
(Const(@{const_name Trueprop}, _) $ (Const (@{const_name QUOT_TRUE}, _) $ _)) => true |
|
580 |
| _ => false |
|
581 |
in |
|
582 |
case find_first find_fun asms of |
|
583 |
SOME (_ $ (_ $ (f $ a))) => (f, a) |
|
584 |
| SOME _ => error "find_qt_asm: no pair" |
|
585 |
| NONE => error "find_qt_asm: no assumption" |
|
586 |
end |
|
587 |
*} |
|
588 |
||
589 |
(* |
|
590 |
To prove that the regularised theorem implies the abs/rep injected, |
|
591 |
we try: |
|
592 |
||
593 |
1) theorems 'trans2' from the appropriate QUOT_TYPE |
|
594 |
2) remove lambdas from both sides: lambda_rsp_tac |
|
595 |
3) remove Ball/Bex from the right hand side |
|
596 |
4) use user-supplied RSP theorems |
|
597 |
5) remove rep_abs from the right side |
|
598 |
6) reflexivity of equality |
|
599 |
7) split applications of lifted type (apply_rsp) |
|
600 |
8) split applications of non-lifted type (cong_tac) |
|
601 |
9) apply extentionality |
|
602 |
A) reflexivity of the relation |
|
603 |
B) assumption |
|
604 |
(Lambdas under respects may have left us some assumptions) |
|
605 |
C) proving obvious higher order equalities by simplifying fun_rel |
|
606 |
(not sure if it is still needed?) |
|
607 |
D) unfolding lambda on one side |
|
608 |
E) simplifying (= ===> =) for simpler respectfulness |
|
609 |
||
610 |
*) |
|
611 |
||
612 |
lemma quot_true_dests: |
|
613 |
shows QT_all: "QUOT_TRUE (All P) \<Longrightarrow> QUOT_TRUE P" |
|
614 |
and QT_ex: "QUOT_TRUE (Ex P) \<Longrightarrow> QUOT_TRUE P" |
|
615 |
and QT_lam: "QUOT_TRUE (\<lambda>x. P x) \<Longrightarrow> (\<And>x. QUOT_TRUE (P x))" |
|
616 |
and QT_ext: "(\<And>x. QUOT_TRUE (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (QUOT_TRUE a \<Longrightarrow> f = g)" |
|
655 | 617 |
by (simp_all add: QUOT_TRUE_def ext) |
597 | 618 |
|
619 |
lemma QUOT_TRUE_imp: "QUOT_TRUE a \<equiv> QUOT_TRUE b" |
|
620 |
by (simp add: QUOT_TRUE_def) |
|
621 |
||
697
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
622 |
lemma regularize_to_injection: "(QUOT_TRUE l \<Longrightarrow> y) \<Longrightarrow> (l = r) \<longrightarrow> y" |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
623 |
by(auto simp add: QUOT_TRUE_def) |
57944c1ef728
Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
695
diff
changeset
|
624 |
|
597 | 625 |
ML {* |
626 |
fun quot_true_conv1 ctxt fnctn ctrm = |
|
627 |
case (term_of ctrm) of |
|
628 |
(Const (@{const_name QUOT_TRUE}, _) $ x) => |
|
629 |
let |
|
630 |
val fx = fnctn x; |
|
631 |
val thy = ProofContext.theory_of ctxt; |
|
632 |
val cx = cterm_of thy x; |
|
633 |
val cfx = cterm_of thy fx; |
|
634 |
val cxt = ctyp_of thy (fastype_of x); |
|
635 |
val cfxt = ctyp_of thy (fastype_of fx); |
|
636 |
val thm = Drule.instantiate' [SOME cxt, SOME cfxt] [SOME cx, SOME cfx] @{thm QUOT_TRUE_imp} |
|
637 |
in |
|
638 |
Conv.rewr_conv thm ctrm |
|
639 |
end |
|
640 |
*} |
|
641 |
||
642 |
ML {* |
|
643 |
fun quot_true_conv ctxt fnctn ctrm = |
|
644 |
case (term_of ctrm) of |
|
645 |
(Const (@{const_name QUOT_TRUE}, _) $ _) => |
|
646 |
quot_true_conv1 ctxt fnctn ctrm |
|
647 |
| _ $ _ => Conv.comb_conv (quot_true_conv ctxt fnctn) ctrm |
|
648 |
| Abs _ => Conv.abs_conv (fn (_, ctxt) => quot_true_conv ctxt fnctn) ctxt ctrm |
|
649 |
| _ => Conv.all_conv ctrm |
|
650 |
*} |
|
651 |
||
652 |
ML {* |
|
653 |
fun quot_true_tac ctxt fnctn = CONVERSION |
|
654 |
((Conv.params_conv ~1 (fn ctxt => |
|
655 |
(Conv.prems_conv ~1 (quot_true_conv ctxt fnctn)))) ctxt) |
|
656 |
*} |
|
657 |
||
658 |
ML {* fun dest_comb (f $ a) = (f, a) *} |
|
659 |
ML {* fun dest_bcomb ((_ $ l) $ r) = (l, r) *} |
|
660 |
(* TODO: Can this be done easier? *) |
|
661 |
ML {* |
|
662 |
fun unlam t = |
|
663 |
case t of |
|
664 |
(Abs a) => snd (Term.dest_abs a) |
|
665 |
| _ => unlam (Abs("", domain_type (fastype_of t), (incr_boundvars 1 t) $ (Bound 0))) |
|
666 |
*} |
|
667 |
||
668 |
ML {* |
|
669 |
fun dest_fun_type (Type("fun", [T, S])) = (T, S) |
|
670 |
| dest_fun_type _ = error "dest_fun_type" |
|
671 |
*} |
|
672 |
||
673 |
ML {* |
|
674 |
val bare_concl = HOLogic.dest_Trueprop o Logic.strip_assums_concl |
|
675 |
*} |
|
676 |
||
677 |
ML {* |
|
678 |
val apply_rsp_tac = |
|
679 |
Subgoal.FOCUS (fn {concl, asms, context,...} => |
|
680 |
case ((HOLogic.dest_Trueprop (term_of concl))) of |
|
681 |
((R2 $ (f $ x) $ (g $ y))) => |
|
682 |
(let |
|
683 |
val (asmf, asma) = find_qt_asm (map term_of asms); |
|
684 |
in |
|
685 |
if (fastype_of asmf) = (fastype_of f) then no_tac else let |
|
686 |
val ty_a = fastype_of x; |
|
687 |
val ty_b = fastype_of asma; |
|
688 |
val ty_c = range_type (type_of f); |
|
689 |
val thy = ProofContext.theory_of context; |
|
690 |
val ty_inst = map (SOME o (ctyp_of thy)) [ty_a, ty_b, ty_c]; |
|
691 |
val thm = Drule.instantiate' ty_inst [] @{thm apply_rsp} |
|
692 |
val te = solve_quotient_assums context thm |
|
693 |
val t_inst = map (SOME o (cterm_of thy)) [R2, f, g, x, y]; |
|
694 |
val thm = Drule.instantiate' [] t_inst te |
|
695 |
in |
|
696 |
compose_tac (false, thm, 2) 1 |
|
697 |
end |
|
698 |
end |
|
699 |
handle ERROR "find_qt_asm: no pair" => no_tac) |
|
700 |
| _ => no_tac) |
|
701 |
*} |
|
702 |
||
703 |
ML {* |
|
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
704 |
fun equals_rsp_tac R ctxt = |
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
705 |
let |
690 | 706 |
val ty = domain_type (fastype_of R); |
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
707 |
val thy = ProofContext.theory_of ctxt |
690 | 708 |
val thm = Drule.instantiate' |
709 |
[SOME (ctyp_of thy ty)] [SOME (cterm_of thy R)] @{thm equals_rsp} |
|
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
710 |
in |
690 | 711 |
rtac thm THEN' quotient_tac ctxt |
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
712 |
end |
690 | 713 |
handle THM _ => K no_tac |
714 |
| TYPE _ => K no_tac |
|
715 |
| TERM _ => K no_tac |
|
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
716 |
*} |
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
717 |
|
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
718 |
ML {* |
597 | 719 |
fun rep_abs_rsp_tac ctxt = |
720 |
SUBGOAL (fn (goal, i) => |
|
721 |
case (bare_concl goal) of |
|
722 |
(rel $ _ $ (rep $ (abs $ _))) => |
|
723 |
(let |
|
724 |
val thy = ProofContext.theory_of ctxt; |
|
725 |
val (ty_a, ty_b) = dest_fun_type (fastype_of abs); |
|
726 |
val ty_inst = map (SOME o (ctyp_of thy)) [ty_a, ty_b]; |
|
727 |
val t_inst = map (SOME o (cterm_of thy)) [rel, abs, rep]; |
|
728 |
val thm = Drule.instantiate' ty_inst t_inst @{thm rep_abs_rsp} |
|
729 |
val te = solve_quotient_assums ctxt thm |
|
730 |
in |
|
731 |
rtac te i |
|
732 |
end |
|
733 |
handle _ => no_tac) |
|
734 |
| _ => no_tac) |
|
735 |
*} |
|
736 |
||
737 |
ML {* |
|
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
738 |
fun inj_repabs_tac_match ctxt = SUBGOAL (fn (goal, i) => |
597 | 739 |
(case (bare_concl goal) of |
740 |
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *) |
|
741 |
((Const (@{const_name fun_rel}, _) $ _ $ _) $ (Abs _) $ (Abs _)) |
|
742 |
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam |
|
743 |
||
744 |
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
|
745 |
| (Const (@{const_name "op ="},_) $ |
|
746 |
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $ |
|
747 |
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _)) |
|
748 |
=> rtac @{thm ball_rsp} THEN' dtac @{thm QT_all} |
|
749 |
||
750 |
(* (R1 ===> op =) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> (Ball\<dots>x) = (Ball\<dots>y) *) |
|
751 |
| (Const (@{const_name fun_rel}, _) $ _ $ _) $ |
|
752 |
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $ |
|
753 |
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) |
|
754 |
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam |
|
755 |
||
756 |
(* (op =) (Bex\<dots>) (Bex\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
|
757 |
| Const (@{const_name "op ="},_) $ |
|
758 |
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $ |
|
759 |
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) |
|
760 |
=> rtac @{thm bex_rsp} THEN' dtac @{thm QT_ex} |
|
761 |
||
762 |
(* (R1 ===> op =) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> (Bex\<dots>x) = (Bex\<dots>y) *) |
|
763 |
| (Const (@{const_name fun_rel}, _) $ _ $ _) $ |
|
764 |
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $ |
|
765 |
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) |
|
766 |
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam |
|
767 |
||
768 |
| (_ $ |
|
769 |
(Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $ |
|
770 |
(Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _)) |
|
771 |
=> rtac @{thm babs_rsp} THEN' RANGE [quotient_tac ctxt] |
|
772 |
||
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
773 |
| Const (@{const_name "op ="},_) $ (R $ _ $ _) $ (_ $ _ $ _) => (rtac @{thm refl} ORELSE' |
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
774 |
(equals_rsp_tac R ctxt THEN' RANGE [ |
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
775 |
quot_true_tac ctxt (fst o dest_bcomb), quot_true_tac ctxt (snd o dest_bcomb)])) |
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
776 |
|
597 | 777 |
(* reflexivity of operators arising from Cong_tac *) |
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
778 |
| Const (@{const_name "op ="},_) $ _ $ _ => rtac @{thm refl} |
597 | 779 |
|
780 |
(* respectfulness of constants; in particular of a simple relation *) |
|
781 |
| _ $ (Const _) $ (Const _) (* fun_rel, list_rel, etc but not equality *) |
|
782 |
=> resolve_tac (rsp_rules_get ctxt) THEN_ALL_NEW quotient_tac ctxt |
|
783 |
||
784 |
(* R (\<dots>) (Rep (Abs \<dots>)) ----> R (\<dots>) (\<dots>) *) |
|
785 |
(* observe ---> *) |
|
624
c4299ce27e46
Removed pattern from quot_rel_rsp, since list_rel and all used introduced ones cannot be patterned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
621
diff
changeset
|
786 |
| _ $ _ $ _ |
c4299ce27e46
Removed pattern from quot_rel_rsp, since list_rel and all used introduced ones cannot be patterned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
621
diff
changeset
|
787 |
=> (rtac @{thm quot_rel_rsp} THEN_ALL_NEW quotient_tac ctxt) ORELSE' rep_abs_rsp_tac ctxt |
597 | 788 |
|
789 |
| _ => error "inj_repabs_tac not a relation" |
|
790 |
) i) |
|
791 |
*} |
|
792 |
||
793 |
ML {* |
|
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
794 |
fun inj_repabs_step_tac ctxt rel_refl = |
597 | 795 |
(FIRST' [ |
686
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
796 |
inj_repabs_tac_match ctxt, |
597 | 797 |
(* R (t $ \<dots>) (t' $ \<dots>) ----> apply_rsp provided type of t needs lifting *) |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
798 |
|
686
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
799 |
apply_rsp_tac ctxt THEN' |
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
800 |
RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)], |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
801 |
|
597 | 802 |
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *) |
803 |
(* merge with previous tactic *) |
|
686
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
804 |
Cong_Tac.cong_tac @{thm cong} THEN' |
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
805 |
RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)], |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
806 |
|
597 | 807 |
(* (op =) (\<lambda>x\<dots>) (\<lambda>x\<dots>) ----> (op =) (\<dots>) (\<dots>) *) |
686
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
808 |
rtac @{thm ext} THEN' quot_true_tac ctxt unlam, |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
809 |
|
597 | 810 |
(* resolving with R x y assumptions *) |
686
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
811 |
atac, |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
812 |
|
597 | 813 |
(* reflexivity of the basic relations *) |
814 |
(* R \<dots> \<dots> *) |
|
686
2ff666f644cc
deleted DT/NDT diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
668
diff
changeset
|
815 |
resolve_tac rel_refl]) |
597 | 816 |
*} |
817 |
||
818 |
ML {* |
|
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
819 |
fun inj_repabs_tac ctxt = |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
820 |
let |
612 | 821 |
val rel_refl = map (OF1 @{thm equivp_reflp}) (equiv_rules_get ctxt) |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
822 |
in |
629
df42285e7286
trans2 replaced with equals_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
624
diff
changeset
|
823 |
inj_repabs_step_tac ctxt rel_refl |
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
824 |
end |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
825 |
|
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
826 |
fun all_inj_repabs_tac ctxt = |
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
827 |
REPEAT_ALL_NEW (inj_repabs_tac ctxt) |
597 | 828 |
*} |
829 |
||
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
830 |
section {* Cleaning of the Theorem *} |
597 | 831 |
|
659
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
832 |
ML {* |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
833 |
fun fun_map_simple_conv xs ctxt ctrm = |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
834 |
case (term_of ctrm) of |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
835 |
((Const (@{const_name "fun_map"}, _) $ _ $ _) $ h $ _) => |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
836 |
if (member (op=) xs h) |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
837 |
then Conv.all_conv ctrm |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
838 |
else Conv.rewr_conv @{thm fun_map.simps[THEN eq_reflection]} ctrm |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
839 |
| _ => Conv.all_conv ctrm |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
840 |
|
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
841 |
fun fun_map_conv xs ctxt ctrm = |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
842 |
case (term_of ctrm) of |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
843 |
_ $ _ => (Conv.comb_conv (fun_map_conv xs ctxt) then_conv |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
844 |
fun_map_simple_conv xs ctxt) ctrm |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
845 |
| Abs _ => Conv.abs_conv (fn (x, ctxt) => fun_map_conv ((term_of x)::xs) ctxt) ctxt ctrm |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
846 |
| _ => Conv.all_conv ctrm |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
847 |
|
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
848 |
fun fun_map_tac ctxt = CONVERSION (fun_map_conv [] ctxt) |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
849 |
*} |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
850 |
|
694 | 851 |
(* Since the patterns for the lhs are different; there are 2 different make-insts *) |
631 | 852 |
(* 1: does ? \<rightarrow> id *) |
694 | 853 |
(* 2: does ? \<rightarrow> non-id *) |
597 | 854 |
ML {* |
855 |
fun make_inst lhs t = |
|
856 |
let |
|
857 |
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs; |
|
858 |
val _ $ (Abs (_, _, g)) = t; |
|
859 |
fun mk_abs i t = |
|
860 |
if incr_boundvars i u aconv t then Bound i |
|
861 |
else (case t of |
|
862 |
t1 $ t2 => mk_abs i t1 $ mk_abs i t2 |
|
863 |
| Abs (s, T, t') => Abs (s, T, mk_abs (i + 1) t') |
|
864 |
| Bound j => if i = j then error "make_inst" else t |
|
865 |
| _ => t); |
|
866 |
in (f, Abs ("x", T, mk_abs 0 g)) end; |
|
867 |
*} |
|
868 |
||
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
869 |
ML {* |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
870 |
fun make_inst2 lhs t = |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
871 |
let |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
872 |
val _ $ (Abs (_, _, (_ $ ((f as Var (_, Type ("fun", [T, _]))) $ u)))) = lhs; |
631 | 873 |
val _ $ (Abs (_, _, (_ $ g))) = t; |
874 |
fun mk_abs i t = |
|
875 |
if incr_boundvars i u aconv t then Bound i |
|
876 |
else (case t of |
|
877 |
t1 $ t2 => mk_abs i t1 $ mk_abs i t2 |
|
878 |
| Abs (s, T, t') => Abs (s, T, mk_abs (i + 1) t') |
|
879 |
| Bound j => if i = j then error "make_inst" else t |
|
880 |
| _ => t); |
|
881 |
in (f, Abs ("x", T, mk_abs 0 g)) end; |
|
882 |
*} |
|
883 |
||
884 |
ML {* |
|
597 | 885 |
fun lambda_prs_simple_conv ctxt ctrm = |
886 |
case (term_of ctrm) of |
|
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
887 |
((Const (@{const_name fun_map}, _) $ r1 $ a2) $ (Abs _)) => |
608
678315da994e
Handling of errors in lambda_prs_conv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
606
diff
changeset
|
888 |
(let |
597 | 889 |
val thy = ProofContext.theory_of ctxt |
890 |
val (ty_b, ty_a) = dest_fun_type (fastype_of r1) |
|
891 |
val (ty_c, ty_d) = dest_fun_type (fastype_of a2) |
|
892 |
val tyinst = map (SOME o (ctyp_of thy)) [ty_a, ty_b, ty_c, ty_d] |
|
893 |
val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)] |
|
894 |
val lpi = Drule.instantiate' tyinst tinst @{thm lambda_prs} |
|
895 |
val te = @{thm eq_reflection} OF [solve_quotient_assums ctxt (solve_quotient_assums ctxt lpi)] |
|
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
896 |
val ti = |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
897 |
(let |
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
898 |
val ts = MetaSimplifier.rewrite_rule (id_simps_get ctxt) te |
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
899 |
val (insp, inst) = make_inst (term_of (Thm.lhs_of ts)) (term_of ctrm) |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
900 |
in |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
901 |
Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts |
608
678315da994e
Handling of errors in lambda_prs_conv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
606
diff
changeset
|
902 |
end handle _ => (* TODO handle only Bind | Error "make_inst" *) |
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
903 |
let |
631 | 904 |
val ts = MetaSimplifier.rewrite_rule (id_simps_get ctxt) te |
905 |
val _ = tracing ("ts rule:\n" ^ (Syntax.string_of_term ctxt (prop_of ts))); |
|
906 |
val _ = tracing ("redex:\n" ^ (Syntax.string_of_term ctxt (term_of ctrm))); |
|
907 |
val (insp, inst) = make_inst2 (term_of (Thm.lhs_of ts)) (term_of ctrm) |
|
908 |
in |
|
909 |
Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts |
|
910 |
end handle _ => (* TODO handle only Bind | Error "make_inst" *) |
|
911 |
let |
|
662 | 912 |
val (insp, inst) = make_inst2 (term_of (Thm.lhs_of te)) (term_of ctrm) |
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
913 |
val td = Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) te |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
914 |
in |
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
915 |
MetaSimplifier.rewrite_rule (id_simps_get ctxt) td |
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
916 |
end); |
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
917 |
val _ = if not (Term.is_Const a2 andalso fst (dest_Const a2) = @{const_name "id"}) then |
597 | 918 |
(tracing "lambda_prs"; |
919 |
tracing ("redex:\n" ^ (Syntax.string_of_term ctxt (term_of ctrm))); |
|
920 |
tracing ("lpi rule:\n" ^ (Syntax.string_of_term ctxt (prop_of lpi))); |
|
921 |
tracing ("te rule:\n" ^ (Syntax.string_of_term ctxt (prop_of te))); |
|
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
600
diff
changeset
|
922 |
tracing ("ti rule:\n" ^ (Syntax.string_of_term ctxt (prop_of ti)))) |
597 | 923 |
else () |
631 | 924 |
|
597 | 925 |
in |
926 |
Conv.rewr_conv ti ctrm |
|
927 |
end |
|
608
678315da994e
Handling of errors in lambda_prs_conv.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
606
diff
changeset
|
928 |
handle _ => Conv.all_conv ctrm) |
597 | 929 |
| _ => Conv.all_conv ctrm |
930 |
*} |
|
931 |
||
932 |
ML {* |
|
933 |
val lambda_prs_conv = |
|
934 |
More_Conv.top_conv lambda_prs_simple_conv |
|
935 |
||
936 |
fun lambda_prs_tac ctxt = CONVERSION (lambda_prs_conv ctxt) |
|
937 |
*} |
|
938 |
||
659
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
939 |
(* 1. folding of definitions and preservation lemmas; *) |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
940 |
(* and simplification with *) |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
941 |
thm babs_prs all_prs ex_prs |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
942 |
(* 2. unfolding of ---> in front of everything, except *) |
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
943 |
(* bound variables *) |
660 | 944 |
thm fun_map.simps |
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
945 |
(* 3. simplification with *) |
661 | 946 |
thm lambda_prs |
660 | 947 |
(* 4. simplification with *) |
659
86c60d55373c
moved function and tuned comment
Christian Urban <urbanc@in.tum.de>
parents:
658
diff
changeset
|
948 |
thm Quotient_abs_rep Quotient_rel_rep id_simps |
660 | 949 |
(* 5. Test for refl *) |
597 | 950 |
|
652
d8f07b5bcfae
implemented cleaning strategy with fun_map.simps on non-bounded variables; still a few rough edges
Christian Urban <urbanc@in.tum.de>
parents:
648
diff
changeset
|
951 |
ML {* |
597 | 952 |
fun clean_tac lthy = |
953 |
let |
|
954 |
val thy = ProofContext.theory_of lthy; |
|
955 |
val defs = map (Thm.varifyT o symmetric o #def) (qconsts_dest thy) |
|
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
956 |
(* FIXME: why is the Thm.varifyT needed: example where it fails is LamEx *) |
658 | 957 |
|
656
c86a47d4966e
Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
655
diff
changeset
|
958 |
val thms1 = defs @ (prs_rules_get lthy) @ @{thms babs_prs all_prs ex_prs} |
658 | 959 |
val thms2 = @{thms Quotient_abs_rep Quotient_rel_rep} @ (id_simps_get lthy) |
597 | 960 |
fun simps thms = (mk_minimal_ss lthy) addsimps thms addSolver quotient_solver |
961 |
in |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
962 |
EVERY' [simp_tac (simps thms1), |
658 | 963 |
fun_map_tac lthy, |
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
964 |
lambda_prs_tac lthy, |
597 | 965 |
simp_tac (simps thms2), |
966 |
TRY o rtac refl] |
|
967 |
end |
|
968 |
*} |
|
969 |
||
689 | 970 |
section {* Tactic for Genralisation of Free Variables in a Goal *} |
597 | 971 |
|
972 |
ML {* |
|
973 |
fun inst_spec ctrm = |
|
974 |
Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec} |
|
975 |
||
976 |
fun inst_spec_tac ctrms = |
|
977 |
EVERY' (map (dtac o inst_spec) ctrms) |
|
978 |
||
979 |
fun all_list xs trm = |
|
980 |
fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm |
|
981 |
||
982 |
fun apply_under_Trueprop f = |
|
983 |
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop |
|
984 |
||
985 |
fun gen_frees_tac ctxt = |
|
986 |
SUBGOAL (fn (concl, i) => |
|
987 |
let |
|
988 |
val thy = ProofContext.theory_of ctxt |
|
989 |
val vrs = Term.add_frees concl [] |
|
990 |
val cvrs = map (cterm_of thy o Free) vrs |
|
991 |
val concl' = apply_under_Trueprop (all_list vrs) concl |
|
992 |
val goal = Logic.mk_implies (concl', concl) |
|
993 |
val rule = Goal.prove ctxt [] [] goal |
|
994 |
(K (EVERY1 [inst_spec_tac (rev cvrs), atac])) |
|
995 |
in |
|
996 |
rtac rule i |
|
997 |
end) |
|
998 |
*} |
|
999 |
||
699
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
1000 |
section {* The General Shape of the Lifting Procedure *} |
597 | 1001 |
|
699
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
1002 |
(* - A is the original raw theorem *) |
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
1003 |
(* - B is the regularized theorem *) |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1004 |
(* - C is the rep/abs injected version of B *) |
699
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
1005 |
(* - D is the lifted theorem *) |
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
1006 |
(* *) |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1007 |
(* - 1st prem is the regularization step *) |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1008 |
(* - 2nd prem is the rep/abs injection step *) |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1009 |
(* - 3rd prem is the cleaning part *) |
699
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
1010 |
(* *) |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1011 |
(* the QUOT_TRUE premise in 2 records the lifted theorem *) |
597 | 1012 |
|
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1013 |
ML {* |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1014 |
val lifting_procedure = |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1015 |
@{lemma "\<lbrakk>A; A \<longrightarrow> B; QUOT_TRUE D \<Longrightarrow> B = C; C = D\<rbrakk> \<Longrightarrow> D" by (simp add: QUOT_TRUE_def)} |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1016 |
*} |
597 | 1017 |
|
1018 |
ML {* |
|
1019 |
fun lift_match_error ctxt fun_str rtrm qtrm = |
|
1020 |
let |
|
1021 |
val rtrm_str = Syntax.string_of_term ctxt rtrm |
|
1022 |
val qtrm_str = Syntax.string_of_term ctxt qtrm |
|
704 | 1023 |
val msg = cat_lines [enclose "[" "]" fun_str, "The quotient theorem", qtrm_str, |
1024 |
"", "does not match with original theorem", rtrm_str] |
|
597 | 1025 |
in |
704 | 1026 |
error msg |
597 | 1027 |
end |
1028 |
*} |
|
1029 |
||
1030 |
ML {* |
|
1031 |
fun procedure_inst ctxt rtrm qtrm = |
|
1032 |
let |
|
1033 |
val thy = ProofContext.theory_of ctxt |
|
1034 |
val rtrm' = HOLogic.dest_Trueprop rtrm |
|
1035 |
val qtrm' = HOLogic.dest_Trueprop qtrm |
|
1036 |
val reg_goal = |
|
1037 |
Syntax.check_term ctxt (regularize_trm ctxt rtrm' qtrm') |
|
1038 |
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm |
|
1039 |
val inj_goal = |
|
1040 |
Syntax.check_term ctxt (inj_repabs_trm ctxt (reg_goal, qtrm')) |
|
1041 |
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm |
|
1042 |
in |
|
1043 |
Drule.instantiate' [] |
|
1044 |
[SOME (cterm_of thy rtrm'), |
|
1045 |
SOME (cterm_of thy reg_goal), |
|
688
fa0f6fdac5de
simplified the instantiation of QUOT_TRUE in procedure_tac
Christian Urban <urbanc@in.tum.de>
parents:
687
diff
changeset
|
1046 |
NONE, |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1047 |
SOME (cterm_of thy inj_goal)] lifting_procedure |
597 | 1048 |
end |
1049 |
*} |
|
1050 |
||
1051 |
ML {* |
|
616 | 1052 |
(* the tactic leaves three subgoals to be proved *) |
597 | 1053 |
fun procedure_tac ctxt rthm = |
1054 |
ObjectLogic.full_atomize_tac |
|
1055 |
THEN' gen_frees_tac ctxt |
|
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
1056 |
THEN' CSUBGOAL (fn (goal, i) => |
597 | 1057 |
let |
1058 |
val rthm' = atomize_thm rthm |
|
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
parents:
606
diff
changeset
|
1059 |
val rule = procedure_inst ctxt (prop_of rthm') (term_of goal) |
597 | 1060 |
in |
688
fa0f6fdac5de
simplified the instantiation of QUOT_TRUE in procedure_tac
Christian Urban <urbanc@in.tum.de>
parents:
687
diff
changeset
|
1061 |
(rtac rule THEN' rtac rthm') i |
597 | 1062 |
end) |
1063 |
*} |
|
1064 |
||
689 | 1065 |
section {* Automatic Proofs *} |
1066 |
||
612 | 1067 |
ML {* |
616 | 1068 |
fun SOLVES' tac = tac THEN_ALL_NEW (K no_tac) |
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1069 |
|
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1070 |
(* prints warning, if goal is unsolved *) |
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1071 |
fun WARN (tac, msg) i st = |
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1072 |
case Seq.pull ((SOLVES' tac) i st) of |
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1073 |
NONE => (warning msg; Seq.single st) |
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1074 |
| seqcell => Seq.make (fn () => seqcell) |
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1075 |
|
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1076 |
fun RANGE_WARN xs = RANGE (map WARN xs) |
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1077 |
*} |
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1078 |
|
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
1079 |
ML {* |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1080 |
local |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1081 |
|
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1082 |
val msg1 = "Regularize proof failed." |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1083 |
val msg2 = cat_lines ["Injection proof failed.", |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1084 |
"This is probably due to missing respects lemmas.", |
715
3d7a9d4d2bb6
added Int example from Larry
Christian Urban <urbanc@in.tum.de>
parents:
704
diff
changeset
|
1085 |
"Try invoking the injection method manually to see", |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1086 |
"which lemmas are missing."] |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1087 |
val msg3 = "Cleaning proof failed." |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1088 |
|
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1089 |
in |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1090 |
|
612 | 1091 |
fun lift_tac ctxt rthm = |
1092 |
procedure_tac ctxt rthm |
|
688
fa0f6fdac5de
simplified the instantiation of QUOT_TRUE in procedure_tac
Christian Urban <urbanc@in.tum.de>
parents:
687
diff
changeset
|
1093 |
THEN' RANGE_WARN |
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1094 |
[(regularize_tac ctxt, msg1), |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1095 |
(all_inj_repabs_tac ctxt, msg2), |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1096 |
(clean_tac ctxt, msg3)] |
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1097 |
|
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
parents:
699
diff
changeset
|
1098 |
end |
612 | 1099 |
*} |
1100 |
||
689 | 1101 |
section {* Methods / Interface *} |
1102 |
||
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1103 |
ML {* |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1104 |
fun mk_method1 tac thm ctxt = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1105 |
SIMPLE_METHOD (HEADGOAL (tac ctxt thm)) |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1106 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1107 |
fun mk_method2 tac ctxt = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1108 |
SIMPLE_METHOD (HEADGOAL (tac ctxt)) |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1109 |
*} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1110 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1111 |
method_setup lifting = |
637
b029f242d85d
chnaged syntax to "lifting theorem"
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
1112 |
{* Attrib.thm >> (mk_method1 lift_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1113 |
{* Lifting of theorems to quotient types. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1114 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1115 |
method_setup lifting_setup = |
637
b029f242d85d
chnaged syntax to "lifting theorem"
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
1116 |
{* Attrib.thm >> (mk_method1 procedure_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1117 |
{* Sets up the three goals for the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1118 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1119 |
method_setup regularize = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1120 |
{* Scan.succeed (mk_method2 regularize_tac) *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1121 |
{* Proves automatically the regularization goals from the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1122 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1123 |
method_setup injection = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1124 |
{* Scan.succeed (mk_method2 all_inj_repabs_tac) *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1125 |
{* Proves automatically the rep/abs injection goals from the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1126 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1127 |
method_setup cleaning = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1128 |
{* Scan.succeed (mk_method2 clean_tac) *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1129 |
{* Proves automatically the cleaning goals from the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
1130 |
|
597 | 1131 |
end |
1132 |