author | Christian Urban <urbanc@in.tum.de> |
Sat, 19 Dec 2009 22:04:34 +0100 | |
changeset 760 | c1989de100b4 |
parent 759 | 119f7d6a3556 |
child 768 | e9e205b904e2 |
permissions | -rw-r--r-- |
759 | 1 |
(* Title: ??/QuotMain.thy |
2 |
Author: Cezary Kaliszyk and Christian Urban |
|
3 |
*) |
|
4 |
||
597 | 5 |
theory QuotMain |
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
6 |
imports QuotScript Prove |
597 | 7 |
uses ("quotient_info.ML") |
725
0d98a4c7f8dc
renamed quotient.ML to quotient_typ.ML
Christian Urban <urbanc@in.tum.de>
parents:
720
diff
changeset
|
8 |
("quotient_typ.ML") |
597 | 9 |
("quotient_def.ML") |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
10 |
("quotient_term.ML") |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
11 |
("quotient_tacs.ML") |
597 | 12 |
begin |
13 |
||
14 |
locale QUOT_TYPE = |
|
15 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
16 |
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b" |
|
17 |
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)" |
|
18 |
assumes equivp: "equivp R" |
|
19 |
and rep_prop: "\<And>y. \<exists>x. Rep y = R x" |
|
20 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
|
21 |
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)" |
|
22 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
|
23 |
begin |
|
24 |
||
25 |
definition |
|
719 | 26 |
abs::"'a \<Rightarrow> 'b" |
597 | 27 |
where |
719 | 28 |
"abs x \<equiv> Abs (R x)" |
597 | 29 |
|
30 |
definition |
|
719 | 31 |
rep::"'b \<Rightarrow> 'a" |
597 | 32 |
where |
719 | 33 |
"rep a = Eps (Rep a)" |
597 | 34 |
|
35 |
lemma lem9: |
|
36 |
shows "R (Eps (R x)) = R x" |
|
37 |
proof - |
|
38 |
have a: "R x x" using equivp by (simp add: equivp_reflp_symp_transp reflp_def) |
|
39 |
then have "R x (Eps (R x))" by (rule someI) |
|
40 |
then show "R (Eps (R x)) = R x" |
|
41 |
using equivp unfolding equivp_def by simp |
|
42 |
qed |
|
43 |
||
44 |
theorem thm10: |
|
719 | 45 |
shows "abs (rep a) \<equiv> a" |
597 | 46 |
apply (rule eq_reflection) |
719 | 47 |
unfolding abs_def rep_def |
597 | 48 |
proof - |
49 |
from rep_prop |
|
50 |
obtain x where eq: "Rep a = R x" by auto |
|
51 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
|
52 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
|
53 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
|
54 |
also have "\<dots> = a" using rep_inverse by simp |
|
55 |
finally |
|
56 |
show "Abs (R (Eps (Rep a))) = a" by simp |
|
57 |
qed |
|
58 |
||
719 | 59 |
lemma rep_refl: |
60 |
shows "R (rep a) (rep a)" |
|
61 |
unfolding rep_def |
|
597 | 62 |
by (simp add: equivp[simplified equivp_def]) |
63 |
||
64 |
lemma lem7: |
|
65 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
|
66 |
apply(rule iffI) |
|
67 |
apply(simp) |
|
68 |
apply(drule rep_inject[THEN iffD2]) |
|
69 |
apply(simp add: abs_inverse) |
|
70 |
done |
|
71 |
||
72 |
theorem thm11: |
|
719 | 73 |
shows "R r r' = (abs r = abs r')" |
74 |
unfolding abs_def |
|
597 | 75 |
by (simp only: equivp[simplified equivp_def] lem7) |
76 |
||
77 |
||
719 | 78 |
lemma rep_abs_rsp: |
79 |
shows "R f (rep (abs g)) = R f g" |
|
80 |
and "R (rep (abs g)) f = R g f" |
|
597 | 81 |
by (simp_all add: thm10 thm11) |
82 |
||
83 |
lemma Quotient: |
|
719 | 84 |
"Quotient R abs rep" |
597 | 85 |
apply(unfold Quotient_def) |
86 |
apply(simp add: thm10) |
|
719 | 87 |
apply(simp add: rep_refl) |
597 | 88 |
apply(subst thm11[symmetric]) |
89 |
apply(simp add: equivp[simplified equivp_def]) |
|
90 |
done |
|
91 |
||
92 |
end |
|
93 |
||
94 |
section {* type definition for the quotient type *} |
|
95 |
||
759 | 96 |
(* auxiliary data for the quotient package *) |
597 | 97 |
use "quotient_info.ML" |
98 |
||
99 |
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
|
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_thm] = fun_quotient |
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents:
643
diff
changeset
|
102 |
lemmas [quot_respect] = quot_rel_rsp |
597 | 103 |
|
104 |
(* 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
|
105 |
lemmas [quot_equiv] = identity_equivp |
597 | 106 |
|
107 |
(* definition of the quotient types *) |
|
725
0d98a4c7f8dc
renamed quotient.ML to quotient_typ.ML
Christian Urban <urbanc@in.tum.de>
parents:
720
diff
changeset
|
108 |
use "quotient_typ.ML" |
597 | 109 |
|
110 |
(* lifting of constants *) |
|
111 |
use "quotient_def.ML" |
|
112 |
||
759 | 113 |
(* the translation functions for the lifting process *) |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
114 |
use "quotient_term.ML" |
597 | 115 |
|
759 | 116 |
(* tactics for proving the theorems *) |
117 |
||
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
118 |
lemma eq_imp_rel: |
759 | 119 |
"equivp R ==> a = b \<longrightarrow> R a b" |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
120 |
by (simp add: equivp_reflp) |
597 | 121 |
|
759 | 122 |
(* an auxiliar constant that records some information *) |
123 |
(* about the lifted theorem *) |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
124 |
definition |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
125 |
"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
|
126 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
127 |
lemma quot_true_dests: |
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
by (simp_all add: QUOT_TRUE_def ext) |
751 | 133 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
134 |
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
|
135 |
by (simp add: QUOT_TRUE_def) |
751 | 136 |
|
759 | 137 |
lemma regularize_to_injection: |
138 |
shows "(QUOT_TRUE l \<Longrightarrow> y) \<Longrightarrow> (l = r) \<longrightarrow> y" |
|
139 |
by(auto simp add: QUOT_TRUE_def) |
|
751 | 140 |
|
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
141 |
use "quotient_tacs.ML" |
751 | 142 |
|
759 | 143 |
(* atomize infrastructure *) |
597 | 144 |
lemma atomize_eqv[atomize]: |
145 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
|
146 |
proof |
|
147 |
assume "A \<equiv> B" |
|
148 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
|
149 |
next |
|
150 |
assume *: "Trueprop A \<equiv> Trueprop B" |
|
151 |
have "A = B" |
|
152 |
proof (cases A) |
|
153 |
case True |
|
154 |
have "A" by fact |
|
155 |
then show "A = B" using * by simp |
|
156 |
next |
|
157 |
case False |
|
158 |
have "\<not>A" by fact |
|
159 |
then show "A = B" using * by auto |
|
160 |
qed |
|
161 |
then show "A \<equiv> B" by (rule eq_reflection) |
|
162 |
qed |
|
163 |
||
759 | 164 |
(* lemmas about simplifying id *) |
668 | 165 |
lemmas [id_simps] = |
597 | 166 |
fun_map_id[THEN eq_reflection] |
167 |
id_apply[THEN eq_reflection] |
|
759 | 168 |
id_def[THEN eq_reflection, symmetric] |
597 | 169 |
|
689 | 170 |
section {* Methods / Interface *} |
171 |
||
632
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
172 |
ML {* |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
173 |
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
|
174 |
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
|
175 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
176 |
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
|
177 |
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
|
178 |
*} |
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
179 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
180 |
method_setup lifting = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
181 |
{* 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
|
182 |
{* 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
|
183 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
184 |
method_setup lifting_setup = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
185 |
{* 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
|
186 |
{* 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
|
187 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
188 |
method_setup regularize = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
189 |
{* 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
|
190 |
{* 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
|
191 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
192 |
method_setup injection = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
193 |
{* 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
|
194 |
{* 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
|
195 |
|
d23416464f62
added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents:
624
diff
changeset
|
196 |
method_setup cleaning = |
758
3104d62e7a16
moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
752
diff
changeset
|
197 |
{* 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
|
198 |
{* 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
|
199 |
|
597 | 200 |
end |
201 |