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