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