The areas / V04. Order and lattices
Mathlib.Order.BooleanAlgebra.Defs
31 declarations. Mathlib docs · Source
(Generalized) Boolean algebras
This file sets up the theory of (generalized) Boolean algebras.
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (⊤) (and hence not all elements may have complements). One
example in mathlib is Finset α, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type α.
GeneralizedBooleanAlgebra α is defined to be a distributive lattice with bottom (⊥) admitting
a relative complement operator, written using "set difference" notation as x \ y (sdiff x y).
For convenience, the BooleanAlgebra type class is defined to extend GeneralizedBooleanAlgebra
so that it is also bundled with a \ operator.
(A terminological point: x \ y is the complement of y relative to the interval [⊥, x]. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
Main declarations
GeneralizedBooleanAlgebra: a type class for generalized Boolean algebrasBooleanAlgebra: a type class for Boolean algebras.Prop.booleanAlgebra: the Boolean algebra instance onProp
Implementation notes
The sup_inf_sdiff and inf_inf_sdiff axioms for the relative complement operator in
GeneralizedBooleanAlgebra are taken from
Wikipedia.
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator a \ b for all a, b. Instead, the postulates there amount to an assumption
that for all a, b : α where a ≤ b, the equations x ⊔ a = b and x ⊓ a = ⊥ have a solution
x. Disjoint.sdiff_unique proves that this x is in fact b \ a.
References
- https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations
- [Postulates for Boolean Algebras and Generalized Boolean Algebras, M.H. Stone][Stone1935]
- [Lattice Theory: Foundation, George Grätzer][Gratzer2011]
Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
Generalized Boolean algebras
Boolean algebras
def BooleanAlgebra.ctorIdx E1 #
{α : Type u} → BooleanAlgebra α → ℕ
def GeneralizedBooleanAlgebra.ctorIdx E1 #
{α : Type u} → GeneralizedBooleanAlgebra α → ℕ
class GeneralizedBooleanAlgebra E3 #
Type u → Type u
A generalized Boolean algebra is a distributive lattice with ⊥ and a relative complement
operation \ (called sdiff, after "set difference") satisfying (a ⊓ b) ⊔ (a \ b) = a and
(a ⊓ b) ⊓ (a \ b) = ⊥, i.e. a \ b is the complement of b in a.
This is a generalization of Boolean algebras which applies to Finset α for arbitrary
(not-necessarily-Fintype) α.
instance GeneralizedBooleanAlgebra.toBot E0 #
{α : Type u} → [self : GeneralizedBooleanAlgebra α] → Bot α
instance GeneralizedBooleanAlgebra.toDistribLattice E0 #
{α : Type u} → [self : GeneralizedBooleanAlgebra α] → DistribLattice α
ctor GeneralizedBooleanAlgebra.mk E0 #
{α : Type u} →
[toDistribLattice : DistribLattice α] →
[toSDiff : SDiff α] →
[toBot : Bot α] →
(∀ (a b : α), a ⊓ b ⊔ a \ b = a) → (∀ (a b : α), a ⊓ b ⊓ a \ b = ⊥) → GeneralizedBooleanAlgebra α
instance GeneralizedBooleanAlgebra.toSDiff E0 #
{α : Type u} → [self : GeneralizedBooleanAlgebra α] → SDiff α
theorem GeneralizedBooleanAlgebra.sup_inf_sdiff E1 #
∀ {α : Type u} [self : GeneralizedBooleanAlgebra α] (a b : α), a ⊓ b ⊔ a \ b = a
For any a, b, (a ⊓ b) ⊔ (a / b) = a
theorem GeneralizedBooleanAlgebra.inf_inf_sdiff E1 #
∀ {α : Type u} [self : GeneralizedBooleanAlgebra α] (a b : α), a ⊓ b ⊓ a \ b = ⊥
For any a, b, (a ⊓ b) ⊓ (a / b) = ⊥
class BooleanAlgebra E3 #
Type u → Type u
A Boolean algebra is a bounded distributive lattice with a complement operator ᶜ such that
x ⊓ xᶜ = ⊥ and x ⊔ xᶜ = ⊤. For convenience, it must also provide a set difference operation \
and a Heyting implication ⇨ satisfying x \ y = x ⊓ yᶜ and x ⇨ y = y ⊔ xᶜ.
This is a generalization of (classical) logic of propositions, or the powerset lattice.
Since BoundedOrder, OrderBot, and OrderTop are mixins that require LE
to be present at define-time, the extends mechanism does not work with them.
Instead, we extend using the underlying Bot and Top data typeclasses, and replicate the
order axioms of those classes here. A "forgetful" instance back to BoundedOrder is provided.
instance BooleanAlgebra.toCompl E0 #
{α : Type u} → [self : BooleanAlgebra α] → Compl α
instance BooleanAlgebra.toSDiff E0 #
{α : Type u} → [self : BooleanAlgebra α] → SDiff α
instance BooleanAlgebra.toTop E0 #
{α : Type u} → [self : BooleanAlgebra α] → Top α
ctor BooleanAlgebra.mk E0 #
{α : Type u} →
[toDistribLattice : DistribLattice α] →
[toCompl : Compl α] →
[toSDiff : SDiff α] →
[toHImp : HImp α] →
[toTop : Top α] →
[toBot : Bot α] →
(∀ (x : α), x ⊓ xᶜ ≤ ⊥) →
(∀ (x : α), ⊤ ≤ x ⊔ xᶜ) →
(∀ (a : α), a ≤ ⊤) →
(∀ (a : α), ⊥ ≤ a) →
autoParam (∀ (x y : α), x \ y = x ⊓ yᶜ) BooleanAlgebra.sdiff_eq._autoParam →
autoParam (∀ (x y : α), x ⇨ y = y ⊔ xᶜ) BooleanAlgebra.himp_eq._autoParam → BooleanAlgebra α
instance BooleanAlgebra.toHImp E0 #
{α : Type u} → [self : BooleanAlgebra α] → HImp α
instance BooleanAlgebra.toBot E0 #
{α : Type u} → [self : BooleanAlgebra α] → Bot α
instance BooleanAlgebra.toDistribLattice E0 #
{α : Type u} → [self : BooleanAlgebra α] → DistribLattice α
theorem BooleanAlgebra.inf_compl_le_bot E2 #
∀ {α : Type u} [self : BooleanAlgebra α] (x : α), x ⊓ xᶜ ≤ ⊥
The infimum of x and xᶜ is at most ⊥
theorem BooleanAlgebra.top_le_sup_compl E2 #
∀ {α : Type u} [self : BooleanAlgebra α] (x : α), ⊤ ≤ x ⊔ xᶜ
The supremum of x and xᶜ is at least ⊤
theorem BooleanAlgebra.le_top E1 #
∀ {α : Type u} [self : BooleanAlgebra α] (a : α), a ≤ ⊤
⊤ is the greatest element
theorem BooleanAlgebra.bot_le E1 #
∀ {α : Type u} [self : BooleanAlgebra α] (a : α), ⊥ ≤ a
⊥ is the least element
theorem BooleanAlgebra.sdiff_eq E0 #
∀ {α : Type u} [self : BooleanAlgebra α] (x y : α), x \ y = x ⊓ yᶜ
x \ y is equal to x ⊓ yᶜ
theorem BooleanAlgebra.himp_eq E0 #
∀ {α : Type u} [self : BooleanAlgebra α] (x y : α), x ⇨ y = y ⊔ xᶜ
x ⇨ y is equal to y ⊔ xᶜ
instance BooleanAlgebra.toBoundedOrder E0 #
{α : Type u} → [h : BooleanAlgebra α] → BoundedOrder α
instance Prop.instBooleanAlgebra E0 #
BooleanAlgebra Prop
instance Bool.instBooleanAlgebra E0 #
BooleanAlgebra Bool
theorem Bool.sup_eq_bor E1 #
(fun x1 x2 ↦ max x1 x2) = or
theorem Bool.inf_eq_band E1 #
(fun x1 x2 ↦ min x1 x2) = and
theorem Bool.compl_eq_bnot E0 #
compl = not
instance PUnit.instBooleanAlgebra E0 #
BooleanAlgebra PUnit.{u_1 + 1}
def DistribLattice.booleanAlgebraOfComplemented E1 #
(α : Type u) → [inst : DistribLattice α] → [inst_1 : BoundedOrder α] → [ComplementedLattice α] → BooleanAlgebra α
An alternative constructor for Boolean algebras: a distributive lattice that is complemented is a Boolean algebra.
This is not an instance, because it creates data using choice.