author | Ning@localhost |
Sun, 20 Sep 2009 05:18:36 +0100 | |
changeset 22 | 5023bf36d81a |
parent 21 | d15121412caa |
child 23 | f6c6cf8c3b98 |
permissions | -rw-r--r-- |
0 | 1 |
theory QuotMain |
6 | 2 |
imports QuotScript QuotList Prove |
0 | 3 |
begin |
4 |
||
5 |
locale QUOT_TYPE = |
|
6 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
7 |
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b" |
|
8 |
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)" |
|
9 |
assumes equiv: "EQUIV R" |
|
10 |
and rep_prop: "\<And>y. \<exists>x. Rep y = R x" |
|
11 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
|
12 |
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)" |
|
13 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
|
15 | 14 |
begin |
0 | 15 |
|
16 |
definition |
|
17 |
"ABS x \<equiv> Abs (R x)" |
|
18 |
||
19 |
definition |
|
20 |
"REP a = Eps (Rep a)" |
|
21 |
||
15 | 22 |
lemma lem9: |
0 | 23 |
shows "R (Eps (R x)) = R x" |
24 |
proof - |
|
25 |
have a: "R x x" using equiv by (simp add: EQUIV_REFL_SYM_TRANS REFL_def) |
|
26 |
then have "R x (Eps (R x))" by (rule someI) |
|
15 | 27 |
then show "R (Eps (R x)) = R x" |
0 | 28 |
using equiv unfolding EQUIV_def by simp |
29 |
qed |
|
30 |
||
31 |
theorem thm10: |
|
32 |
shows "ABS (REP a) = a" |
|
33 |
unfolding ABS_def REP_def |
|
34 |
proof - |
|
15 | 35 |
from rep_prop |
0 | 36 |
obtain x where eq: "Rep a = R x" by auto |
37 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
|
38 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
|
39 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
|
40 |
also have "\<dots> = a" using rep_inverse by simp |
|
41 |
finally |
|
42 |
show "Abs (R (Eps (Rep a))) = a" by simp |
|
43 |
qed |
|
44 |
||
15 | 45 |
lemma REP_refl: |
0 | 46 |
shows "R (REP a) (REP a)" |
47 |
unfolding REP_def |
|
48 |
by (simp add: equiv[simplified EQUIV_def]) |
|
49 |
||
50 |
lemma lem7: |
|
22 | 51 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
0 | 52 |
apply(rule iffI) |
53 |
apply(simp) |
|
54 |
apply(drule rep_inject[THEN iffD2]) |
|
55 |
apply(simp add: abs_inverse) |
|
56 |
done |
|
15 | 57 |
|
0 | 58 |
theorem thm11: |
59 |
shows "R r r' = (ABS r = ABS r')" |
|
60 |
unfolding ABS_def |
|
61 |
by (simp only: equiv[simplified EQUIV_def] lem7) |
|
62 |
||
4 | 63 |
|
2 | 64 |
lemma REP_ABS_rsp: |
4 | 65 |
shows "R f (REP (ABS g)) = R f g" |
66 |
and "R (REP (ABS g)) f = R g f" |
|
67 |
apply(subst thm11) |
|
68 |
apply(simp add: thm10 thm11) |
|
69 |
apply(subst thm11) |
|
70 |
apply(simp add: thm10 thm11) |
|
71 |
done |
|
72 |
||
0 | 73 |
lemma QUOTIENT: |
74 |
"QUOTIENT R ABS REP" |
|
75 |
apply(unfold QUOTIENT_def) |
|
76 |
apply(simp add: thm10) |
|
77 |
apply(simp add: REP_refl) |
|
78 |
apply(subst thm11[symmetric]) |
|
79 |
apply(simp add: equiv[simplified EQUIV_def]) |
|
80 |
done |
|
81 |
||
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
82 |
lemma R_trans: |
22 | 83 |
assumes ab: "R a b" |
84 |
and bc: "R b c" |
|
85 |
shows "R a c" |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
86 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
87 |
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
|
88 |
moreover have ab: "R a b" by fact |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
89 |
moreover have bc: "R b c" by fact |
22 | 90 |
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
|
91 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
92 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
93 |
lemma R_sym: |
22 | 94 |
assumes ab: "R a b" |
95 |
shows "R b a" |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
96 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
97 |
have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
22 | 98 |
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
|
99 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
100 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
101 |
lemma R_trans2: |
22 | 102 |
assumes ac: "R a c" |
103 |
and bd: "R b d" |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
104 |
shows "R a b = R c d" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
105 |
proof |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
106 |
assume ab: "R a b" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
107 |
then have "R b a" using R_sym by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
108 |
then have "R b c" using ac R_trans by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
109 |
then have "R c b" using R_sym by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
110 |
then show "R c d" using bd R_trans by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
111 |
next |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
112 |
assume ccd: "R c d" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
113 |
then have "R a d" using ac R_trans by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
114 |
then have "R d a" using R_sym by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
115 |
then have "R b a" using bd R_trans by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
116 |
then show "R a b" using R_sym by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
117 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
118 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
119 |
lemma REPS_same: |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
120 |
shows "R (REP a) (REP b) = (a = b)" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
121 |
proof |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
122 |
assume as: "R (REP a) (REP b)" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
123 |
from rep_prop |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
124 |
obtain x where eq: "Rep a = R x" by auto |
22 | 125 |
(*also ... not useful in the proof *) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
126 |
from rep_prop |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
127 |
obtain y where eq2: "Rep b = R y" by auto |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
128 |
then have "R (Eps (R x)) (Eps (R y))" using as eq unfolding REP_def by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
129 |
then have "R x (Eps (R y))" using lem9 by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
130 |
then have "R (Eps (R y)) x" using R_sym by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
131 |
then have "R y x" using lem9 by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
132 |
then have "R x y" using R_sym by blast |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
133 |
then have "ABS x = ABS y" using thm11 by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
134 |
then have "Abs (Rep a) = Abs (Rep b)" using eq eq2 unfolding ABS_def by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
135 |
then show "a = b" using rep_inverse by simp |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
136 |
next |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
137 |
assume ab: "a = b" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
138 |
have "REFL 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
|
139 |
then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
140 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
141 |
|
0 | 142 |
end |
143 |
||
144 |
section {* type definition for the quotient type *} |
|
145 |
||
146 |
ML {* |
|
1 | 147 |
(* constructs the term \<lambda>(c::ty \<Rightarrow> bool). \<exists>x. c = rel x *) |
0 | 148 |
fun typedef_term rel ty lthy = |
15 | 149 |
let |
150 |
val [x, c] = [("x", ty), ("c", ty --> @{typ bool})] |
|
0 | 151 |
|> Variable.variant_frees lthy [rel] |
152 |
|> map Free |
|
153 |
in |
|
15 | 154 |
lambda c |
155 |
(HOLogic.mk_exists |
|
1 | 156 |
("x", ty, HOLogic.mk_eq (c, (rel $ x)))) |
0 | 157 |
end |
158 |
*} |
|
159 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
160 |
(* |
0 | 161 |
ML {* |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
162 |
typedef_term @{term R} @{typ "nat"} @{context} |
2 | 163 |
|> Syntax.string_of_term @{context} |
164 |
|> writeln |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
165 |
*}*) |
2 | 166 |
|
167 |
ML {* |
|
15 | 168 |
val typedef_tac = |
0 | 169 |
EVERY1 [rewrite_goal_tac @{thms mem_def}, |
170 |
rtac @{thm exI}, rtac @{thm exI}, rtac @{thm refl}] |
|
171 |
*} |
|
172 |
||
173 |
ML {* |
|
174 |
(* makes the new type definitions *) |
|
175 |
fun typedef_make (qty_name, rel, ty) lthy = |
|
176 |
LocalTheory.theory_result |
|
15 | 177 |
(Typedef.add_typedef false NONE |
0 | 178 |
(qty_name, map fst (Term.add_tfreesT ty []), NoSyn) |
179 |
(typedef_term rel ty lthy) |
|
180 |
NONE typedef_tac) lthy |
|
181 |
*} |
|
182 |
||
2 | 183 |
text {* proves the QUOT_TYPE theorem for the new type *} |
0 | 184 |
ML {* |
15 | 185 |
fun typedef_quot_type_tac equiv_thm (typedef_info: Typedef.info) = |
0 | 186 |
let |
187 |
val rep_thm = #Rep typedef_info |
|
188 |
val rep_inv = #Rep_inverse typedef_info |
|
189 |
val abs_inv = #Abs_inverse typedef_info |
|
190 |
val rep_inj = #Rep_inject typedef_info |
|
191 |
||
192 |
val ss = HOL_basic_ss addsimps @{thms mem_def} |
|
193 |
val rep_thm_simpd = Simplifier.asm_full_simplify ss rep_thm |
|
194 |
val abs_inv_simpd = Simplifier.asm_full_simplify ss abs_inv |
|
195 |
in |
|
196 |
EVERY1 [rtac @{thm QUOT_TYPE.intro}, |
|
15 | 197 |
rtac equiv_thm, |
198 |
rtac rep_thm_simpd, |
|
199 |
rtac rep_inv, |
|
0 | 200 |
rtac abs_inv_simpd, rtac @{thm exI}, rtac @{thm refl}, |
201 |
rtac rep_inj] |
|
202 |
end |
|
203 |
*} |
|
204 |
||
2 | 205 |
term QUOT_TYPE |
206 |
ML {* HOLogic.mk_Trueprop *} |
|
207 |
ML {* Goal.prove *} |
|
208 |
ML {* Syntax.check_term *} |
|
209 |
||
15 | 210 |
ML {* |
0 | 211 |
fun typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy = |
212 |
let |
|
213 |
val quot_type_const = Const (@{const_name "QUOT_TYPE"}, dummyT) |
|
214 |
val goal = HOLogic.mk_Trueprop (quot_type_const $ rel $ abs $ rep) |
|
215 |
|> Syntax.check_term lthy |
|
216 |
in |
|
217 |
Goal.prove lthy [] [] goal |
|
218 |
(fn _ => typedef_quot_type_tac equiv_thm typedef_info) |
|
219 |
end |
|
220 |
*} |
|
221 |
||
222 |
ML {* |
|
223 |
fun typedef_quotient_thm_tac defs quot_type_thm = |
|
15 | 224 |
EVERY1 [K (rewrite_goals_tac defs), |
225 |
rtac @{thm QUOT_TYPE.QUOTIENT}, |
|
0 | 226 |
rtac quot_type_thm] |
227 |
*} |
|
228 |
||
15 | 229 |
ML {* |
0 | 230 |
fun typedef_quotient_thm (rel, abs, rep, abs_def, rep_def, quot_type_thm) lthy = |
231 |
let |
|
232 |
val quotient_const = Const (@{const_name "QUOTIENT"}, dummyT) |
|
233 |
val goal = HOLogic.mk_Trueprop (quotient_const $ rel $ abs $ rep) |
|
234 |
|> Syntax.check_term lthy |
|
235 |
in |
|
236 |
Goal.prove lthy [] [] goal |
|
237 |
(fn _ => typedef_quotient_thm_tac [abs_def, rep_def] quot_type_thm) |
|
238 |
end |
|
239 |
*} |
|
240 |
||
241 |
text {* two wrappers for define and note *} |
|
15 | 242 |
ML {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
243 |
fun make_def (name, mx, rhs) lthy = |
15 | 244 |
let |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
245 |
val ((rhs, (_ , thm)), lthy') = |
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
246 |
LocalTheory.define Thm.internalK ((name, mx), (Attrib.empty_binding, rhs)) lthy |
0 | 247 |
in |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
248 |
((rhs, thm), lthy') |
0 | 249 |
end |
250 |
*} |
|
251 |
||
252 |
ML {* |
|
15 | 253 |
fun reg_thm (name, thm) lthy = |
0 | 254 |
let |
15 | 255 |
val ((_,[thm']), lthy') = LocalTheory.note Thm.theoremK ((name, []), [thm]) lthy |
0 | 256 |
in |
16 | 257 |
(thm', lthy') |
0 | 258 |
end |
259 |
*} |
|
260 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
261 |
ML {* |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
262 |
val no_vars = Thm.rule_attribute (fn context => fn th => |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
263 |
let |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
264 |
val ctxt = Variable.set_body false (Context.proof_of context); |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
265 |
val ((_, [th']), _) = Variable.import true [th] ctxt; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
266 |
in th' end); |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
267 |
*} |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
268 |
|
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
269 |
ML {* |
0 | 270 |
fun typedef_main (qty_name, rel, ty, equiv_thm) lthy = |
15 | 271 |
let |
0 | 272 |
(* generates typedef *) |
16 | 273 |
val ((_, typedef_info), lthy') = typedef_make (qty_name, rel, ty) lthy |
0 | 274 |
|
275 |
(* abs and rep functions *) |
|
276 |
val abs_ty = #abs_type typedef_info |
|
277 |
val rep_ty = #rep_type typedef_info |
|
278 |
val abs_name = #Abs_name typedef_info |
|
279 |
val rep_name = #Rep_name typedef_info |
|
280 |
val abs = Const (abs_name, rep_ty --> abs_ty) |
|
281 |
val rep = Const (rep_name, abs_ty --> rep_ty) |
|
282 |
||
283 |
(* ABS and REP definitions *) |
|
284 |
val ABS_const = Const (@{const_name "QUOT_TYPE.ABS"}, dummyT ) |
|
285 |
val REP_const = Const (@{const_name "QUOT_TYPE.REP"}, dummyT ) |
|
15 | 286 |
val ABS_trm = Syntax.check_term lthy' (ABS_const $ rel $ abs) |
287 |
val REP_trm = Syntax.check_term lthy' (REP_const $ rep) |
|
0 | 288 |
val ABS_name = Binding.prefix_name "ABS_" qty_name |
15 | 289 |
val REP_name = Binding.prefix_name "REP_" qty_name |
290 |
val (((ABS, ABS_def), (REP, REP_def)), lthy'') = |
|
0 | 291 |
lthy' |> make_def (ABS_name, NoSyn, ABS_trm) |
292 |
||>> make_def (REP_name, NoSyn, REP_trm) |
|
293 |
||
294 |
(* quot_type theorem *) |
|
295 |
val quot_thm = typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy'' |
|
296 |
val quot_thm_name = Binding.prefix_name "QUOT_TYPE_" qty_name |
|
297 |
||
298 |
(* quotient theorem *) |
|
299 |
val quotient_thm = typedef_quotient_thm (rel, ABS, REP, ABS_def, REP_def, quot_thm) lthy'' |
|
300 |
val quotient_thm_name = Binding.prefix_name "QUOTIENT_" qty_name |
|
301 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
302 |
(* interpretation *) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
303 |
val bindd = ((Binding.make ("", Position.none)), ([]: Attrib.src list)) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
304 |
val ((_, [eqn1pre]), lthy''') = Variable.import true [ABS_def] lthy''; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
305 |
val eqn1i = Thm.prop_of (symmetric eqn1pre) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
306 |
val ((_, [eqn2pre]), lthy'''') = Variable.import true [REP_def] lthy'''; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
307 |
val eqn2i = Thm.prop_of (symmetric eqn2pre) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
308 |
|
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
309 |
val exp_morphism = ProofContext.export_morphism lthy'''' (ProofContext.init (ProofContext.theory_of lthy'''')); |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
310 |
val exp_term = Morphism.term exp_morphism; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
311 |
val exp = Morphism.thm exp_morphism; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
312 |
|
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
313 |
val mthd = Method.SIMPLE_METHOD ((rtac quot_thm 1) THEN |
16 | 314 |
ALLGOALS (simp_tac (HOL_basic_ss addsimps [(symmetric (exp ABS_def)), (symmetric (exp REP_def))]))) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
315 |
val mthdt = Method.Basic (fn _ => mthd) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
316 |
val bymt = Proof.global_terminal_proof (mthdt, NONE) |
16 | 317 |
val exp_i = [(@{const_name QUOT_TYPE}, ((("QUOT_TYPE_I_" ^ (Binding.name_of qty_name)), true), |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
318 |
Expression.Named [ |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
319 |
("R", rel), |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
320 |
("Abs", abs), |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
321 |
("Rep", rep) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
322 |
]))] |
0 | 323 |
in |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
324 |
lthy'''' |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
325 |
|> reg_thm (quot_thm_name, quot_thm) |
0 | 326 |
||>> reg_thm (quotient_thm_name, quotient_thm) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
327 |
||> LocalTheory.theory (fn thy => |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
328 |
let |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
329 |
val global_eqns = map exp_term [eqn2i, eqn1i]; |
16 | 330 |
(* Not sure if the following context should not be used *) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
331 |
val (global_eqns2, lthy''''') = Variable.import_terms true global_eqns lthy''''; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
332 |
val global_eqns3 = map (fn t => (bindd, t)) global_eqns2; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
333 |
in ProofContext.theory_of (bymt (Expression.interpretation (exp_i, []) global_eqns3 thy)) end) |
0 | 334 |
end |
335 |
*} |
|
336 |
||
337 |
section {* various tests for quotient types*} |
|
338 |
datatype trm = |
|
15 | 339 |
var "nat" |
0 | 340 |
| app "trm" "trm" |
341 |
| lam "nat" "trm" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
342 |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
343 |
axiomatization RR :: "trm \<Rightarrow> trm \<Rightarrow> bool" where |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
344 |
r_eq: "EQUIV RR" |
0 | 345 |
|
2 | 346 |
ML {* |
15 | 347 |
typedef_main |
2 | 348 |
*} |
349 |
||
0 | 350 |
local_setup {* |
16 | 351 |
typedef_main (@{binding "qtrm"}, @{term "RR"}, @{typ trm}, @{thm r_eq}) #> snd |
0 | 352 |
*} |
353 |
||
354 |
term Rep_qtrm |
|
2 | 355 |
term REP_qtrm |
0 | 356 |
term Abs_qtrm |
357 |
term ABS_qtrm |
|
358 |
thm QUOT_TYPE_qtrm |
|
359 |
thm QUOTIENT_qtrm |
|
2 | 360 |
|
16 | 361 |
(* Test interpretation *) |
362 |
thm QUOT_TYPE_I_qtrm.thm11 |
|
363 |
||
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
364 |
print_theorems |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
365 |
|
0 | 366 |
thm Rep_qtrm |
367 |
||
368 |
text {* another test *} |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
369 |
datatype 'a my = Foo |
0 | 370 |
consts Rmy :: "'a my \<Rightarrow> 'a my \<Rightarrow> bool" |
371 |
axioms rmy_eq: "EQUIV Rmy" |
|
372 |
||
373 |
term "\<lambda>(c::'a my\<Rightarrow>bool). \<exists>x. c = Rmy x" |
|
374 |
||
375 |
datatype 'a trm' = |
|
15 | 376 |
var' "'a" |
0 | 377 |
| app' "'a trm'" "'a trm'" |
378 |
| lam' "'a" "'a trm'" |
|
15 | 379 |
|
0 | 380 |
consts R' :: "'a trm' \<Rightarrow> 'a trm' \<Rightarrow> bool" |
381 |
axioms r_eq': "EQUIV R'" |
|
382 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
383 |
|
0 | 384 |
local_setup {* |
16 | 385 |
typedef_main (@{binding "qtrm'"}, @{term "R'"}, @{typ "'a trm'"}, @{thm r_eq'}) #> snd |
0 | 386 |
*} |
387 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
388 |
print_theorems |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
389 |
|
0 | 390 |
term ABS_qtrm' |
391 |
term REP_qtrm' |
|
392 |
thm QUOT_TYPE_qtrm' |
|
393 |
thm QUOTIENT_qtrm' |
|
394 |
thm Rep_qtrm' |
|
395 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
396 |
|
0 | 397 |
text {* a test with lists of terms *} |
398 |
datatype t = |
|
399 |
vr "string" |
|
400 |
| ap "t list" |
|
401 |
| lm "string" "t" |
|
402 |
||
403 |
consts Rt :: "t \<Rightarrow> t \<Rightarrow> bool" |
|
404 |
axioms t_eq: "EQUIV Rt" |
|
405 |
||
406 |
local_setup {* |
|
407 |
typedef_main (@{binding "qt"}, @{term "Rt"}, @{typ "t"}, @{thm t_eq}) #> snd |
|
408 |
*} |
|
409 |
||
410 |
section {* lifting of constants *} |
|
411 |
||
412 |
text {* information about map-functions for type-constructor *} |
|
413 |
ML {* |
|
414 |
type typ_info = {mapfun: string} |
|
415 |
||
416 |
local |
|
417 |
structure Data = GenericDataFun |
|
418 |
(type T = typ_info Symtab.table |
|
419 |
val empty = Symtab.empty |
|
420 |
val extend = I |
|
421 |
fun merge _ = Symtab.merge (K true)) |
|
422 |
in |
|
423 |
val lookup = Symtab.lookup o Data.get |
|
15 | 424 |
fun update k v = Data.map (Symtab.update (k, v)) |
0 | 425 |
end |
426 |
*} |
|
427 |
||
428 |
(* mapfuns for some standard types *) |
|
429 |
setup {* |
|
430 |
Context.theory_map (update @{type_name "list"} {mapfun = @{const_name "map"}}) |
|
431 |
#> Context.theory_map (update @{type_name "*"} {mapfun = @{const_name "prod_fun"}}) |
|
432 |
#> Context.theory_map (update @{type_name "fun"} {mapfun = @{const_name "fun_map"}}) |
|
433 |
*} |
|
434 |
||
2 | 435 |
|
0 | 436 |
ML {* lookup (Context.Proof @{context}) @{type_name list} *} |
437 |
||
438 |
ML {* |
|
439 |
datatype abs_or_rep = abs | rep |
|
440 |
||
15 | 441 |
fun get_fun abs_or_rep rty qty lthy ty = |
0 | 442 |
let |
443 |
val qty_name = Long_Name.base_name (fst (dest_Type qty)) |
|
15 | 444 |
|
0 | 445 |
fun get_fun_aux s fs_tys = |
446 |
let |
|
447 |
val (fs, tys) = split_list fs_tys |
|
15 | 448 |
val (otys, ntys) = split_list tys |
0 | 449 |
val oty = Type (s, otys) |
450 |
val nty = Type (s, ntys) |
|
451 |
val ftys = map (op -->) tys |
|
452 |
in |
|
15 | 453 |
(case (lookup (Context.Proof lthy) s) of |
0 | 454 |
SOME info => (list_comb (Const (#mapfun info, ftys ---> oty --> nty), fs), (oty, nty)) |
455 |
| NONE => raise ERROR ("no map association for type " ^ s)) |
|
456 |
end |
|
457 |
||
458 |
fun get_const abs = (Const ("QuotMain.ABS_" ^ qty_name, rty --> qty), (rty, qty)) |
|
459 |
| get_const rep = (Const ("QuotMain.REP_" ^ qty_name, qty --> rty), (qty, rty)) |
|
460 |
in |
|
461 |
if ty = qty |
|
462 |
then (get_const abs_or_rep) |
|
463 |
else (case ty of |
|
464 |
TFree _ => (Abs ("x", ty, Bound 0), (ty, ty)) |
|
465 |
| Type (_, []) => (Abs ("x", ty, Bound 0), (ty, ty)) |
|
15 | 466 |
| Type (s, tys) => get_fun_aux s (map (get_fun abs_or_rep rty qty lthy) tys) |
0 | 467 |
| _ => raise ERROR ("no variables") |
468 |
) |
|
469 |
end |
|
470 |
*} |
|
471 |
||
472 |
ML {* |
|
2 | 473 |
get_fun rep @{typ t} @{typ qt} @{context} @{typ "t * nat"} |
474 |
|> fst |
|
475 |
|> Syntax.string_of_term @{context} |
|
476 |
|> writeln |
|
477 |
*} |
|
478 |
||
479 |
||
480 |
ML {* |
|
0 | 481 |
fun get_const_def nconst oconst rty qty lthy = |
482 |
let |
|
483 |
val ty = fastype_of nconst |
|
484 |
val (arg_tys, res_ty) = strip_type ty |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
485 |
|
0 | 486 |
val fresh_args = arg_tys |> map (pair "x") |
15 | 487 |
|> Variable.variant_frees lthy [nconst, oconst] |
0 | 488 |
|> map Free |
489 |
||
490 |
val rep_fns = map (fst o get_fun rep rty qty lthy) arg_tys |
|
491 |
val abs_fn = (fst o get_fun abs rty qty lthy) res_ty |
|
492 |
||
493 |
in |
|
494 |
map (op $) (rep_fns ~~ fresh_args) |
|
495 |
|> curry list_comb oconst |
|
496 |
|> curry (op $) abs_fn |
|
497 |
|> fold_rev lambda fresh_args |
|
498 |
end |
|
499 |
*} |
|
500 |
||
501 |
ML {* |
|
15 | 502 |
fun exchange_ty rty qty ty = |
0 | 503 |
if ty = rty then qty |
15 | 504 |
else |
0 | 505 |
(case ty of |
506 |
Type (s, tys) => Type (s, map (exchange_ty rty qty) tys) |
|
507 |
| _ => ty) |
|
508 |
*} |
|
509 |
||
510 |
ML {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
511 |
fun make_const_def nconst_bname oconst mx rty qty lthy = |
0 | 512 |
let |
513 |
val oconst_ty = fastype_of oconst |
|
514 |
val nconst_ty = exchange_ty rty qty oconst_ty |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
515 |
val nconst = Const (Binding.name_of nconst_bname, nconst_ty) |
0 | 516 |
val def_trm = get_const_def nconst oconst rty qty lthy |
517 |
in |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
518 |
make_def (nconst_bname, mx, def_trm) lthy |
15 | 519 |
end |
0 | 520 |
*} |
521 |
||
2 | 522 |
local_setup {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
523 |
make_const_def @{binding VR} @{term "vr"} NoSyn @{typ "t"} @{typ "qt"} #> snd |
2 | 524 |
*} |
525 |
||
526 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
527 |
make_const_def @{binding AP} @{term "ap"} NoSyn @{typ "t"} @{typ "qt"} #> snd |
2 | 528 |
*} |
529 |
||
530 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
531 |
make_const_def @{binding LM} @{term "lm"} NoSyn @{typ "t"} @{typ "qt"} #> snd |
2 | 532 |
*} |
533 |
||
534 |
thm VR_def |
|
535 |
thm AP_def |
|
536 |
thm LM_def |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
537 |
term LM |
2 | 538 |
term VR |
539 |
term AP |
|
540 |
||
541 |
||
0 | 542 |
text {* a test with functions *} |
543 |
datatype 'a t' = |
|
544 |
vr' "string" |
|
545 |
| ap' "('a t') * ('a t')" |
|
546 |
| lm' "'a" "string \<Rightarrow> ('a t')" |
|
547 |
||
548 |
consts Rt' :: "('a t') \<Rightarrow> ('a t') \<Rightarrow> bool" |
|
549 |
axioms t_eq': "EQUIV Rt'" |
|
550 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
551 |
|
0 | 552 |
local_setup {* |
553 |
typedef_main (@{binding "qt'"}, @{term "Rt'"}, @{typ "'a t'"}, @{thm t_eq'}) #> snd |
|
554 |
*} |
|
555 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
556 |
print_theorems |
2 | 557 |
|
0 | 558 |
local_setup {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
559 |
make_const_def @{binding VR'} @{term "vr'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd |
0 | 560 |
*} |
561 |
||
562 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
563 |
make_const_def @{binding AP'} @{term "ap'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd |
0 | 564 |
*} |
565 |
||
566 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
567 |
make_const_def @{binding LM'} @{term "lm'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd |
0 | 568 |
*} |
569 |
||
570 |
thm VR'_def |
|
571 |
thm AP'_def |
|
572 |
thm LM'_def |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
573 |
term LM' |
0 | 574 |
term VR' |
575 |
term AP' |
|
576 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
577 |
|
0 | 578 |
text {* finite set example *} |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
579 |
print_syntax |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
580 |
inductive |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
581 |
list_eq (infix "\<approx>" 50) |
0 | 582 |
where |
583 |
"a#b#xs \<approx> b#a#xs" |
|
584 |
| "[] \<approx> []" |
|
585 |
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs" |
|
586 |
| "a#a#xs \<approx> a#xs" |
|
587 |
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys" |
|
588 |
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3" |
|
589 |
||
590 |
lemma list_eq_sym: |
|
591 |
shows "xs \<approx> xs" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
592 |
apply (induct xs) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
593 |
apply (auto intro: list_eq.intros) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
594 |
done |
0 | 595 |
|
596 |
lemma equiv_list_eq: |
|
597 |
shows "EQUIV list_eq" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
598 |
unfolding EQUIV_REFL_SYM_TRANS REFL_def SYM_def TRANS_def |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
599 |
apply(auto intro: list_eq.intros list_eq_sym) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
600 |
done |
0 | 601 |
|
602 |
local_setup {* |
|
603 |
typedef_main (@{binding "fset"}, @{term "list_eq"}, @{typ "'a list"}, @{thm "equiv_list_eq"}) #> snd |
|
604 |
*} |
|
605 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
606 |
print_theorems |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
607 |
|
0 | 608 |
typ "'a fset" |
609 |
thm "Rep_fset" |
|
610 |
||
611 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
612 |
make_const_def @{binding EMPTY} @{term "[]"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 613 |
*} |
614 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
615 |
term Nil |
0 | 616 |
term EMPTY |
2 | 617 |
thm EMPTY_def |
618 |
||
0 | 619 |
|
620 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
621 |
make_const_def @{binding INSERT} @{term "op #"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 622 |
*} |
623 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
624 |
term Cons |
0 | 625 |
term INSERT |
2 | 626 |
thm INSERT_def |
0 | 627 |
|
628 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
629 |
make_const_def @{binding UNION} @{term "op @"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 630 |
*} |
631 |
||
15 | 632 |
term append |
0 | 633 |
term UNION |
2 | 634 |
thm UNION_def |
635 |
||
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
636 |
(* Maybe the infrastructure should not allow this kind of definition, without showing that |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
637 |
the relation respects lenght... *) |
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
638 |
local_setup {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
639 |
make_const_def @{binding CARD} @{term "length"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
640 |
*} |
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
641 |
|
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
642 |
term length |
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
643 |
term CARD |
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
644 |
thm CARD_def |
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
645 |
|
0 | 646 |
thm QUOTIENT_fset |
647 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
648 |
thm QUOT_TYPE_I_fset.thm11 |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
649 |
|
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
650 |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
651 |
fun |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
652 |
membship :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infix "memb" 100) |
0 | 653 |
where |
654 |
m1: "(x memb []) = False" |
|
655 |
| m2: "(x memb (y#xs)) = ((x=y) \<or> (x memb xs))" |
|
656 |
||
2 | 657 |
lemma mem_respects: |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
658 |
fixes z |
2 | 659 |
assumes a: "list_eq x y" |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
660 |
shows "(z memb x) = (z memb y)" |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
661 |
using a by induct auto |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
662 |
|
2 | 663 |
|
12 | 664 |
lemma cons_preserves: |
665 |
fixes z |
|
666 |
assumes a: "xs \<approx> ys" |
|
667 |
shows "(z # xs) \<approx> (z # ys)" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
668 |
using a by (rule QuotMain.list_eq.intros(5)) |
12 | 669 |
|
11
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
670 |
ML {* |
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
671 |
fun unlam_def orig_ctxt ctxt t = |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
672 |
let val rhs = Thm.rhs_of t in |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
673 |
(case try (Thm.dest_abs NONE) rhs of |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
674 |
SOME (v, vt) => |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
675 |
let |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
676 |
val (vname, vt) = Term.dest_Free (Thm.term_of v) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
677 |
val ([vnname], ctxt) = Variable.variant_fixes [vname] ctxt |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
678 |
val nv = Free(vnname, vt) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
679 |
val t2 = Drule.fun_cong_rule t (Thm.cterm_of (ProofContext.theory_of ctxt) nv) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
680 |
val tnorm = equal_elim (Drule.beta_eta_conversion (Thm.cprop_of t2)) t2 |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
681 |
in unlam_def orig_ctxt ctxt tnorm end |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
682 |
| NONE => singleton (ProofContext.export ctxt orig_ctxt) t) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
683 |
end |
10
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
684 |
*} |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
685 |
|
10
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
686 |
local_setup {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
687 |
make_const_def @{binding IN} @{term "membship"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
10
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
688 |
*} |
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
689 |
|
0 | 690 |
term membship |
691 |
term IN |
|
2 | 692 |
thm IN_def |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
693 |
ML {* unlam_def @{context} @{context} @{thm IN_def} *} |
0 | 694 |
|
2 | 695 |
lemmas a = QUOT_TYPE.ABS_def[OF QUOT_TYPE_fset] |
696 |
thm QUOT_TYPE.thm11[OF QUOT_TYPE_fset, THEN iffD1, simplified a] |
|
0 | 697 |
|
2 | 698 |
lemma yy: |
699 |
shows "(False = x memb []) = (False = IN (x::nat) EMPTY)" |
|
700 |
unfolding IN_def EMPTY_def |
|
701 |
apply(rule_tac f="(op =) False" in arg_cong) |
|
702 |
apply(rule mem_respects) |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
703 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
2 | 704 |
apply(rule list_eq.intros) |
0 | 705 |
done |
706 |
||
2 | 707 |
lemma |
708 |
shows "IN (x::nat) EMPTY = False" |
|
709 |
using m1 |
|
710 |
apply - |
|
711 |
apply(rule yy[THEN iffD1, symmetric]) |
|
712 |
apply(simp) |
|
0 | 713 |
done |
714 |
||
2 | 715 |
lemma |
716 |
shows "((x=y) \<or> (IN x xs) = (IN (x::nat) (INSERT y xs))) = |
|
717 |
((x = y) \<or> x memb REP_fset xs = x memb (y # REP_fset xs))" |
|
718 |
unfolding IN_def INSERT_def |
|
719 |
apply(rule_tac f="(op \<or>) (x=y)" in arg_cong) |
|
720 |
apply(rule_tac f="(op =) (x memb REP_fset xs)" in arg_cong) |
|
721 |
apply(rule mem_respects) |
|
722 |
apply(rule list_eq.intros(3)) |
|
723 |
apply(unfold REP_fset_def ABS_fset_def) |
|
5 | 724 |
apply(simp only: QUOT_TYPE.REP_ABS_rsp[OF QUOT_TYPE_fset]) |
2 | 725 |
apply(rule list_eq_sym) |
726 |
done |
|
0 | 727 |
|
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
728 |
lemma append_respects_fst: |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
729 |
assumes a : "list_eq l1 l2" |
4 | 730 |
shows "list_eq (l1 @ s) (l2 @ s)" |
3 | 731 |
using a |
732 |
apply(induct) |
|
4 | 733 |
apply(auto intro: list_eq.intros) |
734 |
apply(simp add: list_eq_sym) |
|
3 | 735 |
done |
736 |
||
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
737 |
lemma yyy: |
3 | 738 |
shows " |
739 |
( |
|
740 |
(UNION EMPTY s = s) & |
|
741 |
((UNION (INSERT e s1) s2) = (INSERT e (UNION s1 s2))) |
|
742 |
) = ( |
|
743 |
((ABS_fset ([] @ REP_fset s)) = s) & |
|
744 |
((ABS_fset ((e # (REP_fset s1)) @ REP_fset s2)) = ABS_fset (e # (REP_fset s1 @ REP_fset s2))) |
|
745 |
)" |
|
746 |
unfolding UNION_def EMPTY_def INSERT_def |
|
747 |
apply(rule_tac f="(op &)" in arg_cong2) |
|
748 |
apply(rule_tac f="(op =)" in arg_cong2) |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
749 |
apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
750 |
apply(rule append_respects_fst) |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
751 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
3 | 752 |
apply(rule list_eq_sym) |
753 |
apply(simp) |
|
754 |
apply(rule_tac f="(op =)" in arg_cong2) |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
755 |
apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
756 |
apply(rule append_respects_fst) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
757 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
3 | 758 |
apply(rule list_eq_sym) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
759 |
apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
3 | 760 |
apply(rule list_eq.intros(5)) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
761 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
3 | 762 |
apply(rule list_eq_sym) |
763 |
done |
|
764 |
||
765 |
lemma |
|
766 |
shows " |
|
767 |
(UNION EMPTY s = s) & |
|
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
768 |
((UNION (INSERT e s1) s2) = (INSERT e (UNION s1 s2)))" |
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
769 |
apply (simp add: yyy) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
770 |
apply (rule QUOT_TYPE_I_fset.thm10) |
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
771 |
done |
3 | 772 |
|
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
773 |
ML {* |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
774 |
fun mk_rep_abs x = @{term REP_fset} $ (@{term ABS_fset} $ x) |
12 | 775 |
val consts = [@{const_name "Nil"}, @{const_name "append"}, @{const_name "Cons"}, @{const_name "membship"}] |
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
776 |
*} |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
777 |
|
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
778 |
ML {* |
12 | 779 |
fun build_goal thm constructors lifted_type mk_rep_abs = |
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
780 |
let |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
781 |
fun is_const (Const (x, t)) = x mem constructors |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
782 |
| is_const _ = false |
12 | 783 |
fun maybe_mk_rep_abs t = |
784 |
let |
|
785 |
val _ = writeln ("Maybe: " ^ Syntax.string_of_term @{context} t) |
|
786 |
in |
|
787 |
if type_of t = lifted_type then mk_rep_abs t else t |
|
788 |
end |
|
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
789 |
fun build_aux (Abs (s, t, tr)) = (Abs (s, t, build_aux tr)) |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
790 |
| build_aux (f $ a) = |
11
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
791 |
let |
16 | 792 |
val (f, args) = strip_comb (f $ a) |
12 | 793 |
val _ = writeln (Syntax.string_of_term @{context} f) |
11
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
794 |
in |
12 | 795 |
(if is_const f then maybe_mk_rep_abs (list_comb (f, (map maybe_mk_rep_abs (map build_aux args)))) |
11
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
796 |
else list_comb ((build_aux f), (map build_aux args))) |
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
797 |
end |
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
798 |
| build_aux x = |
12 | 799 |
if is_const x then maybe_mk_rep_abs x else x |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
800 |
val concl = HOLogic.dest_Trueprop (Thm.concl_of thm) |
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
801 |
in |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
802 |
HOLogic.mk_eq ((build_aux concl), concl) |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
803 |
end *} |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
804 |
|
16 | 805 |
ML {* val emptyt = (symmetric (unlam_def @{context} @{context} @{thm EMPTY_def})) *} |
806 |
ML {* val in_t = (symmetric (unlam_def @{context} @{context} @{thm IN_def})) *} |
|
807 |
ML {* val uniont = symmetric (unlam_def @{context} @{context} @{thm UNION_def}) *} |
|
808 |
ML {* val cardt = symmetric (unlam_def @{context} @{context} @{thm CARD_def}) *} |
|
809 |
ML {* val insertt = symmetric (unlam_def @{context} @{context} @{thm INSERT_def}) *} |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
810 |
ML {* val fset_defs = @{thms EMPTY_def IN_def UNION_def CARD_def INSERT_def} *} |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
811 |
ML {* val fset_defs_sym = [emptyt, in_t, uniont, cardt, insertt] *} |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
812 |
|
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
813 |
ML {* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
814 |
fun dest_cbinop t = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
815 |
let |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
816 |
val (t2, rhs) = Thm.dest_comb t; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
817 |
val (bop, lhs) = Thm.dest_comb t2; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
818 |
in |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
819 |
(bop, (lhs, rhs)) |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
820 |
end |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
821 |
*} |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
822 |
ML {* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
823 |
fun dest_ceq t = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
824 |
let |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
825 |
val (bop, pair) = dest_cbinop t; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
826 |
val (bop_s, _) = Term.dest_Const (Thm.term_of bop); |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
827 |
in |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
828 |
if bop_s = "op =" then pair else (raise CTERM ("Not an equality", [t])) |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
829 |
end |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
830 |
*} |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
831 |
ML Thm.instantiate |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
832 |
ML {*@{thm arg_cong2}*} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
833 |
ML {*@{thm arg_cong2[of _ _ _ _ "op ="]} *} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
834 |
ML {* val cT = @{cpat "op ="} |> Thm.ctyp_of_term |> Thm.dest_ctyp |> hd *} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
835 |
ML {* |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
836 |
Toplevel.program (fn () => |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
837 |
Drule.instantiate' [SOME cT,SOME cT,SOME @{ctyp bool}] [NONE,NONE,NONE,NONE,SOME (@{cpat "op ="})] @{thm arg_cong2} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
838 |
) |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
839 |
*} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
840 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
841 |
ML {* |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
842 |
fun foo_conv t = |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
843 |
let |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
844 |
val (lhs, rhs) = dest_ceq t; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
845 |
val (bop, _) = dest_cbinop lhs; |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
846 |
val [clT, cr2] = bop |> Thm.ctyp_of_term |> Thm.dest_ctyp; |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
847 |
val [cmT, crT] = Thm.dest_ctyp cr2; |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
848 |
in |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
849 |
Drule.instantiate' [SOME clT,SOME cmT,SOME crT] [NONE,NONE,NONE,NONE,SOME bop] @{thm arg_cong2} |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
850 |
end |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
851 |
*} |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
852 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
853 |
ML {* |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
854 |
fun foo_tac n thm = |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
855 |
let |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
856 |
val concl = Thm.cprem_of thm n; |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
857 |
val (_, cconcl) = Thm.dest_comb concl; |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
858 |
val rewr = foo_conv cconcl; |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
859 |
val _ = tracing (Display.string_of_thm @{context} rewr) |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
860 |
val _ = tracing (Display.string_of_thm @{context} thm) |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
861 |
in |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
862 |
rtac rewr n thm |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
863 |
end |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
864 |
handle CTERM _ => Seq.empty |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
865 |
*} |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
866 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
867 |
(* Has all the theorems about fset plugged in. These should be parameters to the tactic *) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
868 |
|
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
869 |
ML {* |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
870 |
val foo_tac' = |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
871 |
FIRST' [ |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
872 |
rtac @{thm list_eq_sym}, |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
873 |
rtac @{thm cons_preserves}, |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
874 |
rtac @{thm mem_respects}, |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
875 |
foo_tac, |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
876 |
simp_tac (@{simpset} addsimps @{thms QUOT_TYPE_I_fset.REP_ABS_rsp}) |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
877 |
] |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
878 |
*} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
879 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
880 |
thm m1 |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
881 |
|
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
882 |
ML {* |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
883 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm m1})) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
884 |
val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
885 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
886 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
887 |
*} |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
888 |
|
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
889 |
prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
890 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
891 |
apply (tactic {* foo_tac' 1 *}) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
892 |
apply (tactic {* foo_tac' 1 *}) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
893 |
apply (tactic {* foo_tac' 1 *}) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
894 |
apply (tactic {* foo_tac' 1 *}) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
895 |
apply (tactic {* foo_tac' 1 *}) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
896 |
done |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
897 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
898 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
899 |
thm length_append (* Not true but worth checking that the goal is correct *) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
900 |
ML {* |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
901 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm length_append})) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
902 |
val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
903 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
904 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
905 |
*} |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
906 |
(* prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
907 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
908 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
909 |
apply (tactic {* foo_tac' 2 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
910 |
apply (tactic {* foo_tac' 2 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
911 |
apply (tactic {* foo_tac' 2 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
912 |
apply (tactic {* foo_tac' 1 *}) *) |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
913 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
914 |
thm m2 |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
915 |
ML {* |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
916 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm m2})) |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
917 |
val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
918 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
919 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
920 |
*} |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
921 |
prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
922 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
923 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
924 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
925 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
926 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
927 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
928 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
929 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
930 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
931 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
932 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
933 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
934 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
935 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
936 |
done |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
937 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
938 |
thm list_eq.intros(4) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
939 |
ML {* |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
940 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm list_eq.intros(4)})) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
941 |
val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
942 |
val cgoal = cterm_of @{theory} goal |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
943 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
944 |
(* Why doesn't this work? *) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
945 |
val cgoal3 = Thm.rhs_of (MetaSimplifier.rewrite true @{thms QUOT_TYPE_I_fset.thm10 QUOT_TYPE_I_fset.REPS_same} cgoal2) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
946 |
*} |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
947 |
thm QUOT_TYPE_I_fset.thm10 |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
948 |
thm QUOT_TYPE_I_fset.REPS_same |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
949 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
950 |
(* keep it commented out, until we get a proving mechanism *) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
951 |
(*prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal3) *}*) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
952 |
lemma zzz : |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
953 |
"(REP_fset (INSERT a (INSERT a (ABS_fset xs))) \<approx> |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
954 |
REP_fset (INSERT a (ABS_fset xs))) = (a # a # xs \<approx> a # xs)" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
955 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
956 |
apply (simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
957 |
(* apply (simp only: QUOT_TYPE_I_fset.thm10)*) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
958 |
apply (rule QUOT_TYPE_I_fset.R_trans2) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
959 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
960 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
961 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
962 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
963 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
964 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
965 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
966 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
967 |
done |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
968 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
969 |
thm list_eq.intros(5) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
970 |
ML {* |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
971 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}),@{thm list_eq.intros(5)})) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
972 |
val goal = build_goal m1_novars consts @{typ "'a list"} mk_rep_abs |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
973 |
val cgoal = cterm_of @{theory} goal |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
974 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
975 |
*} |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
976 |
prove {* HOLogic.mk_Trueprop (Thm.term_of cgoal2) *} |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
977 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
978 |
apply (rule QUOT_TYPE_I_fset.R_trans2) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
979 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
980 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
981 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
982 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
983 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
984 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
985 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
986 |
apply (tactic {* foo_tac' 1 *}) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
987 |
done |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
988 |
|
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
989 |
(* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
990 |
datatype obj1 = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
991 |
OVAR1 "string" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
992 |
| OBJ1 "(string * (string \<Rightarrow> obj1)) list" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
993 |
| INVOKE1 "obj1 \<Rightarrow> string" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
994 |
| UPDATE1 "obj1 \<Rightarrow> string \<Rightarrow> (string \<Rightarrow> obj1)" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
995 |
*) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
996 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
997 |