equal
deleted
inserted
replaced
1 (* |
1 (* |
2 Title: HOL/Algebra/Lattice.thy |
2 Title: HOL/Algebra/Lattice.thy |
3 Id: $Id$ |
|
4 Author: Clemens Ballarin, started 7 November 2003 |
3 Author: Clemens Ballarin, started 7 November 2003 |
5 Copyright: Clemens Ballarin |
4 Copyright: Clemens Ballarin |
6 |
5 |
7 Most congruence rules by Stephan Hohe. |
6 Most congruence rules by Stephan Hohe. |
8 *) |
7 *) |
14 subsection {* Partial Orders *} |
13 subsection {* Partial Orders *} |
15 |
14 |
16 record 'a gorder = "'a eq_object" + |
15 record 'a gorder = "'a eq_object" + |
17 le :: "['a, 'a] => bool" (infixl "\<sqsubseteq>\<index>" 50) |
16 le :: "['a, 'a] => bool" (infixl "\<sqsubseteq>\<index>" 50) |
18 |
17 |
19 locale weak_partial_order = equivalence L + |
18 locale weak_partial_order = equivalence L for L (structure) + |
20 assumes le_refl [intro, simp]: |
19 assumes le_refl [intro, simp]: |
21 "x \<in> carrier L ==> x \<sqsubseteq> x" |
20 "x \<in> carrier L ==> x \<sqsubseteq> x" |
22 and weak_le_anti_sym [intro]: |
21 and weak_le_anti_sym [intro]: |
23 "[| x \<sqsubseteq> y; y \<sqsubseteq> x; x \<in> carrier L; y \<in> carrier L |] ==> x .= y" |
22 "[| x \<sqsubseteq> y; y \<sqsubseteq> x; x \<in> carrier L; y \<in> carrier L |] ==> x .= y" |
24 and le_trans [trans]: |
23 and le_trans [trans]: |
918 shows "weak_total_order L" |
917 shows "weak_total_order L" |
919 proof qed (rule total) |
918 proof qed (rule total) |
920 |
919 |
921 text {* Total orders are lattices. *} |
920 text {* Total orders are lattices. *} |
922 |
921 |
923 interpretation weak_total_order < weak_lattice |
922 sublocale weak_total_order < weak_lattice |
924 proof |
923 proof |
925 fix x y |
924 fix x y |
926 assume L: "x \<in> carrier L" "y \<in> carrier L" |
925 assume L: "x \<in> carrier L" "y \<in> carrier L" |
927 show "EX s. least L s (Upper L {x, y})" |
926 show "EX s. least L s (Upper L {x, y})" |
928 proof - |
927 proof - |
1124 |
1123 |
1125 locale upper_semilattice = partial_order + |
1124 locale upper_semilattice = partial_order + |
1126 assumes sup_of_two_exists: |
1125 assumes sup_of_two_exists: |
1127 "[| x \<in> carrier L; y \<in> carrier L |] ==> EX s. least L s (Upper L {x, y})" |
1126 "[| x \<in> carrier L; y \<in> carrier L |] ==> EX s. least L s (Upper L {x, y})" |
1128 |
1127 |
1129 interpretation upper_semilattice < weak_upper_semilattice |
1128 sublocale upper_semilattice < weak_upper_semilattice |
1130 proof qed (rule sup_of_two_exists) |
1129 proof qed (rule sup_of_two_exists) |
1131 |
1130 |
1132 locale lower_semilattice = partial_order + |
1131 locale lower_semilattice = partial_order + |
1133 assumes inf_of_two_exists: |
1132 assumes inf_of_two_exists: |
1134 "[| x \<in> carrier L; y \<in> carrier L |] ==> EX s. greatest L s (Lower L {x, y})" |
1133 "[| x \<in> carrier L; y \<in> carrier L |] ==> EX s. greatest L s (Lower L {x, y})" |
1135 |
1134 |
1136 interpretation lower_semilattice < weak_lower_semilattice |
1135 sublocale lower_semilattice < weak_lower_semilattice |
1137 proof qed (rule inf_of_two_exists) |
1136 proof qed (rule inf_of_two_exists) |
1138 |
1137 |
1139 locale lattice = upper_semilattice + lower_semilattice |
1138 locale lattice = upper_semilattice + lower_semilattice |
1140 |
1139 |
1141 |
1140 |
1182 text {* Total Orders *} |
1181 text {* Total Orders *} |
1183 |
1182 |
1184 locale total_order = partial_order + |
1183 locale total_order = partial_order + |
1185 assumes total_order_total: "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqsubseteq> y | y \<sqsubseteq> x" |
1184 assumes total_order_total: "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqsubseteq> y | y \<sqsubseteq> x" |
1186 |
1185 |
1187 interpretation total_order < weak_total_order |
1186 sublocale total_order < weak_total_order |
1188 proof qed (rule total_order_total) |
1187 proof qed (rule total_order_total) |
1189 |
1188 |
1190 text {* Introduction rule: the usual definition of total order *} |
1189 text {* Introduction rule: the usual definition of total order *} |
1191 |
1190 |
1192 lemma (in partial_order) total_orderI: |
1191 lemma (in partial_order) total_orderI: |
1194 shows "total_order L" |
1193 shows "total_order L" |
1195 proof qed (rule total) |
1194 proof qed (rule total) |
1196 |
1195 |
1197 text {* Total orders are lattices. *} |
1196 text {* Total orders are lattices. *} |
1198 |
1197 |
1199 interpretation total_order < lattice |
1198 sublocale total_order < lattice |
1200 proof qed (auto intro: sup_of_two_exists inf_of_two_exists) |
1199 proof qed (auto intro: sup_of_two_exists inf_of_two_exists) |
1201 |
1200 |
1202 |
1201 |
1203 text {* Complete lattices *} |
1202 text {* Complete lattices *} |
1204 |
1203 |
1206 assumes sup_exists: |
1205 assumes sup_exists: |
1207 "[| A \<subseteq> carrier L |] ==> EX s. least L s (Upper L A)" |
1206 "[| A \<subseteq> carrier L |] ==> EX s. least L s (Upper L A)" |
1208 and inf_exists: |
1207 and inf_exists: |
1209 "[| A \<subseteq> carrier L |] ==> EX i. greatest L i (Lower L A)" |
1208 "[| A \<subseteq> carrier L |] ==> EX i. greatest L i (Lower L A)" |
1210 |
1209 |
1211 interpretation complete_lattice < weak_complete_lattice |
1210 sublocale complete_lattice < weak_complete_lattice |
1212 proof qed (auto intro: sup_exists inf_exists) |
1211 proof qed (auto intro: sup_exists inf_exists) |
1213 |
1212 |
1214 text {* Introduction rule: the usual definition of complete lattice *} |
1213 text {* Introduction rule: the usual definition of complete lattice *} |
1215 |
1214 |
1216 lemma (in partial_order) complete_latticeI: |
1215 lemma (in partial_order) complete_latticeI: |