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