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