@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Yaël Dillies
55-/
66import Mathlib.Order.Sublattice
7+ import LeanCamCombi.Mathlib.Order.SupClosed
78
89/-!
910# Boolean subalgebras
@@ -13,16 +14,19 @@ This file defines boolean subalgebras.
1314
1415open Function Set
1516
16- variable {ι : Sort *} {α β γ : Type *} [BooleanAlgebra α] [BooleanAlgebra β] [BooleanAlgebra γ]
17+ variable {ι : Sort *} {α β γ : Type *}
1718
1819variable (α) in
19- /-- A boolean subalgebra of a boolean algebra is a set containing the suprema, infima of any of its elements. -/
20- structure BooleanSubalgebra extends Sublattice α where
20+ /-- A boolean subalgebra of a boolean algebra is a set containing the bottom and top elements, and
21+ closed under suprema, infima and complements. -/
22+ structure BooleanSubalgebra [BooleanAlgebra α] extends Sublattice α where
2123 compl_mem' {a} : a ∈ carrier → aᶜ ∈ carrier
2224 bot_mem' : ⊥ ∈ carrier
2325
2426namespace BooleanSubalgebra
25- variable {L M : BooleanSubalgebra α} {f : BoundedLatticeHom α β} {s t : Set α} {a b : α}
27+ section BooleanAlgebra
28+ variable [BooleanAlgebra α] [BooleanAlgebra β] [BooleanAlgebra γ] {L M : BooleanSubalgebra α}
29+ {f : BoundedLatticeHom α β} {s t : Set α} {a b : α}
2630
2731initialize_simps_projections BooleanSubalgebra (carrier → coe)
2832
@@ -39,21 +43,23 @@ lemma compl_mem (ha : a ∈ L) : aᶜ ∈ L := L.compl_mem' ha
3943@[simp] lemma compl_mem_iff : aᶜ ∈ L ↔ a ∈ L := ⟨fun ha ↦ by simpa using compl_mem ha, compl_mem⟩
4044@[simp] lemma bot_mem : ⊥ ∈ L := L.bot_mem'
4145@[simp] lemma top_mem : ⊤ ∈ L := by simpa using compl_mem L.bot_mem
46+ lemma sup_mem (ha : a ∈ L) (hb : b ∈ L) : a ⊔ b ∈ L := L.supClosed ha hb
47+ lemma inf_mem (ha : a ∈ L) (hb : b ∈ L) : a ⊓ b ∈ L := L.infClosed ha hb
4248lemma sdiff_mem (ha : a ∈ L) (hb : b ∈ L) : a \ b ∈ L := by
4349 simpa [sdiff_eq] using L.infClosed ha (compl_mem hb)
4450lemma himp_mem (ha : a ∈ L) (hb : b ∈ L) : a ⇨ b ∈ L := by
4551 simpa [himp_eq] using L.supClosed hb (compl_mem ha)
4652
47- @[simp] lemma mem_carrier : a ∈ L.carrier ↔ a ∈ L := Iff .rfl
53+ @[simp] lemma mem_carrier : a ∈ L.carrier ↔ a ∈ L := .rfl
4854@[simp] lemma mem_mk {L : Sublattice α} (h_compl h_bot) : a ∈ mk L h_compl h_bot ↔ a ∈ L := .rfl
4955@[simp] lemma coe_mk (L : Sublattice α) (h_compl h_bot) : (mk L h_compl h_bot : Set α) = L := rfl
5056@[simp] lemma mk_le_mk {L M : Sublattice α} (hL_compl hL_bot hM_compl hM_bot) :
5157 mk L hL_compl hL_bot ≤ mk M hM_compl hM_bot ↔ L ≤ M := .rfl
5258@[simp] lemma mk_lt_mk {L M : Sublattice α} (hL_compl hL_bot hM_compl hM_bot) :
5359 mk L hL_compl hL_bot < mk M hM_compl hM_bot ↔ L < M := .rfl
5460
55- /-- Copy of a boolean subalgebra with a new `carrier` equal to the old one. Useful to fix definitional
56- equalities. -/
61+ /-- Copy of a boolean subalgebra with a new `carrier` equal to the old one. Useful to fix
62+ definitional equalities. -/
5763protected def copy (L : BooleanSubalgebra α) (s : Set α) (hs : s = L) : BooleanSubalgebra α where
5864 toSublattice := L.toSublattice.copy s <| by subst hs; rfl
5965 compl_mem' := by subst hs; exact L.compl_mem'
@@ -140,7 +146,7 @@ lemma inclusion_apply (h : L ≤ M) (a : L) : inclusion h a = Set.inclusion h a
140146
141147lemma inclusion_injective (h : L ≤ M) : Injective <| inclusion h := Set.inclusion_injective h
142148
143- @[simp] lemma inclusion_rfl (L : BooleanSubalgebra α) : inclusion le_rfl = BoundedLatticeHom .id L := rfl
149+ @[simp] lemma inclusion_rfl (L : BooleanSubalgebra α) : inclusion le_rfl = .id L := rfl
144150@[simp] lemma subtype_comp_inclusion (h : L ≤ M) : M.subtype.comp (inclusion h) = L.subtype := rfl
145151
146152/-- The maximum boolean subalgebra of a lattice. -/
@@ -230,17 +236,17 @@ def comap (f : BoundedLatticeHom α β) (L : BooleanSubalgebra β) : BooleanSuba
230236 supClosed' := L.supClosed.preimage _
231237 infClosed' := L.infClosed.preimage _
232238
233- @[simp, norm_cast] lemma coe_comap (L : BooleanSubalgebra β) (f : BoundedLatticeHom α β) : L.comap f = f ⁻¹' L :=
234- rfl
239+ @[simp, norm_cast]
240+ lemma coe_comap (L : BooleanSubalgebra β) (f : BoundedLatticeHom α β) : L.comap f = f ⁻¹' L := rfl
235241
236- @[simp] lemma mem_comap {L : BooleanSubalgebra β} : a ∈ L.comap f ↔ f a ∈ L := Iff .rfl
242+ @[simp] lemma mem_comap {L : BooleanSubalgebra β} : a ∈ L.comap f ↔ f a ∈ L := .rfl
237243
238244lemma comap_mono : Monotone (comap f) := fun _ _ ↦ preimage_mono
239245
240246@[simp] lemma comap_id (L : BooleanSubalgebra α) : L.comap (BoundedLatticeHom.id _) = L := rfl
241247
242- @[simp] lemma comap_comap (L : BooleanSubalgebra γ) (g : BoundedLatticeHom β γ) (f : BoundedLatticeHom α β) :
243- (L.comap g).comap f = L.comap (g.comp f) := rfl
248+ @[simp] lemma comap_comap (L : BooleanSubalgebra γ) (g : BoundedLatticeHom β γ)
249+ (f : BoundedLatticeHom α β) : ( L.comap g).comap f = L.comap (g.comp f) := rfl
244250
245251/-- The image of a boolean subalgebra along a monoid homomorphism is a boolean subalgebra. -/
246252def map (f : BoundedLatticeHom α β) (L : BooleanSubalgebra α) : BooleanSubalgebra β where
@@ -250,11 +256,16 @@ def map (f : BoundedLatticeHom α β) (L : BooleanSubalgebra α) : BooleanSubalg
250256 supClosed' := L.supClosed.image f
251257 infClosed' := L.infClosed.image f
252258
253- @[simp] lemma coe_map (f : BoundedLatticeHom α β) (L : BooleanSubalgebra α) : (L.map f : Set β) = f '' L := rfl
254- @[simp] lemma mem_map {b : β} : b ∈ L.map f ↔ ∃ a ∈ L, f a = b := Iff.rfl
259+ @[simp] lemma coe_map (f : BoundedLatticeHom α β) (L : BooleanSubalgebra α) :
260+ (L.map f : Set β) = f '' L := rfl
261+
262+ @[simp] lemma mem_map {b : β} : b ∈ L.map f ↔ ∃ a ∈ L, f a = b := .rfl
263+
264+ lemma mem_map_of_mem (f : BoundedLatticeHom α β) {a : α} : a ∈ L → f a ∈ L.map f :=
265+ mem_image_of_mem f
255266
256- lemma mem_map_of_mem (f : BoundedLatticeHom α β) { a : α} : a ∈ L → f a ∈ L.map f := mem_image_of_mem f
257- lemma apply_coe_mem_map (f : BoundedLatticeHom α β) (a : L) : f a ∈ L.map f := mem_map_of_mem f a.prop
267+ lemma apply_coe_mem_map (f : BoundedLatticeHom α β) ( a : L) : f a ∈ L.map f :=
268+ mem_map_of_mem f a.prop
258269
259270lemma map_mono : Monotone (map f) := fun _ _ ↦ image_subset _
260271
@@ -278,19 +289,20 @@ lemma map_symm_eq_iff_eq_map {M : BooleanSubalgebra β} {e : β ≃o α} :
278289 L.map ↑e.symm = M ↔ L = M.map ↑e := by
279290 simp_rw [← coe_inj]; exact (Equiv.eq_image_iff_symm_image_eq _ _ _).symm
280291
281- lemma map_le_iff_le_comap {f : BoundedLatticeHom α β} {M : BooleanSubalgebra β} : L.map f ≤ M ↔ L ≤ M.comap f :=
282- image_subset_iff
292+ lemma map_le_iff_le_comap {f : BoundedLatticeHom α β} {M : BooleanSubalgebra β} :
293+ L.map f ≤ M ↔ L ≤ M.comap f := image_subset_iff
283294
284295lemma gc_map_comap (f : BoundedLatticeHom α β) : GaloisConnection (map f) (comap f) :=
285296 fun _ _ ↦ map_le_iff_le_comap
286297
287- @[simp] lemma map_bot (f : BoundedLatticeHom α β) : (⊥ : BooleanSubalgebra α).map f = ⊥ := (gc_map_comap f).l_bot
298+ @[simp] lemma map_bot (f : BoundedLatticeHom α β) : (⊥ : BooleanSubalgebra α).map f = ⊥ :=
299+ (gc_map_comap f).l_bot
288300
289- lemma map_sup (f : BoundedLatticeHom α β) (L M : BooleanSubalgebra α) : (L ⊔ M).map f = L.map f ⊔ M.map f :=
290- (gc_map_comap f).l_sup
301+ lemma map_sup (f : BoundedLatticeHom α β) (L M : BooleanSubalgebra α) :
302+ (L ⊔ M).map f = L.map f ⊔ M.map f := (gc_map_comap f).l_sup
291303
292- lemma map_iSup (f : BoundedLatticeHom α β) (L : ι → BooleanSubalgebra α) : (⨆ i, L i).map f = ⨆ i, (L i).map f :=
293- (gc_map_comap f).l_iSup
304+ lemma map_iSup (f : BoundedLatticeHom α β) (L : ι → BooleanSubalgebra α) :
305+ (⨆ i, L i).map f = ⨆ i, (L i).map f := (gc_map_comap f).l_iSup
294306
295307@[simp] lemma comap_top (f : BoundedLatticeHom α β) : (⊤ : BooleanSubalgebra β).comap f = ⊤ :=
296308 (gc_map_comap f).u_top
@@ -318,4 +330,50 @@ lemma map_inf (L M : BooleanSubalgebra α) (f : BoundedLatticeHom α β) (hf : I
318330lemma map_top (f : BoundedLatticeHom α β) (h : Surjective f) : BooleanSubalgebra.map f ⊤ = ⊤ :=
319331 SetLike.coe_injective <| by simp [h.range_eq]
320332
333+ /-- The minimum boolean algebra containing a given set. -/
334+ def closure (s : Set α) : BooleanSubalgebra α := sInf {L | s ⊆ L}
335+
336+ variable {s : Set α}
337+
338+ lemma mem_closure {x : α} : x ∈ closure s ↔ ∀ ⦃L : BooleanSubalgebra α⦄, s ⊆ L → x ∈ L := mem_sInf
339+
340+ @[aesop safe 20 apply (rule_sets := [SetLike] )]
341+ lemma subset_closure : s ⊆ closure s := fun _ hx ↦ mem_closure.2 fun _ hK ↦ hK hx
342+
343+ @[simp] lemma closure_le : closure s ≤ L ↔ s ⊆ L := ⟨subset_closure.trans, fun h ↦ sInf_le h⟩
344+
345+ /-- An induction principle for closure membership. If `p` holds for `⊥` and all elements of `s`, and
346+ is preserved under suprema and complement, then `p` holds for all elements of the closure of `s`. -/
347+ @[elab_as_elim]
348+ lemma closure_bot_sup_induction {p : ∀ g ∈ closure s, Prop } (mem : ∀ x hx, p x (subset_closure hx))
349+ (bot : p ⊥ bot_mem)
350+ (sup : ∀ x hx y hy, p x hx → p y hy → p (x ⊔ y) (supClosed _ hx hy))
351+ (compl : ∀ x hx, p x hx → p xᶜ (compl_mem hx)) {x} (hx : x ∈ closure s) : p x hx :=
352+ have inf ⦃x hx y hy⦄ (hx' : p x hx) (hy' : p y hy) : p (x ⊓ y) (infClosed _ hx hy) := by
353+ simpa using compl _ _ <| sup _ _ _ _ (compl _ _ hx') (compl _ _ hy')
354+ let L : BooleanSubalgebra α :=
355+ { carrier := { x | ∃ hx, p x hx }
356+ supClosed' := fun _a ⟨_, ha⟩ _b ⟨_, hb⟩ ↦ ⟨_, sup _ _ _ _ ha hb⟩
357+ infClosed' := fun _a ⟨_, ha⟩ _b ⟨_, hb⟩ ↦ ⟨_, inf ha hb⟩
358+ bot_mem' := ⟨_, bot⟩
359+ compl_mem' := fun ⟨_, hb⟩ ↦ ⟨_, compl _ _ hb⟩ }
360+ closure_le (L := L).mpr (fun y hy ↦ ⟨subset_closure hy, mem y hy⟩) hx |>.elim fun _ ↦ id
361+
362+ end BooleanAlgebra
363+
364+ section CompleteBooleanAlgebra
365+ variable [CompleteBooleanAlgebra α] {L : BooleanSubalgebra α} {f : ι → α} {s : Set α}
366+
367+ lemma iSup_mem [Finite ι] (hf : ∀ i, f i ∈ L) : ⨆ i, f i ∈ L := L.supClosed.iSup_mem bot_mem hf
368+ lemma iInf_mem [Finite ι] (hf : ∀ i, f i ∈ L) : ⨅ i, f i ∈ L := L.infClosed.iInf_mem top_mem hf
369+ lemma sSup_mem (hs : s.Finite) (hsL : s ⊆ L) : sSup s ∈ L := L.supClosed.sSup_mem hs bot_mem hsL
370+ lemma sInf_mem (hs : s.Finite) (hsL : s ⊆ L) : sInf s ∈ L := L.infClosed.sInf_mem hs top_mem hsL
371+
372+ lemma biSup_mem {ι : Type *} {t : Set ι} {f : ι → α} (ht : t.Finite) (hf : ∀ i ∈ t, f i ∈ L) :
373+ ⨆ i ∈ t, f i ∈ L := L.supClosed.biSup_mem ht bot_mem hf
374+
375+ lemma biInf_mem {ι : Type *} {t : Set ι} {f : ι → α} (ht : t.Finite) (hf : ∀ i ∈ t, f i ∈ L) :
376+ ⨅ i ∈ t, f i ∈ L := L.infClosed.biInf_mem ht top_mem hf
377+
378+ end CompleteBooleanAlgebra
321379end BooleanSubalgebra
0 commit comments