597
|
1 |
theory QuotMain
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
2 |
imports QuotScript Prove
|
597
|
3 |
uses ("quotient_info.ML")
|
725
|
4 |
("quotient_typ.ML")
|
597
|
5 |
("quotient_def.ML")
|
758
|
6 |
("quotient_term.ML")
|
|
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
|
95 |
ML {* print_mapsinfo @{context} *}
|
|
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>
diff
changeset
|
98 |
|
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
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>
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>
diff
changeset
|
104 |
lemmas [quot_equiv] = identity_equivp
|
597
|
105 |
|
|
106 |
(* definition of the quotient types *)
|
725
|
107 |
use "quotient_typ.ML"
|
597
|
108 |
|
|
109 |
(* lifting of constants *)
|
|
110 |
use "quotient_def.ML"
|
|
111 |
|
758
|
112 |
(* the translation functions *)
|
|
113 |
use "quotient_term.ML"
|
597
|
114 |
|
758
|
115 |
(* tactics *)
|
|
116 |
lemma eq_imp_rel:
|
|
117 |
"equivp R ==> a = b --> R a b"
|
|
118 |
by (simp add: equivp_reflp)
|
597
|
119 |
|
758
|
120 |
definition
|
|
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>
diff
changeset
|
122 |
|
758
|
123 |
lemma quot_true_dests:
|
|
124 |
shows QT_all: "QUOT_TRUE (All P) \<Longrightarrow> QUOT_TRUE P"
|
|
125 |
and QT_ex: "QUOT_TRUE (Ex P) \<Longrightarrow> QUOT_TRUE P"
|
|
126 |
and QT_lam: "QUOT_TRUE (\<lambda>x. P x) \<Longrightarrow> (\<And>x. QUOT_TRUE (P x))"
|
|
127 |
and QT_ext: "(\<And>x. QUOT_TRUE (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (QUOT_TRUE a \<Longrightarrow> f = g)"
|
|
128 |
by (simp_all add: QUOT_TRUE_def ext)
|
751
|
129 |
|
758
|
130 |
lemma QUOT_TRUE_imp: "QUOT_TRUE a \<equiv> QUOT_TRUE b"
|
|
131 |
by (simp add: QUOT_TRUE_def)
|
751
|
132 |
|
758
|
133 |
lemma regularize_to_injection: "(QUOT_TRUE l \<Longrightarrow> y) \<Longrightarrow> (l = r) \<longrightarrow> y"
|
|
134 |
by(auto simp add: QUOT_TRUE_def)
|
751
|
135 |
|
758
|
136 |
use "quotient_tacs.ML"
|
751
|
137 |
|
614
|
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
|
160 |
section {* Infrastructure about id *}
|
|
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
|
169 |
ML {*
|
|
170 |
fun mk_method1 tac thm ctxt =
|
|
171 |
SIMPLE_METHOD (HEADGOAL (tac ctxt thm))
|
|
172 |
|
|
173 |
fun mk_method2 tac ctxt =
|
|
174 |
SIMPLE_METHOD (HEADGOAL (tac ctxt))
|
|
175 |
*}
|
|
176 |
|
|
177 |
method_setup lifting =
|
758
|
178 |
{* Attrib.thm >> (mk_method1 Quotient_Tacs.lift_tac) *}
|
632
|
179 |
{* Lifting of theorems to quotient types. *}
|
|
180 |
|
|
181 |
method_setup lifting_setup =
|
758
|
182 |
{* Attrib.thm >> (mk_method1 Quotient_Tacs.procedure_tac) *}
|
632
|
183 |
{* Sets up the three goals for the lifting procedure. *}
|
|
184 |
|
|
185 |
method_setup regularize =
|
758
|
186 |
{* Scan.succeed (mk_method2 Quotient_Tacs.regularize_tac) *}
|
632
|
187 |
{* Proves automatically the regularization goals from the lifting procedure. *}
|
|
188 |
|
|
189 |
method_setup injection =
|
758
|
190 |
{* Scan.succeed (mk_method2 Quotient_Tacs.all_inj_repabs_tac) *}
|
632
|
191 |
{* Proves automatically the rep/abs injection goals from the lifting procedure. *}
|
|
192 |
|
|
193 |
method_setup cleaning =
|
758
|
194 |
{* Scan.succeed (mk_method2 Quotient_Tacs.clean_tac) *}
|
632
|
195 |
{* Proves automatically the cleaning goals from the lifting procedure. *}
|
|
196 |
|
597
|
197 |
end
|
|
198 |
|