919
+ − 1
(* Title: QuotMain.thy
759
+ − 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>
diff
changeset
+ − 6
imports QuotScript Prove
597
+ − 7
uses ("quotient_info.ML")
725
+ − 8
("quotient_typ.ML")
597
+ − 9
("quotient_def.ML")
758
+ − 10
("quotient_term.ML")
+ − 11
("quotient_tacs.ML")
597
+ − 12
begin
+ − 13
781
+ − 14
locale Quot_Type =
597
+ − 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
919
+ − 35
text {*
+ − 36
The naming of the lemmas follows the quotient paper
+ − 37
by Peter Homeier.
+ − 38
*}
+ − 39
597
+ − 40
lemma lem9:
+ − 41
shows "R (Eps (R x)) = R x"
+ − 42
proof -
+ − 43
have a: "R x x" using equivp by (simp add: equivp_reflp_symp_transp reflp_def)
+ − 44
then have "R x (Eps (R x))" by (rule someI)
+ − 45
then show "R (Eps (R x)) = R x"
+ − 46
using equivp unfolding equivp_def by simp
+ − 47
qed
+ − 48
+ − 49
theorem thm10:
719
+ − 50
shows "abs (rep a) \<equiv> a"
597
+ − 51
apply (rule eq_reflection)
719
+ − 52
unfolding abs_def rep_def
597
+ − 53
proof -
+ − 54
from rep_prop
+ − 55
obtain x where eq: "Rep a = R x" by auto
+ − 56
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp
+ − 57
also have "\<dots> = Abs (R x)" using lem9 by simp
+ − 58
also have "\<dots> = Abs (Rep a)" using eq by simp
+ − 59
also have "\<dots> = a" using rep_inverse by simp
+ − 60
finally
+ − 61
show "Abs (R (Eps (Rep a))) = a" by simp
+ − 62
qed
+ − 63
719
+ − 64
lemma rep_refl:
+ − 65
shows "R (rep a) (rep a)"
+ − 66
unfolding rep_def
597
+ − 67
by (simp add: equivp[simplified equivp_def])
+ − 68
+ − 69
lemma lem7:
919
+ − 70
shows "(R x = R y) = (Abs (R x) = Abs (R y))" (is "?LHS = ?RHS")
+ − 71
proof -
+ − 72
have "?RHS = (Rep (Abs (R x)) = Rep (Abs (R y)))" by (simp add: rep_inject)
+ − 73
also have "\<dots> = ?LHS" by (simp add: abs_inverse)
+ − 74
finally show "?LHS = ?RHS" by simp
+ − 75
qed
597
+ − 76
+ − 77
theorem thm11:
719
+ − 78
shows "R r r' = (abs r = abs r')"
+ − 79
unfolding abs_def
597
+ − 80
by (simp only: equivp[simplified equivp_def] lem7)
+ − 81
719
+ − 82
lemma rep_abs_rsp:
+ − 83
shows "R f (rep (abs g)) = R f g"
+ − 84
and "R (rep (abs g)) f = R g f"
597
+ − 85
by (simp_all add: thm10 thm11)
+ − 86
+ − 87
lemma Quotient:
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 88
shows "Quotient R abs rep"
919
+ − 89
unfolding Quotient_def
597
+ − 90
apply(simp add: thm10)
719
+ − 91
apply(simp add: rep_refl)
597
+ − 92
apply(subst thm11[symmetric])
+ − 93
apply(simp add: equivp[simplified equivp_def])
+ − 94
done
+ − 95
+ − 96
end
+ − 97
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 98
section {* ML setup *}
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 99
919
+ − 100
text {* Auxiliary data for the quotient package *}
869
ce5f78f0eac5
Finished organising an efficient datastructure for qconst_info.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 101
597
+ − 102
use "quotient_info.ML"
+ − 103
+ − 104
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
+ − 105
909
+ − 106
lemmas [quot_thm] = fun_quotient
911
+ − 107
lemmas [quot_respect] = quot_rel_rsp
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 108
lemmas [quot_equiv] = identity_equivp
597
+ − 109
919
+ − 110
+ − 111
text {* Lemmas about simplifying id's. *}
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 112
lemmas [id_simps] =
919
+ − 113
id_def[symmetric, THEN eq_reflection]
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 114
fun_map_id[THEN eq_reflection]
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 115
id_apply[THEN eq_reflection]
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 116
id_o[THEN eq_reflection]
825
+ − 117
o_id[THEN eq_reflection]
+ − 118
eq_comp_r
774
b4ffb8826105
moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 119
919
+ − 120
text {* Translation functions for the lifting process. *}
774
b4ffb8826105
moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 121
use "quotient_term.ML"
b4ffb8826105
moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 122
b4ffb8826105
moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 123
919
+ − 124
text {* Definitions of the quotient types. *}
725
+ − 125
use "quotient_typ.ML"
597
+ − 126
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 127
919
+ − 128
text {* Definitions for quotient constants. *}
597
+ − 129
use "quotient_def.ML"
+ − 130
759
+ − 131
919
+ − 132
text {*
+ − 133
An auxiliar constant for recording some information
+ − 134
about the lifted theorem in a tactic.
+ − 135
*}
758
+ − 136
definition
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 137
"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
+ − 138
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 139
lemma
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 140
shows QT_all: "Quot_True (All P) \<Longrightarrow> Quot_True P"
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 141
and QT_ex: "Quot_True (Ex P) \<Longrightarrow> Quot_True P"
907
+ − 142
and QT_ex1: "Quot_True (Ex1 P) \<Longrightarrow> Quot_True P"
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 143
and QT_lam: "Quot_True (\<lambda>x. P x) \<Longrightarrow> (\<And>x. Quot_True (P x))"
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 144
and QT_ext: "(\<And>x. Quot_True (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (Quot_True a \<Longrightarrow> f = g)"
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 145
by (simp_all add: Quot_True_def ext)
751
+ − 146
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 147
lemma QT_imp: "Quot_True a \<equiv> Quot_True b"
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 148
by (simp add: Quot_True_def)
751
+ − 149
919
+ − 150
text {* Tactics for proving the lifted theorems *}
758
+ − 151
use "quotient_tacs.ML"
751
+ − 152
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 153
689
+ − 154
section {* Methods / Interface *}
+ − 155
632
+ − 156
ML {*
896
4e0b89d886ac
liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 157
fun mk_method1 tac thms ctxt =
4e0b89d886ac
liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 158
SIMPLE_METHOD (HEADGOAL (tac ctxt thms))
632
+ − 159
+ − 160
fun mk_method2 tac ctxt =
+ − 161
SIMPLE_METHOD (HEADGOAL (tac ctxt))
+ − 162
*}
+ − 163
+ − 164
method_setup lifting =
896
4e0b89d886ac
liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 165
{* Attrib.thms >> (mk_method1 Quotient_Tacs.lift_tac) *}
632
+ − 166
{* Lifting of theorems to quotient types. *}
+ − 167
+ − 168
method_setup lifting_setup =
758
+ − 169
{* Attrib.thm >> (mk_method1 Quotient_Tacs.procedure_tac) *}
632
+ − 170
{* Sets up the three goals for the lifting procedure. *}
+ − 171
+ − 172
method_setup regularize =
758
+ − 173
{* Scan.succeed (mk_method2 Quotient_Tacs.regularize_tac) *}
632
+ − 174
{* Proves automatically the regularization goals from the lifting procedure. *}
+ − 175
+ − 176
method_setup injection =
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 177
{* Scan.succeed (mk_method2 Quotient_Tacs.all_injection_tac) *}
632
+ − 178
{* Proves automatically the rep/abs injection goals from the lifting procedure. *}
+ − 179
+ − 180
method_setup cleaning =
758
+ − 181
{* Scan.succeed (mk_method2 Quotient_Tacs.clean_tac) *}
632
+ − 182
{* Proves automatically the cleaning goals from the lifting procedure. *}
+ − 183
597
+ − 184
end
+ − 185