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