11 |
11 |
12 subsection{* Lattices *} |
12 subsection{* Lattices *} |
13 |
13 |
14 text{* |
14 text{* |
15 This theory of lattices only defines binary sup and inf |
15 This theory of lattices only defines binary sup and inf |
16 operations. The extension to (finite) sets is done in theories |
16 operations. The extension to complete lattices is done in theory |
17 @{text FixedPoint} and @{text Finite_Set}. |
17 @{text FixedPoint}. |
18 *} |
18 *} |
19 |
19 |
20 class lower_semilattice = order + |
20 class lower_semilattice = order + |
21 fixes inf :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 70) |
21 fixes inf :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 70) |
22 assumes inf_le1 [simp]: "x \<sqinter> y \<sqsubseteq> x" |
22 assumes inf_le1 [simp]: "x \<sqinter> y \<sqsubseteq> x" |
276 have leI: "\<And>x y z. x \<^loc>\<le> z \<Longrightarrow> y \<^loc>\<le> z \<Longrightarrow> x \<nabla> y \<^loc>\<le> z" by (blast intro: least) |
276 have leI: "\<And>x y z. x \<^loc>\<le> z \<Longrightarrow> y \<^loc>\<le> z \<Longrightarrow> x \<nabla> y \<^loc>\<le> z" by (blast intro: least) |
277 show "x \<nabla> y \<^loc>\<le> x \<squnion> y" by (rule leI) simp_all |
277 show "x \<nabla> y \<^loc>\<le> x \<squnion> y" by (rule leI) simp_all |
278 qed |
278 qed |
279 |
279 |
280 |
280 |
281 subsection {* min/max on linear orders as special case of inf/sup *} |
281 subsection {* @{const min}/@{const max} on linear orders as |
|
282 special case of @{const inf}/@{const sup} *} |
|
283 |
|
284 lemma (in linorder) distrib_lattice_min_max: |
|
285 "distrib_lattice_pred (op \<^loc>\<le>) (op \<^loc><) min max" |
|
286 proof unfold_locales |
|
287 have aux: "\<And>x y \<Colon> 'a. x \<^loc>< y \<Longrightarrow> y \<^loc>\<le> x \<Longrightarrow> x = y" |
|
288 by (auto simp add: less_le antisym) |
|
289 fix x y z |
|
290 show "max x (min y z) = min (max x y) (max x z)" |
|
291 unfolding min_def max_def |
|
292 by (auto simp add: intro: antisym, unfold not_le, |
|
293 auto intro: less_trans le_less_trans aux) |
|
294 qed (auto simp add: min_def max_def not_le less_imp_le) |
282 |
295 |
283 interpretation min_max: |
296 interpretation min_max: |
284 distrib_lattice ["op \<le> \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" min max] |
297 distrib_lattice ["op \<le> \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" min max] |
285 apply unfold_locales |
298 by (rule distrib_lattice_min_max [unfolded linorder_class_min linorder_class_max]) |
286 apply (simp add: min_def linorder_not_le order_less_imp_le) |
|
287 apply (simp add: min_def linorder_not_le order_less_imp_le) |
|
288 apply (simp add: min_def linorder_not_le order_less_imp_le) |
|
289 apply (simp add: max_def linorder_not_le order_less_imp_le) |
|
290 apply (simp add: max_def linorder_not_le order_less_imp_le) |
|
291 unfolding min_def max_def by auto |
|
292 |
299 |
293 lemma inf_min: "inf = (min \<Colon> 'a\<Colon>{lower_semilattice, linorder} \<Rightarrow> 'a \<Rightarrow> 'a)" |
300 lemma inf_min: "inf = (min \<Colon> 'a\<Colon>{lower_semilattice, linorder} \<Rightarrow> 'a \<Rightarrow> 'a)" |
294 by (rule ext)+ auto |
301 by (rule ext)+ auto |
295 |
302 |
296 lemma sup_max: "sup = (max \<Colon> 'a\<Colon>{upper_semilattice, linorder} \<Rightarrow> 'a \<Rightarrow> 'a)" |
303 lemma sup_max: "sup = (max \<Colon> 'a\<Colon>{upper_semilattice, linorder} \<Rightarrow> 'a \<Rightarrow> 'a)" |