author | haftmann |
Fri, 02 Mar 2012 21:45:45 +0100 | |
changeset 46767 | 807a5d219c23 |
parent 45694 | 4a8743618257 |
child 49834 | b27bbb021df1 |
permissions | -rw-r--r-- |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
1 |
(* Title: HOL/ex/PER.thy |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
2 |
Author: Oscar Slotosch and Markus Wenzel, TU Muenchen |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
3 |
*) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
4 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
5 |
header {* Partial equivalence relations *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
6 |
|
16417 | 7 |
theory PER imports Main begin |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
8 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
9 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
10 |
Higher-order quotients are defined over partial equivalence |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
11 |
relations (PERs) instead of total ones. We provide axiomatic type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
12 |
classes @{text "equiv < partial_equiv"} and a type constructor |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
13 |
@{text "'a quot"} with basic operations. This development is based |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
14 |
on: |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
15 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
16 |
Oscar Slotosch: \emph{Higher Order Quotients and their |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
17 |
Implementation in Isabelle HOL.} Elsa L. Gunter and Amy Felty, |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
18 |
editors, Theorem Proving in Higher Order Logics: TPHOLs '97, |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
19 |
Springer LNCS 1275, 1997. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
20 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
21 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
22 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
23 |
subsection {* Partial equivalence *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
24 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
25 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
26 |
Type class @{text partial_equiv} models partial equivalence |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
27 |
relations (PERs) using the polymorphic @{text "\<sim> :: 'a => 'a => |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
28 |
bool"} relation, which is required to be symmetric and transitive, |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
29 |
but not necessarily reflexive. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
30 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
31 |
|
35315 | 32 |
class partial_equiv = |
33 |
fixes eqv :: "'a => 'a => bool" (infixl "\<sim>" 50) |
|
34 |
assumes partial_equiv_sym [elim?]: "x \<sim> y ==> y \<sim> x" |
|
35 |
assumes partial_equiv_trans [trans]: "x \<sim> y ==> y \<sim> z ==> x \<sim> z" |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
36 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
37 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
38 |
\medskip The domain of a partial equivalence relation is the set of |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
39 |
reflexive elements. Due to symmetry and transitivity this |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
40 |
characterizes exactly those elements that are connected with |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
41 |
\emph{any} other one. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
42 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
43 |
|
19736 | 44 |
definition |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
20811
diff
changeset
|
45 |
"domain" :: "'a::partial_equiv set" where |
19736 | 46 |
"domain = {x. x \<sim> x}" |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
47 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
48 |
lemma domainI [intro]: "x \<sim> x ==> x \<in> domain" |
20811 | 49 |
unfolding domain_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
50 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
51 |
lemma domainD [dest]: "x \<in> domain ==> x \<sim> x" |
20811 | 52 |
unfolding domain_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
53 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
54 |
theorem domainI' [elim?]: "x \<sim> y ==> x \<in> domain" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
55 |
proof |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
56 |
assume xy: "x \<sim> y" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
57 |
also from xy have "y \<sim> x" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
58 |
finally show "x \<sim> x" . |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
59 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
60 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
61 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
62 |
subsection {* Equivalence on function spaces *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
63 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
64 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
65 |
The @{text \<sim>} relation is lifted to function spaces. It is |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
66 |
important to note that this is \emph{not} the direct product, but a |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
67 |
structural one corresponding to the congruence property. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
68 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
69 |
|
35315 | 70 |
instantiation "fun" :: (partial_equiv, partial_equiv) partial_equiv |
71 |
begin |
|
72 |
||
73 |
definition |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
74 |
eqv_fun_def: "f \<sim> g == \<forall>x \<in> domain. \<forall>y \<in> domain. x \<sim> y --> f x \<sim> g y" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
75 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
76 |
lemma partial_equiv_funI [intro?]: |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
77 |
"(!!x y. x \<in> domain ==> y \<in> domain ==> x \<sim> y ==> f x \<sim> g y) ==> f \<sim> g" |
20811 | 78 |
unfolding eqv_fun_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
79 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
80 |
lemma partial_equiv_funD [dest?]: |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
81 |
"f \<sim> g ==> x \<in> domain ==> y \<in> domain ==> x \<sim> y ==> f x \<sim> g y" |
20811 | 82 |
unfolding eqv_fun_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
83 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
84 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
85 |
The class of partial equivalence relations is closed under function |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
86 |
spaces (in \emph{both} argument positions). |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
87 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
88 |
|
35315 | 89 |
instance proof |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
90 |
fix f g h :: "'a::partial_equiv => 'b::partial_equiv" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
91 |
assume fg: "f \<sim> g" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
92 |
show "g \<sim> f" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
93 |
proof |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
94 |
fix x y :: 'a |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
95 |
assume x: "x \<in> domain" and y: "y \<in> domain" |
20811 | 96 |
assume "x \<sim> y" then have "y \<sim> x" .. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
97 |
with fg y x have "f y \<sim> g x" .. |
20811 | 98 |
then show "g x \<sim> f y" .. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
99 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
100 |
assume gh: "g \<sim> h" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
101 |
show "f \<sim> h" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
102 |
proof |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
103 |
fix x y :: 'a |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
104 |
assume x: "x \<in> domain" and y: "y \<in> domain" and "x \<sim> y" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
105 |
with fg have "f x \<sim> g y" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
106 |
also from y have "y \<sim> y" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
107 |
with gh y y have "g y \<sim> h y" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
108 |
finally show "f x \<sim> h y" . |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
109 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
110 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
111 |
|
35315 | 112 |
end |
113 |
||
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
114 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
115 |
subsection {* Total equivalence *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
116 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
117 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
118 |
The class of total equivalence relations on top of PERs. It |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
119 |
coincides with the standard notion of equivalence, i.e.\ @{text "\<sim> |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
120 |
:: 'a => 'a => bool"} is required to be reflexive, transitive and |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
121 |
symmetric. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
122 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
123 |
|
35315 | 124 |
class equiv = |
125 |
assumes eqv_refl [intro]: "x \<sim> x" |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
126 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
127 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
128 |
On total equivalences all elements are reflexive, and congruence |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
129 |
holds unconditionally. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
130 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
131 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
132 |
theorem equiv_domain [intro]: "(x::'a::equiv) \<in> domain" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
133 |
proof |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
134 |
show "x \<sim> x" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
135 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
136 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
137 |
theorem equiv_cong [dest?]: "f \<sim> g ==> x \<sim> y ==> f x \<sim> g (y::'a::equiv)" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
138 |
proof - |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
139 |
assume "f \<sim> g" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
140 |
moreover have "x \<in> domain" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
141 |
moreover have "y \<in> domain" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
142 |
moreover assume "x \<sim> y" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
143 |
ultimately show ?thesis .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
144 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
145 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
146 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
147 |
subsection {* Quotient types *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
148 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
149 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
150 |
The quotient type @{text "'a quot"} consists of all |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
151 |
\emph{equivalence classes} over elements of the base type @{typ 'a}. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
152 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
153 |
|
45694
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
35315
diff
changeset
|
154 |
definition "quot = {{x. a \<sim> x}| a::'a::partial_equiv. True}" |
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
35315
diff
changeset
|
155 |
|
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
35315
diff
changeset
|
156 |
typedef (open) 'a quot = "quot :: 'a::partial_equiv set set" |
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
35315
diff
changeset
|
157 |
unfolding quot_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
158 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
159 |
lemma quotI [intro]: "{x. a \<sim> x} \<in> quot" |
20811 | 160 |
unfolding quot_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
161 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
162 |
lemma quotE [elim]: "R \<in> quot ==> (!!a. R = {x. a \<sim> x} ==> C) ==> C" |
20811 | 163 |
unfolding quot_def by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
164 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
165 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
166 |
\medskip Abstracted equivalence classes are the canonical |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
167 |
representation of elements of a quotient type. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
168 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
169 |
|
19736 | 170 |
definition |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
20811
diff
changeset
|
171 |
eqv_class :: "('a::partial_equiv) => 'a quot" ("\<lfloor>_\<rfloor>") where |
19736 | 172 |
"\<lfloor>a\<rfloor> = Abs_quot {x. a \<sim> x}" |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
173 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
174 |
theorem quot_rep: "\<exists>a. A = \<lfloor>a\<rfloor>" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
175 |
proof (cases A) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
176 |
fix R assume R: "A = Abs_quot R" |
20811 | 177 |
assume "R \<in> quot" then have "\<exists>a. R = {x. a \<sim> x}" by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
178 |
with R have "\<exists>a. A = Abs_quot {x. a \<sim> x}" by blast |
20811 | 179 |
then show ?thesis by (unfold eqv_class_def) |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
180 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
181 |
|
20811 | 182 |
lemma quot_cases [cases type: quot]: |
183 |
obtains (rep) a where "A = \<lfloor>a\<rfloor>" |
|
184 |
using quot_rep by blast |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
185 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
186 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
187 |
subsection {* Equality on quotients *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
188 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
189 |
text {* |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
190 |
Equality of canonical quotient elements corresponds to the original |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
10352
diff
changeset
|
191 |
relation as follows. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
192 |
*} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
193 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
194 |
theorem eqv_class_eqI [intro]: "a \<sim> b ==> \<lfloor>a\<rfloor> = \<lfloor>b\<rfloor>" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
195 |
proof - |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
196 |
assume ab: "a \<sim> b" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
197 |
have "{x. a \<sim> x} = {x. b \<sim> x}" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
198 |
proof (rule Collect_cong) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
199 |
fix x show "(a \<sim> x) = (b \<sim> x)" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
200 |
proof |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
201 |
from ab have "b \<sim> a" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
202 |
also assume "a \<sim> x" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
203 |
finally show "b \<sim> x" . |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
204 |
next |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
205 |
note ab |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
206 |
also assume "b \<sim> x" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
207 |
finally show "a \<sim> x" . |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
208 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
209 |
qed |
20811 | 210 |
then show ?thesis by (simp only: eqv_class_def) |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
211 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
212 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
213 |
theorem eqv_class_eqD' [dest?]: "\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor> ==> a \<in> domain ==> a \<sim> b" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
214 |
proof (unfold eqv_class_def) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
215 |
assume "Abs_quot {x. a \<sim> x} = Abs_quot {x. b \<sim> x}" |
20811 | 216 |
then have "{x. a \<sim> x} = {x. b \<sim> x}" by (simp only: Abs_quot_inject quotI) |
217 |
moreover assume "a \<in> domain" then have "a \<sim> a" .. |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
218 |
ultimately have "a \<in> {x. b \<sim> x}" by blast |
20811 | 219 |
then have "b \<sim> a" by blast |
220 |
then show "a \<sim> b" .. |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
221 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
222 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
223 |
theorem eqv_class_eqD [dest?]: "\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor> ==> a \<sim> (b::'a::equiv)" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
224 |
proof (rule eqv_class_eqD') |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
225 |
show "a \<in> domain" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
226 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
227 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
228 |
lemma eqv_class_eq' [simp]: "a \<in> domain ==> (\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor>) = (a \<sim> b)" |
28616
ac1da69fbc5a
avoid accidental dependency of automated proof on sort equiv;
wenzelm
parents:
23373
diff
changeset
|
229 |
using eqv_class_eqI eqv_class_eqD' by (blast del: eqv_refl) |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
230 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
231 |
lemma eqv_class_eq [simp]: "(\<lfloor>a\<rfloor> = \<lfloor>b\<rfloor>) = (a \<sim> (b::'a::equiv))" |
20811 | 232 |
using eqv_class_eqI eqv_class_eqD by blast |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
233 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
234 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
235 |
subsection {* Picking representing elements *} |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
236 |
|
19736 | 237 |
definition |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
20811
diff
changeset
|
238 |
pick :: "'a::partial_equiv quot => 'a" where |
19736 | 239 |
"pick A = (SOME a. A = \<lfloor>a\<rfloor>)" |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
240 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
241 |
theorem pick_eqv' [intro?, simp]: "a \<in> domain ==> pick \<lfloor>a\<rfloor> \<sim> a" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
242 |
proof (unfold pick_def) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
243 |
assume a: "a \<in> domain" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
244 |
show "(SOME x. \<lfloor>a\<rfloor> = \<lfloor>x\<rfloor>) \<sim> a" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
245 |
proof (rule someI2) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
246 |
show "\<lfloor>a\<rfloor> = \<lfloor>a\<rfloor>" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
247 |
fix x assume "\<lfloor>a\<rfloor> = \<lfloor>x\<rfloor>" |
23373 | 248 |
from this and a have "a \<sim> x" .. |
20811 | 249 |
then show "x \<sim> a" .. |
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
250 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
251 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
252 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
253 |
theorem pick_eqv [intro, simp]: "pick \<lfloor>a\<rfloor> \<sim> (a::'a::equiv)" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
254 |
proof (rule pick_eqv') |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
255 |
show "a \<in> domain" .. |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
256 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
257 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
258 |
theorem pick_inverse: "\<lfloor>pick A\<rfloor> = (A::'a::equiv quot)" |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
259 |
proof (cases A) |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
260 |
fix a assume a: "A = \<lfloor>a\<rfloor>" |
20811 | 261 |
then have "pick A \<sim> a" by simp |
262 |
then have "\<lfloor>pick A\<rfloor> = \<lfloor>a\<rfloor>" by simp |
|
10352
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
263 |
with a show ?thesis by simp |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
264 |
qed |
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
265 |
|
638e1fc6ca74
Partial equivalence relations (leftover from HOL/Quot);
wenzelm
parents:
diff
changeset
|
266 |
end |