author | Christian Urban <urbanc@in.tum.de> |
Thu, 17 Dec 2009 14:58:33 +0100 | |
changeset 758 | 3104d62e7a16 |
parent 752 | 17d06b5ec197 |
child 759 | 119f7d6a3556 |
permissions | -rw-r--r-- |
597 | 1 |
theory QuotMain |
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
2 |
imports QuotScript Prove |
597 | 3 |
uses ("quotient_info.ML") |
725
0d98a4c7f8dc
renamed quotient.ML to quotient_typ.ML
Christian Urban <urbanc@in.tum.de>
parents:
720
diff
changeset
|
4 |
("quotient_typ.ML") |
597 | 5 |
("quotient_def.ML") |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
6 |
("quotient_term.ML") |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
7 |
("quotient_tacs.ML") |
597 | 8 |
begin |
9 |
||
10 |
locale QUOT_TYPE = |
|
11 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
12 |
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b" |
|
13 |
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)" |
|
14 |
assumes equivp: "equivp R" |
|
15 |
and rep_prop: "\<And>y. \<exists>x. Rep y = R x" |
|
16 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
|
17 |
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)" |
|
18 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
|
19 |
begin |
|
20 |
||
21 |
definition |
|
719 | 22 |
abs::"'a \<Rightarrow> 'b" |
597 | 23 |
where |
719 | 24 |
"abs x \<equiv> Abs (R x)" |
597 | 25 |
|
26 |
definition |
|
719 | 27 |
rep::"'b \<Rightarrow> 'a" |
597 | 28 |
where |
719 | 29 |
"rep a = Eps (Rep a)" |
597 | 30 |
|
31 |
lemma lem9: |
|
32 |
shows "R (Eps (R x)) = R x" |
|
33 |
proof - |
|
34 |
have a: "R x x" using equivp by (simp add: equivp_reflp_symp_transp reflp_def) |
|
35 |
then have "R x (Eps (R x))" by (rule someI) |
|
36 |
then show "R (Eps (R x)) = R x" |
|
37 |
using equivp unfolding equivp_def by simp |
|
38 |
qed |
|
39 |
||
40 |
theorem thm10: |
|
719 | 41 |
shows "abs (rep a) \<equiv> a" |
597 | 42 |
apply (rule eq_reflection) |
719 | 43 |
unfolding abs_def rep_def |
597 | 44 |
proof - |
45 |
from rep_prop |
|
46 |
obtain x where eq: "Rep a = R x" by auto |
|
47 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
|
48 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
|
49 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
|
50 |
also have "\<dots> = a" using rep_inverse by simp |
|
51 |
finally |
|
52 |
show "Abs (R (Eps (Rep a))) = a" by simp |
|
53 |
qed |
|
54 |
||
719 | 55 |
lemma rep_refl: |
56 |
shows "R (rep a) (rep a)" |
|
57 |
unfolding rep_def |
|
597 | 58 |
by (simp add: equivp[simplified equivp_def]) |
59 |
||
60 |
lemma lem7: |
|
61 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
|
62 |
apply(rule iffI) |
|
63 |
apply(simp) |
|
64 |
apply(drule rep_inject[THEN iffD2]) |
|
65 |
apply(simp add: abs_inverse) |
|
66 |
done |
|
67 |
||
68 |
theorem thm11: |
|
719 | 69 |
shows "R r r' = (abs r = abs r')" |
70 |
unfolding abs_def |
|
597 | 71 |
by (simp only: equivp[simplified equivp_def] lem7) |
72 |
||
73 |
||
719 | 74 |
lemma rep_abs_rsp: |
75 |
shows "R f (rep (abs g)) = R f g" |
|
76 |
and "R (rep (abs g)) f = R g f" |
|
597 | 77 |
by (simp_all add: thm10 thm11) |
78 |
||
79 |
lemma Quotient: |
|
719 | 80 |
"Quotient R abs rep" |
597 | 81 |
apply(unfold Quotient_def) |
82 |
apply(simp add: thm10) |
|
719 | 83 |
apply(simp add: rep_refl) |
597 | 84 |
apply(subst thm11[symmetric]) |
85 |
apply(simp add: equivp[simplified equivp_def]) |
|
86 |
done |
|
87 |
||
88 |
end |
|
89 |
||
90 |
section {* type definition for the quotient type *} |
|
91 |
||
92 |
(* the auxiliary data for the quotient types *) |
|
93 |
use "quotient_info.ML" |
|
94 |
||
699
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
95 |
ML {* print_mapsinfo @{context} *} |
aa157e957655
added maps-printout and tuned some comments
Christian Urban <urbanc@in.tum.de>
parents:
697
diff
changeset
|
96 |
|
597 | 97 |
declare [[map "fun" = (fun_map, fun_rel)]] |
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents:
614
diff
changeset
|
98 |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
99 |
lemmas [quot_thm] = fun_quotient |
597 | 100 |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
101 |
lemmas [quot_respect] = quot_rel_rsp |
597 | 102 |
|
103 |
(* fun_map is not here since equivp is not true *) |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
104 |
lemmas [quot_equiv] = identity_equivp |
597 | 105 |
|
106 |
(* definition of the quotient types *) |
|
725
0d98a4c7f8dc
renamed quotient.ML to quotient_typ.ML
Christian Urban <urbanc@in.tum.de>
parents:
720
diff
changeset
|
107 |
use "quotient_typ.ML" |
597 | 108 |
|
109 |
(* lifting of constants *) |
|
110 |
use "quotient_def.ML" |
|
111 |
||
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
112 |
(* the translation functions *) |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
113 |
use "quotient_term.ML" |
597 | 114 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
115 |
(* tactics *) |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
116 |
lemma eq_imp_rel: |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
117 |
"equivp R ==> a = b --> R a b" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
118 |
by (simp add: equivp_reflp) |
597 | 119 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
120 |
definition |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
121 |
"QUOT_TRUE x \<equiv> True" |
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents:
602
diff
changeset
|
122 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
123 |
lemma quot_true_dests: |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
124 |
shows QT_all: "QUOT_TRUE (All P) \<Longrightarrow> QUOT_TRUE P" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
125 |
and QT_ex: "QUOT_TRUE (Ex P) \<Longrightarrow> QUOT_TRUE P" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
126 |
and QT_lam: "QUOT_TRUE (\<lambda>x. P x) \<Longrightarrow> (\<And>x. QUOT_TRUE (P x))" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
127 |
and QT_ext: "(\<And>x. QUOT_TRUE (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (QUOT_TRUE a \<Longrightarrow> f = g)" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
128 |
by (simp_all add: QUOT_TRUE_def ext) |
751 | 129 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
130 |
lemma QUOT_TRUE_imp: "QUOT_TRUE a \<equiv> QUOT_TRUE b" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
131 |
by (simp add: QUOT_TRUE_def) |
751 | 132 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
133 |
lemma regularize_to_injection: "(QUOT_TRUE l \<Longrightarrow> y) \<Longrightarrow> (l = r) \<longrightarrow> y" |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
134 |
by(auto simp add: QUOT_TRUE_def) |
751 | 135 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
136 |
use "quotient_tacs.ML" |
751 | 137 |
|
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
138 |
section {* Atomize Infrastructure *} |
597 | 139 |
|
140 |
lemma atomize_eqv[atomize]: |
|
141 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
|
142 |
proof |
|
143 |
assume "A \<equiv> B" |
|
144 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
|
145 |
next |
|
146 |
assume *: "Trueprop A \<equiv> Trueprop B" |
|
147 |
have "A = B" |
|
148 |
proof (cases A) |
|
149 |
case True |
|
150 |
have "A" by fact |
|
151 |
then show "A = B" using * by simp |
|
152 |
next |
|
153 |
case False |
|
154 |
have "\<not>A" by fact |
|
155 |
then show "A = B" using * by auto |
|
156 |
qed |
|
157 |
then show "A \<equiv> B" by (rule eq_reflection) |
|
158 |
qed |
|
159 |
||
614
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
160 |
section {* Infrastructure about id *} |
51a4208162ed
added a thm list for ids
Christian Urban <urbanc@in.tum.de>
parents:
613
diff
changeset
|
161 |
|
668 | 162 |
lemmas [id_simps] = |
597 | 163 |
fun_map_id[THEN eq_reflection] |
164 |
id_apply[THEN eq_reflection] |
|
165 |
id_def[THEN eq_reflection,symmetric] |
|
166 |
||
689 | 167 |
section {* Methods / Interface *} |
168 |
||
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
169 |
ML {* |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
170 |
fun mk_method1 tac thm ctxt = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
171 |
SIMPLE_METHOD (HEADGOAL (tac ctxt thm)) |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
172 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
173 |
fun mk_method2 tac ctxt = |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
174 |
SIMPLE_METHOD (HEADGOAL (tac ctxt)) |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
175 |
*} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
176 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
177 |
method_setup lifting = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
178 |
{* Attrib.thm >> (mk_method1 Quotient_Tacs.lift_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
179 |
{* Lifting of theorems to quotient types. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
180 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
181 |
method_setup lifting_setup = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
182 |
{* Attrib.thm >> (mk_method1 Quotient_Tacs.procedure_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
183 |
{* Sets up the three goals for the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
184 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
185 |
method_setup regularize = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
186 |
{* Scan.succeed (mk_method2 Quotient_Tacs.regularize_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
187 |
{* Proves automatically the regularization goals from the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
188 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
189 |
method_setup injection = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
190 |
{* Scan.succeed (mk_method2 Quotient_Tacs.all_inj_repabs_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
191 |
{* Proves automatically the rep/abs injection goals from the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
192 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
193 |
method_setup cleaning = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
194 |
{* Scan.succeed (mk_method2 Quotient_Tacs.clean_tac) *} |
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
195 |
{* Proves automatically the cleaning goals from the lifting procedure. *} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
196 |
|
597 | 197 |
end |
198 |