-
Notifications
You must be signed in to change notification settings - Fork 251
/
CompleteBooleanAlgebra.lean
626 lines (507 loc) · 27.5 KB
/
CompleteBooleanAlgebra.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Yaël Dillies
-/
import Mathlib.Order.CompleteLattice
import Mathlib.Order.Directed
import Mathlib.Logic.Equiv.Set
#align_import order.complete_boolean_algebra from "leanprover-community/mathlib"@"71b36b6f3bbe3b44e6538673819324d3ee9fcc96"
/-!
# Frames, completely distributive lattices and complete Boolean algebras
In this file we define and provide API for (co)frames, completely distributive lattices and
complete Boolean algebras.
We distinguish two different distributivity properties:
1. `inf_iSup_eq : (a ⊓ ⨆ i, f i) = ⨆ i, a ⊓ f i` (finite `⊓` distributes over infinite `⨆`).
This is required by `Frame`, `CompleteDistribLattice`, and `CompleteBooleanAlgebra`
(`Coframe`, etc., require the dual property).
2. `iInf_iSup_eq : (⨅ i, ⨆ j, f i j) = ⨆ s, ⨅ i, f i (s i)`
(infinite `⨅` distributes over infinite `⨆`).
This stronger property is called "completely distributive",
and is required by `CompletelyDistribLattice` and `CompleteAtomicBooleanAlgebra`.
## Typeclasses
* `Order.Frame`: Frame: A complete lattice whose `⊓` distributes over `⨆`.
* `Order.Coframe`: Coframe: A complete lattice whose `⊔` distributes over `⨅`.
* `CompleteDistribLattice`: Complete distributive lattices: A complete lattice whose `⊓` and `⊔`
distribute over `⨆` and `⨅` respectively.
* `CompleteBooleanAlgebra`: Complete Boolean algebra: A Boolean algebra whose `⊓`
and `⊔` distribute over `⨆` and `⨅` respectively.
* `CompletelyDistribLattice`: Completely distributive lattices: A complete lattice whose
`⨅` and `⨆` satisfy `iInf_iSup_eq`.
* `CompleteBooleanAlgebra`: Complete Boolean algebra: A Boolean algebra whose `⊓`
and `⊔` distribute over `⨆` and `⨅` respectively.
* `CompleteAtomicBooleanAlgebra`: Complete atomic Boolean algebra:
A complete Boolean algebra which is additionally completely distributive.
(This implies that it's (co)atom(ist)ic.)
A set of opens gives rise to a topological space precisely if it forms a frame. Such a frame is also
completely distributive, but not all frames are. `Filter` is a coframe but not a completely
distributive lattice.
## References
* [Wikipedia, *Complete Heyting algebra*](https://en.wikipedia.org/wiki/Complete_Heyting_algebra)
* [Francis Borceux, *Handbook of Categorical Algebra III*][borceux-vol3]
-/
set_option autoImplicit true
open Function Set
universe u v w
variable {α : Type u} {β : Type v} {ι : Sort w} {κ : ι → Sort w'}
/-- A frame, aka complete Heyting algebra, is a complete lattice whose `⊓` distributes over `⨆`. -/
class Order.Frame (α : Type*) extends CompleteLattice α where
inf_sSup_le_iSup_inf (a : α) (s : Set α) : a ⊓ sSup s ≤ ⨆ b ∈ s, a ⊓ b
#align order.frame Order.Frame
/-- In a frame, `⊓` distributes over `⨆`. -/
add_decl_doc Order.Frame.inf_sSup_le_iSup_inf
/-- A coframe, aka complete Brouwer algebra or complete co-Heyting algebra, is a complete lattice
whose `⊔` distributes over `⨅`. -/
class Order.Coframe (α : Type*) extends CompleteLattice α where
iInf_sup_le_sup_sInf (a : α) (s : Set α) : ⨅ b ∈ s, a ⊔ b ≤ a ⊔ sInf s
#align order.coframe Order.Coframe
/-- In a coframe, `⊔` distributes over `⨅`. -/
add_decl_doc Order.Coframe.iInf_sup_le_sup_sInf
open Order
/-- A complete distributive lattice is a complete lattice whose `⊔` and `⊓` respectively
distribute over `⨅` and `⨆`. -/
class CompleteDistribLattice (α : Type*) extends Frame α where
iInf_sup_le_sup_sInf : ∀ a s, ⨅ b ∈ s, a ⊔ b ≤ a ⊔ sInf s
#align complete_distrib_lattice CompleteDistribLattice
/-- In a complete distributive lattice, `⊔` distributes over `⨅`. -/
add_decl_doc CompleteDistribLattice.iInf_sup_le_sup_sInf
-- See note [lower instance priority]
instance (priority := 100) CompleteDistribLattice.toCoframe [CompleteDistribLattice α] :
Coframe α :=
{ ‹CompleteDistribLattice α› with }
#align complete_distrib_lattice.to_coframe CompleteDistribLattice.toCoframe
/-- A completely distributive lattice is a complete lattice whose `⨅` and `⨆`
distribute over each other. -/
class CompletelyDistribLattice (α : Type u) extends CompleteLattice α where
protected iInf_iSup_eq {ι : Type u} {κ : ι → Type u} (f : ∀ a, κ a → α) :
(⨅ a, ⨆ b, f a b) = ⨆ g : ∀ a, κ a, ⨅ a, f a (g a)
theorem le_iInf_iSup [CompleteLattice α] {f : ∀ a, κ a → α} :
(⨆ g : ∀ a, κ a, ⨅ a, f a (g a)) ≤ ⨅ a, ⨆ b, f a b :=
iSup_le fun _ => le_iInf fun a => le_trans (iInf_le _ a) (le_iSup _ _)
theorem iInf_iSup_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
(⨅ a, ⨆ b, f a b) = ⨆ g : ∀ a, κ a, ⨅ a, f a (g a) :=
(le_antisymm · le_iInf_iSup) <| calc
_ = ⨅ a : range (range <| f ·), ⨆ b : a.1, b.1 := by
simp_rw [iInf_subtype, iInf_range, iSup_subtype, iSup_range]
_ = _ := CompletelyDistribLattice.iInf_iSup_eq _
_ ≤ _ := iSup_le fun g => by
refine le_trans ?_ <| le_iSup _ fun a => Classical.choose (g ⟨_, a, rfl⟩).2
refine le_iInf fun a => le_trans (iInf_le _ ⟨range (f a), a, rfl⟩) ?_
rw [← Classical.choose_spec (g ⟨_, a, rfl⟩).2]
theorem iSup_iInf_le [CompleteLattice α] {f : ∀ a, κ a → α} :
(⨆ a, ⨅ b, f a b) ≤ ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) :=
le_iInf_iSup (α := αᵒᵈ)
theorem iSup_iInf_eq [CompletelyDistribLattice α] {f : ∀ a, κ a → α} :
(⨆ a, ⨅ b, f a b) = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by
refine le_antisymm iSup_iInf_le ?_
rw [iInf_iSup_eq]
refine iSup_le fun g => ?_
have ⟨a, ha⟩ : ∃ a, ∀ b, ∃ f, ∃ h : a = g f, h ▸ b = f (g f) := of_not_not fun h => by
push_neg at h
choose h hh using h
have := hh _ h rfl
contradiction
refine le_trans ?_ (le_iSup _ a)
refine le_iInf fun b => ?_
obtain ⟨h, rfl, rfl⟩ := ha b
exact iInf_le _ _
instance (priority := 100) CompletelyDistribLattice.toCompleteDistribLattice
[CompletelyDistribLattice α] : CompleteDistribLattice α where
iInf_sup_le_sup_sInf a s := calc
_ = ⨅ b : s, ⨆ x : Bool, cond x a b := by simp_rw [iInf_subtype, iSup_bool_eq, cond]
_ = _ := iInf_iSup_eq
_ ≤ _ := iSup_le fun f => by
if h : ∀ i, f i = false then
simp [h, iInf_subtype, ← sInf_eq_iInf]
else
have ⟨i, h⟩ : ∃ i, f i = true := by simpa using h
refine le_trans (iInf_le _ i) ?_
simp [h]
inf_sSup_le_iSup_inf a s := calc
_ = ⨅ x : Bool, ⨆ y : cond x PUnit s, match x with | true => a | false => y.1 := by
simp_rw [iInf_bool_eq, cond, iSup_const, iSup_subtype, sSup_eq_iSup]
_ = _ := iInf_iSup_eq
_ ≤ _ := by
simp_rw [iInf_bool_eq]
refine iSup_le fun g => le_trans ?_ (le_iSup _ (g false).1)
refine le_trans ?_ (le_iSup _ (g false).2)
rfl
-- See note [lower instance priority]
instance (priority := 100) CompleteLinearOrder.toCompletelyDistribLattice [CompleteLinearOrder α] :
CompletelyDistribLattice α where
iInf_iSup_eq {α β} g := by
let lhs := ⨅ a, ⨆ b, g a b
let rhs := ⨆ h : ∀ a, β a, ⨅ a, g a (h a)
suffices lhs ≤ rhs from le_antisymm this le_iInf_iSup
if h : ∃ x, rhs < x ∧ x < lhs then
rcases h with ⟨x, hr, hl⟩
suffices rhs ≥ x from nomatch not_lt.2 this hr
have : ∀ a, ∃ b, x < g a b := fun a =>
lt_iSup_iff.1 <| lt_of_not_le fun h =>
lt_irrefl x (lt_of_lt_of_le hl (le_trans (iInf_le _ a) h))
choose f hf using this
refine le_trans ?_ (le_iSup _ f)
exact le_iInf fun a => le_of_lt (hf a)
else
refine le_of_not_lt fun hrl : rhs < lhs => not_le_of_lt hrl ?_
replace h : ∀ x, x ≤ rhs ∨ lhs ≤ x := by
simpa only [not_exists, not_and_or, not_or, not_lt] using h
have : ∀ a, ∃ b, rhs < g a b := fun a =>
lt_iSup_iff.1 <| lt_of_lt_of_le hrl (iInf_le _ a)
choose f hf using this
have : ∀ a, lhs ≤ g a (f a) := fun a =>
(h (g a (f a))).resolve_left (by simpa using hf a)
refine le_trans ?_ (le_iSup _ f)
exact le_iInf fun a => this _
section Frame
variable [Frame α] {s t : Set α} {a b : α}
instance OrderDual.instCoframe : Coframe αᵒᵈ where
__ := OrderDual.instCompleteLattice α
iInf_sup_le_sup_sInf := @Frame.inf_sSup_le_iSup_inf α _
#align order_dual.coframe OrderDual.instCoframe
theorem inf_sSup_eq : a ⊓ sSup s = ⨆ b ∈ s, a ⊓ b :=
(Frame.inf_sSup_le_iSup_inf _ _).antisymm iSup_inf_le_inf_sSup
#align inf_Sup_eq inf_sSup_eq
theorem sSup_inf_eq : sSup s ⊓ b = ⨆ a ∈ s, a ⊓ b := by
simpa only [inf_comm] using @inf_sSup_eq α _ s b
#align Sup_inf_eq sSup_inf_eq
theorem iSup_inf_eq (f : ι → α) (a : α) : (⨆ i, f i) ⊓ a = ⨆ i, f i ⊓ a := by
rw [iSup, sSup_inf_eq, iSup_range]
#align supr_inf_eq iSup_inf_eq
theorem inf_iSup_eq (a : α) (f : ι → α) : (a ⊓ ⨆ i, f i) = ⨆ i, a ⊓ f i := by
simpa only [inf_comm] using iSup_inf_eq f a
#align inf_supr_eq inf_iSup_eq
instance Prod.instFrame (α β) [Frame α] [Frame β] : Frame (α × β) where
__ := Prod.instCompleteLattice α β
inf_sSup_le_iSup_inf a s := by
simp [Prod.le_def, sSup_eq_iSup, fst_iSup, snd_iSup, fst_iInf, snd_iInf, inf_iSup_eq]
theorem iSup₂_inf_eq {f : ∀ i, κ i → α} (a : α) :
(⨆ (i) (j), f i j) ⊓ a = ⨆ (i) (j), f i j ⊓ a := by
simp only [iSup_inf_eq]
#align bsupr_inf_eq iSup₂_inf_eq
theorem inf_iSup₂_eq {f : ∀ i, κ i → α} (a : α) :
(a ⊓ ⨆ (i) (j), f i j) = ⨆ (i) (j), a ⊓ f i j := by
simp only [inf_iSup_eq]
#align inf_bsupr_eq inf_iSup₂_eq
theorem iSup_inf_iSup {ι ι' : Type*} {f : ι → α} {g : ι' → α} :
((⨆ i, f i) ⊓ ⨆ j, g j) = ⨆ i : ι × ι', f i.1 ⊓ g i.2 := by
simp_rw [iSup_inf_eq, inf_iSup_eq, iSup_prod]
#align supr_inf_supr iSup_inf_iSup
theorem biSup_inf_biSup {ι ι' : Type*} {f : ι → α} {g : ι' → α} {s : Set ι} {t : Set ι'} :
((⨆ i ∈ s, f i) ⊓ ⨆ j ∈ t, g j) = ⨆ p ∈ s ×ˢ t, f (p : ι × ι').1 ⊓ g p.2 := by
simp only [iSup_subtype', iSup_inf_iSup]
exact (Equiv.surjective _).iSup_congr (Equiv.Set.prod s t).symm fun x => rfl
#align bsupr_inf_bsupr biSup_inf_biSup
theorem sSup_inf_sSup : sSup s ⊓ sSup t = ⨆ p ∈ s ×ˢ t, (p : α × α).1 ⊓ p.2 := by
simp only [sSup_eq_iSup, biSup_inf_biSup]
#align Sup_inf_Sup sSup_inf_sSup
theorem iSup_disjoint_iff {f : ι → α} : Disjoint (⨆ i, f i) a ↔ ∀ i, Disjoint (f i) a := by
simp only [disjoint_iff, iSup_inf_eq, iSup_eq_bot]
#align supr_disjoint_iff iSup_disjoint_iff
theorem disjoint_iSup_iff {f : ι → α} : Disjoint a (⨆ i, f i) ↔ ∀ i, Disjoint a (f i) := by
simpa only [disjoint_comm] using @iSup_disjoint_iff
#align disjoint_supr_iff disjoint_iSup_iff
theorem iSup₂_disjoint_iff {f : ∀ i, κ i → α} :
Disjoint (⨆ (i) (j), f i j) a ↔ ∀ i j, Disjoint (f i j) a := by
simp_rw [iSup_disjoint_iff]
#align supr₂_disjoint_iff iSup₂_disjoint_iff
theorem disjoint_iSup₂_iff {f : ∀ i, κ i → α} :
Disjoint a (⨆ (i) (j), f i j) ↔ ∀ i j, Disjoint a (f i j) := by
simp_rw [disjoint_iSup_iff]
#align disjoint_supr₂_iff disjoint_iSup₂_iff
theorem sSup_disjoint_iff {s : Set α} : Disjoint (sSup s) a ↔ ∀ b ∈ s, Disjoint b a := by
simp only [disjoint_iff, sSup_inf_eq, iSup_eq_bot]
#align Sup_disjoint_iff sSup_disjoint_iff
theorem disjoint_sSup_iff {s : Set α} : Disjoint a (sSup s) ↔ ∀ b ∈ s, Disjoint a b := by
simpa only [disjoint_comm] using @sSup_disjoint_iff
#align disjoint_Sup_iff disjoint_sSup_iff
theorem iSup_inf_of_monotone {ι : Type*} [Preorder ι] [IsDirected ι (· ≤ ·)] {f g : ι → α}
(hf : Monotone f) (hg : Monotone g) : ⨆ i, f i ⊓ g i = (⨆ i, f i) ⊓ ⨆ i, g i := by
refine' (le_iSup_inf_iSup f g).antisymm _
rw [iSup_inf_iSup]
refine' iSup_mono' fun i => _
rcases directed_of (· ≤ ·) i.1 i.2 with ⟨j, h₁, h₂⟩
exact ⟨j, inf_le_inf (hf h₁) (hg h₂)⟩
#align supr_inf_of_monotone iSup_inf_of_monotone
theorem iSup_inf_of_antitone {ι : Type*} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {f g : ι → α}
(hf : Antitone f) (hg : Antitone g) : ⨆ i, f i ⊓ g i = (⨆ i, f i) ⊓ ⨆ i, g i :=
@iSup_inf_of_monotone α _ ιᵒᵈ _ _ f g hf.dual_left hg.dual_left
#align supr_inf_of_antitone iSup_inf_of_antitone
instance Pi.instFrame {ι : Type*} {π : ι → Type*} [∀ i, Frame (π i)] : Frame (∀ i, π i) where
__ := Pi.instCompleteLattice
inf_sSup_le_iSup_inf a s := fun i => by
simp only [sSup_apply, iSup_apply, inf_apply, inf_iSup_eq, ← iSup_subtype'']; rfl
#align pi.frame Pi.instFrame
-- see Note [lower instance priority]
instance (priority := 100) Frame.toDistribLattice : DistribLattice α :=
DistribLattice.ofInfSupLe fun a b c => by
rw [← sSup_pair, ← sSup_pair, inf_sSup_eq, ← sSup_image, image_pair]
#align frame.to_distrib_lattice Frame.toDistribLattice
end Frame
section Coframe
variable [Coframe α] {s t : Set α} {a b : α}
instance OrderDual.instFrame : Frame αᵒᵈ where
__ := OrderDual.instCompleteLattice α
inf_sSup_le_iSup_inf := @Coframe.iInf_sup_le_sup_sInf α _
#align order_dual.frame OrderDual.instFrame
theorem sup_sInf_eq : a ⊔ sInf s = ⨅ b ∈ s, a ⊔ b :=
@inf_sSup_eq αᵒᵈ _ _ _
#align sup_Inf_eq sup_sInf_eq
theorem sInf_sup_eq : sInf s ⊔ b = ⨅ a ∈ s, a ⊔ b :=
@sSup_inf_eq αᵒᵈ _ _ _
#align Inf_sup_eq sInf_sup_eq
theorem iInf_sup_eq (f : ι → α) (a : α) : (⨅ i, f i) ⊔ a = ⨅ i, f i ⊔ a :=
@iSup_inf_eq αᵒᵈ _ _ _ _
#align infi_sup_eq iInf_sup_eq
theorem sup_iInf_eq (a : α) (f : ι → α) : (a ⊔ ⨅ i, f i) = ⨅ i, a ⊔ f i :=
@inf_iSup_eq αᵒᵈ _ _ _ _
#align sup_infi_eq sup_iInf_eq
instance Prod.instCoframe (α β) [Coframe α] [Coframe β] : Coframe (α × β) where
__ := Prod.instCompleteLattice α β
iInf_sup_le_sup_sInf a s := by
simp [Prod.le_def, sInf_eq_iInf, fst_iSup, snd_iSup, fst_iInf, snd_iInf, sup_iInf_eq]
theorem iInf₂_sup_eq {f : ∀ i, κ i → α} (a : α) : (⨅ (i) (j), f i j) ⊔ a = ⨅ (i) (j), f i j ⊔ a :=
@iSup₂_inf_eq αᵒᵈ _ _ _ _ _
#align binfi_sup_eq iInf₂_sup_eq
theorem sup_iInf₂_eq {f : ∀ i, κ i → α} (a : α) : (a ⊔ ⨅ (i) (j), f i j) = ⨅ (i) (j), a ⊔ f i j :=
@inf_iSup₂_eq αᵒᵈ _ _ _ _ _
#align sup_binfi_eq sup_iInf₂_eq
theorem iInf_sup_iInf {ι ι' : Type*} {f : ι → α} {g : ι' → α} :
((⨅ i, f i) ⊔ ⨅ i, g i) = ⨅ i : ι × ι', f i.1 ⊔ g i.2 :=
@iSup_inf_iSup αᵒᵈ _ _ _ _ _
#align infi_sup_infi iInf_sup_iInf
theorem biInf_sup_biInf {ι ι' : Type*} {f : ι → α} {g : ι' → α} {s : Set ι} {t : Set ι'} :
((⨅ i ∈ s, f i) ⊔ ⨅ j ∈ t, g j) = ⨅ p ∈ s ×ˢ t, f (p : ι × ι').1 ⊔ g p.2 :=
@biSup_inf_biSup αᵒᵈ _ _ _ _ _ _ _
#align binfi_sup_binfi biInf_sup_biInf
theorem sInf_sup_sInf : sInf s ⊔ sInf t = ⨅ p ∈ s ×ˢ t, (p : α × α).1 ⊔ p.2 :=
@sSup_inf_sSup αᵒᵈ _ _ _
#align Inf_sup_Inf sInf_sup_sInf
theorem iInf_sup_of_monotone {ι : Type*} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {f g : ι → α}
(hf : Monotone f) (hg : Monotone g) : ⨅ i, f i ⊔ g i = (⨅ i, f i) ⊔ ⨅ i, g i :=
@iSup_inf_of_antitone αᵒᵈ _ _ _ _ _ _ hf.dual_right hg.dual_right
#align infi_sup_of_monotone iInf_sup_of_monotone
theorem iInf_sup_of_antitone {ι : Type*} [Preorder ι] [IsDirected ι (· ≤ ·)] {f g : ι → α}
(hf : Antitone f) (hg : Antitone g) : ⨅ i, f i ⊔ g i = (⨅ i, f i) ⊔ ⨅ i, g i :=
@iSup_inf_of_monotone αᵒᵈ _ _ _ _ _ _ hf.dual_right hg.dual_right
#align infi_sup_of_antitone iInf_sup_of_antitone
instance Pi.instCoframe {ι : Type*} {π : ι → Type*} [∀ i, Coframe (π i)] : Coframe (∀ i, π i) where
__ := Pi.instCompleteLattice
iInf_sup_le_sup_sInf a s := fun i => by
simp only [sInf_apply, iInf_apply, sup_apply, sup_iInf_eq, ← iInf_subtype'']; rfl
#align pi.coframe Pi.instCoframe
-- see Note [lower instance priority]
instance (priority := 100) Coframe.toDistribLattice : DistribLattice α where
__ := ‹Coframe α›
le_sup_inf a b c := by
rw [← sInf_pair, ← sInf_pair, sup_sInf_eq, ← sInf_image, image_pair]
#align coframe.to_distrib_lattice Coframe.toDistribLattice
end Coframe
section CompleteDistribLattice
variable [CompleteDistribLattice α] {a b : α} {s t : Set α}
-- Porting note (#11083): this is mysteriously slow. Minimised in
-- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Performance.20issue.20with.20.60CompleteBooleanAlgebra.60
-- but not yet resolved.
instance OrderDual.instCompleteDistribLattice (α) [CompleteDistribLattice α] :
CompleteDistribLattice αᵒᵈ where
__ := OrderDual.instFrame
__ := OrderDual.instCoframe
instance Prod.instCompleteDistribLattice (α β)
[CompleteDistribLattice α] [CompleteDistribLattice β] :
CompleteDistribLattice (α × β) where
__ := Prod.instCompleteLattice α β
__ := Prod.instFrame α β
__ := Prod.instCoframe α β
instance Pi.instCompleteDistribLattice {ι : Type*} {π : ι → Type*}
[∀ i, CompleteDistribLattice (π i)] : CompleteDistribLattice (∀ i, π i) where
__ := Pi.instFrame
__ := Pi.instCoframe
#align pi.complete_distrib_lattice Pi.instCompleteDistribLattice
end CompleteDistribLattice
section CompletelyDistribLattice
instance OrderDual.instCompletelyDistribLattice (α) [CompletelyDistribLattice α] :
CompletelyDistribLattice αᵒᵈ where
__ := OrderDual.instCompleteLattice α
iInf_iSup_eq _ := iSup_iInf_eq (α := α)
instance Prod.instCompletelyDistribLattice (α β)
[CompletelyDistribLattice α] [CompletelyDistribLattice β] :
CompletelyDistribLattice (α × β) where
__ := Prod.instCompleteLattice α β
iInf_iSup_eq f := by ext <;> simp [fst_iSup, fst_iInf, snd_iSup, snd_iInf, iInf_iSup_eq]
instance Pi.instCompletelyDistribLattice {ι : Type*} {π : ι → Type*}
[∀ i, CompletelyDistribLattice (π i)] : CompletelyDistribLattice (∀ i, π i) where
__ := Pi.instCompleteLattice
iInf_iSup_eq f := by ext i; simp only [iInf_apply, iSup_apply, iInf_iSup_eq]
end CompletelyDistribLattice
/--
A complete Boolean algebra is a Boolean algebra that is also a complete distributive lattice.
It is only completely distributive if it is also atomic.
-/
class CompleteBooleanAlgebra (α) extends BooleanAlgebra α, CompleteDistribLattice α
#align complete_boolean_algebra CompleteBooleanAlgebra
instance Prod.instCompleteBooleanAlgebra (α β)
[CompleteBooleanAlgebra α] [CompleteBooleanAlgebra β] :
CompleteBooleanAlgebra (α × β) where
__ := Prod.instBooleanAlgebra α β
__ := Prod.instCompleteDistribLattice α β
instance Pi.instCompleteBooleanAlgebra {ι : Type*} {π : ι → Type*}
[∀ i, CompleteBooleanAlgebra (π i)] : CompleteBooleanAlgebra (∀ i, π i) where
__ := Pi.instBooleanAlgebra
__ := Pi.instCompleteDistribLattice
#align pi.complete_boolean_algebra Pi.instCompleteBooleanAlgebra
instance OrderDual.instCompleteBooleanAlgebra (α) [CompleteBooleanAlgebra α] :
CompleteBooleanAlgebra αᵒᵈ where
__ := OrderDual.instBooleanAlgebra α
__ := OrderDual.instCompleteDistribLattice α
section CompleteBooleanAlgebra
variable [CompleteBooleanAlgebra α] {a b : α} {s : Set α} {f : ι → α}
theorem compl_iInf : (iInf f)ᶜ = ⨆ i, (f i)ᶜ :=
le_antisymm
(compl_le_of_compl_le <| le_iInf fun i => compl_le_of_compl_le <|
le_iSup (HasCompl.compl ∘ f) i)
(iSup_le fun _ => compl_le_compl <| iInf_le _ _)
#align compl_infi compl_iInf
theorem compl_iSup : (iSup f)ᶜ = ⨅ i, (f i)ᶜ :=
compl_injective (by simp [compl_iInf])
#align compl_supr compl_iSup
theorem compl_sInf : (sInf s)ᶜ = ⨆ i ∈ s, iᶜ := by simp only [sInf_eq_iInf, compl_iInf]
#align compl_Inf compl_sInf
theorem compl_sSup : (sSup s)ᶜ = ⨅ i ∈ s, iᶜ := by simp only [sSup_eq_iSup, compl_iSup]
#align compl_Sup compl_sSup
theorem compl_sInf' : (sInf s)ᶜ = sSup (HasCompl.compl '' s) :=
compl_sInf.trans sSup_image.symm
#align compl_Inf' compl_sInf'
theorem compl_sSup' : (sSup s)ᶜ = sInf (HasCompl.compl '' s) :=
compl_sSup.trans sInf_image.symm
#align compl_Sup' compl_sSup'
end CompleteBooleanAlgebra
/--
A complete atomic Boolean algebra is a complete Boolean algebra
that is also completely distributive.
We take iSup_iInf_eq as the definition here,
and prove later on that this implies atomicity.
-/
class CompleteAtomicBooleanAlgebra (α : Type u) extends
CompletelyDistribLattice α, CompleteBooleanAlgebra α where
iInf_sup_le_sup_sInf := CompletelyDistribLattice.toCompleteDistribLattice.iInf_sup_le_sup_sInf
inf_sSup_le_iSup_inf := CompletelyDistribLattice.toCompleteDistribLattice.inf_sSup_le_iSup_inf
instance Prod.instCompleteAtomicBooleanAlgebra (α β)
[CompleteAtomicBooleanAlgebra α] [CompleteAtomicBooleanAlgebra β] :
CompleteAtomicBooleanAlgebra (α × β) where
__ := Prod.instBooleanAlgebra α β
__ := Prod.instCompletelyDistribLattice α β
instance Pi.instCompleteAtomicBooleanAlgebra {ι : Type*} {π : ι → Type*}
[∀ i, CompleteAtomicBooleanAlgebra (π i)] : CompleteAtomicBooleanAlgebra (∀ i, π i) where
__ := Pi.instCompleteBooleanAlgebra
iInf_iSup_eq f := by ext; rw [iInf_iSup_eq]
instance OrderDual.instCompleteAtomicBooleanAlgebra (α) [CompleteAtomicBooleanAlgebra α] :
CompleteAtomicBooleanAlgebra αᵒᵈ where
__ := OrderDual.instCompleteBooleanAlgebra α
__ := OrderDual.instCompletelyDistribLattice α
instance Prop.instCompleteAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra Prop where
__ := Prop.instCompleteLattice
__ := Prop.instBooleanAlgebra
iInf_iSup_eq f := by simp [Classical.skolem]
instance Prop.instCompleteBooleanAlgebra : CompleteBooleanAlgebra Prop := inferInstance
#align Prop.complete_boolean_algebra Prop.instCompleteBooleanAlgebra
section lift
-- See note [reducible non-instances]
/-- Pullback an `Order.Frame` along an injection. -/
@[reducible]
protected def Function.Injective.frame [Sup α] [Inf α] [SupSet α] [InfSet α] [Top α] [Bot α]
[Frame β] (f : α → β) (hf : Injective f) (map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b)
(map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b) (map_sSup : ∀ s, f (sSup s) = ⨆ a ∈ s, f a)
(map_sInf : ∀ s, f (sInf s) = ⨅ a ∈ s, f a) (map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥) :
Frame α where
__ := hf.completeLattice f map_sup map_inf map_sSup map_sInf map_top map_bot
inf_sSup_le_iSup_inf a s := by
change f (a ⊓ sSup s) ≤ f _
rw [← sSup_image, map_inf, map_sSup s, inf_iSup₂_eq]
simp_rw [← map_inf]
exact ((map_sSup _).trans iSup_image).ge
#align function.injective.frame Function.Injective.frame
-- See note [reducible non-instances]
/-- Pullback an `Order.Coframe` along an injection. -/
@[reducible]
protected def Function.Injective.coframe [Sup α] [Inf α] [SupSet α] [InfSet α] [Top α] [Bot α]
[Coframe β] (f : α → β) (hf : Injective f) (map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b)
(map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b) (map_sSup : ∀ s, f (sSup s) = ⨆ a ∈ s, f a)
(map_sInf : ∀ s, f (sInf s) = ⨅ a ∈ s, f a) (map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥) :
Coframe α where
__ := hf.completeLattice f map_sup map_inf map_sSup map_sInf map_top map_bot
iInf_sup_le_sup_sInf a s := by
change f _ ≤ f (a ⊔ sInf s)
rw [← sInf_image, map_sup, map_sInf s, sup_iInf₂_eq]
simp_rw [← map_sup]
exact ((map_sInf _).trans iInf_image).le
#align function.injective.coframe Function.Injective.coframe
-- See note [reducible non-instances]
/-- Pullback a `CompleteDistribLattice` along an injection. -/
@[reducible]
protected def Function.Injective.completeDistribLattice [Sup α] [Inf α] [SupSet α] [InfSet α]
[Top α] [Bot α] [CompleteDistribLattice β] (f : α → β) (hf : Function.Injective f)
(map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b) (map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b)
(map_sSup : ∀ s, f (sSup s) = ⨆ a ∈ s, f a) (map_sInf : ∀ s, f (sInf s) = ⨅ a ∈ s, f a)
(map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥) : CompleteDistribLattice α where
__ := hf.frame f map_sup map_inf map_sSup map_sInf map_top map_bot
__ := hf.coframe f map_sup map_inf map_sSup map_sInf map_top map_bot
#align function.injective.complete_distrib_lattice Function.Injective.completeDistribLattice
-- See note [reducible non-instances]
/-- Pullback a `CompletelyDistribLattice` along an injection. -/
@[reducible]
protected def Function.Injective.completelyDistribLattice [Sup α] [Inf α] [SupSet α] [InfSet α]
[Top α] [Bot α] [CompletelyDistribLattice β] (f : α → β) (hf : Function.Injective f)
(map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b) (map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b)
(map_sSup : ∀ s, f (sSup s) = ⨆ a ∈ s, f a) (map_sInf : ∀ s, f (sInf s) = ⨅ a ∈ s, f a)
(map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥) : CompletelyDistribLattice α where
__ := hf.completeLattice f map_sup map_inf map_sSup map_sInf map_top map_bot
iInf_iSup_eq g := hf <| by
simp_rw [iInf, map_sInf, iInf_range, iSup, map_sSup, iSup_range, map_sInf, iInf_range,
iInf_iSup_eq]
-- See note [reducible non-instances]
/-- Pullback a `CompleteBooleanAlgebra` along an injection. -/
@[reducible]
protected def Function.Injective.completeBooleanAlgebra [Sup α] [Inf α] [SupSet α] [InfSet α]
[Top α] [Bot α] [HasCompl α] [SDiff α] [CompleteBooleanAlgebra β] (f : α → β)
(hf : Function.Injective f) (map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b)
(map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b) (map_sSup : ∀ s, f (sSup s) = ⨆ a ∈ s, f a)
(map_sInf : ∀ s, f (sInf s) = ⨅ a ∈ s, f a) (map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥)
(map_compl : ∀ a, f aᶜ = (f a)ᶜ) (map_sdiff : ∀ a b, f (a \ b) = f a \ f b) :
CompleteBooleanAlgebra α where
__ := hf.completeDistribLattice f map_sup map_inf map_sSup map_sInf map_top map_bot
__ := hf.booleanAlgebra f map_sup map_inf map_top map_bot map_compl map_sdiff
#align function.injective.complete_boolean_algebra Function.Injective.completeBooleanAlgebra
-- See note [reducible non-instances]
/-- Pullback a `CompleteAtomicBooleanAlgebra` along an injection. -/
@[reducible]
protected def Function.Injective.completeAtomicBooleanAlgebra [Sup α] [Inf α] [SupSet α] [InfSet α]
[Top α] [Bot α] [HasCompl α] [SDiff α] [CompleteAtomicBooleanAlgebra β] (f : α → β)
(hf : Function.Injective f) (map_sup : ∀ a b, f (a ⊔ b) = f a ⊔ f b)
(map_inf : ∀ a b, f (a ⊓ b) = f a ⊓ f b) (map_sSup : ∀ s, f (sSup s) = ⨆ a ∈ s, f a)
(map_sInf : ∀ s, f (sInf s) = ⨅ a ∈ s, f a) (map_top : f ⊤ = ⊤) (map_bot : f ⊥ = ⊥)
(map_compl : ∀ a, f aᶜ = (f a)ᶜ) (map_sdiff : ∀ a b, f (a \ b) = f a \ f b) :
CompleteAtomicBooleanAlgebra α where
__ := hf.completelyDistribLattice f map_sup map_inf map_sSup map_sInf map_top map_bot
__ := hf.booleanAlgebra f map_sup map_inf map_top map_bot map_compl map_sdiff
end lift
namespace PUnit
variable (s : Set PUnit.{u + 1}) (x y : PUnit.{u + 1})
instance instCompleteAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra PUnit := by
refine'
{ PUnit.instBooleanAlgebra with
sSup := fun _ => unit
sInf := fun _ => unit
.. } <;>
(intros; trivial)
instance instCompleteBooleanAlgebra : CompleteBooleanAlgebra PUnit := inferInstance
instance instCompleteLinearOrder : CompleteLinearOrder PUnit :=
{ PUnit.instCompleteBooleanAlgebra, PUnit.instLinearOrder with }
@[simp]
theorem sSup_eq : sSup s = unit :=
rfl
#align punit.Sup_eq PUnit.sSup_eq
@[simp]
theorem sInf_eq : sInf s = unit :=
rfl
#align punit.Inf_eq PUnit.sInf_eq
end PUnit