author | haftmann |
Fri, 26 Oct 2007 21:22:17 +0200 | |
changeset 25206 | 9c84ec7217a9 |
parent 25102 | db3e412c4cb1 |
child 25382 | 72cfe89f7b21 |
permissions | -rw-r--r-- |
21249 | 1 |
(* Title: HOL/Lattices.thy |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
4 |
*) |
|
5 |
||
22454 | 6 |
header {* Abstract lattices *} |
21249 | 7 |
|
8 |
theory Lattices |
|
9 |
imports Orderings |
|
10 |
begin |
|
11 |
||
12 |
subsection{* Lattices *} |
|
13 |
||
25206 | 14 |
notation |
15 |
less_eq (infix "\<sqsubseteq>" 50) |
|
16 |
and |
|
17 |
less (infix "\<sqsubset>" 50) |
|
18 |
||
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
19 |
class lower_semilattice = order + |
21249 | 20 |
fixes inf :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 70) |
22737 | 21 |
assumes inf_le1 [simp]: "x \<sqinter> y \<sqsubseteq> x" |
22 |
and inf_le2 [simp]: "x \<sqinter> y \<sqsubseteq> y" |
|
21733 | 23 |
and inf_greatest: "x \<sqsubseteq> y \<Longrightarrow> x \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> y \<sqinter> z" |
21249 | 24 |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
25 |
class upper_semilattice = order + |
21249 | 26 |
fixes sup :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<squnion>" 65) |
22737 | 27 |
assumes sup_ge1 [simp]: "x \<sqsubseteq> x \<squnion> y" |
28 |
and sup_ge2 [simp]: "y \<sqsubseteq> x \<squnion> y" |
|
21733 | 29 |
and sup_least: "y \<sqsubseteq> x \<Longrightarrow> z \<sqsubseteq> x \<Longrightarrow> y \<squnion> z \<sqsubseteq> x" |
21249 | 30 |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
31 |
class lattice = lower_semilattice + upper_semilattice |
21249 | 32 |
|
21733 | 33 |
subsubsection{* Intro and elim rules*} |
34 |
||
35 |
context lower_semilattice |
|
36 |
begin |
|
21249 | 37 |
|
25062 | 38 |
lemma le_infI1[intro]: |
39 |
assumes "a \<sqsubseteq> x" |
|
40 |
shows "a \<sqinter> b \<sqsubseteq> x" |
|
41 |
proof (rule order_trans) |
|
42 |
show "a \<sqinter> b \<sqsubseteq> a" and "a \<sqsubseteq> x" using assms by simp |
|
43 |
qed |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
44 |
lemmas (in -) [rule del] = le_infI1 |
21249 | 45 |
|
25062 | 46 |
lemma le_infI2[intro]: |
47 |
assumes "b \<sqsubseteq> x" |
|
48 |
shows "a \<sqinter> b \<sqsubseteq> x" |
|
49 |
proof (rule order_trans) |
|
50 |
show "a \<sqinter> b \<sqsubseteq> b" and "b \<sqsubseteq> x" using assms by simp |
|
51 |
qed |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
52 |
lemmas (in -) [rule del] = le_infI2 |
21733 | 53 |
|
21734 | 54 |
lemma le_infI[intro!]: "x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> b \<Longrightarrow> x \<sqsubseteq> a \<sqinter> b" |
21733 | 55 |
by(blast intro: inf_greatest) |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
56 |
lemmas (in -) [rule del] = le_infI |
21249 | 57 |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
58 |
lemma le_infE [elim!]: "x \<sqsubseteq> a \<sqinter> b \<Longrightarrow> (x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> b \<Longrightarrow> P) \<Longrightarrow> P" |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
59 |
by (blast intro: order_trans) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
60 |
lemmas (in -) [rule del] = le_infE |
21249 | 61 |
|
21734 | 62 |
lemma le_inf_iff [simp]: |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
63 |
"x \<sqsubseteq> y \<sqinter> z = (x \<sqsubseteq> y \<and> x \<sqsubseteq> z)" |
21733 | 64 |
by blast |
65 |
||
21734 | 66 |
lemma le_iff_inf: "(x \<sqsubseteq> y) = (x \<sqinter> y = x)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
67 |
by (blast intro: antisym dest: eq_iff [THEN iffD1]) |
21249 | 68 |
|
25206 | 69 |
lemma mono_inf: |
70 |
fixes f :: "'a \<Rightarrow> 'b\<Colon>lower_semilattice" |
|
71 |
shows "mono f \<Longrightarrow> f (A \<sqinter> B) \<le> f A \<sqinter> f B" |
|
72 |
by (auto simp add: mono_def intro: Lattices.inf_greatest) |
|
21733 | 73 |
|
25206 | 74 |
end |
21733 | 75 |
|
76 |
context upper_semilattice |
|
77 |
begin |
|
21249 | 78 |
|
21734 | 79 |
lemma le_supI1[intro]: "x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> a \<squnion> b" |
25062 | 80 |
by (rule order_trans) auto |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
81 |
lemmas (in -) [rule del] = le_supI1 |
21249 | 82 |
|
21734 | 83 |
lemma le_supI2[intro]: "x \<sqsubseteq> b \<Longrightarrow> x \<sqsubseteq> a \<squnion> b" |
25062 | 84 |
by (rule order_trans) auto |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
85 |
lemmas (in -) [rule del] = le_supI2 |
21733 | 86 |
|
21734 | 87 |
lemma le_supI[intro!]: "a \<sqsubseteq> x \<Longrightarrow> b \<sqsubseteq> x \<Longrightarrow> a \<squnion> b \<sqsubseteq> x" |
21733 | 88 |
by(blast intro: sup_least) |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
89 |
lemmas (in -) [rule del] = le_supI |
21249 | 90 |
|
21734 | 91 |
lemma le_supE[elim!]: "a \<squnion> b \<sqsubseteq> x \<Longrightarrow> (a \<sqsubseteq> x \<Longrightarrow> b \<sqsubseteq> x \<Longrightarrow> P) \<Longrightarrow> P" |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
92 |
by (blast intro: order_trans) |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
93 |
lemmas (in -) [rule del] = le_supE |
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
94 |
|
21734 | 95 |
lemma ge_sup_conv[simp]: |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
96 |
"x \<squnion> y \<sqsubseteq> z = (x \<sqsubseteq> z \<and> y \<sqsubseteq> z)" |
21733 | 97 |
by blast |
98 |
||
21734 | 99 |
lemma le_iff_sup: "(x \<sqsubseteq> y) = (x \<squnion> y = y)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
100 |
by (blast intro: antisym dest: eq_iff [THEN iffD1]) |
21734 | 101 |
|
25206 | 102 |
lemma mono_sup: |
103 |
fixes f :: "'a \<Rightarrow> 'b\<Colon>upper_semilattice" |
|
104 |
shows "mono f \<Longrightarrow> f A \<squnion> f B \<le> f (A \<squnion> B)" |
|
105 |
by (auto simp add: mono_def intro: Lattices.sup_least) |
|
21733 | 106 |
|
25206 | 107 |
end |
23878 | 108 |
|
21733 | 109 |
|
110 |
subsubsection{* Equational laws *} |
|
21249 | 111 |
|
21733 | 112 |
context lower_semilattice |
113 |
begin |
|
114 |
||
115 |
lemma inf_commute: "(x \<sqinter> y) = (y \<sqinter> x)" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
116 |
by (blast intro: antisym) |
21733 | 117 |
|
118 |
lemma inf_assoc: "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
119 |
by (blast intro: antisym) |
21733 | 120 |
|
121 |
lemma inf_idem[simp]: "x \<sqinter> x = x" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
122 |
by (blast intro: antisym) |
21733 | 123 |
|
124 |
lemma inf_left_idem[simp]: "x \<sqinter> (x \<sqinter> y) = x \<sqinter> y" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
125 |
by (blast intro: antisym) |
21733 | 126 |
|
127 |
lemma inf_absorb1: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
128 |
by (blast intro: antisym) |
21733 | 129 |
|
130 |
lemma inf_absorb2: "y \<sqsubseteq> x \<Longrightarrow> x \<sqinter> y = y" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
131 |
by (blast intro: antisym) |
21733 | 132 |
|
133 |
lemma inf_left_commute: "x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
134 |
by (blast intro: antisym) |
21733 | 135 |
|
136 |
lemmas inf_ACI = inf_commute inf_assoc inf_left_commute inf_left_idem |
|
137 |
||
138 |
end |
|
139 |
||
140 |
||
141 |
context upper_semilattice |
|
142 |
begin |
|
21249 | 143 |
|
21733 | 144 |
lemma sup_commute: "(x \<squnion> y) = (y \<squnion> x)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
145 |
by (blast intro: antisym) |
21733 | 146 |
|
147 |
lemma sup_assoc: "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
148 |
by (blast intro: antisym) |
21733 | 149 |
|
150 |
lemma sup_idem[simp]: "x \<squnion> x = x" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
151 |
by (blast intro: antisym) |
21733 | 152 |
|
153 |
lemma sup_left_idem[simp]: "x \<squnion> (x \<squnion> y) = x \<squnion> y" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
154 |
by (blast intro: antisym) |
21733 | 155 |
|
156 |
lemma sup_absorb1: "y \<sqsubseteq> x \<Longrightarrow> x \<squnion> y = x" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
157 |
by (blast intro: antisym) |
21733 | 158 |
|
159 |
lemma sup_absorb2: "x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
160 |
by (blast intro: antisym) |
21249 | 161 |
|
21733 | 162 |
lemma sup_left_commute: "x \<squnion> (y \<squnion> z) = y \<squnion> (x \<squnion> z)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
163 |
by (blast intro: antisym) |
21733 | 164 |
|
165 |
lemmas sup_ACI = sup_commute sup_assoc sup_left_commute sup_left_idem |
|
166 |
||
167 |
end |
|
21249 | 168 |
|
21733 | 169 |
context lattice |
170 |
begin |
|
171 |
||
172 |
lemma inf_sup_absorb: "x \<sqinter> (x \<squnion> y) = x" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
173 |
by (blast intro: antisym inf_le1 inf_greatest sup_ge1) |
21733 | 174 |
|
175 |
lemma sup_inf_absorb: "x \<squnion> (x \<sqinter> y) = x" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
176 |
by (blast intro: antisym sup_ge1 sup_least inf_le1) |
21733 | 177 |
|
21734 | 178 |
lemmas ACI = inf_ACI sup_ACI |
179 |
||
22454 | 180 |
lemmas inf_sup_ord = inf_le1 inf_le2 sup_ge1 sup_ge2 |
181 |
||
21734 | 182 |
text{* Towards distributivity *} |
21249 | 183 |
|
21734 | 184 |
lemma distrib_sup_le: "x \<squnion> (y \<sqinter> z) \<sqsubseteq> (x \<squnion> y) \<sqinter> (x \<squnion> z)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
185 |
by blast |
21734 | 186 |
|
187 |
lemma distrib_inf_le: "(x \<sqinter> y) \<squnion> (x \<sqinter> z) \<sqsubseteq> x \<sqinter> (y \<squnion> z)" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
188 |
by blast |
21734 | 189 |
|
190 |
||
191 |
text{* If you have one of them, you have them all. *} |
|
21249 | 192 |
|
21733 | 193 |
lemma distrib_imp1: |
21249 | 194 |
assumes D: "!!x y z. x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)" |
195 |
shows "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)" |
|
196 |
proof- |
|
197 |
have "x \<squnion> (y \<sqinter> z) = (x \<squnion> (x \<sqinter> z)) \<squnion> (y \<sqinter> z)" by(simp add:sup_inf_absorb) |
|
198 |
also have "\<dots> = x \<squnion> (z \<sqinter> (x \<squnion> y))" by(simp add:D inf_commute sup_assoc) |
|
199 |
also have "\<dots> = ((x \<squnion> y) \<sqinter> x) \<squnion> ((x \<squnion> y) \<sqinter> z)" |
|
200 |
by(simp add:inf_sup_absorb inf_commute) |
|
201 |
also have "\<dots> = (x \<squnion> y) \<sqinter> (x \<squnion> z)" by(simp add:D) |
|
202 |
finally show ?thesis . |
|
203 |
qed |
|
204 |
||
21733 | 205 |
lemma distrib_imp2: |
21249 | 206 |
assumes D: "!!x y z. x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)" |
207 |
shows "x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)" |
|
208 |
proof- |
|
209 |
have "x \<sqinter> (y \<squnion> z) = (x \<sqinter> (x \<squnion> z)) \<sqinter> (y \<squnion> z)" by(simp add:inf_sup_absorb) |
|
210 |
also have "\<dots> = x \<sqinter> (z \<squnion> (x \<sqinter> y))" by(simp add:D sup_commute inf_assoc) |
|
211 |
also have "\<dots> = ((x \<sqinter> y) \<squnion> x) \<sqinter> ((x \<sqinter> y) \<squnion> z)" |
|
212 |
by(simp add:sup_inf_absorb sup_commute) |
|
213 |
also have "\<dots> = (x \<sqinter> y) \<squnion> (x \<sqinter> z)" by(simp add:D) |
|
214 |
finally show ?thesis . |
|
215 |
qed |
|
216 |
||
21734 | 217 |
(* seems unused *) |
218 |
lemma modular_le: "x \<sqsubseteq> z \<Longrightarrow> x \<squnion> (y \<sqinter> z) \<sqsubseteq> (x \<squnion> y) \<sqinter> z" |
|
219 |
by blast |
|
220 |
||
21733 | 221 |
end |
21249 | 222 |
|
223 |
||
24164 | 224 |
subsection {* Distributive lattices *} |
21249 | 225 |
|
22454 | 226 |
class distrib_lattice = lattice + |
21249 | 227 |
assumes sup_inf_distrib1: "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)" |
228 |
||
21733 | 229 |
context distrib_lattice |
230 |
begin |
|
231 |
||
232 |
lemma sup_inf_distrib2: |
|
21249 | 233 |
"(y \<sqinter> z) \<squnion> x = (y \<squnion> x) \<sqinter> (z \<squnion> x)" |
234 |
by(simp add:ACI sup_inf_distrib1) |
|
235 |
||
21733 | 236 |
lemma inf_sup_distrib1: |
21249 | 237 |
"x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)" |
238 |
by(rule distrib_imp2[OF sup_inf_distrib1]) |
|
239 |
||
21733 | 240 |
lemma inf_sup_distrib2: |
21249 | 241 |
"(y \<squnion> z) \<sqinter> x = (y \<sqinter> x) \<squnion> (z \<sqinter> x)" |
242 |
by(simp add:ACI inf_sup_distrib1) |
|
243 |
||
21733 | 244 |
lemmas distrib = |
21249 | 245 |
sup_inf_distrib1 sup_inf_distrib2 inf_sup_distrib1 inf_sup_distrib2 |
246 |
||
21733 | 247 |
end |
248 |
||
21249 | 249 |
|
22454 | 250 |
subsection {* Uniqueness of inf and sup *} |
251 |
||
22737 | 252 |
lemma (in lower_semilattice) inf_unique: |
22454 | 253 |
fixes f (infixl "\<triangle>" 70) |
25062 | 254 |
assumes le1: "\<And>x y. x \<triangle> y \<le> x" and le2: "\<And>x y. x \<triangle> y \<le> y" |
255 |
and greatest: "\<And>x y z. x \<le> y \<Longrightarrow> x \<le> z \<Longrightarrow> x \<le> y \<triangle> z" |
|
22737 | 256 |
shows "x \<sqinter> y = x \<triangle> y" |
22454 | 257 |
proof (rule antisym) |
25062 | 258 |
show "x \<triangle> y \<le> x \<sqinter> y" by (rule le_infI) (rule le1, rule le2) |
22454 | 259 |
next |
25062 | 260 |
have leI: "\<And>x y z. x \<le> y \<Longrightarrow> x \<le> z \<Longrightarrow> x \<le> y \<triangle> z" by (blast intro: greatest) |
261 |
show "x \<sqinter> y \<le> x \<triangle> y" by (rule leI) simp_all |
|
22454 | 262 |
qed |
263 |
||
22737 | 264 |
lemma (in upper_semilattice) sup_unique: |
22454 | 265 |
fixes f (infixl "\<nabla>" 70) |
25062 | 266 |
assumes ge1 [simp]: "\<And>x y. x \<le> x \<nabla> y" and ge2: "\<And>x y. y \<le> x \<nabla> y" |
267 |
and least: "\<And>x y z. y \<le> x \<Longrightarrow> z \<le> x \<Longrightarrow> y \<nabla> z \<le> x" |
|
22737 | 268 |
shows "x \<squnion> y = x \<nabla> y" |
22454 | 269 |
proof (rule antisym) |
25062 | 270 |
show "x \<squnion> y \<le> x \<nabla> y" by (rule le_supI) (rule ge1, rule ge2) |
22454 | 271 |
next |
25062 | 272 |
have leI: "\<And>x y z. x \<le> z \<Longrightarrow> y \<le> z \<Longrightarrow> x \<nabla> y \<le> z" by (blast intro: least) |
273 |
show "x \<nabla> y \<le> x \<squnion> y" by (rule leI) simp_all |
|
22454 | 274 |
qed |
275 |
||
276 |
||
22916 | 277 |
subsection {* @{const min}/@{const max} on linear orders as |
278 |
special case of @{const inf}/@{const sup} *} |
|
279 |
||
280 |
lemma (in linorder) distrib_lattice_min_max: |
|
25062 | 281 |
"distrib_lattice (op \<le>) (op <) min max" |
22916 | 282 |
proof unfold_locales |
25062 | 283 |
have aux: "\<And>x y \<Colon> 'a. x < y \<Longrightarrow> y \<le> x \<Longrightarrow> x = y" |
22916 | 284 |
by (auto simp add: less_le antisym) |
285 |
fix x y z |
|
286 |
show "max x (min y z) = min (max x y) (max x z)" |
|
287 |
unfolding min_def max_def |
|
24640
85a6c200ecd3
Simplified proofs due to transitivity reasoner setup.
ballarin
parents:
24514
diff
changeset
|
288 |
by auto |
22916 | 289 |
qed (auto simp add: min_def max_def not_le less_imp_le) |
21249 | 290 |
|
291 |
interpretation min_max: |
|
22454 | 292 |
distrib_lattice ["op \<le> \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" min max] |
23948 | 293 |
by (rule distrib_lattice_min_max) |
21249 | 294 |
|
22454 | 295 |
lemma inf_min: "inf = (min \<Colon> 'a\<Colon>{lower_semilattice, linorder} \<Rightarrow> 'a \<Rightarrow> 'a)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
296 |
by (rule ext)+ (auto intro: antisym) |
21733 | 297 |
|
22454 | 298 |
lemma sup_max: "sup = (max \<Colon> 'a\<Colon>{upper_semilattice, linorder} \<Rightarrow> 'a \<Rightarrow> 'a)" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
299 |
by (rule ext)+ (auto intro: antisym) |
21733 | 300 |
|
21249 | 301 |
lemmas le_maxI1 = min_max.sup_ge1 |
302 |
lemmas le_maxI2 = min_max.sup_ge2 |
|
21381 | 303 |
|
21249 | 304 |
lemmas max_ac = min_max.sup_assoc min_max.sup_commute |
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
305 |
mk_left_commute [of max, OF min_max.sup_assoc min_max.sup_commute] |
21249 | 306 |
|
307 |
lemmas min_ac = min_max.inf_assoc min_max.inf_commute |
|
22422
ee19cdb07528
stepping towards uniform lattice theory development in HOL
haftmann
parents:
22384
diff
changeset
|
308 |
mk_left_commute [of min, OF min_max.inf_assoc min_max.inf_commute] |
21249 | 309 |
|
22454 | 310 |
text {* |
311 |
Now we have inherited antisymmetry as an intro-rule on all |
|
312 |
linear orders. This is a problem because it applies to bool, which is |
|
313 |
undesirable. |
|
314 |
*} |
|
315 |
||
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
316 |
lemmas [rule del] = min_max.le_infI min_max.le_supI |
22454 | 317 |
min_max.le_supE min_max.le_infE min_max.le_supI1 min_max.le_supI2 |
318 |
min_max.le_infI1 min_max.le_infI2 |
|
319 |
||
320 |
||
23878 | 321 |
subsection {* Complete lattices *} |
322 |
||
323 |
class complete_lattice = lattice + |
|
324 |
fixes Inf :: "'a set \<Rightarrow> 'a" ("\<Sqinter>_" [900] 900) |
|
24345 | 325 |
and Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900) |
23878 | 326 |
assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x" |
24345 | 327 |
and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A" |
328 |
assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A" |
|
329 |
and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z" |
|
23878 | 330 |
begin |
331 |
||
25062 | 332 |
lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<le> a}" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
333 |
by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) |
23878 | 334 |
|
25062 | 335 |
lemma Sup_Inf: "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<le> b}" |
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
336 |
by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least) |
23878 | 337 |
|
338 |
lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}" |
|
24345 | 339 |
unfolding Sup_Inf by auto |
23878 | 340 |
|
341 |
lemma Sup_Univ: "\<Squnion>UNIV = \<Sqinter>{}" |
|
342 |
unfolding Inf_Sup by auto |
|
343 |
||
344 |
lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A" |
|
345 |
apply (rule antisym) |
|
346 |
apply (rule le_infI) |
|
347 |
apply (rule Inf_lower) |
|
348 |
apply simp |
|
349 |
apply (rule Inf_greatest) |
|
350 |
apply (rule Inf_lower) |
|
351 |
apply simp |
|
352 |
apply (rule Inf_greatest) |
|
353 |
apply (erule insertE) |
|
354 |
apply (rule le_infI1) |
|
355 |
apply simp |
|
356 |
apply (rule le_infI2) |
|
357 |
apply (erule Inf_lower) |
|
358 |
done |
|
359 |
||
24345 | 360 |
lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A" |
23878 | 361 |
apply (rule antisym) |
362 |
apply (rule Sup_least) |
|
363 |
apply (erule insertE) |
|
364 |
apply (rule le_supI1) |
|
365 |
apply simp |
|
366 |
apply (rule le_supI2) |
|
367 |
apply (erule Sup_upper) |
|
368 |
apply (rule le_supI) |
|
369 |
apply (rule Sup_upper) |
|
370 |
apply simp |
|
371 |
apply (rule Sup_least) |
|
372 |
apply (rule Sup_upper) |
|
373 |
apply simp |
|
374 |
done |
|
375 |
||
376 |
lemma Inf_singleton [simp]: |
|
377 |
"\<Sqinter>{a} = a" |
|
378 |
by (auto intro: antisym Inf_lower Inf_greatest) |
|
379 |
||
24345 | 380 |
lemma Sup_singleton [simp]: |
23878 | 381 |
"\<Squnion>{a} = a" |
382 |
by (auto intro: antisym Sup_upper Sup_least) |
|
383 |
||
384 |
lemma Inf_insert_simp: |
|
385 |
"\<Sqinter>insert a A = (if A = {} then a else a \<sqinter> \<Sqinter>A)" |
|
386 |
by (cases "A = {}") (simp_all, simp add: Inf_insert) |
|
387 |
||
388 |
lemma Sup_insert_simp: |
|
389 |
"\<Squnion>insert a A = (if A = {} then a else a \<squnion> \<Squnion>A)" |
|
390 |
by (cases "A = {}") (simp_all, simp add: Sup_insert) |
|
391 |
||
392 |
lemma Inf_binary: |
|
393 |
"\<Sqinter>{a, b} = a \<sqinter> b" |
|
394 |
by (simp add: Inf_insert_simp) |
|
395 |
||
396 |
lemma Sup_binary: |
|
397 |
"\<Squnion>{a, b} = a \<squnion> b" |
|
398 |
by (simp add: Sup_insert_simp) |
|
399 |
||
400 |
definition |
|
24749 | 401 |
top :: 'a |
23878 | 402 |
where |
25206 | 403 |
"top = \<Sqinter>{}" |
23878 | 404 |
|
405 |
definition |
|
24749 | 406 |
bot :: 'a |
23878 | 407 |
where |
25206 | 408 |
"bot = \<Squnion>{}" |
23878 | 409 |
|
25062 | 410 |
lemma top_greatest [simp]: "x \<le> top" |
23878 | 411 |
by (unfold top_def, rule Inf_greatest, simp) |
412 |
||
25062 | 413 |
lemma bot_least [simp]: "bot \<le> x" |
23878 | 414 |
by (unfold bot_def, rule Sup_least, simp) |
415 |
||
416 |
definition |
|
24749 | 417 |
SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" |
23878 | 418 |
where |
25206 | 419 |
"SUPR A f == \<Squnion> (f ` A)" |
23878 | 420 |
|
421 |
definition |
|
24749 | 422 |
INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" |
23878 | 423 |
where |
25206 | 424 |
"INFI A f == \<Sqinter> (f ` A)" |
23878 | 425 |
|
24749 | 426 |
end |
427 |
||
23878 | 428 |
syntax |
429 |
"_SUP1" :: "pttrns => 'b => 'b" ("(3SUP _./ _)" [0, 10] 10) |
|
430 |
"_SUP" :: "pttrn => 'a set => 'b => 'b" ("(3SUP _:_./ _)" [0, 10] 10) |
|
431 |
"_INF1" :: "pttrns => 'b => 'b" ("(3INF _./ _)" [0, 10] 10) |
|
432 |
"_INF" :: "pttrn => 'a set => 'b => 'b" ("(3INF _:_./ _)" [0, 10] 10) |
|
433 |
||
434 |
translations |
|
435 |
"SUP x y. B" == "SUP x. SUP y. B" |
|
436 |
"SUP x. B" == "CONST SUPR UNIV (%x. B)" |
|
437 |
"SUP x. B" == "SUP x:UNIV. B" |
|
438 |
"SUP x:A. B" == "CONST SUPR A (%x. B)" |
|
439 |
"INF x y. B" == "INF x. INF y. B" |
|
440 |
"INF x. B" == "CONST INFI UNIV (%x. B)" |
|
441 |
"INF x. B" == "INF x:UNIV. B" |
|
442 |
"INF x:A. B" == "CONST INFI A (%x. B)" |
|
443 |
||
444 |
(* To avoid eta-contraction of body: *) |
|
445 |
print_translation {* |
|
446 |
let |
|
447 |
fun btr' syn (A :: Abs abs :: ts) = |
|
448 |
let val (x,t) = atomic_abs_tr' abs |
|
449 |
in list_comb (Syntax.const syn $ x $ A $ t, ts) end |
|
450 |
val const_syntax_name = Sign.const_syntax_name @{theory} o fst o dest_Const |
|
451 |
in |
|
452 |
[(const_syntax_name @{term SUPR}, btr' "_SUP"),(const_syntax_name @{term "INFI"}, btr' "_INF")] |
|
453 |
end |
|
454 |
*} |
|
455 |
||
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
456 |
context complete_lattice |
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
457 |
begin |
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
458 |
|
23878 | 459 |
lemma le_SUPI: "i : A \<Longrightarrow> M i \<le> (SUP i:A. M i)" |
460 |
by (auto simp add: SUPR_def intro: Sup_upper) |
|
461 |
||
462 |
lemma SUP_leI: "(\<And>i. i : A \<Longrightarrow> M i \<le> u) \<Longrightarrow> (SUP i:A. M i) \<le> u" |
|
463 |
by (auto simp add: SUPR_def intro: Sup_least) |
|
464 |
||
465 |
lemma INF_leI: "i : A \<Longrightarrow> (INF i:A. M i) \<le> M i" |
|
466 |
by (auto simp add: INFI_def intro: Inf_lower) |
|
467 |
||
468 |
lemma le_INFI: "(\<And>i. i : A \<Longrightarrow> u \<le> M i) \<Longrightarrow> u \<le> (INF i:A. M i)" |
|
469 |
by (auto simp add: INFI_def intro: Inf_greatest) |
|
470 |
||
471 |
lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (SUP i:A. M) = M" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
472 |
by (auto intro: antisym SUP_leI le_SUPI) |
23878 | 473 |
|
474 |
lemma INF_const[simp]: "A \<noteq> {} \<Longrightarrow> (INF i:A. M) = M" |
|
25102
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
475 |
by (auto intro: antisym INF_leI le_INFI) |
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
476 |
|
db3e412c4cb1
antisymmetry not a default intro rule any longer
haftmann
parents:
25062
diff
changeset
|
477 |
end |
23878 | 478 |
|
479 |
||
22454 | 480 |
subsection {* Bool as lattice *} |
481 |
||
482 |
instance bool :: distrib_lattice |
|
25206 | 483 |
inf_bool_eq: "P \<sqinter> Q \<equiv> P \<and> Q" |
484 |
sup_bool_eq: "P \<squnion> Q \<equiv> P \<or> Q" |
|
22454 | 485 |
by intro_classes (auto simp add: inf_bool_eq sup_bool_eq le_bool_def) |
486 |
||
23878 | 487 |
instance bool :: complete_lattice |
25206 | 488 |
Inf_bool_def: "\<Sqinter>A \<equiv> \<forall>x\<in>A. x" |
489 |
Sup_bool_def: "\<Squnion>A \<equiv> \<exists>x\<in>A. x" |
|
24345 | 490 |
by intro_classes (auto simp add: Inf_bool_def Sup_bool_def le_bool_def) |
23878 | 491 |
|
492 |
lemma Inf_empty_bool [simp]: |
|
25206 | 493 |
"\<Sqinter>{}" |
23878 | 494 |
unfolding Inf_bool_def by auto |
495 |
||
496 |
lemma not_Sup_empty_bool [simp]: |
|
497 |
"\<not> Sup {}" |
|
24345 | 498 |
unfolding Sup_bool_def by auto |
23878 | 499 |
|
500 |
lemma top_bool_eq: "top = True" |
|
501 |
by (iprover intro!: order_antisym le_boolI top_greatest) |
|
502 |
||
503 |
lemma bot_bool_eq: "bot = False" |
|
504 |
by (iprover intro!: order_antisym le_boolI bot_least) |
|
505 |
||
506 |
||
507 |
subsection {* Set as lattice *} |
|
508 |
||
509 |
instance set :: (type) distrib_lattice |
|
25206 | 510 |
inf_set_eq: "A \<sqinter> B \<equiv> A \<inter> B" |
511 |
sup_set_eq: "A \<squnion> B \<equiv> A \<union> B" |
|
23878 | 512 |
by intro_classes (auto simp add: inf_set_eq sup_set_eq) |
513 |
||
514 |
lemmas [code func del] = inf_set_eq sup_set_eq |
|
515 |
||
24514
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
516 |
lemma mono_Int: "mono f \<Longrightarrow> f (A \<inter> B) \<subseteq> f A \<inter> f B" |
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
517 |
apply (fold inf_set_eq sup_set_eq) |
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
518 |
apply (erule mono_inf) |
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
519 |
done |
23878 | 520 |
|
24514
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
521 |
lemma mono_Un: "mono f \<Longrightarrow> f A \<union> f B \<subseteq> f (A \<union> B)" |
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
522 |
apply (fold inf_set_eq sup_set_eq) |
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
523 |
apply (erule mono_sup) |
540eaf87e42d
mono_Int/Un: proper proof, avoid illegal schematic type vars;
wenzelm
parents:
24345
diff
changeset
|
524 |
done |
23878 | 525 |
|
526 |
instance set :: (type) complete_lattice |
|
25206 | 527 |
Inf_set_def: "\<Sqinter>S \<equiv> \<Inter>S" |
528 |
Sup_set_def: "\<Squnion>S \<equiv> \<Union>S" |
|
24345 | 529 |
by intro_classes (auto simp add: Inf_set_def Sup_set_def) |
23878 | 530 |
|
24345 | 531 |
lemmas [code func del] = Inf_set_def Sup_set_def |
23878 | 532 |
|
533 |
lemma top_set_eq: "top = UNIV" |
|
534 |
by (iprover intro!: subset_antisym subset_UNIV top_greatest) |
|
535 |
||
536 |
lemma bot_set_eq: "bot = {}" |
|
537 |
by (iprover intro!: subset_antisym empty_subsetI bot_least) |
|
538 |
||
539 |
||
540 |
subsection {* Fun as lattice *} |
|
541 |
||
542 |
instance "fun" :: (type, lattice) lattice |
|
25206 | 543 |
inf_fun_eq: "f \<sqinter> g \<equiv> (\<lambda>x. f x \<sqinter> g x)" |
544 |
sup_fun_eq: "f \<squnion> g \<equiv> (\<lambda>x. f x \<squnion> g x)" |
|
23878 | 545 |
apply intro_classes |
546 |
unfolding inf_fun_eq sup_fun_eq |
|
547 |
apply (auto intro: le_funI) |
|
548 |
apply (rule le_funI) |
|
549 |
apply (auto dest: le_funD) |
|
550 |
apply (rule le_funI) |
|
551 |
apply (auto dest: le_funD) |
|
552 |
done |
|
553 |
||
554 |
lemmas [code func del] = inf_fun_eq sup_fun_eq |
|
555 |
||
556 |
instance "fun" :: (type, distrib_lattice) distrib_lattice |
|
557 |
by default (auto simp add: inf_fun_eq sup_fun_eq sup_inf_distrib1) |
|
558 |
||
559 |
instance "fun" :: (type, complete_lattice) complete_lattice |
|
25206 | 560 |
Inf_fun_def: "\<Sqinter>A \<equiv> (\<lambda>x. \<Sqinter>{y. \<exists>f\<in>A. y = f x})" |
561 |
Sup_fun_def: "\<Squnion>A \<equiv> (\<lambda>x. \<Squnion>{y. \<exists>f\<in>A. y = f x})" |
|
24345 | 562 |
by intro_classes |
563 |
(auto simp add: Inf_fun_def Sup_fun_def le_fun_def |
|
564 |
intro: Inf_lower Sup_upper Inf_greatest Sup_least) |
|
23878 | 565 |
|
24345 | 566 |
lemmas [code func del] = Inf_fun_def Sup_fun_def |
23878 | 567 |
|
568 |
lemma Inf_empty_fun: |
|
25206 | 569 |
"\<Sqinter>{} = (\<lambda>_. \<Sqinter>{})" |
23878 | 570 |
by rule (auto simp add: Inf_fun_def) |
571 |
||
572 |
lemma Sup_empty_fun: |
|
25206 | 573 |
"\<Squnion>{} = (\<lambda>_. \<Squnion>{})" |
24345 | 574 |
by rule (auto simp add: Sup_fun_def) |
23878 | 575 |
|
576 |
lemma top_fun_eq: "top = (\<lambda>x. top)" |
|
577 |
by (iprover intro!: order_antisym le_funI top_greatest) |
|
578 |
||
579 |
lemma bot_fun_eq: "bot = (\<lambda>x. bot)" |
|
580 |
by (iprover intro!: order_antisym le_funI bot_least) |
|
581 |
||
582 |
||
583 |
text {* redundant bindings *} |
|
22454 | 584 |
|
585 |
lemmas inf_aci = inf_ACI |
|
586 |
lemmas sup_aci = sup_ACI |
|
587 |
||
25062 | 588 |
no_notation |
25206 | 589 |
less_eq (infix "\<sqsubseteq>" 50) |
590 |
and |
|
591 |
less (infix "\<sqsubset>" 50) |
|
592 |
and |
|
593 |
inf (infixl "\<sqinter>" 70) |
|
594 |
and |
|
595 |
sup (infixl "\<squnion>" 65) |
|
596 |
and |
|
597 |
Inf ("\<Sqinter>_" [900] 900) |
|
598 |
and |
|
599 |
Sup ("\<Squnion>_" [900] 900) |
|
25062 | 600 |
|
21249 | 601 |
end |