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