14738
|
1 |
(* Title: HOL/LOrder.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Steven Obua, TU Muenchen
|
|
4 |
*)
|
|
5 |
|
21312
|
6 |
header "Lattice Orders"
|
14738
|
7 |
|
15131
|
8 |
theory LOrder
|
21249
|
9 |
imports Lattices
|
15131
|
10 |
begin
|
14738
|
11 |
|
21312
|
12 |
text {* The theory of lattices developed here is taken from
|
|
13 |
\cite{Birkhoff79}. *}
|
14738
|
14 |
|
|
15 |
constdefs
|
|
16 |
is_meet :: "(('a::order) \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> bool"
|
|
17 |
"is_meet m == ! a b x. m a b \<le> a \<and> m a b \<le> b \<and> (x \<le> a \<and> x \<le> b \<longrightarrow> x \<le> m a b)"
|
|
18 |
is_join :: "(('a::order) \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> bool"
|
|
19 |
"is_join j == ! a b x. a \<le> j a b \<and> b \<le> j a b \<and> (a \<le> x \<and> b \<le> x \<longrightarrow> j a b \<le> x)"
|
|
20 |
|
|
21 |
lemma is_meet_unique:
|
|
22 |
assumes "is_meet u" "is_meet v" shows "u = v"
|
|
23 |
proof -
|
|
24 |
{
|
|
25 |
fix a b :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
|
|
26 |
assume a: "is_meet a"
|
|
27 |
assume b: "is_meet b"
|
|
28 |
{
|
|
29 |
fix x y
|
|
30 |
let ?za = "a x y"
|
|
31 |
let ?zb = "b x y"
|
|
32 |
from a have za_le: "?za <= x & ?za <= y" by (auto simp add: is_meet_def)
|
|
33 |
with b have "?za <= ?zb" by (auto simp add: is_meet_def)
|
|
34 |
}
|
|
35 |
}
|
|
36 |
note f_le = this
|
|
37 |
show "u = v" by ((rule ext)+, simp_all add: order_antisym prems f_le)
|
|
38 |
qed
|
|
39 |
|
|
40 |
lemma is_join_unique:
|
|
41 |
assumes "is_join u" "is_join v" shows "u = v"
|
|
42 |
proof -
|
|
43 |
{
|
|
44 |
fix a b :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
|
|
45 |
assume a: "is_join a"
|
|
46 |
assume b: "is_join b"
|
|
47 |
{
|
|
48 |
fix x y
|
|
49 |
let ?za = "a x y"
|
|
50 |
let ?zb = "b x y"
|
|
51 |
from a have za_le: "x <= ?za & y <= ?za" by (auto simp add: is_join_def)
|
|
52 |
with b have "?zb <= ?za" by (auto simp add: is_join_def)
|
|
53 |
}
|
|
54 |
}
|
|
55 |
note f_le = this
|
|
56 |
show "u = v" by ((rule ext)+, simp_all add: order_antisym prems f_le)
|
|
57 |
qed
|
|
58 |
|
|
59 |
axclass join_semilorder < order
|
|
60 |
join_exists: "? j. is_join j"
|
|
61 |
|
|
62 |
axclass meet_semilorder < order
|
|
63 |
meet_exists: "? m. is_meet m"
|
|
64 |
|
|
65 |
axclass lorder < join_semilorder, meet_semilorder
|
|
66 |
|
|
67 |
constdefs
|
|
68 |
meet :: "('a::meet_semilorder) \<Rightarrow> 'a \<Rightarrow> 'a"
|
|
69 |
"meet == THE m. is_meet m"
|
|
70 |
join :: "('a::join_semilorder) \<Rightarrow> 'a \<Rightarrow> 'a"
|
|
71 |
"join == THE j. is_join j"
|
|
72 |
|
|
73 |
lemma is_meet_meet: "is_meet (meet::'a \<Rightarrow> 'a \<Rightarrow> ('a::meet_semilorder))"
|
|
74 |
proof -
|
|
75 |
from meet_exists obtain k::"'a \<Rightarrow> 'a \<Rightarrow> 'a" where "is_meet k" ..
|
|
76 |
with is_meet_unique[of _ k] show ?thesis
|
|
77 |
by (simp add: meet_def theI[of is_meet])
|
|
78 |
qed
|
|
79 |
|
|
80 |
lemma meet_unique: "(is_meet m) = (m = meet)"
|
|
81 |
by (insert is_meet_meet, auto simp add: is_meet_unique)
|
|
82 |
|
|
83 |
lemma is_join_join: "is_join (join::'a \<Rightarrow> 'a \<Rightarrow> ('a::join_semilorder))"
|
|
84 |
proof -
|
|
85 |
from join_exists obtain k::"'a \<Rightarrow> 'a \<Rightarrow> 'a" where "is_join k" ..
|
|
86 |
with is_join_unique[of _ k] show ?thesis
|
|
87 |
by (simp add: join_def theI[of is_join])
|
|
88 |
qed
|
|
89 |
|
|
90 |
lemma join_unique: "(is_join j) = (j = join)"
|
|
91 |
by (insert is_join_join, auto simp add: is_join_unique)
|
|
92 |
|
21733
|
93 |
interpretation meet_semilat:
|
|
94 |
lower_semilattice ["op \<le> \<Colon> 'a\<Colon>meet_semilorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" meet]
|
21380
|
95 |
proof unfold_locales
|
21733
|
96 |
fix x y z :: "'a\<Colon>meet_semilorder"
|
21380
|
97 |
from is_meet_meet have "is_meet meet" by blast
|
|
98 |
note meet = this is_meet_def
|
|
99 |
from meet show "meet x y \<le> x" by blast
|
|
100 |
from meet show "meet x y \<le> y" by blast
|
|
101 |
from meet show "x \<le> y \<Longrightarrow> x \<le> z \<Longrightarrow> x \<le> meet y z" by blast
|
21733
|
102 |
qed
|
|
103 |
|
|
104 |
interpretation join_semilat:
|
|
105 |
upper_semilattice ["op \<le> \<Colon> 'a\<Colon>join_semilorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" join]
|
|
106 |
proof unfold_locales
|
|
107 |
fix x y z :: "'a\<Colon>join_semilorder"
|
21380
|
108 |
from is_join_join have "is_join join" by blast
|
|
109 |
note join = this is_join_def
|
|
110 |
from join show "x \<le> join x y" by blast
|
|
111 |
from join show "y \<le> join x y" by blast
|
21733
|
112 |
from join show "x \<le> z \<Longrightarrow> y \<le> z \<Longrightarrow> join x y \<le> z" by blast
|
21380
|
113 |
qed
|
|
114 |
|
21733
|
115 |
declare
|
|
116 |
join_semilat.antisym_intro[rule del] meet_semilat.antisym_intro[rule del]
|
|
117 |
join_semilat.less_eq_supE[rule del] meet_semilat.less_eq_infE[rule del]
|
14738
|
118 |
|
21733
|
119 |
interpretation meet_join_lat:
|
|
120 |
lattice ["op \<le> \<Colon> 'a\<Colon>lorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" meet join]
|
|
121 |
by unfold_locales
|
14738
|
122 |
|
21733
|
123 |
lemmas meet_left_le = meet_semilat.inf_le1
|
|
124 |
lemmas meet_right_le = meet_semilat.inf_le2
|
|
125 |
lemmas le_meetI[rule del] = meet_semilat.less_eq_infI
|
|
126 |
(* intro! breaks a proof in Hyperreal/SEQ and NumberTheory/IntPrimes *)
|
|
127 |
lemmas join_left_le = join_semilat.sup_ge1
|
|
128 |
lemmas join_right_le = join_semilat.sup_ge2
|
|
129 |
lemmas join_leI[rule del] = join_semilat.less_eq_supI
|
21312
|
130 |
|
21733
|
131 |
lemmas meet_join_le = meet_left_le meet_right_le join_left_le join_right_le
|
21312
|
132 |
|
21733
|
133 |
lemmas le_meet = meet_semilat.less_eq_inf_conv
|
21312
|
134 |
|
21733
|
135 |
lemmas le_join = join_semilat.above_sup_conv
|
14738
|
136 |
|
|
137 |
lemma is_meet_min: "is_meet (min::'a \<Rightarrow> 'a \<Rightarrow> ('a::linorder))"
|
|
138 |
by (auto simp add: is_meet_def min_def)
|
|
139 |
|
|
140 |
lemma is_join_max: "is_join (max::'a \<Rightarrow> 'a \<Rightarrow> ('a::linorder))"
|
|
141 |
by (auto simp add: is_join_def max_def)
|
|
142 |
|
|
143 |
instance linorder \<subseteq> meet_semilorder
|
|
144 |
proof
|
|
145 |
from is_meet_min show "? (m::'a\<Rightarrow>'a\<Rightarrow>('a::linorder)). is_meet m" by auto
|
|
146 |
qed
|
|
147 |
|
|
148 |
instance linorder \<subseteq> join_semilorder
|
|
149 |
proof
|
|
150 |
from is_join_max show "? (j::'a\<Rightarrow>'a\<Rightarrow>('a::linorder)). is_join j" by auto
|
|
151 |
qed
|
|
152 |
|
|
153 |
instance linorder \<subseteq> lorder ..
|
|
154 |
|
|
155 |
lemma meet_min: "meet = (min :: 'a\<Rightarrow>'a\<Rightarrow>('a::linorder))"
|
|
156 |
by (simp add: is_meet_meet is_meet_min is_meet_unique)
|
|
157 |
|
|
158 |
lemma join_max: "join = (max :: 'a\<Rightarrow>'a\<Rightarrow>('a::linorder))"
|
|
159 |
by (simp add: is_join_join is_join_max is_join_unique)
|
|
160 |
|
21733
|
161 |
lemmas meet_idempotent = meet_semilat.inf_idem
|
|
162 |
lemmas join_idempotent = join_semilat.sup_idem
|
|
163 |
lemmas meet_comm = meet_semilat.inf_commute
|
|
164 |
lemmas join_comm = join_semilat.sup_commute
|
|
165 |
lemmas meet_leI1[rule del] = meet_semilat.less_eq_infI1
|
|
166 |
lemmas meet_leI2[rule del] = meet_semilat.less_eq_infI2
|
|
167 |
lemmas le_joinI1[rule del] = join_semilat.less_eq_supI1
|
|
168 |
lemmas le_joinI2[rule del] = join_semilat.less_eq_supI2
|
|
169 |
lemmas meet_assoc = meet_semilat.inf_assoc
|
|
170 |
lemmas join_assoc = join_semilat.sup_assoc
|
|
171 |
lemmas meet_left_comm = meet_semilat.inf_left_commute
|
|
172 |
lemmas meet_left_idempotent = meet_semilat.inf_left_idem
|
|
173 |
lemmas join_left_comm = join_semilat.sup_left_commute
|
|
174 |
lemmas join_left_idempotent= join_semilat.sup_left_idem
|
14738
|
175 |
|
|
176 |
lemmas meet_aci = meet_assoc meet_comm meet_left_comm meet_left_idempotent
|
|
177 |
lemmas join_aci = join_assoc join_comm join_left_comm join_left_idempotent
|
|
178 |
|
21312
|
179 |
lemma le_def_meet: "(x <= y) = (meet x y = x)"
|
|
180 |
apply rule
|
|
181 |
apply(simp add: order_antisym)
|
|
182 |
apply(subgoal_tac "meet x y <= y")
|
|
183 |
apply(simp)
|
|
184 |
apply(simp (no_asm))
|
|
185 |
done
|
14738
|
186 |
|
21312
|
187 |
lemma le_def_join: "(x <= y) = (join x y = y)"
|
|
188 |
apply rule
|
|
189 |
apply(simp add: order_antisym)
|
|
190 |
apply(subgoal_tac "x <= join x y")
|
|
191 |
apply(simp)
|
|
192 |
apply(simp (no_asm))
|
|
193 |
done
|
|
194 |
|
21733
|
195 |
lemmas join_absorp2 = join_semilat.sup_absorb2
|
|
196 |
lemmas join_absorp1 = join_semilat.sup_absorb1
|
21312
|
197 |
|
21733
|
198 |
lemmas meet_absorp1 = meet_semilat.inf_absorb1
|
|
199 |
lemmas meet_absorp2 = meet_semilat.inf_absorb2
|
14738
|
200 |
|
|
201 |
lemma meet_join_absorp: "meet x (join x y) = x"
|
21312
|
202 |
by(simp add:meet_absorp1)
|
14738
|
203 |
|
|
204 |
lemma join_meet_absorp: "join x (meet x y) = x"
|
21312
|
205 |
by(simp add:join_absorp1)
|
14738
|
206 |
|
|
207 |
lemma meet_mono: "y \<le> z \<Longrightarrow> meet x y \<le> meet x z"
|
21312
|
208 |
by(simp add:meet_leI2)
|
14738
|
209 |
|
|
210 |
lemma join_mono: "y \<le> z \<Longrightarrow> join x y \<le> join x z"
|
21312
|
211 |
by(simp add:le_joinI2)
|
14738
|
212 |
|
|
213 |
lemma distrib_join_le: "join x (meet y z) \<le> meet (join x y) (join x z)" (is "_ <= ?r")
|
|
214 |
proof -
|
21312
|
215 |
have a: "x <= ?r" by (simp_all add:le_meetI)
|
|
216 |
have b: "meet y z <= ?r" by (simp add:le_joinI2)
|
|
217 |
from a b show ?thesis by (simp add: join_leI)
|
14738
|
218 |
qed
|
|
219 |
|
21312
|
220 |
lemma distrib_meet_le: "join (meet x y) (meet x z) \<le> meet x (join y z)" (is "?l <= _")
|
14738
|
221 |
proof -
|
21312
|
222 |
have a: "?l <= x" by (simp_all add: join_leI)
|
|
223 |
have b: "?l <= join y z" by (simp add:meet_leI2)
|
|
224 |
from a b show ?thesis by (simp add: le_meetI)
|
14738
|
225 |
qed
|
|
226 |
|
|
227 |
lemma meet_join_eq_imp_le: "a = c \<or> a = d \<or> b = c \<or> b = d \<Longrightarrow> meet a b \<le> join c d"
|
21312
|
228 |
by (auto simp:meet_leI2 meet_leI1)
|
14738
|
229 |
|
|
230 |
lemma modular_le: "x \<le> z \<Longrightarrow> join x (meet y z) \<le> meet (join x y) z" (is "_ \<Longrightarrow> ?t <= _")
|
|
231 |
proof -
|
|
232 |
assume a: "x <= z"
|
21312
|
233 |
have b: "?t <= join x y" by (simp_all add: join_leI meet_join_eq_imp_le )
|
|
234 |
have c: "?t <= z" by (simp_all add: a join_leI)
|
|
235 |
from b c show ?thesis by (simp add: le_meetI)
|
14738
|
236 |
qed
|
|
237 |
|
15131
|
238 |
end
|