author | Christian Urban <urbanc@in.tum.de> |
Sat, 17 Oct 2009 12:19:06 +0200 | |
changeset 118 | 1c30d48bfc15 |
parent 117 | 28f7dbd99314 |
child 122 | 768c5d319a0a |
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 {* |
|
93
ec29be471518
Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
92
diff
changeset
|
245 |
update @{type_name "list"} {mapfun = @{const_name "map"}, relfun = @{const_name "LIST_REL"}} #> |
ec29be471518
Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
92
diff
changeset
|
246 |
update @{type_name "*"} {mapfun = @{const_name "prod_fun"}, relfun = @{const_name "prod_rel"}} #> |
75
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 |
||
109
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
250 |
|
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
251 |
ML {* lookup @{theory} @{type_name list} *} |
0 | 252 |
|
110
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
253 |
|
0 | 254 |
ML {* |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
255 |
(* calculates the aggregate abs and rep functions for a given type; |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
256 |
repF is for constants' arguments; absF is for constants; |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
257 |
function types need to be treated specially, since repF and absF |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
258 |
change |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
259 |
*) |
46 | 260 |
datatype flag = absF | repF |
0 | 261 |
|
109
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
262 |
fun negF absF = repF |
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
263 |
| negF repF = absF |
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
264 |
|
46 | 265 |
fun get_fun flag rty qty lthy ty = |
0 | 266 |
let |
267 |
val qty_name = Long_Name.base_name (fst (dest_Type qty)) |
|
15 | 268 |
|
0 | 269 |
fun get_fun_aux s fs_tys = |
270 |
let |
|
271 |
val (fs, tys) = split_list fs_tys |
|
15 | 272 |
val (otys, ntys) = split_list tys |
0 | 273 |
val oty = Type (s, otys) |
274 |
val nty = Type (s, ntys) |
|
275 |
val ftys = map (op -->) tys |
|
276 |
in |
|
59
1a92820a5b85
simplified the storage of the map-functions by using TheoryDataFun
Christian Urban <urbanc@in.tum.de>
parents:
58
diff
changeset
|
277 |
(case (lookup (ProofContext.theory_of lthy) s) of |
110
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
278 |
SOME info => (list_comb (Const (#mapfun info, ftys ---> (oty --> nty)), fs), (oty, nty)) |
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
279 |
| NONE => raise ERROR ("no map association for type " ^ s)) |
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
280 |
end |
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
281 |
|
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
282 |
fun get_fun_fun fs_tys = |
110
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
283 |
let |
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
284 |
val (fs, tys) = split_list fs_tys |
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
285 |
val ([oty1, oty2], [nty1, nty2]) = split_list tys |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
286 |
val oty = Type ("fun", [nty1, oty2]) |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
287 |
val nty = Type ("fun", [oty1, nty2]) |
110
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
288 |
val ftys = map (op -->) tys |
f5f641c05794
A fix for one fun_map; doesn't work for more.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
109
diff
changeset
|
289 |
in |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
290 |
(list_comb (Const (@{const_name "fun_map"}, ftys ---> oty --> nty), fs), (oty, nty)) |
0 | 291 |
end |
292 |
||
46 | 293 |
fun get_const absF = (Const ("QuotMain.ABS_" ^ qty_name, rty --> qty), (rty, qty)) |
294 |
| 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
|
295 |
|
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
|
296 |
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
|
297 |
|
0 | 298 |
in |
299 |
if ty = qty |
|
46 | 300 |
then (get_const flag) |
0 | 301 |
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
|
302 |
TFree _ => (mk_identity ty, (ty, ty)) |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
303 |
| Type (_, []) => (mk_identity ty, (ty, ty)) |
109
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
304 |
| Type ("fun" , [ty1, ty2]) => |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
305 |
get_fun_fun [get_fun (negF flag) rty qty lthy ty1, get_fun flag rty qty lthy ty2] |
46 | 306 |
| 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
|
307 |
| _ => raise ERROR ("no type variables") |
0 | 308 |
) |
309 |
end |
|
310 |
*} |
|
311 |
||
312 |
ML {* |
|
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
313 |
get_fun repF @{typ t} @{typ qt} @{context} @{typ "((((qt \<Rightarrow> qt) \<Rightarrow> qt) \<Rightarrow> qt) list) * nat"} |
2 | 314 |
|> fst |
315 |
|> Syntax.string_of_term @{context} |
|
316 |
|> writeln |
|
317 |
*} |
|
318 |
||
46 | 319 |
ML {* |
109
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
320 |
get_fun absF @{typ t} @{typ qt} @{context} @{typ "qt * nat"} |
46 | 321 |
|> fst |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
322 |
|> Syntax.string_of_term @{context} |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
323 |
|> writeln |
109
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
324 |
*} |
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
325 |
|
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
326 |
ML {* |
118
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
327 |
get_fun absF @{typ t} @{typ qt} @{context} @{typ "(qt \<Rightarrow> qt) \<Rightarrow> qt"} |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
328 |
|> fst |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
329 |
|> Syntax.pretty_term @{context} |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
330 |
|> Pretty.string_of |
1c30d48bfc15
slightly simplified get_fun function
Christian Urban <urbanc@in.tum.de>
parents:
117
diff
changeset
|
331 |
|> writeln |
109
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
332 |
*} |
386671ef36bd
fixed the problem with function types; but only type_of works; cterm_of does not work
Christian Urban <urbanc@in.tum.de>
parents:
108
diff
changeset
|
333 |
|
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
334 |
text {* produces the definition for a lifted constant *} |
86 | 335 |
|
2 | 336 |
ML {* |
0 | 337 |
fun get_const_def nconst oconst rty qty lthy = |
338 |
let |
|
339 |
val ty = fastype_of nconst |
|
340 |
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
|
341 |
|
0 | 342 |
val fresh_args = arg_tys |> map (pair "x") |
15 | 343 |
|> Variable.variant_frees lthy [nconst, oconst] |
0 | 344 |
|> map Free |
345 |
||
46 | 346 |
val rep_fns = map (fst o get_fun repF rty qty lthy) arg_tys |
347 |
val abs_fn = (fst o get_fun absF rty qty lthy) res_ty |
|
0 | 348 |
|
349 |
in |
|
350 |
map (op $) (rep_fns ~~ fresh_args) |
|
351 |
|> curry list_comb oconst |
|
352 |
|> curry (op $) abs_fn |
|
353 |
|> fold_rev lambda fresh_args |
|
354 |
end |
|
355 |
*} |
|
356 |
||
357 |
ML {* |
|
15 | 358 |
fun exchange_ty rty qty ty = |
49 | 359 |
if ty = rty |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
360 |
then qty |
15 | 361 |
else |
0 | 362 |
(case ty of |
363 |
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
|
364 |
| _ => ty |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
365 |
) |
0 | 366 |
*} |
367 |
||
368 |
ML {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
369 |
fun make_const_def nconst_bname oconst mx rty qty lthy = |
0 | 370 |
let |
371 |
val oconst_ty = fastype_of oconst |
|
372 |
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
|
373 |
val nconst = Const (Binding.name_of nconst_bname, nconst_ty) |
0 | 374 |
val def_trm = get_const_def nconst oconst rty qty lthy |
375 |
in |
|
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
77
diff
changeset
|
376 |
define (nconst_bname, mx, def_trm) lthy |
15 | 377 |
end |
0 | 378 |
*} |
379 |
||
111 | 380 |
(* A test whether get_fun works properly |
381 |
consts bla :: "(t \<Rightarrow> t) \<Rightarrow> t" |
|
382 |
local_setup {* |
|
383 |
fn lthy => (Toplevel.program (fn () => |
|
384 |
make_const_def @{binding bla'} @{term "bla"} NoSyn @{typ "t"} @{typ "qt"} lthy |
|
385 |
)) |> snd |
|
386 |
*} |
|
387 |
*) |
|
388 |
||
2 | 389 |
local_setup {* |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
390 |
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
|
391 |
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
|
392 |
make_const_def @{binding LM} @{term "lm"} NoSyn @{typ "t"} @{typ "qt"} #> snd |
2 | 393 |
*} |
394 |
||
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
395 |
term vr |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
396 |
term ap |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
397 |
term lm |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
398 |
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
|
399 |
term LM |
2 | 400 |
term VR |
401 |
term AP |
|
402 |
||
0 | 403 |
text {* a test with functions *} |
404 |
datatype 'a t' = |
|
405 |
vr' "string" |
|
406 |
| ap' "('a t') * ('a t')" |
|
407 |
| lm' "'a" "string \<Rightarrow> ('a t')" |
|
408 |
||
409 |
consts Rt' :: "('a t') \<Rightarrow> ('a t') \<Rightarrow> bool" |
|
410 |
axioms t_eq': "EQUIV Rt'" |
|
411 |
||
81
c8d58e2cda58
slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents:
80
diff
changeset
|
412 |
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
|
413 |
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
|
414 |
done |
0 | 415 |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
416 |
print_theorems |
2 | 417 |
|
0 | 418 |
local_setup {* |
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
419 |
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
|
420 |
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
|
421 |
make_const_def @{binding LM'} @{term "lm'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd |
0 | 422 |
*} |
423 |
||
41
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
424 |
term vr' |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
425 |
term ap' |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
426 |
term ap' |
72d63aa8af68
added ctxt as explicit argument to build_goal; tuned
Christian Urban <urbanc@in.tum.de>
parents:
40
diff
changeset
|
427 |
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
|
428 |
term LM' |
0 | 429 |
term VR' |
430 |
term AP' |
|
431 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
432 |
|
0 | 433 |
text {* finite set example *} |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
434 |
print_syntax |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
435 |
inductive |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
436 |
list_eq (infix "\<approx>" 50) |
0 | 437 |
where |
438 |
"a#b#xs \<approx> b#a#xs" |
|
439 |
| "[] \<approx> []" |
|
440 |
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs" |
|
441 |
| "a#a#xs \<approx> a#xs" |
|
442 |
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys" |
|
443 |
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3" |
|
444 |
||
47 | 445 |
lemma list_eq_refl: |
0 | 446 |
shows "xs \<approx> xs" |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
447 |
apply (induct xs) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
448 |
apply (auto intro: list_eq.intros) |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
449 |
done |
0 | 450 |
|
451 |
lemma equiv_list_eq: |
|
452 |
shows "EQUIV list_eq" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
453 |
unfolding EQUIV_REFL_SYM_TRANS REFL_def SYM_def TRANS_def |
47 | 454 |
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
|
455 |
done |
0 | 456 |
|
81
c8d58e2cda58
slightly modified the parser
Christian Urban <urbanc@in.tum.de>
parents:
80
diff
changeset
|
457 |
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
|
458 |
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
|
459 |
done |
0 | 460 |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
461 |
print_theorems |
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
462 |
|
0 | 463 |
typ "'a fset" |
464 |
thm "Rep_fset" |
|
465 |
||
466 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
467 |
make_const_def @{binding EMPTY} @{term "[]"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 468 |
*} |
469 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
470 |
term Nil |
0 | 471 |
term EMPTY |
2 | 472 |
thm EMPTY_def |
473 |
||
0 | 474 |
|
475 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
476 |
make_const_def @{binding INSERT} @{term "op #"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 477 |
*} |
478 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
479 |
term Cons |
0 | 480 |
term INSERT |
2 | 481 |
thm INSERT_def |
0 | 482 |
|
483 |
local_setup {* |
|
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
484 |
make_const_def @{binding UNION} @{term "op @"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd |
0 | 485 |
*} |
486 |
||
15 | 487 |
term append |
0 | 488 |
term UNION |
2 | 489 |
thm UNION_def |
490 |
||
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
491 |
|
0 | 492 |
thm QUOTIENT_fset |
493 |
||
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
494 |
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
|
495 |
|
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
496 |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
497 |
fun |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
498 |
membship :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infix "memb" 100) |
0 | 499 |
where |
500 |
m1: "(x memb []) = False" |
|
501 |
| m2: "(x memb (y#xs)) = ((x=y) \<or> (x memb xs))" |
|
502 |
||
2 | 503 |
lemma mem_respects: |
9
eac147a5eb33
Changed to the use of "modern interface"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
8
diff
changeset
|
504 |
fixes z |
2 | 505 |
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
|
506 |
shows "(z memb x) = (z memb y)" |
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
507 |
using a by induct auto |
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
508 |
|
2 | 509 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
510 |
fun |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
511 |
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
|
512 |
where |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
513 |
card1_nil: "(card1 []) = 0" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
514 |
| 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
|
515 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
516 |
local_setup {* |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
517 |
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
|
518 |
*} |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
519 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
520 |
term card1 |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
521 |
term card |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
522 |
thm card_def |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
523 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
524 |
(* text {* |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
525 |
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
|
526 |
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
|
527 |
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
|
528 |
*}*) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
529 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
530 |
lemma card1_rsp: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
531 |
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
|
532 |
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
|
533 |
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
|
534 |
using e apply induct |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
535 |
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
|
536 |
done |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
537 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
538 |
lemma card1_0: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
539 |
fixes a :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
540 |
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
|
541 |
apply (induct a) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
542 |
apply (simp) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
543 |
apply (simp_all) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
544 |
apply meson |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
545 |
apply (simp_all) |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
546 |
done |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
547 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
548 |
lemma not_mem_card1: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
549 |
fixes x :: "'a" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
550 |
fixes xs :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
551 |
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
|
552 |
by simp |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
553 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
554 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
555 |
lemma mem_cons: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
556 |
fixes x :: "'a" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
557 |
fixes xs :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
558 |
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
|
559 |
shows "x # xs \<approx> xs" |
49 | 560 |
using a |
38 | 561 |
apply (induct xs) |
562 |
apply (auto intro: list_eq.intros) |
|
563 |
done |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
564 |
|
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
565 |
lemma card1_suc: |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
566 |
fixes xs :: "'a list" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
567 |
fixes n :: "nat" |
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
568 |
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
|
569 |
shows "\<exists>a ys. ~(a memb ys) \<and> xs \<approx> (a # ys)" |
49 | 570 |
using c |
38 | 571 |
apply(induct xs) |
572 |
apply (metis Suc_neq_Zero card1_0) |
|
47 | 573 |
apply (metis QUOT_TYPE_I_fset.R_trans QuotMain.card1_cons list_eq_refl mem_cons) |
38 | 574 |
done |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
575 |
|
97
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
576 |
primrec |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
577 |
fold1 |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
578 |
where |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
579 |
"fold1 f (g :: 'a \<Rightarrow> 'b) (z :: 'b) [] = z" |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
580 |
| "fold1 f g z (a # A) = |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
581 |
(if ((!u v. (f u v = f v u)) |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
582 |
\<and> (!u v w. ((f u (f v w) = f (f u v) w)))) |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
583 |
then ( |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
584 |
if (a memb A) then (fold1 f g z A) else (f (g a) (fold1 f g z A)) |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
585 |
) else z)" |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
586 |
|
100
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
587 |
(* fold1_def is not usable, but: *) |
97
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
588 |
thm fold1.simps |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
589 |
|
12 | 590 |
lemma cons_preserves: |
591 |
fixes z |
|
592 |
assumes a: "xs \<approx> ys" |
|
593 |
shows "(z # xs) \<approx> (z # ys)" |
|
13
c13bb9e02eb7
Fixes after suggestions from Makarius:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
12
diff
changeset
|
594 |
using a by (rule QuotMain.list_eq.intros(5)) |
12 | 595 |
|
60
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
596 |
lemma fs1_strong_cases: |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
597 |
fixes X :: "'a list" |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
598 |
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
|
599 |
apply (induct X) |
4826ad24f772
First theorem with quantifiers. Learned how to use sledgehammer.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
58
diff
changeset
|
600 |
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
|
601 |
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
|
602 |
done |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
603 |
|
10
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
604 |
local_setup {* |
17
55b646c6c4cd
More naming/binding suggestions from Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
16
diff
changeset
|
605 |
make_const_def @{binding 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
|
606 |
*} |
b11b405b8271
Make both kinds of definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
9
diff
changeset
|
607 |
|
0 | 608 |
term membship |
609 |
term IN |
|
2 | 610 |
thm IN_def |
66
564bf4343f63
another improvement to unlam_def
Christian Urban <urbanc@in.tum.de>
parents:
65
diff
changeset
|
611 |
|
2 | 612 |
lemmas a = QUOT_TYPE.ABS_def[OF QUOT_TYPE_fset] |
613 |
thm QUOT_TYPE.thm11[OF QUOT_TYPE_fset, THEN iffD1, simplified a] |
|
0 | 614 |
|
2 | 615 |
lemma yy: |
616 |
shows "(False = x memb []) = (False = IN (x::nat) EMPTY)" |
|
617 |
unfolding IN_def EMPTY_def |
|
618 |
apply(rule_tac f="(op =) False" in arg_cong) |
|
619 |
apply(rule mem_respects) |
|
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
620 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
2 | 621 |
apply(rule list_eq.intros) |
0 | 622 |
done |
623 |
||
2 | 624 |
lemma |
625 |
shows "IN (x::nat) EMPTY = False" |
|
626 |
using m1 |
|
627 |
apply - |
|
628 |
apply(rule yy[THEN iffD1, symmetric]) |
|
629 |
apply(simp) |
|
0 | 630 |
done |
631 |
||
2 | 632 |
lemma |
633 |
shows "((x=y) \<or> (IN x xs) = (IN (x::nat) (INSERT y xs))) = |
|
23 | 634 |
((x=y) \<or> x memb REP_fset xs = x memb (y # REP_fset xs))" |
2 | 635 |
unfolding IN_def INSERT_def |
636 |
apply(rule_tac f="(op \<or>) (x=y)" in arg_cong) |
|
637 |
apply(rule_tac f="(op =) (x memb REP_fset xs)" in arg_cong) |
|
638 |
apply(rule mem_respects) |
|
639 |
apply(rule list_eq.intros(3)) |
|
640 |
apply(unfold REP_fset_def ABS_fset_def) |
|
5 | 641 |
apply(simp only: QUOT_TYPE.REP_ABS_rsp[OF QUOT_TYPE_fset]) |
47 | 642 |
apply(rule list_eq_refl) |
2 | 643 |
done |
0 | 644 |
|
7
3e77ad0abc6a
- Build an interpretation for fset from ML level and use it
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
6
diff
changeset
|
645 |
lemma append_respects_fst: |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
646 |
assumes a : "list_eq l1 l2" |
4 | 647 |
shows "list_eq (l1 @ s) (l2 @ s)" |
3 | 648 |
using a |
649 |
apply(induct) |
|
4 | 650 |
apply(auto intro: list_eq.intros) |
47 | 651 |
apply(simp add: list_eq_refl) |
3 | 652 |
done |
653 |
||
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
654 |
lemma yyy: |
3 | 655 |
shows " |
656 |
( |
|
657 |
(UNION EMPTY s = s) & |
|
658 |
((UNION (INSERT e s1) s2) = (INSERT e (UNION s1 s2))) |
|
659 |
) = ( |
|
660 |
((ABS_fset ([] @ REP_fset s)) = s) & |
|
661 |
((ABS_fset ((e # (REP_fset s1)) @ REP_fset s2)) = ABS_fset (e # (REP_fset s1 @ REP_fset s2))) |
|
662 |
)" |
|
663 |
unfolding UNION_def EMPTY_def INSERT_def |
|
664 |
apply(rule_tac f="(op &)" in arg_cong2) |
|
665 |
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
|
666 |
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
|
667 |
apply(rule append_respects_fst) |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
668 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
47 | 669 |
apply(rule list_eq_refl) |
3 | 670 |
apply(simp) |
671 |
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
|
672 |
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
|
673 |
apply(rule append_respects_fst) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
674 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
47 | 675 |
apply(rule list_eq_refl) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
676 |
apply(simp only: QUOT_TYPE_I_fset.thm11[symmetric]) |
3 | 677 |
apply(rule list_eq.intros(5)) |
14
5f6ee943c697
Generalized interpretation, works for all examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
13
diff
changeset
|
678 |
apply(simp only: QUOT_TYPE_I_fset.REP_ABS_rsp) |
47 | 679 |
apply(rule list_eq_refl) |
3 | 680 |
done |
681 |
||
682 |
lemma |
|
683 |
shows " |
|
684 |
(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
|
685 |
((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
|
686 |
apply (simp add: yyy) |
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
687 |
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
|
688 |
done |
3 | 689 |
|
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
690 |
ML {* |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
691 |
fun mk_rep x = @{term REP_fset} $ x; |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
692 |
fun mk_abs x = @{term ABS_fset} $ x; |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
693 |
val consts = [@{const_name "Nil"}, @{const_name "Cons"}, |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
694 |
@{const_name "membship"}, @{const_name "card1"}, |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
695 |
@{const_name "append"}, @{const_name "fold1"}]; |
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
696 |
*} |
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
697 |
|
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
698 |
ML {* val tm = @{term "x :: 'a list"} *} |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
699 |
ML {* val ty = exchange_ty @{typ "'a list"} @{typ "'a fset"} (fastype_of tm) *} |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
700 |
ML {* (fst (get_fun repF @{typ "'a list"} @{typ "'a fset"} @{context} ty)) $ tm *} |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
701 |
|
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
|
8
54afbcf2a758
Initial version of the function that builds goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
7
diff
changeset
|
706 |
ML {* |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
707 |
fun needs_lift (rty as Type (rty_s, _)) ty = |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
708 |
case ty of |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
709 |
Type (s, tys) => |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
710 |
(s = rty_s) orelse (exists (needs_lift rty) tys) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
711 |
| _ => false |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
712 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
713 |
*} |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
714 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
715 |
ML {* |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
716 |
fun build_goal_term lthy thm constructors rty qty = |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
717 |
let |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
718 |
fun mk_rep tm = |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
719 |
let |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
720 |
val ty = exchange_ty rty qty (fastype_of tm) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
721 |
in fst (get_fun repF rty qty lthy ty) $ tm end |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
722 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
723 |
fun mk_abs tm = |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
724 |
let |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
725 |
val _ = tracing (Syntax.string_of_term @{context} tm) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
726 |
val _ = tracing (Syntax.string_of_typ @{context} (fastype_of tm)) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
727 |
val ty = exchange_ty rty qty (fastype_of tm) in |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
728 |
fst (get_fun absF rty qty lthy ty) $ tm end |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
729 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
730 |
fun is_constructor (Const (x, _)) = member (op =) constructors x |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
731 |
| is_constructor _ = false; |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
732 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
733 |
fun build_aux lthy tm = |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
734 |
case tm of |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
735 |
Abs (a as (_, vty, _)) => |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
736 |
let |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
737 |
val (vs, t) = Term.dest_abs a; |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
738 |
val v = Free(vs, vty); |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
739 |
val t' = lambda v (build_aux lthy t) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
740 |
in |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
741 |
if (not (needs_lift rty (fastype_of tm))) then t' |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
742 |
else mk_rep (mk_abs ( |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
743 |
if not (needs_lift rty vty) then t' |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
744 |
else |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
745 |
let |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
746 |
val v' = mk_rep (mk_abs v); |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
747 |
val t1 = Envir.beta_norm (t' $ v') |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
748 |
in |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
749 |
lambda v t1 |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
750 |
end |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
751 |
)) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
752 |
end |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
753 |
| x => |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
754 |
let |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
755 |
val _ = tracing (">>" ^ Syntax.string_of_term @{context} tm) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
756 |
val (opp, tms0) = Term.strip_comb tm |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
757 |
val tms = map (build_aux lthy) tms0 |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
758 |
val ty = fastype_of tm |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
759 |
in |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
760 |
if (((fst (Term.dest_Const opp)) = @{const_name Respects}) handle _ => false) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
761 |
then (list_comb (opp, (hd tms0) :: (tl tms))) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
762 |
else if (is_constructor opp andalso needs_lift rty ty) then |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
763 |
mk_rep (mk_abs (list_comb (opp,tms))) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
764 |
else if ((Term.is_Free opp) andalso (length tms > 0) andalso (needs_lift rty ty)) then |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
765 |
mk_rep(mk_abs(list_comb(opp,tms))) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
766 |
else if tms = [] then opp |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
767 |
else list_comb(opp, tms) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
768 |
end |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
769 |
in |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
770 |
build_aux lthy (Thm.prop_of thm) |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
771 |
end |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
772 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
773 |
*} |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
774 |
|
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
775 |
ML {* |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
776 |
fun build_goal_term_old ctxt thm constructors rty qty mk_rep mk_abs = |
49 | 777 |
let |
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
778 |
fun mk_rep_abs x = mk_rep (mk_abs x); |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
779 |
|
49 | 780 |
fun is_constructor (Const (x, _)) = member (op =) constructors x |
781 |
| is_constructor _ = false; |
|
782 |
||
43
e51af8bace65
Cleaning the code with Makarius
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42
diff
changeset
|
783 |
fun maybe_mk_rep_abs t = |
49 | 784 |
let |
785 |
val _ = writeln ("Maybe: " ^ Syntax.string_of_term ctxt t) |
|
786 |
in |
|
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
787 |
if fastype_of t = rty then mk_rep_abs t else t |
49 | 788 |
end; |
789 |
||
56
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
790 |
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
|
791 |
| is_all _ = false; |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
792 |
|
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
|
793 |
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
|
794 |
| 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
|
795 |
|
49 | 796 |
fun build_aux ctxt1 tm = |
797 |
let |
|
798 |
val (head, args) = Term.strip_comb tm; |
|
799 |
val args' = map (build_aux ctxt1) args; |
|
800 |
in |
|
801 |
(case head of |
|
802 |
Abs (x, T, t) => |
|
55
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
803 |
if T = rty then let |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
804 |
val ([x'], ctxt2) = Variable.variant_fixes [x] ctxt1; |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
805 |
val v = Free (x', qty); |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
806 |
val t' = subst_bound (mk_rep v, t); |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
807 |
val rec_term = build_aux ctxt2 t'; |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
808 |
val _ = tracing (Syntax.string_of_term ctxt2 t') |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
809 |
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
|
810 |
in |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
811 |
Term.lambda_name (x, v) rec_term |
b2ab3ba388a0
Handling abstraction correctly.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
54
diff
changeset
|
812 |
end else let |
49 | 813 |
val ([x'], ctxt2) = Variable.variant_fixes [x] ctxt1; |
814 |
val v = Free (x', T); |
|
815 |
val t' = subst_bound (v, t); |
|
816 |
val rec_term = build_aux ctxt2 t'; |
|
817 |
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
|
818 |
| _ => (* 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
|
819 |
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
|
820 |
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
|
821 |
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
|
822 |
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
|
823 |
else if is_constructor head then |
49 | 824 |
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
|
825 |
else |
ec5fbe7ab427
First version of handling of the universal quantifier
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
55
diff
changeset
|
826 |
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
|
827 |
) |
49 | 828 |
end; |
829 |
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
|
830 |
build_aux ctxt (Thm.prop_of thm) |
49 | 831 |
end |
832 |
*} |
|
833 |
||
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
|
834 |
ML {* |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
835 |
fun build_goal ctxt thm cons rty qty = |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
836 |
Logic.mk_equals ((Thm.prop_of thm), (build_goal_term ctxt thm cons rty qty)) |
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
|
837 |
*} |
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
|
838 |
|
67 | 839 |
ML {* |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
840 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m2})) |
67 | 841 |
*} |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
842 |
|
67 | 843 |
ML {* |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
844 |
cterm_of @{theory} (prop_of m1_novars); |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
845 |
cterm_of @{theory} (build_goal_term @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"}); |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
846 |
cterm_of @{theory} (build_goal_term_old @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} mk_rep mk_abs) |
67 | 847 |
*} |
848 |
||
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
|
849 |
|
100
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
850 |
text {* |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
851 |
Unabs_def converts a definition given as |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
852 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
853 |
c \<equiv> %x. %y. f x y |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
854 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
855 |
to a theorem of the form |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
856 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
857 |
c x y \<equiv> f x y |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
858 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
859 |
This function is needed to rewrite the right-hand |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
860 |
side to the left-hand side. |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
861 |
*} |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
862 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
863 |
ML {* |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
864 |
fun unabs_def ctxt def = |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
865 |
let |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
866 |
val (lhs, rhs) = Thm.dest_equals (cprop_of def) |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
867 |
val xs = strip_abs_vars (term_of rhs) |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
868 |
val (_, ctxt') = Variable.add_fixes (map fst xs) ctxt |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
869 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
870 |
val thy = ProofContext.theory_of ctxt' |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
871 |
val cxs = map (cterm_of thy o Free) xs |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
872 |
val new_lhs = Drule.list_comb (lhs, cxs) |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
873 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
874 |
fun get_conv [] = Conv.rewr_conv def |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
875 |
| get_conv (x::xs) = Conv.fun_conv (get_conv xs) |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
876 |
in |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
877 |
get_conv xs new_lhs |> |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
878 |
singleton (ProofContext.export ctxt' ctxt) |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
879 |
end |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
880 |
*} |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
881 |
|
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
882 |
ML {* (* Test: *) @{thm IN_def}; unabs_def @{context} @{thm IN_def} *} |
09f4d69f7b66
Reordering the code, part 2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
99
diff
changeset
|
883 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
884 |
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
|
885 |
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
|
886 |
|
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
|
887 |
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
|
888 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
49 | 889 |
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
|
890 |
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
|
891 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
49 | 892 |
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
|
893 |
assume *: "Trueprop A \<equiv> Trueprop B" |
49 | 894 |
have "A = B" |
895 |
proof (cases A) |
|
896 |
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
|
897 |
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
|
898 |
then show "A = B" using * by simp |
49 | 899 |
next |
900 |
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
|
901 |
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
|
902 |
then show "A = B" using * by auto |
49 | 903 |
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
|
904 |
then show "A \<equiv> B" by (rule eq_reflection) |
49 | 905 |
qed |
906 |
||
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
907 |
(* Has all the theorems about fset plugged in. These should be parameters to the tactic *) |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
908 |
ML {* |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
909 |
fun transconv_fset_tac' ctxt = |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
910 |
(LocalDefs.unfold_tac @{context} fset_defs) THEN |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
911 |
ObjectLogic.full_atomize_tac 1 THEN |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
912 |
REPEAT_ALL_NEW (FIRST' [ |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
913 |
rtac @{thm list_eq_refl}, |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
914 |
rtac @{thm cons_preserves}, |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
915 |
rtac @{thm mem_respects}, |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
916 |
rtac @{thm card1_rsp}, |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
917 |
rtac @{thm QUOT_TYPE_I_fset.R_trans2}, |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
918 |
CHANGED o (simp_tac ((Simplifier.context ctxt HOL_ss) addsimps @{thms QUOT_TYPE_I_fset.REP_ABS_rsp})), |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
919 |
Cong_Tac.cong_tac @{thm cong}, |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
920 |
rtac @{thm ext} |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
921 |
]) 1 |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
922 |
*} |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
923 |
|
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
924 |
ML {* |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
925 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m1})) |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
926 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
927 |
val cgoal = cterm_of @{theory} goal |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
928 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite false fset_defs_sym cgoal) |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
929 |
*} |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
930 |
|
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
931 |
(*notation ( output) "prop" ("#_" [1000] 1000) *) |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
932 |
notation ( output) "Trueprop" ("#_" [1000] 1000) |
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
933 |
|
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
934 |
|
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
935 |
prove {* (Thm.term_of cgoal2) *} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
936 |
apply (tactic {* transconv_fset_tac' @{context} *}) |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
937 |
done |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
938 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
939 |
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
|
940 |
ML {* |
49 | 941 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm length_append})) |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
942 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
943 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
944 |
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
|
945 |
*} |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
946 |
prove {* Thm.term_of cgoal2 *} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
947 |
apply (tactic {* transconv_fset_tac' @{context} *}) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
948 |
sorry |
19
55aefc2d524a
The tactic still only for fset
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
18
diff
changeset
|
949 |
|
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
950 |
thm m2 |
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
951 |
ML {* |
49 | 952 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm m2})) |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
953 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} |
20
ccc220a23887
Testing the tactic further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
19
diff
changeset
|
954 |
val cgoal = cterm_of @{theory} goal |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
955 |
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
|
956 |
*} |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
957 |
prove {* Thm.term_of cgoal2 *} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
958 |
apply (tactic {* transconv_fset_tac' @{context} *}) |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
959 |
done |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
960 |
|
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
961 |
thm list_eq.intros(4) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
962 |
ML {* |
49 | 963 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list_eq.intros(4)})) |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
964 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
965 |
val cgoal = cterm_of @{theory} goal |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
966 |
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
|
967 |
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
|
968 |
*} |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
969 |
|
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
970 |
(* 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
|
971 |
prove zzz : {* Thm.term_of cgoal3 *} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
972 |
apply (tactic {* transconv_fset_tac' @{context} *}) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
973 |
done |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
974 |
|
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
975 |
(*lemma zzz' : |
24
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
976 |
"(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
|
977 |
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
|
978 |
|
6885fa184e89
Merged with my changes from the morning:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
23
diff
changeset
|
979 |
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
|
980 |
ML {* val zzz'' = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} @{thm zzz'} *} |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
981 |
*) |
25
9020ee23a020
The tactic with REPEAT, CHANGED and a proper simpset.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
24
diff
changeset
|
982 |
|
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
983 |
thm list_eq.intros(5) |
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
984 |
ML {* |
49 | 985 |
val m1_novars = snd(no_vars ((Context.Theory @{theory}), @{thm list_eq.intros(5)})) |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
986 |
val goal = build_goal @{context} m1_novars consts @{typ "'a list"} @{typ "'a fset"} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
987 |
val cgoal = cterm_of @{theory} goal |
49 | 988 |
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
|
989 |
*} |
30
e35198635d64
Using "atomize" the versions with arbitrary Trueprops can be proven.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
29
diff
changeset
|
990 |
prove {* Thm.term_of cgoal2 *} |
103
4aef3882b436
Cleaning the code, part 4
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
101
diff
changeset
|
991 |
apply (tactic {* transconv_fset_tac' @{context} *}) |
21
d15121412caa
Added more useful quotient facts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
20
diff
changeset
|
992 |
done |
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
993 |
|
99
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
994 |
section {* handling quantifiers - regularize *} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
995 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
996 |
text {* tyRel takes a type and builds a relation that a quantifier over this |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
997 |
type needs to respect. *} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
998 |
ML {* |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
999 |
fun tyRel ty rty rel lthy = |
102 | 1000 |
if ty = rty |
1001 |
then rel |
|
99
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1002 |
else (case ty of |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1003 |
Type (s, tys) => |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1004 |
let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1005 |
val tys_rel = map (fn ty => ty --> ty --> @{typ bool}) tys; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1006 |
val ty_out = ty --> ty --> @{typ bool}; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1007 |
val tys_out = tys_rel ---> ty_out; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1008 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1009 |
(case (lookup (ProofContext.theory_of lthy) s) of |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1010 |
SOME (info) => list_comb (Const (#relfun info, tys_out), map (fn ty => tyRel ty rty rel lthy) tys) |
102 | 1011 |
| NONE => HOLogic.eq_const ty |
99
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1012 |
) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1013 |
end |
102 | 1014 |
| _ => HOLogic.eq_const ty) |
99
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1015 |
*} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1016 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1017 |
ML {* |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1018 |
cterm_of @{theory} (tyRel @{typ "trm \<Rightarrow> bool"} @{typ "trm"} @{term "RR"} @{context}) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1019 |
*} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1020 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1021 |
definition |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1022 |
Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1023 |
where |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1024 |
"(x \<in> p) \<Longrightarrow> (Babs p m x = m x)" |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1025 |
(* TODO: Consider defining it with an "if"; sth like: |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1026 |
Babs p m = \<lambda>x. if x \<in> p then m x else undefined |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1027 |
*) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1028 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1029 |
ML {* |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1030 |
(* trm \<Rightarrow> new_trm *) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1031 |
fun regularise trm rty rel lthy = |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1032 |
case trm of |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1033 |
Abs (x, T, t) => |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1034 |
if (needs_lift rty T) then let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1035 |
val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1036 |
val v = Free (x', T); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1037 |
val t' = subst_bound (v, t); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1038 |
val rec_term = regularise t' rty rel lthy2; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1039 |
val lam_term = Term.lambda_name (x, v) rec_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1040 |
val sub_res_term = tyRel T rty rel lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1041 |
val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1042 |
val res_term = respects $ sub_res_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1043 |
val ty = fastype_of trm; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1044 |
val rabs = Const (@{const_name Babs}, (fastype_of res_term) --> ty --> ty); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1045 |
val rabs_term = (rabs $ res_term) $ lam_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1046 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1047 |
rabs_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1048 |
end else let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1049 |
val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1050 |
val v = Free (x', T); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1051 |
val t' = subst_bound (v, t); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1052 |
val rec_term = regularise t' rty rel lthy2; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1053 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1054 |
Term.lambda_name (x, v) rec_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1055 |
end |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1056 |
| ((Const (@{const_name "All"}, at)) $ (Abs (x, T, t))) => |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1057 |
if (needs_lift rty T) then let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1058 |
val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1059 |
val v = Free (x', T); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1060 |
val t' = subst_bound (v, t); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1061 |
val rec_term = regularise t' rty rel lthy2; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1062 |
val lam_term = Term.lambda_name (x, v) rec_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1063 |
val sub_res_term = tyRel T rty rel lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1064 |
val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1065 |
val res_term = respects $ sub_res_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1066 |
val ty = fastype_of lam_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1067 |
val rall = Const (@{const_name Ball}, (fastype_of res_term) --> ty --> @{typ bool}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1068 |
val rall_term = (rall $ res_term) $ lam_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1069 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1070 |
rall_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1071 |
end else let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1072 |
val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1073 |
val v = Free (x', T); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1074 |
val t' = subst_bound (v, t); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1075 |
val rec_term = regularise t' rty rel lthy2; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1076 |
val lam_term = Term.lambda_name (x, v) rec_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1077 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1078 |
Const(@{const_name "All"}, at) $ lam_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1079 |
end |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1080 |
| ((Const (@{const_name "All"}, at)) $ P) => |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1081 |
let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1082 |
val (_, [al, _]) = dest_Type (fastype_of P); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1083 |
val ([x], lthy2) = Variable.variant_fixes [""] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1084 |
val v = (Free (x, al)); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1085 |
val abs = Term.lambda_name (x, v) (P $ v); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1086 |
in regularise ((Const (@{const_name "All"}, at)) $ abs) rty rel lthy2 end |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1087 |
| ((Const (@{const_name "Ex"}, at)) $ (Abs (x, T, t))) => |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1088 |
if (needs_lift rty T) then let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1089 |
val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1090 |
val v = Free (x', T); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1091 |
val t' = subst_bound (v, t); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1092 |
val rec_term = regularise t' rty rel lthy2; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1093 |
val lam_term = Term.lambda_name (x, v) rec_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1094 |
val sub_res_term = tyRel T rty rel lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1095 |
val respects = Const (@{const_name Respects}, (fastype_of sub_res_term) --> T --> @{typ bool}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1096 |
val res_term = respects $ sub_res_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1097 |
val ty = fastype_of lam_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1098 |
val rall = Const (@{const_name Bex}, (fastype_of res_term) --> ty --> @{typ bool}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1099 |
val rall_term = (rall $ res_term) $ lam_term; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1100 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1101 |
rall_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1102 |
end else let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1103 |
val ([x'], lthy2) = Variable.variant_fixes [x] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1104 |
val v = Free (x', T); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1105 |
val t' = subst_bound (v, t); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1106 |
val rec_term = regularise t' rty rel lthy2; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1107 |
val lam_term = Term.lambda_name (x, v) rec_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1108 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1109 |
Const(@{const_name "Ex"}, at) $ lam_term |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1110 |
end |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1111 |
| ((Const (@{const_name "Ex"}, at)) $ P) => |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1112 |
let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1113 |
val (_, [al, _]) = dest_Type (fastype_of P); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1114 |
val ([x], lthy2) = Variable.variant_fixes [""] lthy; |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1115 |
val v = (Free (x, al)); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1116 |
val abs = Term.lambda_name (x, v) (P $ v); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1117 |
in regularise ((Const (@{const_name "Ex"}, at)) $ abs) rty rel lthy2 end |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1118 |
| a $ b => (regularise a rty rel lthy) $ (regularise b rty rel lthy) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1119 |
| _ => trm |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1120 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1121 |
*} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1122 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1123 |
ML {* |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1124 |
cterm_of @{theory} (regularise @{term "\<lambda>x :: int. x"} @{typ "trm"} @{term "RR"} @{context}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1125 |
cterm_of @{theory} (regularise @{term "\<lambda>x :: trm. x"} @{typ "trm"} @{term "RR"} @{context}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1126 |
cterm_of @{theory} (regularise @{term "\<forall>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1127 |
cterm_of @{theory} (regularise @{term "\<exists>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1128 |
cterm_of @{theory} (regularise @{term "All (P :: trm \<Rightarrow> bool)"} @{typ "trm"} @{term "RR"} @{context}); |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1129 |
*} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1130 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1131 |
ML {* |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1132 |
fun atomize_thm thm = |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1133 |
let |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1134 |
val thm' = forall_intr_vars thm |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1135 |
val thm'' = ObjectLogic.atomize (cprop_of thm') |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1136 |
in |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1137 |
Simplifier.rewrite_rule [thm''] thm' |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1138 |
end |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1139 |
*} |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1140 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1141 |
thm list.induct |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1142 |
lemma list_induct_hol4: |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1143 |
fixes P :: "'a list \<Rightarrow> bool" |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1144 |
assumes "((P []) \<and> (\<forall>t. (P t) \<longrightarrow> (\<forall>h. (P (h # t)))))" |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1145 |
shows "(\<forall>l. (P l))" |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1146 |
sorry |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1147 |
|
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1148 |
ML {* atomize_thm @{thm list_induct_hol4} *} |
99
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1149 |
|
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1150 |
(*fun prove_reg trm \<Rightarrow> thm (we might need some facts to do this) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1151 |
trm == new_trm |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1152 |
*) |
19e5aceb8c2d
Reordering the code, part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
98
diff
changeset
|
1153 |
|
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1154 |
ML {* val li = Thm.freezeT (atomize_thm @{thm list_induct_hol4}) *} |
87
9220c51e5155
atomize_thm and meta_quantify.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
86
diff
changeset
|
1155 |
|
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
1156 |
prove list_induct_r: {* |
93
ec29be471518
Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
92
diff
changeset
|
1157 |
Logic.mk_implies |
94
ecfc2e1fd15e
Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
93
diff
changeset
|
1158 |
((prop_of li), |
ecfc2e1fd15e
Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
93
diff
changeset
|
1159 |
(regularise (prop_of li) @{typ "'a List.list"} @{term "op \<approx>"} @{context})) *} |
93
ec29be471518
Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
92
diff
changeset
|
1160 |
apply (simp only: equiv_res_forall[OF equiv_list_eq]) |
94
ecfc2e1fd15e
Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
93
diff
changeset
|
1161 |
thm RIGHT_RES_FORALL_REGULAR |
ecfc2e1fd15e
Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
93
diff
changeset
|
1162 |
apply (rule RIGHT_RES_FORALL_REGULAR) |
93
ec29be471518
Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
92
diff
changeset
|
1163 |
prefer 2 |
ec29be471518
Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
92
diff
changeset
|
1164 |
apply (assumption) |
104 | 1165 |
apply (metis) |
94
ecfc2e1fd15e
Forgot to save, second part of the commit
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
93
diff
changeset
|
1166 |
done |
87
9220c51e5155
atomize_thm and meta_quantify.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
86
diff
changeset
|
1167 |
|
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
1168 |
ML {* val thm = @{thm list_induct_r} OF [li] *} |
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
1169 |
ML {* val trm = build_goal @{context} thm consts @{typ "'a list"} @{typ "'a fset"} *} |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1170 |
thm APPLY_RSP |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1171 |
lemmas APPLY_RSP_I = APPLY_RSP[of "(op \<approx> ===> op =) ===> op =" "(ABS_fset ---> id) ---> id" "(REP_fset ---> id) ---> id" "op =" "id" "id"] |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1172 |
lemmas APPLY_RSP_I2 = APPLY_RSP[of "op \<approx>" "ABS_fset" "REP_fset" "op =" "id" "id"] |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1173 |
|
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1174 |
thm REP_ABS_RSP(2) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1175 |
lemmas REP_ABS_RSP_I = REP_ABS_RSP(1)[of "(op \<approx> ===> op =) ===> op =" "(ABS_fset ---> id) ---> id" "(REP_fset ---> id) ---> id"] |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1176 |
|
111 | 1177 |
prove trm |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1178 |
thm UNION_def |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1179 |
apply (atomize(full)) |
113
e3a963e6418b
Symmetric version of REP_ABS_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
112
diff
changeset
|
1180 |
apply (simp only: id_def[symmetric]) |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1181 |
|
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1182 |
(* APPLY_RSP_TAC *) |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1183 |
ML_prf {* |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1184 |
val (_, gc') = Thm.dest_comb (Subgoal.focus @{context} 1 (Isar.goal ()) |> fst |> #concl) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1185 |
val (_, tc') = Thm.dest_comb (cterm_of @{theory} (concl_of @{thm "APPLY_RSP_I" })) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1186 |
val m = Thm.match (tc', gc') |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1187 |
val t2 = Drule.instantiate m @{thm "APPLY_RSP_I" } |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1188 |
*} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1189 |
apply (tactic {* rtac t2 1 *}) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1190 |
prefer 4 |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1191 |
(* ABS_REP_RSP_TAC *) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1192 |
ML_prf {* |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1193 |
val (_, gc') = Thm.dest_comb (Subgoal.focus @{context} 1 (Isar.goal ()) |> fst |> #concl) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1194 |
val (_, tc') = Thm.dest_comb (cterm_of @{theory} (concl_of @{thm "REP_ABS_RSP_I" })) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1195 |
val m = Thm.match (tc', gc') |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1196 |
val t2 = Drule.instantiate m @{thm "REP_ABS_RSP_I" } |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1197 |
*} |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1198 |
apply (tactic {* rtac t2 1 *}) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1199 |
prefer 2 |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1200 |
|
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1201 |
(* LAMBDA_RES_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1202 |
apply (simp only: FUN_REL.simps) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1203 |
apply (rule allI) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1204 |
apply (rule allI) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1205 |
apply (rule impI) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1206 |
|
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1207 |
(* MK_COMB_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1208 |
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *}) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1209 |
(* MK_COMB_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1210 |
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *}) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1211 |
(* REFL_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1212 |
apply (simp) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1213 |
(* MK_COMB_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1214 |
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *}) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1215 |
(* MK_COMB_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1216 |
apply (tactic {* Cong_Tac.cong_tac @{thm cong} 1 *}) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1217 |
(* REFL_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1218 |
apply (simp) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1219 |
(* APPLY_RSP_TAC *) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1220 |
ML_prf {* Isar.goal () *} |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1221 |
ML_prf {* val t = Thm.lift_rule (hd (cprems_of (Isar.goal ()))) @{thm "APPLY_RSP_I2" } *} |
113
e3a963e6418b
Symmetric version of REP_ABS_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
112
diff
changeset
|
1222 |
ML_prf {* |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1223 |
val (tc') = (Logic.strip_assums_concl (prop_of t)); |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1224 |
val ps = Logic.strip_params (prop_of t) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1225 |
val tt = Term.list_abs (ps, tc') |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1226 |
val ct = cterm_of @{theory} tt |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1227 |
*} |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1228 |
ML_prf {* |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1229 |
val goal = hd (prems_of (Isar.goal ())) |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1230 |
val goalc = Logic.strip_assums_concl goal |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1231 |
*} |
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1232 |
ML_prf {* |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1233 |
val goalct = cterm_of @{theory} (hd ( prems_of (Isar.goal ()))) |
113
e3a963e6418b
Symmetric version of REP_ABS_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
112
diff
changeset
|
1234 |
*} |
e3a963e6418b
Symmetric version of REP_ABS_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
112
diff
changeset
|
1235 |
|
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1236 |
ML_prf {* |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1237 |
val ps = Logic.strip_params goal |
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1238 |
val goal' = cterm_of @{theory} (Term.list_abs (ps, goalc)) |
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1239 |
val goal'' = cterm_of @{theory} (Term.subst_bounds ((map Free ps), goalc)) |
114
3cdb743b7605
Fighting with the instantiation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
113
diff
changeset
|
1240 |
*} |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1241 |
ML_prf {* ct; goal'' *} |
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1242 |
|
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1243 |
ML_prf {* val nlct = cterm_of @{theory} (concl_of @{thm "APPLY_RSP_I2" }) *} |
116
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1244 |
|
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1245 |
ML_prf {* Thm.match (nlct, goal'') *} |
116
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1246 |
ML_prf {* ct *} |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1247 |
|
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1248 |
|
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1249 |
(*apply (tactic {*Cong_Tac.cong_tac @{thm APPLY_RSP_I2} 1 *}) *) |
116
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1250 |
ML_prf {* t *} |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1251 |
ML_prf {* |
116
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1252 |
val man_inst = |
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1253 |
Drule.instantiate' [SOME @{ctyp 'a}, SOME @{ctyp bool}] |
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1254 |
[ |
117
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1255 |
SOME @{cterm "\<lambda>(x\<Colon>'a list \<Rightarrow> bool) (y\<Colon>'a list \<Rightarrow> bool). x"}, |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1256 |
SOME @{cterm "\<lambda>(x\<Colon>'a list \<Rightarrow> bool) (y\<Colon>'a list \<Rightarrow> bool). (ABS_fset ---> id) ((REP_fset ---> id) y)"}, |
116
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1257 |
SOME @{cterm "\<lambda>(x\<Colon>'a list \<Rightarrow> bool) (y\<Colon>'a list \<Rightarrow> bool). ([]::'a list)"}, |
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1258 |
SOME @{cterm "\<lambda>(x\<Colon>'a list \<Rightarrow> bool) (y\<Colon>'a list \<Rightarrow> bool). (REP_fset (ABS_fset ([]::'a list)))"} |
2c378008a7da
Fully manually instantiated. Still fails...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
115
diff
changeset
|
1259 |
] t |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1260 |
*} |
117
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1261 |
ML_prf {* |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1262 |
val (tc') = (Logic.strip_assums_concl (prop_of man_inst)); |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1263 |
val ps = Logic.strip_params (prop_of man_inst) |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1264 |
val tt = Term.list_abs (ps, tc') |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1265 |
val ct = cterm_of @{theory} tt |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1266 |
*} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1267 |
ML_prf {* |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1268 |
fun dest_cbinop t = |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1269 |
let |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1270 |
val (t2, rhs) = Thm.dest_comb t; |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1271 |
val (bop, lhs) = Thm.dest_comb t2; |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1272 |
in |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1273 |
(bop, (lhs, rhs)) |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1274 |
end |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1275 |
*} |
115
22a503280deb
Little progress with match/instantiate
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
114
diff
changeset
|
1276 |
|
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1277 |
|
117
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1278 |
ML_prf {* val (a, b) = (snd (Thm.dest_abs NONE ct), (snd (Thm.dest_abs NONE goal'))) *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1279 |
ML_prf {* val (a, b) = (snd (Thm.dest_abs NONE a), (snd (Thm.dest_abs NONE b))) *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1280 |
ML_prf {* val (a, b) = (snd (Thm.dest_comb a), snd (Thm.dest_comb b)) *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1281 |
ML_prf {* val (a, b) = ((fst o snd) (dest_cbinop a), (fst o snd) (dest_cbinop b)) *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1282 |
ML_prf {* (term_of a, term_of b) *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1283 |
ML_prf {* (Envir.beta_norm (term_of a), term_of b) *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1284 |
ML_prf {* Thm.beta_conv *} |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1285 |
ML_prf man_inst |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1286 |
thm APPLY_RSP_I2 |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1287 |
apply (tactic {* compose_tac (false,man_inst,0) 1 *}) |
28f7dbd99314
The instantiated version is the same modulo beta
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
116
diff
changeset
|
1288 |
|
111 | 1289 |
sorry |
107
ab53ddefc542
A proper build_goal_term function.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
106
diff
changeset
|
1290 |
|
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1291 |
thm list.recs(2) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1292 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1293 |
|
106 | 1294 |
ML {* val card1_suc_f = Thm.freezeT (atomize_thm @{thm card1_suc}) *} |
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
95
diff
changeset
|
1295 |
|
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
95
diff
changeset
|
1296 |
prove card1_suc_r: {* |
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
95
diff
changeset
|
1297 |
Logic.mk_implies |
106 | 1298 |
((prop_of card1_suc_f), |
1299 |
(regularise (prop_of card1_suc_f) @{typ "'a List.list"} @{term "op \<approx>"} @{context})) *} |
|
104 | 1300 |
apply (simp add: equiv_res_forall[OF equiv_list_eq] equiv_res_exists[OF equiv_list_eq]) |
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
95
diff
changeset
|
1301 |
done |
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
95
diff
changeset
|
1302 |
|
106 | 1303 |
ML {* @{thm card1_suc_r} OF [card1_suc_f] *} |
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
95
diff
changeset
|
1304 |
|
97
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1305 |
ML {* val li = Thm.freezeT (atomize_thm @{thm fold1.simps(2)}) *} |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1306 |
prove fold1_def_2_r: {* |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1307 |
Logic.mk_implies |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1308 |
((prop_of li), |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1309 |
(regularise (prop_of li) @{typ "'a List.list"} @{term "op \<approx>"} @{context})) *} |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1310 |
apply (simp add: equiv_res_forall[OF equiv_list_eq]) |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1311 |
done |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1312 |
|
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1313 |
ML {* @{thm fold1_def_2_r} OF [li] *} |
0d34f2e60d5d
The definition of Fold1
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
96
diff
changeset
|
1314 |
|
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1315 |
ML {* |
49 | 1316 |
fun lift_theorem_fset_aux thm lthy = |
1317 |
let |
|
1318 |
val ((_, [novars]), lthy2) = Variable.import true [thm] lthy; |
|
111 | 1319 |
val goal = build_goal @{context} novars consts @{typ "'a list"} @{typ "'a fset"}; |
49 | 1320 |
val cgoal = cterm_of @{theory} goal; |
1321 |
val cgoal2 = Thm.rhs_of (MetaSimplifier.rewrite true fset_defs_sym cgoal); |
|
106 | 1322 |
val tac = transconv_fset_tac' @{context}; |
49 | 1323 |
val cthm = Goal.prove_internal [] cgoal2 (fn _ => tac); |
1324 |
val nthm = MetaSimplifier.rewrite_rule [symmetric cthm] (snd (no_vars (Context.Theory @{theory}, thm))) |
|
1325 |
val nthm2 = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same QUOT_TYPE_I_fset.thm10} nthm; |
|
1326 |
val [nthm3] = ProofContext.export lthy2 lthy [nthm2] |
|
1327 |
in |
|
1328 |
nthm3 |
|
1329 |
end |
|
1330 |
*} |
|
1331 |
||
1332 |
ML {* lift_theorem_fset_aux @{thm m1} @{context} *} |
|
1333 |
||
1334 |
ML {* |
|
1335 |
fun lift_theorem_fset name thm lthy = |
|
1336 |
let |
|
1337 |
val lifted_thm = lift_theorem_fset_aux thm lthy; |
|
88
19d3856abb81
slight simplification of atomize_thm
Christian Urban <urbanc@in.tum.de>
parents:
87
diff
changeset
|
1338 |
val (_, lthy2) = note (name, lifted_thm) lthy; |
49 | 1339 |
in |
1340 |
lthy2 |
|
1341 |
end; |
|
1342 |
*} |
|
1343 |
||
1344 |
local_setup {* lift_theorem_fset @{binding "m1_lift"} @{thm m1} *} |
|
1345 |
local_setup {* lift_theorem_fset @{binding "leqi4_lift"} @{thm list_eq.intros(4)} *} |
|
1346 |
local_setup {* lift_theorem_fset @{binding "leqi5_lift"} @{thm list_eq.intros(5)} *} |
|
1347 |
local_setup {* lift_theorem_fset @{binding "m2_lift"} @{thm m2} *} |
|
1348 |
thm m1_lift |
|
1349 |
thm leqi4_lift |
|
1350 |
thm leqi5_lift |
|
1351 |
thm m2_lift |
|
106 | 1352 |
ML {* @{thm card1_suc_r} OF [card1_suc_f] *} |
1353 |
(*ML {* Toplevel.program (fn () => lift_theorem_fset @{binding "card_suc"} |
|
1354 |
(@{thm card1_suc_r} OF [card1_suc_f]) @{context}) *}*) |
|
1355 |
(*local_setup {* lift_theorem_fset @{binding "card_suc"} @{thm card1_suc} *}*) |
|
49 | 1356 |
|
1357 |
thm leqi4_lift |
|
1358 |
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
|
1359 |
val (nam, typ) = hd (Term.add_vars (prop_of @{thm leqi4_lift}) []) |
49 | 1360 |
val (_, l) = dest_Type typ |
1361 |
val t = Type ("QuotMain.fset", l) |
|
1362 |
val v = Var (nam, t) |
|
1363 |
val cv = cterm_of @{theory} ((term_of @{cpat "REP_fset"}) $ v) |
|
1364 |
*} |
|
1365 |
||
1366 |
ML {* |
|
1367 |
Toplevel.program (fn () => |
|
1368 |
MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.thm10} ( |
|
1369 |
Drule.instantiate' [] [NONE, SOME (cv)] @{thm leqi4_lift} |
|
1370 |
) |
|
1371 |
) |
|
1372 |
*} |
|
1373 |
||
77 | 1374 |
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
|
1375 |
(((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
|
1376 |
(((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
|
1377 |
(\<lambda>P. |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1378 |
(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
|
1379 |
(REP_fset (ABS_fset [])) \<and> |
77 | 1380 |
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
|
1381 |
((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
|
1382 |
((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
|
1383 |
(\<lambda>t. |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1384 |
((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
|
1385 |
((REP_fset ---> id) P) |
73
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1386 |
(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
|
1387 |
(!h. |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1388 |
(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
|
1389 |
((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
|
1390 |
(REP_fset |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1391 |
(ABS_fset |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1392 |
(h # |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1393 |
REP_fset |
73
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1394 |
(ABS_fset t)))))))) \<longrightarrow> |
77 | 1395 |
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
|
1396 |
((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
|
1397 |
((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
|
1398 |
(\<lambda>l. |
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1399 |
(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
|
1400 |
((REP_fset ---> id) P) |
74
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1401 |
(REP_fset (ABS_fset l))))))))) |
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1402 |
|
77 | 1403 |
= Ball (Respects ((op \<approx>) ===> (op =))) |
1404 |
(\<lambda>P. ((P []) \<and> (Ball (Respects (op \<approx>)) (\<lambda>t. P t \<longrightarrow> (\<forall>h. (P (h # t)))))) \<longrightarrow> |
|
1405 |
(Ball (Respects (op \<approx>)) (\<lambda>l. P l)))" |
|
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1406 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1407 |
thm APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" "REP_fset ---> (id ---> id)" "ABS_fset ---> (id ---> id)" "op =" "id" "id"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1408 |
proof - |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1409 |
note APPLY_RSP_I = APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" "REP_fset ---> (id ---> id)" "ABS_fset ---> (id ---> id)" "op =" "id" "id"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1410 |
show ?thesis apply - |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1411 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1412 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1413 |
ML_prf {* |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1414 |
val gc = Subgoal.focus @{context} 1 (Isar.goal ()) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1415 |
|> fst |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1416 |
|> #concl |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1417 |
val tc = cterm_of @{theory} (concl_of ( @{thm "APPLY_RSP" })) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1418 |
val (_, tc') = Thm.dest_comb tc |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1419 |
val (_, gc') = Thm.dest_comb gc |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1420 |
*} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1421 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1422 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1423 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1424 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1425 |
ML_prf {* |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1426 |
(gc', tc') |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1427 |
*} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1428 |
ML_prf {* Pattern.first_order_match *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1429 |
ML_prf {* Thm.match (@{cpat "?P::?'a"}, @{cterm "1::nat"}) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1430 |
ML_prf {* Pattern.match @{theory} (term_of @{cpat "?P::nat"}, term_of @{cterm "1::nat"}) (Vartab.empty, Vartab.empty) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1431 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1432 |
ML_prf {* val (op1, (l1, r1)) = dest_cbinop tc' *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1433 |
ML_prf {* val (op2, (l2, r2)) = dest_cbinop gc' *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1434 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1435 |
ML_prf {* val mo = Thm.match (op1, op2) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1436 |
ML_prf {* val t1 = Drule.instantiate mo @{thm "APPLY_RSP" } *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1437 |
ML_prf {* val tc = cterm_of @{theory} (concl_of t1) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1438 |
ML_prf {* val (_, tc') = Thm.dest_comb tc *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1439 |
ML_prf {* val (op1, (l1, r1)) = dest_cbinop tc' *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1440 |
ML_prf {* val (mlty, mlt) = Thm.match (l1, l2) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1441 |
ML_prf {* val t2 = Drule.instantiate (mlty, []) t1 *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1442 |
ML_prf {* val tc = cterm_of @{theory} (concl_of t2) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1443 |
ML_prf {* val (_, tc') = Thm.dest_comb tc *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1444 |
ML_prf {* val (op1, (l1, r1)) = dest_cbinop tc' *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1445 |
ML_prf {* val mr = Thm.match (r1, r2) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1446 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1447 |
ML_prf {* val t3 = Drule.instantiate ml t2 *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1448 |
ML_prf {* val tc = cterm_of @{theory} (concl_of t3) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1449 |
ML_prf {* val (_, tc') = Thm.dest_comb tc *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1450 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1451 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1452 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1453 |
ML_prf {* mtyl; mtyr *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1454 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1455 |
ML_prf {* val ol1 = Thm.capply op1 l1 *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1456 |
ML_prf {* val ol2 = Thm.capply op2 l2 *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1457 |
ML_prf {* (ol1, ol2); Thm.match (ol1, ol2) *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1458 |
ML_prf {* val w1 = Thm.capply ol1 r1 *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1459 |
ML_prf {* val w2 = Thm.capply ol2 r2 *} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1460 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1461 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1462 |
. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1463 |
(*ML_prf {* (w1, w2); Thm.match (w1, w2) *}*) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1464 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1465 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1466 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1467 |
ML_prf {* |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1468 |
(tc', gc') |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1469 |
*} |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1470 |
|
95
8c3a35da4560
Proving the proper RepAbs version
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
94
diff
changeset
|
1471 |
thm APPLY_RSP |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1472 |
thm APPLY_RSP[of "op \<approx> ===> (op = ===> op =)"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1473 |
term "(op \<approx> ===> op =) ===> op =" |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1474 |
proof - |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1475 |
note APPLY_RSP_I2 = APPLY_RSP[of "(op \<approx> ===> op =) ===> op =" "(ABS_fset ---> id) ---> id" "(REP_fset ---> id) ---> id" "op =" "id" "id" "Ball (Respects op \<approx> ===> op =)" "Ball (Respects op \<approx> ===> op =)"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1476 |
show ?thesis apply - |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1477 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1478 |
thm APPLY_RSP_I2[of _ "\<lambda>P. (P [] \<and> (\<forall>t\<Colon>'b list\<in>Respects op \<approx>. P t \<longrightarrow> (\<forall>h\<Colon>'b. P (h # t))) \<longrightarrow> |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1479 |
(\<forall>l\<Colon>'b list\<in>Respects op \<approx>. P l))"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1480 |
proof - |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1481 |
note APPLY_RSP_I3=APPLY_RSP_I2[of _ "\<lambda>P. (P [] \<and> (\<forall>t\<Colon>'b list\<in>Respects op \<approx>. P t \<longrightarrow> (\<forall>h\<Colon>'b. P (h # t))) \<longrightarrow> |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1482 |
(\<forall>l\<Colon>'b list\<in>Respects op \<approx>. P l))"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1483 |
show ?thesis apply - |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1484 |
term "(REP_fset ---> id ---> id |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1485 |
(ABS_fset ---> id ---> id |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1486 |
(\<lambda>P\<Colon>'a list \<Rightarrow> bool. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1487 |
ABS_fset ---> id (REP_fset ---> id P) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1488 |
(REP_fset (ABS_fset [])) \<and> |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1489 |
Ball (Respects op \<approx>) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1490 |
(ABS_fset ---> id |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1491 |
(REP_fset ---> id |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1492 |
(\<lambda>t\<Colon>'a list. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1493 |
ABS_fset ---> id (REP_fset ---> id P) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1494 |
(REP_fset (ABS_fset t)) \<longrightarrow> |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1495 |
(\<forall>h\<Colon>'a. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1496 |
ABS_fset ---> id (REP_fset ---> id P) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1497 |
(REP_fset |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1498 |
(ABS_fset |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1499 |
(h # REP_fset (ABS_fset t)))))))) \<longrightarrow> |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1500 |
Ball (Respects op \<approx>) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1501 |
(ABS_fset ---> id |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1502 |
(REP_fset ---> id |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1503 |
(\<lambda>l\<Colon>'a list. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1504 |
ABS_fset ---> id (REP_fset ---> id P) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1505 |
(REP_fset (ABS_fset l))))))))" |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1506 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1507 |
apply (rule APPLY_RSP_I3) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1508 |
term "Ball (Respects op \<approx> ===> op =)" |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1509 |
thm APPLY_RSP_I [of _ "Ball (Respects op \<approx> ===> op =)"] |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1510 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1511 |
thm APPLY_RSP |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1512 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1513 |
. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1514 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1515 |
apply (tactic {* Cong_Tac.cong_tac @{thm APPLY_RSP_I} 1 *} ) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1516 |
|
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1517 |
apply (tactic {* match_tac @{thms APPLY_RSP_I} 1 *}) |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1518 |
. |
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1519 |
|
111 | 1520 |
apply (rule APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" "REP_fset ---> (id ---> id)" "ABS_fset ---> (id ---> id)" "op =" "id" "id"]) |
95
8c3a35da4560
Proving the proper RepAbs version
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
94
diff
changeset
|
1521 |
apply (rule APPLY_RSP[of "op \<approx> ===> (op = ===> op =)" _ _ "op ="]) |
74
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1522 |
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
|
1523 |
thm LAMBDA_PRS1[symmetric] |
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1524 |
(*apply (simp only:LAMBDA_PRS1[symmetric] FUN_QUOTIENT IDENTITY_QUOTIENT QUOT_TYPE_I_fset.QUOTIENT)*) |
77 | 1525 |
apply (unfold Ball_def) |
74
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1526 |
apply (simp only: IN_RESPECTS) |
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1527 |
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
|
1528 |
apply (unfold id_def) |
74
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1529 |
(*apply (simp only: FUN_MAP_I)*) |
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1530 |
apply (simp) |
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1531 |
apply (simp only: QUOT_TYPE_I_fset.thm10) |
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1532 |
.. |
73
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1533 |
apply (simp add:IN_RESPECTS) |
74
0370493040f3
Further with the manual proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
73
diff
changeset
|
1534 |
|
73
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1535 |
|
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1536 |
|
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1537 |
|
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1538 |
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
|
1539 |
|
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1540 |
apply (rule ext) |
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1541 |
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
|
1542 |
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
|
1543 |
apply (simp add:cons_preserves) |
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1544 |
|
fdaf1466daf0
Further experiments with proving induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
72
diff
changeset
|
1545 |
|
72
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1546 |
|
4efc9e6661a4
Testing if I can prove the regularized version of induction manually
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
71
diff
changeset
|
1547 |
(*prove aaa: {* (Thm.term_of cgoal2) *} |
45 | 1548 |
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
|
1549 |
apply (atomize(full)) |
101
4f93c5a026d2
Reordering the code, part 3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
100
diff
changeset
|
1550 |
apply (tactic {* transconv_fset_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
|
1551 |
done*) |
29
2b59bf690633
Proper definition of CARD and some properties of it.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
28
diff
changeset
|
1552 |
|
18
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1553 |
(* |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1554 |
datatype obj1 = |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1555 |
OVAR1 "string" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1556 |
| OBJ1 "(string * (string \<Rightarrow> obj1)) list" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1557 |
| INVOKE1 "obj1 \<Rightarrow> string" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1558 |
| UPDATE1 "obj1 \<Rightarrow> string \<Rightarrow> (string \<Rightarrow> obj1)" |
ce522150c1f7
Infrastructure for the tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
17
diff
changeset
|
1559 |
*) |
53 | 1560 |
|
57 | 1561 |
end |
112
0d6d37d0589d
Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
111
diff
changeset
|
1562 |