@@ -5,7 +5,7 @@ Authors: Johannes Hölzl
5
5
6
6
Defines the inf/sup (semi)-lattice with optionally top/bot type class hierarchy.
7
7
-/
8
- import order.basic
8
+ import order.rel_classes
9
9
10
10
set_option old_structure_cmd true
11
11
@@ -42,6 +42,9 @@ class semilattice_sup (α : Type u) extends has_sup α, partial_order α :=
42
42
(le_sup_right : ∀ a b : α, b ≤ a ⊔ b)
43
43
(sup_le : ∀ a b c : α, a ≤ c → b ≤ c → a ⊔ b ≤ c)
44
44
45
+ instance (α : Type *) [has_inf α] : has_sup (order_dual α) := ⟨((⊓) : α → α → α)⟩
46
+ instance (α : Type *) [has_sup α] : has_inf (order_dual α) := ⟨((⊔) : α → α → α)⟩
47
+
45
48
section semilattice_sup
46
49
variables [semilattice_sup α] {a b c d : α}
47
50
@@ -104,12 +107,14 @@ lemma sup_ind [is_total α (≤)] (a b : α) {p : α → Prop} (ha : p a) (hb :
104
107
(is_total.total a b).elim (λ h : a ≤ b, by rwa sup_eq_right.2 h) (λ h, by rwa sup_eq_left.2 h)
105
108
106
109
@[simp] lemma sup_lt_iff [is_total α (≤)] {a b c : α} : b ⊔ c < a ↔ b < a ∧ c < a :=
107
- ⟨λ h, ⟨lt_of_le_of_lt le_sup_left h, lt_of_le_of_lt le_sup_right h⟩,
108
- λ h, sup_ind b c h.1 h.2 ⟩
110
+ ⟨λ h, ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, λ h, sup_ind b c h.1 h.2 ⟩
109
111
110
112
@[simp] lemma le_sup_iff [is_total α (≤)] {a b c : α} : a ≤ b ⊔ c ↔ a ≤ b ∨ a ≤ c :=
111
113
by rw [← not_iff_not]; simp only [not_or_distrib, @sup_lt_iff α, @not_le (as_linear_order α)]
112
114
115
+ @[simp] lemma lt_sup_iff [is_total α (≤)] {a b c : α} : a < b ⊔ c ↔ a < b ∨ a < c :=
116
+ by { rw ← not_iff_not, simp only [not_or_distrib, @not_lt (as_linear_order α), sup_le_iff] }
117
+
113
118
@[simp] theorem sup_idem : a ⊔ a = a :=
114
119
by apply le_antisymm; simp
115
120
@@ -171,6 +176,18 @@ class semilattice_inf (α : Type u) extends has_inf α, partial_order α :=
171
176
(inf_le_right : ∀ a b : α, a ⊓ b ≤ b)
172
177
(le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c)
173
178
179
+ instance (α) [semilattice_inf α] : semilattice_sup (order_dual α) :=
180
+ { le_sup_left := semilattice_inf.inf_le_left,
181
+ le_sup_right := semilattice_inf.inf_le_right,
182
+ sup_le := assume a b c hca hcb, @semilattice_inf.le_inf α _ _ _ _ hca hcb,
183
+ .. order_dual.partial_order α, .. order_dual.has_sup α }
184
+
185
+ instance (α) [semilattice_sup α] : semilattice_inf (order_dual α) :=
186
+ { inf_le_left := @le_sup_left α _,
187
+ inf_le_right := @le_sup_right α _,
188
+ le_inf := assume a b c hca hcb, @sup_le α _ _ _ _ hca hcb,
189
+ .. order_dual.partial_order α, .. order_dual.has_inf α }
190
+
174
191
section semilattice_inf
175
192
variables [semilattice_inf α] {a b c d : α}
176
193
@@ -196,8 +213,7 @@ theorem inf_le_right_of_le (h : b ≤ c) : a ⊓ b ≤ c :=
196
213
le_trans inf_le_right h
197
214
198
215
@[simp] theorem le_inf_iff : a ≤ b ⊓ c ↔ a ≤ b ∧ a ≤ c :=
199
- ⟨assume h : a ≤ b ⊓ c, ⟨le_trans h inf_le_left, le_trans h inf_le_right⟩,
200
- assume ⟨h₁, h₂⟩, le_inf h₁ h₂⟩
216
+ @sup_le_iff (order_dual α) _ _ _ _
201
217
202
218
@[simp] theorem inf_eq_left : a ⊓ b = a ↔ a ≤ b :=
203
219
le_antisymm_iff.trans $ by simp [le_refl]
@@ -230,51 +246,40 @@ theorem le_of_inf_eq (h : a ⊓ b = a) : a ≤ b :=
230
246
by { rw ← h, simp }
231
247
232
248
lemma inf_ind [is_total α (≤)] (a b : α) {p : α → Prop } (ha : p a) (hb : p b) : p (a ⊓ b) :=
233
- (is_total.total a b).elim (λ h : a ≤ b, by rwa inf_eq_left. 2 h) (λ h, by rwa inf_eq_right. 2 h)
249
+ @sup_ind (order_dual α) _ _ _ _ _ ha hb
234
250
235
251
@[simp] lemma lt_inf_iff [is_total α (≤)] {a b c : α} : a < b ⊓ c ↔ a < b ∧ a < c :=
236
- ⟨λ h, ⟨lt_of_lt_of_le h inf_le_left, lt_of_lt_of_le h inf_le_right⟩,
237
- λ h, inf_ind b c h.1 h.2 ⟩
252
+ @sup_lt_iff (order_dual α) _ _ _ _ _
238
253
239
254
@[simp] lemma inf_le_iff [is_total α (≤)] {a b c : α} : b ⊓ c ≤ a ↔ b ≤ a ∨ c ≤ a :=
240
- by rw [← not_iff_not]; simp only [not_or_distrib, @lt_inf_iff α, @not_le (as_linear_order α)]
255
+ @le_sup_iff (order_dual α) _ _ _ _ _
241
256
242
257
@[simp] theorem inf_idem : a ⊓ a = a :=
243
- by apply le_antisymm; simp
258
+ @sup_idem (order_dual α) _ _
244
259
245
260
instance inf_is_idempotent : is_idempotent α (⊓) := ⟨@inf_idem _ _⟩
246
261
247
262
theorem inf_comm : a ⊓ b = b ⊓ a :=
248
- by apply le_antisymm; simp
263
+ @sup_comm (order_dual α) _ _ _
249
264
250
265
instance inf_is_commutative : is_commutative α (⊓) := ⟨@inf_comm _ _⟩
251
266
252
267
theorem inf_assoc : a ⊓ b ⊓ c = a ⊓ (b ⊓ c) :=
253
- le_antisymm
254
- (le_inf
255
- (inf_le_left_of_le inf_le_left)
256
- (le_inf (inf_le_left_of_le inf_le_right) inf_le_right))
257
- (le_inf
258
- (le_inf inf_le_left (inf_le_right_of_le inf_le_left))
259
- (inf_le_right_of_le inf_le_right))
268
+ @sup_assoc (order_dual α) _ a b c
260
269
261
270
instance inf_is_associative : is_associative α (⊓) := ⟨@inf_assoc _ _⟩
262
271
263
272
@[simp] lemma inf_left_idem : a ⊓ (a ⊓ b) = a ⊓ b :=
264
- by rw [← inf_assoc, inf_idem]
273
+ @sup_left_idem (order_dual α) _ a b
265
274
266
275
@[simp] lemma inf_right_idem : (a ⊓ b) ⊓ b = a ⊓ b :=
267
- by rw [inf_assoc, inf_idem]
276
+ @sup_right_idem (order_dual α) _ a b
268
277
269
278
lemma inf_left_comm (a b c : α) : a ⊓ (b ⊓ c) = b ⊓ (a ⊓ c) :=
270
- by rw [← inf_assoc, ← inf_assoc, @inf_comm α _ a]
279
+ @sup_left_comm (order_dual α) _ a b c
271
280
272
281
lemma forall_le_or_exists_lt_inf (a : α) : (∀b, a ≤ b) ∨ (∃b, b < a) :=
273
- suffices (∃b, ¬a ≤ b) → (∃b, b < a),
274
- by rwa [or_iff_not_imp_left, not_forall],
275
- assume ⟨b, hb⟩,
276
- have a ⊓ b ≠ a, from assume eq, hb $ eq ▸ inf_le_right,
277
- ⟨a ⊓ b, lt_of_le_of_ne inf_le_left ‹a ⊓ b ≠ a›⟩
282
+ @forall_le_or_exists_lt_sup (order_dual α) _ a
278
283
279
284
theorem semilattice_inf.ext_inf {α} {A B : semilattice_inf α}
280
285
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y)
@@ -293,11 +298,14 @@ end
293
298
294
299
end semilattice_inf
295
300
296
- /- Lattices -/
301
+ /-! ### Lattices -/
297
302
298
303
/-- A lattice is a join-semilattice which is also a meet-semilattice. -/
299
304
class lattice (α : Type u) extends semilattice_sup α, semilattice_inf α
300
305
306
+ instance (α) [lattice α] : lattice (order_dual α) :=
307
+ { .. order_dual.semilattice_sup α, .. order_dual.semilattice_inf α }
308
+
301
309
section lattice
302
310
variables [lattice α] {a b c d : α}
303
311
@@ -355,6 +363,10 @@ calc x ⊓ (y ⊔ z) = (x ⊓ (x ⊔ z)) ⊓ (y ⊔ z) : by rw [inf_sup_se
355
363
... = ((x ⊓ y) ⊔ x) ⊓ ((x ⊓ y) ⊔ z) : by rw [sup_comm]
356
364
... = (x ⊓ y) ⊔ (x ⊓ z) : by rw [sup_inf_left]
357
365
366
+ instance (α : Type *) [distrib_lattice α] : distrib_lattice (order_dual α) :=
367
+ { le_sup_inf := assume x y z, le_of_eq inf_sup_left.symm,
368
+ .. order_dual.lattice α }
369
+
358
370
theorem inf_sup_right : (y ⊔ z) ⊓ x = (y ⊓ x) ⊔ (z ⊓ x) :=
359
371
by simp only [inf_sup_left, λy:α, @inf_comm α _ y x, eq_self_iff_true]
360
372
@@ -374,10 +386,13 @@ le_antisymm
374
386
375
387
end distrib_lattice
376
388
377
- /- Lattices derived from linear orders -/
389
+ /-!
390
+ ### Lattices derived from linear orders
391
+ -/
378
392
379
393
@[priority 100 ] -- see Note [lower instance priority]
380
- instance lattice_of_decidable_linear_order {α : Type u} [o : decidable_linear_order α] : lattice α :=
394
+ instance lattice_of_decidable_linear_order {α : Type u} [o : decidable_linear_order α] :
395
+ lattice α :=
381
396
{ sup := max,
382
397
le_sup_left := le_max_left,
383
398
le_sup_right := le_max_right,
@@ -427,39 +442,10 @@ le_inf (h inf_le_left) (h inf_le_right)
427
442
lemma map_inf [semilattice_inf α] [is_total α (≤)] [semilattice_inf β] {f : α → β}
428
443
(hf : monotone f) (x y : α) :
429
444
f (x ⊓ y) = f x ⊓ f y :=
430
- (is_total.total x y).elim
431
- (λ h : x ≤ y, by simp only [h, hf h, inf_of_le_left])
432
- (λ h, by simp only [h, hf h, inf_of_le_right])
445
+ @monotone.map_sup (order_dual α) _ _ _ _ _ hf.order_dual x y
433
446
434
447
end monotone
435
448
436
- namespace order_dual
437
- variable (α)
438
-
439
- instance [has_inf α] : has_sup (order_dual α) := ⟨((⊓) : α → α → α)⟩
440
- instance [has_sup α] : has_inf (order_dual α) := ⟨((⊔) : α → α → α)⟩
441
-
442
- instance [semilattice_inf α] : semilattice_sup (order_dual α) :=
443
- { le_sup_left := @inf_le_left α _,
444
- le_sup_right := @inf_le_right α _,
445
- sup_le := assume a b c hca hcb, @le_inf α _ _ _ _ hca hcb,
446
- .. order_dual.partial_order α, .. order_dual.has_sup α }
447
-
448
- instance [semilattice_sup α] : semilattice_inf (order_dual α) :=
449
- { inf_le_left := @le_sup_left α _,
450
- inf_le_right := @le_sup_right α _,
451
- le_inf := assume a b c hca hcb, @sup_le α _ _ _ _ hca hcb,
452
- .. order_dual.partial_order α, .. order_dual.has_inf α }
453
-
454
- instance [lattice α] : lattice (order_dual α) :=
455
- { .. order_dual.semilattice_sup α, .. order_dual.semilattice_inf α }
456
-
457
- instance [distrib_lattice α] : distrib_lattice (order_dual α) :=
458
- { le_sup_inf := assume x y z, le_of_eq inf_sup_left.symm,
459
- .. order_dual.lattice α }
460
-
461
- end order_dual
462
-
463
449
namespace prod
464
450
variables (α β)
465
451
0 commit comments