author | Christian Urban <urbanc@in.tum.de> |
Tue, 06 Oct 2009 02:02:51 +0200 | |
changeset 65 | da982cded326 |
parent 64 | 33d7bcfd5603 |
child 66 | 564bf4343f63 |
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: |
|
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
32 |
shows "ABS (REP a) \<equiv> a" |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
33 |
apply (rule eq_reflection) |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
34 |
unfolding ABS_def REP_def |
0 | 35 |
proof - |
15 | 36 |
from rep_prop |
0 | 37 |
obtain x where eq: "Rep a = R x" by auto |
38 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
|
39 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
|
40 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
|
41 |
also have "\<dots> = a" using rep_inverse by simp |
|
42 |
finally |
|
43 |
show "Abs (R (Eps (Rep a))) = a" by simp |
|
44 |
qed |
|
45 |
||
15 | 46 |
lemma REP_refl: |
0 | 47 |
shows "R (REP a) (REP a)" |
48 |
unfolding REP_def |
|
49 |
by (simp add: equiv[simplified EQUIV_def]) |
|
50 |
||
51 |
lemma lem7: |
|
22 | 52 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
0 | 53 |
apply(rule iffI) |
54 |
apply(simp) |
|
55 |
apply(drule rep_inject[THEN iffD2]) |
|
56 |
apply(simp add: abs_inverse) |
|
57 |
done |
|
15 | 58 |
|
0 | 59 |
theorem thm11: |
60 |
shows "R r r' = (ABS r = ABS r')" |
|
61 |
unfolding ABS_def |
|
62 |
by (simp only: equiv[simplified EQUIV_def] lem7) |
|
63 |
||
4 | 64 |
|
2 | 65 |
lemma REP_ABS_rsp: |
4 | 66 |
shows "R f (REP (ABS g)) = R f g" |
67 |
and "R (REP (ABS g)) f = R g f" |
|
23 | 68 |
by (simp_all add: thm10 thm11) |
4 | 69 |
|
0 | 70 |
lemma QUOTIENT: |
71 |
"QUOTIENT R ABS REP" |
|
72 |
apply(unfold QUOTIENT_def) |
|
73 |
apply(simp add: thm10) |
|
74 |
apply(simp add: REP_refl) |
|
75 |
apply(subst thm11[symmetric]) |
|
76 |
apply(simp add: equiv[simplified EQUIV_def]) |
|
77 |
done |
|
78 |
||
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
79 |
lemma R_trans: |
49 | 80 |
assumes ab: "R a b" |
81 |
and bc: "R b c" |
|
22 | 82 |
shows "R a c" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
83 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
84 |
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
|
85 |
moreover have ab: "R a b" by fact |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
86 |
moreover have bc: "R b c" by fact |
22 | 87 |
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
|
88 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
89 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
90 |
lemma R_sym: |
49 | 91 |
assumes ab: "R a b" |
22 | 92 |
shows "R b a" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
93 |
proof - |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
94 |
have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
22 | 95 |
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
|
96 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
97 |
|
49 | 98 |
lemma R_trans2: |
99 |
assumes ac: "R a c" |
|
22 | 100 |
and bd: "R b d" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
101 |
shows "R a b = R c d" |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
102 |
proof |
23 | 103 |
assume "R a b" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
next |
23 | 109 |
assume "R c d" |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
115 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
116 |
lemma REPS_same: |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
117 |
shows "R (REP a) (REP b) \<equiv> (a = b)" |
38 | 118 |
proof - |
119 |
have "R (REP a) (REP b) = (a = b)" |
|
120 |
proof |
|
121 |
assume as: "R (REP a) (REP b)" |
|
122 |
from rep_prop |
|
123 |
obtain x y |
|
124 |
where eqs: "Rep a = R x" "Rep b = R y" by blast |
|
125 |
from eqs have "R (Eps (R x)) (Eps (R y))" using as unfolding REP_def by simp |
|
126 |
then have "R x (Eps (R y))" using lem9 by simp |
|
127 |
then have "R (Eps (R y)) x" using R_sym by blast |
|
128 |
then have "R y x" using lem9 by simp |
|
129 |
then have "R x y" using R_sym by blast |
|
130 |
then have "ABS x = ABS y" using thm11 by simp |
|
131 |
then have "Abs (Rep a) = Abs (Rep b)" using eqs unfolding ABS_def by simp |
|
132 |
then show "a = b" using rep_inverse by simp |
|
133 |
next |
|
134 |
assume ab: "a = b" |
|
135 |
have "REFL R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
|
136 |
then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto |
|
137 |
qed |
|
138 |
then show "R (REP a) (REP b) \<equiv> (a = b)" by simp |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
139 |
qed |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
140 |
|
0 | 141 |
end |
142 |
||
143 |
section {* type definition for the quotient type *} |
|
144 |
||
145 |
ML {* |
|
1 | 146 |
(* constructs the term \<lambda>(c::ty \<Rightarrow> bool). \<exists>x. c = rel x *) |
0 | 147 |
fun typedef_term rel ty lthy = |
15 | 148 |
let |
149 |
val [x, c] = [("x", ty), ("c", ty --> @{typ bool})] |
|
0 | 150 |
|> Variable.variant_frees lthy [rel] |
151 |
|> map Free |
|
152 |
in |
|
15 | 153 |
lambda c |
49 | 154 |
(HOLogic.exists_const ty $ |
39
980d45c4a726
fixed a bug in my code: function typedef_term constructs now now the correct term when the relation is called x
Christian Urban <urbanc@in.tum.de>
parents:
38
diff
changeset
|
155 |
lambda x (HOLogic.mk_eq (c, (rel $ x)))) |
0 | 156 |
end |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
157 |
*} |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
158 |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
159 |
ML {* |
26 | 160 |
(* makes the new type definitions and proves non-emptyness*) |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
161 |
fun typedef_make (qty_name, mx, rel, ty) lthy = |
49 | 162 |
let |
26 | 163 |
val typedef_tac = |
164 |
EVERY1 [rewrite_goal_tac @{thms mem_def}, |
|
49 | 165 |
rtac @{thm exI}, |
166 |
rtac @{thm exI}, |
|
26 | 167 |
rtac @{thm refl}] |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
168 |
val tfrees = map fst (Term.add_tfreesT ty []) |
26 | 169 |
in |
170 |
LocalTheory.theory_result |
|
171 |
(Typedef.add_typedef false NONE |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
172 |
(qty_name, tfrees, mx) |
26 | 173 |
(typedef_term rel ty lthy) |
174 |
NONE typedef_tac) lthy |
|
175 |
end |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
176 |
*} |
0 | 177 |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
178 |
ML {* |
40
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
179 |
(* tactic to prove the QUOT_TYPE theorem for the new type *) |
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
180 |
fun typedef_quot_type_tac equiv_thm (typedef_info: Typedef.info) lthy = |
0 | 181 |
let |
182 |
val rep_thm = #Rep typedef_info |
|
183 |
val rep_inv = #Rep_inverse typedef_info |
|
184 |
val abs_inv = #Abs_inverse typedef_info |
|
185 |
val rep_inj = #Rep_inject typedef_info |
|
186 |
||
187 |
val ss = HOL_basic_ss addsimps @{thms mem_def} |
|
188 |
val rep_thm_simpd = Simplifier.asm_full_simplify ss rep_thm |
|
189 |
val abs_inv_simpd = Simplifier.asm_full_simplify ss abs_inv |
|
190 |
in |
|
191 |
EVERY1 [rtac @{thm QUOT_TYPE.intro}, |
|
15 | 192 |
rtac equiv_thm, |
193 |
rtac rep_thm_simpd, |
|
194 |
rtac rep_inv, |
|
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
195 |
rtac abs_inv_simpd, |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
196 |
rtac @{thm exI}, |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
197 |
rtac @{thm refl}, |
0 | 198 |
rtac rep_inj] |
199 |
end |
|
200 |
||
201 |
fun typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy = |
|
202 |
let |
|
203 |
val quot_type_const = Const (@{const_name "QUOT_TYPE"}, dummyT) |
|
204 |
val goal = HOLogic.mk_Trueprop (quot_type_const $ rel $ abs $ rep) |
|
205 |
|> Syntax.check_term lthy |
|
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
206 |
val _ = goal |> Syntax.string_of_term lthy |> tracing |
0 | 207 |
in |
208 |
Goal.prove lthy [] [] goal |
|
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
209 |
(K (typedef_quot_type_tac equiv_thm typedef_info lthy)) |
0 | 210 |
end |
211 |
||
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
212 |
|
40
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
213 |
(* proves the quotient theorem *) |
0 | 214 |
fun typedef_quotient_thm (rel, abs, rep, abs_def, rep_def, quot_type_thm) lthy = |
215 |
let |
|
216 |
val quotient_const = Const (@{const_name "QUOTIENT"}, dummyT) |
|
217 |
val goal = HOLogic.mk_Trueprop (quotient_const $ rel $ abs $ rep) |
|
218 |
|> Syntax.check_term lthy |
|
26 | 219 |
|
220 |
val typedef_quotient_thm_tac = |
|
221 |
EVERY1 [K (rewrite_goals_tac [abs_def, rep_def]), |
|
222 |
rtac @{thm QUOT_TYPE.QUOTIENT}, |
|
223 |
rtac quot_type_thm] |
|
0 | 224 |
in |
49 | 225 |
Goal.prove lthy [] [] goal |
26 | 226 |
(K typedef_quotient_thm_tac) |
0 | 227 |
end |
228 |
*} |
|
229 |
||
230 |
text {* two wrappers for define and note *} |
|
15 | 231 |
ML {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
232 |
fun make_def (name, mx, rhs) lthy = |
15 | 233 |
let |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
234 |
val ((rhs, (_ , thm)), lthy') = |
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
235 |
LocalTheory.define Thm.internalK ((name, mx), (Attrib.empty_binding, rhs)) lthy |
0 | 236 |
in |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
237 |
((rhs, thm), lthy') |
0 | 238 |
end |
239 |
*} |
|
240 |
||
241 |
ML {* |
|
26 | 242 |
fun note_thm (name, thm) lthy = |
0 | 243 |
let |
15 | 244 |
val ((_,[thm']), lthy') = LocalTheory.note Thm.theoremK ((name, []), [thm]) lthy |
0 | 245 |
in |
16 | 246 |
(thm', lthy') |
0 | 247 |
end |
248 |
*} |
|
249 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
250 |
ML {* |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
251 |
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
|
252 |
let |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
253 |
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
|
254 |
val ((_, [th']), _) = Variable.import true [th] ctxt; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
255 |
in th' end); |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
256 |
*} |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
257 |
|
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
258 |
ML {* |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
259 |
fun typedef_main (qty_name, mx, rel, ty, equiv_thm) lthy = |
15 | 260 |
let |
0 | 261 |
(* generates typedef *) |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
262 |
val ((_, typedef_info), lthy1) = typedef_make (qty_name, mx, rel, ty) lthy |
0 | 263 |
|
264 |
(* abs and rep functions *) |
|
265 |
val abs_ty = #abs_type typedef_info |
|
266 |
val rep_ty = #rep_type typedef_info |
|
267 |
val abs_name = #Abs_name typedef_info |
|
268 |
val rep_name = #Rep_name typedef_info |
|
269 |
val abs = Const (abs_name, rep_ty --> abs_ty) |
|
270 |
val rep = Const (rep_name, abs_ty --> rep_ty) |
|
271 |
||
272 |
(* ABS and REP definitions *) |
|
273 |
val ABS_const = Const (@{const_name "QUOT_TYPE.ABS"}, dummyT ) |
|
274 |
val REP_const = Const (@{const_name "QUOT_TYPE.REP"}, dummyT ) |
|
26 | 275 |
val ABS_trm = Syntax.check_term lthy1 (ABS_const $ rel $ abs) |
276 |
val REP_trm = Syntax.check_term lthy1 (REP_const $ rep) |
|
0 | 277 |
val ABS_name = Binding.prefix_name "ABS_" qty_name |
15 | 278 |
val REP_name = Binding.prefix_name "REP_" qty_name |
26 | 279 |
val (((ABS, ABS_def), (REP, REP_def)), lthy2) = |
280 |
lthy1 |> make_def (ABS_name, NoSyn, ABS_trm) |
|
0 | 281 |
||>> make_def (REP_name, NoSyn, REP_trm) |
282 |
||
283 |
(* quot_type theorem *) |
|
26 | 284 |
val quot_thm = typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy2 |
0 | 285 |
val quot_thm_name = Binding.prefix_name "QUOT_TYPE_" qty_name |
286 |
||
287 |
(* quotient theorem *) |
|
26 | 288 |
val quotient_thm = typedef_quotient_thm (rel, ABS, REP, ABS_def, REP_def, quot_thm) lthy2 |
0 | 289 |
val quotient_thm_name = Binding.prefix_name "QUOTIENT_" qty_name |
290 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
291 |
(* interpretation *) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
292 |
val bindd = ((Binding.make ("", Position.none)), ([]: Attrib.src list)) |
26 | 293 |
val ((_, [eqn1pre]), lthy3) = Variable.import true [ABS_def] lthy2; |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
294 |
val eqn1i = Thm.prop_of (symmetric eqn1pre) |
26 | 295 |
val ((_, [eqn2pre]), lthy4) = Variable.import true [REP_def] lthy3; |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
296 |
val eqn2i = Thm.prop_of (symmetric eqn2pre) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
297 |
|
26 | 298 |
val exp_morphism = ProofContext.export_morphism lthy4 (ProofContext.init (ProofContext.theory_of lthy4)); |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
299 |
val exp_term = Morphism.term exp_morphism; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
300 |
val exp = Morphism.thm exp_morphism; |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
301 |
|
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
302 |
val mthd = Method.SIMPLE_METHOD ((rtac quot_thm 1) THEN |
16 | 303 |
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
|
304 |
val mthdt = Method.Basic (fn _ => mthd) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
305 |
val bymt = Proof.global_terminal_proof (mthdt, NONE) |
16 | 306 |
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
|
307 |
Expression.Named [ |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
308 |
("R", rel), |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
309 |
("Abs", abs), |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
310 |
("Rep", rep) |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
311 |
]))] |
0 | 312 |
in |
26 | 313 |
lthy4 |
314 |
|> note_thm (quot_thm_name, quot_thm) |
|
315 |
||>> note_thm (quotient_thm_name, quotient_thm) |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
316 |
||> LocalTheory.theory (fn thy => |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
317 |
let |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
318 |
val global_eqns = map exp_term [eqn2i, eqn1i]; |
16 | 319 |
(* Not sure if the following context should not be used *) |
26 | 320 |
val (global_eqns2, lthy5) = Variable.import_terms true global_eqns lthy4; |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
321 |
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
|
322 |
in ProofContext.theory_of (bymt (Expression.interpretation (exp_i, []) global_eqns3 thy)) end) |
0 | 323 |
end |
324 |
*} |
|
325 |
||
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
326 |
|
0 | 327 |
section {* various tests for quotient types*} |
328 |
datatype trm = |
|
15 | 329 |
var "nat" |
0 | 330 |
| app "trm" "trm" |
331 |
| lam "nat" "trm" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
332 |
|
49 | 333 |
axiomatization |
334 |
RR :: "trm \<Rightarrow> trm \<Rightarrow> bool" |
|
26 | 335 |
where |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
336 |
r_eq: "EQUIV RR" |
0 | 337 |
|
338 |
local_setup {* |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
339 |
typedef_main (@{binding "qtrm"}, NoSyn, @{term "RR"}, @{typ trm}, @{thm r_eq}) #> snd |
0 | 340 |
*} |
341 |
||
342 |
term Rep_qtrm |
|
2 | 343 |
term REP_qtrm |
0 | 344 |
term Abs_qtrm |
345 |
term ABS_qtrm |
|
346 |
thm QUOT_TYPE_qtrm |
|
347 |
thm QUOTIENT_qtrm |
|
2 | 348 |
|
16 | 349 |
(* Test interpretation *) |
350 |
thm QUOT_TYPE_I_qtrm.thm11 |
|
26 | 351 |
thm QUOT_TYPE.thm11 |
16 | 352 |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
353 |
print_theorems |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
354 |
|
0 | 355 |
thm Rep_qtrm |
356 |
||
357 |
text {* another test *} |
|
358 |
datatype 'a trm' = |
|
15 | 359 |
var' "'a" |
0 | 360 |
| app' "'a trm'" "'a trm'" |
361 |
| lam' "'a" "'a trm'" |
|
15 | 362 |
|
0 | 363 |
consts R' :: "'a trm' \<Rightarrow> 'a trm' \<Rightarrow> bool" |
364 |
axioms r_eq': "EQUIV R'" |
|
365 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
366 |
|
0 | 367 |
local_setup {* |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
368 |
typedef_main (@{binding "qtrm'"}, NoSyn, @{term "R'"}, @{typ "'a trm'"}, @{thm r_eq'}) #> snd |
0 | 369 |
*} |
370 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
371 |
print_theorems |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
372 |
|
0 | 373 |
term ABS_qtrm' |
374 |
term REP_qtrm' |
|
375 |
thm QUOT_TYPE_qtrm' |
|
376 |
thm QUOTIENT_qtrm' |
|
377 |
thm Rep_qtrm' |
|
378 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
379 |
|
0 | 380 |
text {* a test with lists of terms *} |
381 |
datatype t = |
|
382 |
vr "string" |
|
383 |
| ap "t list" |
|
384 |
| lm "string" "t" |
|
385 |
||
386 |
consts Rt :: "t \<Rightarrow> t \<Rightarrow> bool" |
|
387 |
axioms t_eq: "EQUIV Rt" |
|
388 |
||
389 |
local_setup {* |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
390 |
typedef_main (@{binding "qt"}, NoSyn, @{term "Rt"}, @{typ "t"}, @{thm t_eq}) #> snd |
0 | 391 |
*} |
392 |
||
393 |
section {* lifting of constants *} |
|
394 |
||
395 |
text {* information about map-functions for type-constructor *} |
|
396 |
ML {* |
|
397 |
type typ_info = {mapfun: string} |
|
398 |
||
399 |
local |
|
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
400 |
structure Data = TheoryDataFun |
0 | 401 |
(type T = typ_info Symtab.table |
402 |
val empty = Symtab.empty |
|
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
403 |
val copy = I |
0 | 404 |
val extend = I |
405 |
fun merge _ = Symtab.merge (K true)) |
|
406 |
in |
|
46 | 407 |
val lookup = Symtab.lookup o Data.get |
408 |
fun update k v = Data.map (Symtab.update (k, v)) |
|
0 | 409 |
end |
410 |
*} |
|
411 |
||
412 |
(* mapfuns for some standard types *) |
|
413 |
setup {* |
|
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
414 |
update @{type_name "list"} {mapfun = @{const_name "map"}} #> |
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
415 |
update @{type_name "*"} {mapfun = @{const_name "prod_fun"}} #> |
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
416 |
update @{type_name "fun"} {mapfun = @{const_name "fun_map"}} |
0 | 417 |
*} |
418 |
||
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
419 |
ML {* lookup @{theory} @{type_name list} *} |
0 | 420 |
|
421 |
ML {* |
|
46 | 422 |
datatype flag = absF | repF |
0 | 423 |
|
46 | 424 |
fun get_fun flag rty qty lthy ty = |
0 | 425 |
let |
426 |
val qty_name = Long_Name.base_name (fst (dest_Type qty)) |
|
15 | 427 |
|
0 | 428 |
fun get_fun_aux s fs_tys = |
429 |
let |
|
430 |
val (fs, tys) = split_list fs_tys |
|
15 | 431 |
val (otys, ntys) = split_list tys |
0 | 432 |
val oty = Type (s, otys) |
433 |
val nty = Type (s, ntys) |
|
434 |
val ftys = map (op -->) tys |
|
435 |
in |
|
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
436 |
(case (lookup (ProofContext.theory_of lthy) s) of |
0 | 437 |
SOME info => (list_comb (Const (#mapfun info, ftys ---> oty --> nty), fs), (oty, nty)) |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
438 |
| NONE => raise ERROR ("no map association for type " ^ s)) |
0 | 439 |
end |
440 |
||
46 | 441 |
fun get_const absF = (Const ("QuotMain.ABS_" ^ qty_name, rty --> qty), (rty, qty)) |
442 |
| get_const repF = (Const ("QuotMain.REP_" ^ qty_name, qty --> rty), (qty, rty)) |
|
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
443 |
|
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
444 |
fun mk_identity ty = Abs ("x", ty, Bound 0) |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
445 |
|
0 | 446 |
in |
447 |
if ty = qty |
|
46 | 448 |
then (get_const flag) |
0 | 449 |
else (case ty of |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
450 |
TFree _ => (mk_identity ty, (ty, ty)) |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
451 |
| Type (_, []) => (mk_identity ty, (ty, ty)) |
46 | 452 |
| Type (s, tys) => get_fun_aux s (map (get_fun flag rty qty lthy) tys) |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
453 |
| _ => raise ERROR ("no type variables") |
0 | 454 |
) |
455 |
end |
|
456 |
*} |
|
457 |
||
458 |
ML {* |
|
46 | 459 |
get_fun repF @{typ t} @{typ qt} @{context} @{typ "t * nat"} |
2 | 460 |
|> fst |
461 |
|> Syntax.string_of_term @{context} |
|
462 |
|> writeln |
|
463 |
*} |
|
464 |
||
46 | 465 |
ML {* |
466 |
get_fun absF @{typ t} @{typ qt} @{context} @{typ "t * nat"} |
|
467 |
|> fst |
|
468 |
|> Syntax.string_of_term @{context} |
|
469 |
|> writeln |
|
470 |
*} |
|
2 | 471 |
|
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
472 |
text {* produces the definition for a lifted constant *} |
2 | 473 |
ML {* |
0 | 474 |
fun get_const_def nconst oconst rty qty lthy = |
475 |
let |
|
476 |
val ty = fastype_of nconst |
|
477 |
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
|
478 |
|
0 | 479 |
val fresh_args = arg_tys |> map (pair "x") |
15 | 480 |
|> Variable.variant_frees lthy [nconst, oconst] |
0 | 481 |
|> map Free |
482 |
||
46 | 483 |
val rep_fns = map (fst o get_fun repF rty qty lthy) arg_tys |
484 |
val abs_fn = (fst o get_fun absF rty qty lthy) res_ty |
|
0 | 485 |
|
486 |
in |
|
487 |
map (op $) (rep_fns ~~ fresh_args) |
|
488 |
|> curry list_comb oconst |
|
489 |
|> curry (op $) abs_fn |
|
490 |
|> fold_rev lambda fresh_args |
|
491 |
end |
|
492 |
*} |
|
493 |
||
494 |
ML {* |
|
15 | 495 |
fun exchange_ty rty qty ty = |
49 | 496 |
if ty = rty |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
497 |
then qty |
15 | 498 |
else |
0 | 499 |
(case ty of |
500 |
Type (s, tys) => Type (s, map (exchange_ty rty qty) tys) |
|
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
501 |
| _ => ty |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
502 |
) |
0 | 503 |
*} |
504 |
||
505 |
ML {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
506 |
fun make_const_def nconst_bname oconst mx rty qty lthy = |
0 | 507 |
let |
508 |
val oconst_ty = fastype_of oconst |
|
509 |
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
|
510 |
val nconst = Const (Binding.name_of nconst_bname, nconst_ty) |
0 | 511 |
val def_trm = get_const_def nconst oconst rty qty lthy |
512 |
in |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
513 |
make_def (nconst_bname, mx, def_trm) lthy |
15 | 514 |
end |
0 | 515 |
*} |
516 |
||
2 | 517 |
local_setup {* |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
518 |
make_const_def @{binding VR} @{term "vr"} NoSyn @{typ "t"} @{typ "qt"} #> snd #> |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
519 |
make_const_def @{binding AP} @{term "ap"} NoSyn @{typ "t"} @{typ "qt"} #> snd #> |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
520 |
make_const_def @{binding LM} @{term "lm"} NoSyn @{typ "t"} @{typ "qt"} #> snd |
2 | 521 |
*} |
522 |
||
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
523 |
term vr |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
524 |
term ap |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
525 |
term lm |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
526 |
thm VR_def AP_def LM_def |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
527 |
term LM |
2 | 528 |
term VR |
529 |
term AP |
|
530 |
||
0 | 531 |
text {* a test with functions *} |
532 |
datatype 'a t' = |
|
533 |
vr' "string" |
|
534 |
| ap' "('a t') * ('a t')" |
|
535 |
| lm' "'a" "string \<Rightarrow> ('a t')" |
|
536 |
||
537 |
consts Rt' :: "('a t') \<Rightarrow> ('a t') \<Rightarrow> bool" |
|
538 |
axioms t_eq': "EQUIV Rt'" |
|
539 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
540 |
|
0 | 541 |
local_setup {* |
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
542 |
typedef_main (@{binding "qt'"}, NoSyn, @{term "Rt'"}, @{typ "'a t'"}, @{thm t_eq'}) #> snd |
0 | 543 |
*} |
544 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
545 |
print_theorems |
2 | 546 |
|
0 | 547 |
local_setup {* |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
548 |
make_const_def @{binding VR'} @{term "vr'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd #> |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
549 |
make_const_def @{binding AP'} @{term "ap'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd #> |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
550 |
make_const_def @{binding LM'} @{term "lm'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd |
0 | 551 |
*} |
552 |
||
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
553 |
term vr' |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
554 |
term ap' |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
555 |
term ap' |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
556 |
thm VR'_def AP'_def LM'_def |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
557 |
term LM' |
0 | 558 |
term VR' |
559 |
term AP' |
|
560 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
561 |
|
0 | 562 |
text {* finite set example *} |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
563 |
print_syntax |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
564 |
inductive |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
565 |
list_eq (infix "\<approx>" 50) |
0 | 566 |
where |
567 |
"a#b#xs \<approx> b#a#xs" |
|
568 |
| "[] \<approx> []" |
|
569 |
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs" |
|
570 |
| "a#a#xs \<approx> a#xs" |
|
571 |
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys" |
|
572 |
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3" |
|
573 |
||
47 | 574 |
lemma list_eq_refl: |
0 | 575 |
shows "xs \<approx> xs" |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
576 |
apply (induct xs) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
577 |
apply (auto intro: list_eq.intros) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
578 |
done |
0 | 579 |
|
580 |
lemma equiv_list_eq: |
|
581 |
shows "EQUIV list_eq" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
582 |
unfolding EQUIV_REFL_SYM_TRANS REFL_def SYM_def TRANS_def |
47 | 583 |
apply(auto intro: list_eq.intros list_eq_refl) |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
584 |
done |
0 | 585 |
|
586 |
local_setup {* |
|
63
980c95c2bf7f
added an explicit syntax-argument to the function make_def (is needed if the user gives an syntax annotation for quotient types)
Christian Urban <urbanc@in.tum.de>
parents:
62
diff
changeset
|
587 |
typedef_main (@{binding "fset"}, NoSyn, @{term "list_eq"}, @{typ "'a list"}, @{thm "equiv_list_eq"}) #> snd |
0 | 588 |
*} |
589 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
590 |
print_theorems |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
591 |
|
0 | 592 |
typ "'a fset" |
593 |
thm "Rep_fset" |
|
594 |
||
595 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
596 |
make_const_def @{binding EMPTY} @{term "[]"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 597 |
*} |
598 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
599 |
term Nil |
0 | 600 |
term EMPTY |
2 | 601 |
thm EMPTY_def |
602 |
||
0 | 603 |
|
604 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
605 |
make_const_def @{binding INSERT} @{term "op #"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 606 |
*} |
607 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
608 |
term Cons |
0 | 609 |
term INSERT |
2 | 610 |
thm INSERT_def |
0 | 611 |
|
612 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
613 |
make_const_def @{binding UNION} @{term "op @"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 614 |
*} |
615 |
||
15 | 616 |
term append |
0 | 617 |
term UNION |
2 | 618 |
thm UNION_def |
619 |
||
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
620 |
|
0 | 621 |
thm QUOTIENT_fset |
622 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
623 |
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
|
624 |
|
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
625 |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
626 |
fun |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
627 |
membship :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infix "memb" 100) |
0 | 628 |
where |
629 |
m1: "(x memb []) = False" |
|
630 |
| m2: "(x memb (y#xs)) = ((x=y) \<or> (x memb xs))" |
|
631 |
||
2 | 632 |
lemma mem_respects: |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
633 |
fixes z |
2 | 634 |
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
|
635 |
shows "(z memb x) = (z memb y)" |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
636 |
using a by induct auto |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
637 |
|
2 | 638 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
639 |
fun |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
640 |
card1 :: "'a list \<Rightarrow> nat" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
641 |
where |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
642 |
card1_nil: "(card1 []) = 0" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
643 |
| card1_cons: "(card1 (x # xs)) = (if (x memb xs) then (card1 xs) else (Suc (card1 xs)))" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
644 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
645 |
local_setup {* |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
646 |
make_const_def @{binding card} @{term "card1"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
647 |
*} |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
648 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
649 |
term card1 |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
650 |
term card |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
651 |
thm card_def |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
652 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
653 |
(* text {* |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
654 |
Maybe make_const_def should require a theorem that says that the particular lifted function |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
655 |
respects the relation. With it such a definition would be impossible: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
656 |
make_const_def @{binding CARD} @{term "length"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
657 |
*}*) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
658 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
659 |
lemma card1_rsp: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
660 |
fixes a b :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
661 |
assumes e: "a \<approx> b" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
662 |
shows "card1 a = card1 b" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
663 |
using e apply induct |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
664 |
apply (simp_all add:mem_respects) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
665 |
done |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
666 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
667 |
lemma card1_0: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
668 |
fixes a :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
669 |
shows "(card1 a = 0) = (a = [])" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
670 |
apply (induct a) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
671 |
apply (simp) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
672 |
apply (simp_all) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
673 |
apply meson |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
674 |
apply (simp_all) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
675 |
done |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
676 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
677 |
lemma not_mem_card1: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
678 |
fixes x :: "'a" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
679 |
fixes xs :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
680 |
shows "~(x memb xs) \<Longrightarrow> card1 (x # xs) = Suc (card1 xs)" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
681 |
by simp |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
682 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
683 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
684 |
lemma mem_cons: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
685 |
fixes x :: "'a" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
686 |
fixes xs :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
687 |
assumes a : "x memb xs" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
688 |
shows "x # xs \<approx> xs" |
49 | 689 |
using a |
38 | 690 |
apply (induct xs) |
691 |
apply (auto intro: list_eq.intros) |
|
692 |
done |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
693 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
694 |
lemma card1_suc: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
695 |
fixes xs :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
696 |
fixes n :: "nat" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
697 |
assumes c: "card1 xs = Suc n" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
698 |
shows "\<exists>a ys. ~(a memb ys) \<and> xs \<approx> (a # ys)" |
49 | 699 |
using c |
38 | 700 |
apply(induct xs) |
701 |
apply (metis Suc_neq_Zero card1_0) |
|
47 | 702 |
apply (metis QUOT_TYPE_I_fset.R_trans QuotMain.card1_cons list_eq_refl mem_cons) |
38 | 703 |
done |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
704 |
|
12 | 705 |
lemma cons_preserves: |
706 |
fixes z |
|
707 |
assumes a: "xs \<approx> ys" |
|
708 |
shows "(z # xs) \<approx> (z # ys)" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
709 |
using a by (rule QuotMain.list_eq.intros(5)) |
12 | 710 |
|
60
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
711 |
lemma fs1_strong_cases: |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
712 |
fixes X :: "'a list" |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
713 |
shows "(X = []) \<or> (\<exists>a. \<exists> Y. (~(a memb Y) \<and> (X \<approx> a # Y)))" |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
714 |
apply (induct X) |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
715 |
apply (simp) |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
716 |
apply (erule disjE) |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
717 |
apply (metis QuotMain.m1 list_eq_refl) |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
718 |
apply (metis QUOT_TYPE_I_fset.R_sym QUOT_TYPE_I_fset.thm11 list_eq_refl mem_cons) |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
719 |
done |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
720 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
721 |
text {* |
49 | 722 |
Unlam_def converts a definition given as |
40
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
723 |
|
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
724 |
c \<equiv> %x. %y. f x y |
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
725 |
|
49 | 726 |
to a theorem of the form |
727 |
||
728 |
c x y \<equiv> f x y |
|
40
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
729 |
|
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
730 |
This function is needed to rewrite the right-hand |
c8187c293587
slightly tuned the comment for unlam
Christian Urban <urbanc@in.tum.de>
parents:
39
diff
changeset
|
731 |
side to the left-hand side. |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
732 |
*} |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
733 |
|
11
0bc0db2e83f2
Use metavariables in the 'non-lambda' definitions
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
10
diff
changeset
|
734 |
ML {* |
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
735 |
fun unlam_def ctxt def = |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
736 |
let |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
737 |
val (lhs, rhs) = Thm.dest_equals (cprop_of def) |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
738 |
val xs = strip_abs_vars (term_of rhs) |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
739 |
val (_, ctxt') = Variable.add_fixes (map fst xs) ctxt |
65
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
740 |
|
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
741 |
val thy = ProofContext.theory_of ctxt' |
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
742 |
fun get_lhs xs = |
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
743 |
let |
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
744 |
val cxs = map (cterm_of thy o Free) xs |
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
745 |
in |
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
746 |
Drule.list_comb (lhs, cxs) |
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
747 |
end |
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
748 |
|
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
749 |
fun get_conv [] = Conv.rewr_conv def |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
750 |
| get_conv (x::xs) = Conv.fun_conv (get_conv xs) |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
751 |
|
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
752 |
in |
65
da982cded326
one further improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
64
diff
changeset
|
753 |
get_conv xs (get_lhs xs) |> |
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
754 |
singleton (ProofContext.export ctxt' ctxt) |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
755 |
end |
10
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
756 |
*} |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
757 |
|
10
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
758 |
local_setup {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
759 |
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
|
760 |
*} |
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
761 |
|
0 | 762 |
term membship |
763 |
term IN |
|
2 | 764 |
thm IN_def |
64
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
765 |
ML {* (Conv.fun_conv (Conv.fun_conv (Conv.rewr_conv @{thm IN_def}))) @{cterm "IN x y"}*} |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
766 |
ML {* MetaSimplifier.rewrite_rule @{thms IN_def} @{thm IN_def}*} |
33d7bcfd5603
simplified the unlam_def function
Christian Urban <urbanc@in.tum.de>
parents:
63
diff
changeset
|
767 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
768 |
ML {* unlam_def @{context} @{thm IN_def} *} |
0 | 769 |
|
2 | 770 |
lemmas a = QUOT_TYPE.ABS_def[OF QUOT_TYPE_fset] |
771 |
thm QUOT_TYPE.thm11[OF QUOT_TYPE_fset, THEN iffD1, simplified a] |
|
0 | 772 |
|
2 | 773 |
lemma yy: |
774 |
shows "(False = x memb []) = (False = IN (x::nat) EMPTY)" |
|
775 |
unfolding IN_def EMPTY_def |
|
776 |
apply(rule_tac f="(op =) False" in arg_cong) |
|
777 |
apply(rule mem_respects) |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
778 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
2 | 779 |
apply(rule list_eq.intros) |
0 | 780 |
done |
781 |
||
2 | 782 |
lemma |
783 |
shows "IN (x::nat) EMPTY = False" |
|
784 |
using m1 |
|
785 |
apply - |
|
786 |
apply(rule yy[THEN iffD1, symmetric]) |
|
787 |
apply(simp) |
|
0 | 788 |
done |
789 |
||
2 | 790 |
lemma |
791 |
shows "((x=y) \<or> (IN x xs) = (IN (x::nat) (INSERT y xs))) = |
|
23 | 792 |
((x=y) \<or> x memb REP_fset xs = x memb (y # REP_fset xs))" |
2 | 793 |
unfolding IN_def INSERT_def |
794 |
apply(rule_tac f="(op \<or>) (x=y)" in arg_cong) |
|
795 |
apply(rule_tac f="(op =) (x memb REP_fset xs)" in arg_cong) |
|
796 |
apply(rule mem_respects) |
|
797 |
apply(rule list_eq.intros(3)) |
|
798 |
apply(unfold REP_fset_def ABS_fset_def) |
|
5 | 799 |
apply(simp only: QUOT_TYPE.REP_ABS_rsp[OF QUOT_TYPE_fset]) |
47 | 800 |
apply(rule list_eq_refl) |
2 | 801 |
done |
0 | 802 |
|
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
803 |
lemma append_respects_fst: |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
804 |
assumes a : "list_eq l1 l2" |
4 | 805 |
shows "list_eq (l1 @ s) (l2 @ s)" |
3 | 806 |
using a |
807 |
apply(induct) |
|
4 | 808 |
apply(auto intro: list_eq.intros) |
47 | 809 |
apply(simp add: list_eq_refl) |
3 | 810 |
done |
811 |
||
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
812 |
lemma yyy: |
3 | 813 |
shows " |
814 |
( |
|
815 |
(UNION EMPTY s = s) & |
|
816 |
((UNION (INSERT e s1) s2) = (INSERT e (UNION s1 s2))) |
|
817 |
) = ( |
|
818 |
((ABS_fset ([] @ REP_fset s)) = s) & |
|
819 |
((ABS_fset ((e # (REP_fset s1)) @ REP_fset s2)) = ABS_fset (e # (REP_fset s1 @ REP_fset s2))) |
|
820 |
)" |
|
821 |
unfolding UNION_def EMPTY_def INSERT_def |
|
822 |
apply(rule_tac f="(op &)" in arg_cong2) |
|
823 |
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
|
824 |
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
|
825 |
apply(rule append_respects_fst) |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
826 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
47 | 827 |
apply(rule list_eq_refl) |
3 | 828 |
apply(simp) |
829 |
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
|
830 |
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
|
831 |
apply(rule append_respects_fst) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
832 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
47 | 833 |
apply(rule list_eq_refl) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
834 |
apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
3 | 835 |
apply(rule list_eq.intros(5)) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
836 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
47 | 837 |
apply(rule list_eq_refl) |
3 | 838 |
done |
839 |
||
840 |
lemma |
|
841 |
shows " |
|
842 |
(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
|
843 |
((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
|
844 |
apply (simp add: yyy) |
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
845 |
apply (simp add: 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
|
846 |
done |
3 | 847 |
|
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
848 |
ML {* |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
849 |
fun mk_rep x = @{term REP_fset} $ x; |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
850 |
fun mk_abs x = @{term ABS_fset} $ x; |
49 | 851 |
val consts = [@{const_name "Nil"}, @{const_name "append"}, |
852 |
@{const_name "Cons"}, @{const_name "membship"}, |
|
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
853 |
@{const_name "card1"}] |
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
854 |
*} |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
855 |
|
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
856 |
ML {* val qty = @{typ "'a fset"} *} |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
857 |
ML {* val tt = Type ("fun", [Type ("fun", [qty, @{typ "prop"}]), @{typ "prop"}]) *} |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
858 |
ML {* val fall = Const(@{const_name all}, dummyT) *} |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
859 |
|
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
860 |
ML {* Syntax.check_term *} |
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
861 |
|
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
862 |
ML {* |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
863 |
fun build_goal_term ctxt thm constructors rty qty mk_rep mk_abs = |
49 | 864 |
let |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
865 |
fun mk_rep_abs x = mk_rep (mk_abs x); |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
866 |
|
49 | 867 |
fun is_constructor (Const (x, _)) = member (op =) constructors x |
868 |
| is_constructor _ = false; |
|
869 |
||
43
e51af8bace65
Cleaning the code with Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42
diff
changeset
|
870 |
fun maybe_mk_rep_abs t = |
49 | 871 |
let |
872 |
val _ = writeln ("Maybe: " ^ Syntax.string_of_term ctxt t) |
|
873 |
in |
|
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
874 |
if fastype_of t = rty then mk_rep_abs t else t |
49 | 875 |
end; |
876 |
||
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
877 |
fun is_all (Const ("all", Type("fun", [Type("fun", [ty, _]), _]))) = ty = rty |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
878 |
| is_all _ = false; |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
879 |
|
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
880 |
fun is_ex (Const ("Ex", Type("fun", [Type("fun", [ty, _]), _]))) = ty = rty |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
881 |
| is_ex _ = false; |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
882 |
|
49 | 883 |
fun build_aux ctxt1 tm = |
884 |
let |
|
885 |
val (head, args) = Term.strip_comb tm; |
|
886 |
val args' = map (build_aux ctxt1) args; |
|
887 |
in |
|
888 |
(case head of |
|
889 |
Abs (x, T, t) => |
|
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
890 |
if T = rty then let |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
891 |
val ([x'], ctxt2) = Variable.variant_fixes [x] ctxt1; |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
892 |
val v = Free (x', qty); |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
893 |
val t' = subst_bound (mk_rep v, t); |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
894 |
val rec_term = build_aux ctxt2 t'; |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
895 |
val _ = tracing (Syntax.string_of_term ctxt2 t') |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
896 |
val _ = tracing (Syntax.string_of_term ctxt2 (Term.lambda_name (x, v) rec_term)) |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
897 |
in |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
898 |
Term.lambda_name (x, v) rec_term |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
899 |
end else let |
49 | 900 |
val ([x'], ctxt2) = Variable.variant_fixes [x] ctxt1; |
901 |
val v = Free (x', T); |
|
902 |
val t' = subst_bound (v, t); |
|
903 |
val rec_term = build_aux ctxt2 t'; |
|
904 |
in Term.lambda_name (x, v) rec_term end |
|
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
905 |
| _ => (* I assume that we never lift 'prop' since it is not of sort type *) |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
906 |
if is_all head then |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
907 |
list_comb (Const(@{const_name all}, dummyT), args') |> Syntax.check_term ctxt1 |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
908 |
else if is_ex head then |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
909 |
list_comb (Const(@{const_name Ex}, dummyT), args') |> Syntax.check_term ctxt1 |
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
910 |
else if is_constructor head then |
49 | 911 |
maybe_mk_rep_abs (list_comb (head, map maybe_mk_rep_abs args')) |
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
912 |
else |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
913 |
maybe_mk_rep_abs (list_comb (head, args')) |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
914 |
) |
49 | 915 |
end; |
916 |
in |
|
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
917 |
build_aux ctxt (Thm.prop_of thm) |
49 | 918 |
end |
919 |
*} |
|
920 |
||
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
921 |
ML {* |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
922 |
fun build_goal ctxt thm cons rty qty mk_rep mk_abs = |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
923 |
Logic.mk_equals ((build_goal_term ctxt thm cons rty qty mk_rep mk_abs), (Thm.prop_of thm)) |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
924 |
*} |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
925 |
|
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
926 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
927 |
ML {* val fset_defs = @{thms EMPTY_def IN_def UNION_def card_def INSERT_def} *} |
49 | 928 |
ML {* val fset_defs_sym = map (fn t => symmetric (unlam_def @{context} t)) fset_defs *} |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
929 |
|
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
930 |
ML {* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
931 |
fun dest_cbinop t = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
932 |
let |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
933 |
val (t2, rhs) = Thm.dest_comb t; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
934 |
val (bop, lhs) = Thm.dest_comb t2; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
935 |
in |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
936 |
(bop, (lhs, rhs)) |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
937 |
end |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
938 |
*} |
38 | 939 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
940 |
ML {* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
941 |
fun dest_ceq t = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
942 |
let |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
943 |
val (bop, pair) = dest_cbinop t; |
49 | 944 |
val (bop_s, _) = Term.dest_Const (Thm.term_of bop); |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
945 |
in |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
946 |
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
|
947 |
end |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
948 |
*} |
38 | 949 |
|
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
950 |
ML Thm.instantiate |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
951 |
ML {*@{thm arg_cong2}*} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
952 |
ML {*@{thm arg_cong2[of _ _ _ _ "op ="]} *} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
953 |
ML {* val cT = @{cpat "op ="} |> Thm.ctyp_of_term |> Thm.dest_ctyp |> hd *} |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
954 |
ML {* |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
955 |
Toplevel.program (fn () => |
50
18d8bcd769b3
Checked again with the version on my hard-drive backedup yesterday and fixed small whitespace issues.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
49
diff
changeset
|
956 |
Drule.instantiate' [SOME cT, SOME cT, SOME @{ctyp bool}] [NONE, NONE, NONE, NONE, SOME (@{cpat "op ="})] @{thm arg_cong2} |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
957 |
) |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
958 |
*} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
959 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
960 |
ML {* |
49 | 961 |
fun split_binop_conv t = |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
962 |
let |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
963 |
val (lhs, rhs) = dest_ceq t; |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
964 |
val (bop, _) = dest_cbinop lhs; |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
965 |
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
|
966 |
val [cmT, crT] = Thm.dest_ctyp cr2; |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
967 |
in |
49 | 968 |
Drule.instantiate' [SOME clT, SOME cmT, SOME crT] [NONE, NONE, NONE, NONE, SOME bop] @{thm arg_cong2} |
969 |
end |
|
970 |
*} |
|
971 |
||
972 |
ML {* |
|
973 |
fun split_arg_conv t = |
|
974 |
let |
|
975 |
val (lhs, rhs) = dest_ceq t; |
|
976 |
val (lop, larg) = Thm.dest_comb lhs; |
|
977 |
val [caT, crT] = lop |> Thm.ctyp_of_term |> Thm.dest_ctyp; |
|
978 |
in |
|
979 |
Drule.instantiate' [SOME caT, SOME crT] [NONE, NONE, SOME lop] @{thm arg_cong} |
|
35
fdc5962936fa
Correctly handling abstractions while building goals
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
34
diff
changeset
|
980 |
end |
fdc5962936fa
Correctly handling abstractions while building goals
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
34
diff
changeset
|
981 |
*} |
fdc5962936fa
Correctly handling abstractions while building goals
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
34
diff
changeset
|
982 |
|
fdc5962936fa
Correctly handling abstractions while building goals
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
34
diff
changeset
|
983 |
ML {* |
49 | 984 |
fun split_binop_tac n thm = |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
985 |
let |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
986 |
val concl = Thm.cprem_of thm n; |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
987 |
val (_, cconcl) = Thm.dest_comb concl; |
49 | 988 |
val rewr = split_binop_conv cconcl; |
989 |
in |
|
990 |
rtac rewr n thm |
|
991 |
end |
|
992 |
handle CTERM _ => Seq.empty |
|
993 |
*} |
|
994 |
||
995 |
ML {* |
|
996 |
fun split_arg_tac n thm = |
|
997 |
let |
|
998 |
val concl = Thm.cprem_of thm n; |
|
999 |
val (_, cconcl) = Thm.dest_comb concl; |
|
1000 |
val rewr = split_arg_conv cconcl; |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1001 |
in |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1002 |
rtac rewr n thm |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1003 |
end |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1004 |
handle CTERM _ => Seq.empty |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1005 |
*} |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1006 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1007 |
(* 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
|
1008 |
|
32
999300935e9c
Make the tactic use Trueprop_cong and atomize.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
31
diff
changeset
|
1009 |
lemma trueprop_cong: |
999300935e9c
Make the tactic use Trueprop_cong and atomize.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
31
diff
changeset
|
1010 |
shows "(a \<equiv> b) \<Longrightarrow> (Trueprop a \<equiv> Trueprop b)" |
999300935e9c
Make the tactic use Trueprop_cong and atomize.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
31
diff
changeset
|
1011 |
by auto |
999300935e9c
Make the tactic use Trueprop_cong and atomize.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
31
diff
changeset
|
1012 |
|
57 | 1013 |
ML {* |
1014 |
Cong_Tac.cong_tac |
|
1015 |
*} |
|
49 | 1016 |
|
1017 |
thm QUOT_TYPE_I_fset.R_trans2 |
|
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1018 |
ML {* |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1019 |
fun foo_tac' ctxt = |
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1020 |
REPEAT_ALL_NEW (FIRST' [ |
49 | 1021 |
(* rtac @{thm trueprop_cong},*) |
47 | 1022 |
rtac @{thm list_eq_refl}, |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1023 |
rtac @{thm cons_preserves}, |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1024 |
rtac @{thm mem_respects}, |
49 | 1025 |
rtac @{thm card1_rsp}, |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1026 |
rtac @{thm QUOT_TYPE_I_fset.R_trans2}, |
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1027 |
CHANGED o (simp_tac ((Simplifier.context ctxt HOL_ss) addsimps @{thms QUOT_TYPE_I_fset.REP_ABS_rsp})), |
57 | 1028 |
Cong_Tac.cong_tac @{thm cong}, |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1029 |
rtac @{thm ext} |
51
32c0985563a8
Tested new build_goal and removed old one, eq_reflection is included in atomize, card_suc tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
50
diff
changeset
|
1030 |
(* rtac @{thm eq_reflection},*) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1031 |
(* CHANGED o (ObjectLogic.full_atomize_tac)*) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1032 |
]) |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1033 |
*} |
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1034 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1035 |
ML {* |
49 | 1036 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m1})) |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1037 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1038 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1039 |
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
|
1040 |
*} |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1041 |
|
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1042 |
(*notation ( output) "prop" ("#_" [1000] 1000) *) |
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1043 |
notation ( output) "Trueprop" ("#_" [1000] 1000) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1044 |
|
49 | 1045 |
lemma atomize_eqv [atomize]: "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
1046 |
(is "?rhs \<equiv> ?lhs") |
|
1047 |
proof |
|
1048 |
assume "PROP ?lhs" then show "PROP ?rhs" by unfold |
|
1049 |
next |
|
1050 |
assume *: "PROP ?rhs" |
|
1051 |
have "A = B" |
|
1052 |
proof (cases A) |
|
1053 |
case True |
|
1054 |
with * have B by unfold |
|
1055 |
with `A` show ?thesis by simp |
|
1056 |
next |
|
1057 |
case False |
|
1058 |
with * have "~ B" by auto |
|
1059 |
with `~ A` show ?thesis by simp |
|
1060 |
qed |
|
1061 |
then show "PROP ?lhs" by (rule eq_reflection) |
|
1062 |
qed |
|
1063 |
||
1064 |
||
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1065 |
prove {* (Thm.term_of cgoal2) *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1066 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1067 |
apply (atomize(full)) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1068 |
apply (tactic {* foo_tac' @{context} 1 *}) |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1069 |
done |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1070 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1071 |
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
|
1072 |
ML {* |
49 | 1073 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm length_append})) |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1074 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1075 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1076 |
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
|
1077 |
*} |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1078 |
prove {* Thm.term_of cgoal2 *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1079 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1080 |
apply (atomize(full)) |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1081 |
apply (tactic {* foo_tac' @{context} 1 *}) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1082 |
sorry |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
1083 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1084 |
thm m2 |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1085 |
ML {* |
49 | 1086 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m2})) |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1087 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
1088 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1089 |
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
|
1090 |
*} |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1091 |
prove {* Thm.term_of cgoal2 *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1092 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1093 |
apply (atomize(full)) |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1094 |
apply (tactic {* foo_tac' @{context} 1 *}) |
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1095 |
done |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1096 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1097 |
thm list_eq.intros(4) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1098 |
ML {* |
49 | 1099 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list_eq.intros(4)})) |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1100 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1101 |
val cgoal = cterm_of @{theory} goal |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1102 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1103 |
val cgoal3 = Thm.rhs_of (MetaSimplifier.rewrite true @{thms QUOT_TYPE_I_fset.thm10} cgoal2) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1104 |
*} |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1105 |
|
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1106 |
(* It is the same, but we need a name for it. *) |
52
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1107 |
prove zzz : {* Thm.term_of cgoal3 *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1108 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1109 |
apply (atomize(full)) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1110 |
apply (tactic {* foo_tac' @{context} 1 *}) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1111 |
done |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1112 |
|
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1113 |
lemma zzz' : |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1114 |
"(REP_fset (INSERT a (INSERT a (ABS_fset xs))) \<approx> REP_fset (INSERT a (ABS_fset xs)))" |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1115 |
using list_eq.intros(4) by (simp only: zzz) |
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1116 |
|
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
1117 |
thm QUOT_TYPE_I_fset.REPS_same |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1118 |
ML {* val zzz'' = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} @{thm zzz'} *} |
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1119 |
|
46 | 1120 |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1121 |
thm list_eq.intros(5) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1122 |
ML {* |
49 | 1123 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list_eq.intros(5)})) |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1124 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
38 | 1125 |
*} |
1126 |
ML {* |
|
49 | 1127 |
val cgoal = |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1128 |
Toplevel.program (fn () => |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1129 |
cterm_of @{theory} goal |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1130 |
) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1131 |
*} |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1132 |
ML {* |
49 | 1133 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1134 |
*} |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
1135 |
prove {* Thm.term_of cgoal2 *} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1136 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1137 |
apply (atomize(full)) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
1138 |
apply (tactic {* foo_tac' @{context} 1 *}) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
1139 |
done |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1140 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1141 |
thm list.induct |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1142 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1143 |
ML {* |
50
18d8bcd769b3
Checked again with the version on my hard-drive backedup yesterday and fixed small whitespace issues.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
49
diff
changeset
|
1144 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list.induct})) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1145 |
*} |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1146 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1147 |
ML {* |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1148 |
val goal = |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1149 |
Toplevel.program (fn () => |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1150 |
build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1151 |
) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1152 |
*} |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1153 |
ML {* |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1154 |
val cgoal = |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1155 |
Toplevel.program (fn () => |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1156 |
cterm_of @{theory} goal |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1157 |
) |
49 | 1158 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal) |
35
fdc5962936fa
Correctly handling abstractions while building goals
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
34
diff
changeset
|
1159 |
*} |
50
18d8bcd769b3
Checked again with the version on my hard-drive backedup yesterday and fixed small whitespace issues.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
49
diff
changeset
|
1160 |
|
33
e8f1fa50329a
Found the source for the exception and added a handle for it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
32
diff
changeset
|
1161 |
prove {* (Thm.term_of cgoal2) *} |
e8f1fa50329a
Found the source for the exception and added a handle for it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
32
diff
changeset
|
1162 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1163 |
apply (atomize(full)) |
49 | 1164 |
apply (tactic {* foo_tac' @{context} 1 *}) |
33
e8f1fa50329a
Found the source for the exception and added a handle for it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
32
diff
changeset
|
1165 |
sorry |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1166 |
|
49 | 1167 |
ML {* |
1168 |
fun lift_theorem_fset_aux thm lthy = |
|
1169 |
let |
|
1170 |
val ((_, [novars]), lthy2) = Variable.import true [thm] lthy; |
|
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1171 |
val goal = build_goal @{context} novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs; |
49 | 1172 |
val cgoal = cterm_of @{theory} goal; |
1173 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal); |
|
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1174 |
val tac = (LocalDefs.unfold_tac @{context} fset_defs) THEN (ObjectLogic.full_atomize_tac 1) THEN (foo_tac' @{context}) 1; |
49 | 1175 |
val cthm = Goal.prove_internal [] cgoal2 (fn _ => tac); |
1176 |
val nthm = MetaSimplifier.rewrite_rule [symmetric cthm] (snd (no_vars (Context.Theory @{theory}, thm))) |
|
1177 |
val nthm2 = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same QUOT_TYPE_I_fset.thm10} nthm; |
|
1178 |
val [nthm3] = ProofContext.export lthy2 lthy [nthm2] |
|
1179 |
in |
|
1180 |
nthm3 |
|
1181 |
end |
|
1182 |
*} |
|
1183 |
||
1184 |
ML {* lift_theorem_fset_aux @{thm m1} @{context} *} |
|
1185 |
||
1186 |
ML {* |
|
1187 |
fun lift_theorem_fset name thm lthy = |
|
1188 |
let |
|
1189 |
val lifted_thm = lift_theorem_fset_aux thm lthy; |
|
1190 |
val (_, lthy2) = note_thm (name, lifted_thm) lthy; |
|
1191 |
in |
|
1192 |
lthy2 |
|
1193 |
end; |
|
1194 |
*} |
|
1195 |
||
1196 |
local_setup {* lift_theorem_fset @{binding "m1_lift"} @{thm m1} *} |
|
1197 |
local_setup {* lift_theorem_fset @{binding "leqi4_lift"} @{thm list_eq.intros(4)} *} |
|
1198 |
local_setup {* lift_theorem_fset @{binding "leqi5_lift"} @{thm list_eq.intros(5)} *} |
|
1199 |
local_setup {* lift_theorem_fset @{binding "m2_lift"} @{thm m2} *} |
|
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1200 |
(*ML {* Toplevel.program (fn () => lift_theorem_fset @{binding "card_suc"} @{thm card1_suc} @{context}) *} |
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1201 |
local_setup {* lift_theorem_fset @{binding "card_suc"} @{thm card1_suc} *}*) |
49 | 1202 |
|
1203 |
thm m1_lift |
|
1204 |
thm leqi4_lift |
|
1205 |
thm leqi5_lift |
|
1206 |
thm m2_lift |
|
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1207 |
(*thm card_suc*) |
49 | 1208 |
|
1209 |
thm leqi4_lift |
|
1210 |
ML {* |
|
62
58384c90a5e5
used prop_of to get the term of a theorem (replaces crep_thm)
Christian Urban <urbanc@in.tum.de>
parents:
61
diff
changeset
|
1211 |
val (nam, typ) = hd (Term.add_vars (prop_of @{thm leqi4_lift}) []) |
49 | 1212 |
val (_, l) = dest_Type typ |
1213 |
val t = Type ("QuotMain.fset", l) |
|
1214 |
val v = Var (nam, t) |
|
1215 |
val cv = cterm_of @{theory} ((term_of @{cpat "REP_fset"}) $ v) |
|
1216 |
*} |
|
1217 |
||
1218 |
ML {* |
|
1219 |
Toplevel.program (fn () => |
|
1220 |
MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.thm10} ( |
|
1221 |
Drule.instantiate' [] [NONE, SOME (cv)] @{thm leqi4_lift} |
|
1222 |
) |
|
1223 |
) |
|
1224 |
*} |
|
1225 |
||
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1226 |
(* |
52
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1227 |
thm card_suc |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1228 |
ML {* |
62
58384c90a5e5
used prop_of to get the term of a theorem (replaces crep_thm)
Christian Urban <urbanc@in.tum.de>
parents:
61
diff
changeset
|
1229 |
val (nam, typ) = hd (tl (Term.add_vars (prop_of @{thm card_suc})) []) |
52
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1230 |
val (_, l) = dest_Type typ |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1231 |
val t = Type ("QuotMain.fset", l) |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1232 |
val v = Var (nam, t) |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1233 |
val cv = cterm_of @{theory} ((term_of @{cpat "REP_fset"}) $ v) |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1234 |
*} |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1235 |
|
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1236 |
ML {* |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1237 |
Toplevel.program (fn () => |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1238 |
MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.thm10} ( |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1239 |
Drule.instantiate' [] [SOME (cv)] @{thm card_suc} |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1240 |
) |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1241 |
) |
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1242 |
*} |
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1243 |
*) |
52
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1244 |
|
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1245 |
|
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1246 |
|
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1247 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1248 |
thm card1_suc |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1249 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1250 |
ML {* |
50
18d8bcd769b3
Checked again with the version on my hard-drive backedup yesterday and fixed small whitespace issues.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
49
diff
changeset
|
1251 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm card1_suc})) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1252 |
*} |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1253 |
ML {* |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
1254 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1255 |
*} |
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1256 |
ML {* term_of @{cpat "all"} *} |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1257 |
ML {* |
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1258 |
val cgoal = |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1259 |
Toplevel.program (fn () => |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1260 |
cterm_of @{theory} goal |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
1261 |
); |
49 | 1262 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1263 |
*} |
49 | 1264 |
ML {* @{term "\<exists>x. P x"} *} |
1265 |
ML {* Thm.bicompose *} |
|
52
6584b1ceedce
Partially fix lifting of card_suc. The quantified variable still needs to be changed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
51
diff
changeset
|
1266 |
prove aaa: {* (Thm.term_of cgoal2) *} |
45 | 1267 |
apply (tactic {* LocalDefs.unfold_tac @{context} fset_defs *} ) |
58
f2565006dc5a
Just one atomize is enough for the currently lifted theorems. Properly lift 'all' and 'Ex'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
57
diff
changeset
|
1268 |
apply (atomize(full)) |
49 | 1269 |
apply (tactic {* foo_tac' @{context} 1 *}) |
51
32c0985563a8
Tested new build_goal and removed old one, eq_reflection is included in atomize, card_suc tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
50
diff
changeset
|
1270 |
done |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1271 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1272 |
(* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1273 |
datatype obj1 = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1274 |
OVAR1 "string" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1275 |
| OBJ1 "(string * (string \<Rightarrow> obj1)) list" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1276 |
| INVOKE1 "obj1 \<Rightarrow> string" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1277 |
| UPDATE1 "obj1 \<Rightarrow> string \<Rightarrow> (string \<Rightarrow> obj1)" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1278 |
*) |
53 | 1279 |
|
57 | 1280 |
end |