(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 α
.
generalized_boolean_algebra α
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 boolean_algebra
type class is defined to extend generalized_boolean_algebra
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 #
has_compl
: a type class for the complement operatorgeneralized_boolean_algebra
: a type class for generalized Boolean algebrasboolean_algebra.core
: a type class with the minimal assumptions for a Boolean algebrasboolean_algebra
: the main type class for Boolean algebras; it extends bothgeneralized_boolean_algebra
andboolean_algebra.core
. An instance ofboolean_algebra
can be obtained from one ofboolean_algebra.core
usingboolean_algebra.of_core
.Prop.boolean_algebra
: the Boolean algebra instance onProp
Implementation notes #
The sup_inf_sdiff
and inf_inf_sdiff
axioms for the relative complement operator in
generalized_boolean_algebra
are taken from
Wikipedia.
Stone's paper introducing generalized Boolean algebras 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
.
Notations #
xᶜ
is notation forcompl x
x \ y
is notation forsdiff x y
.
References #
- https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations
- Postulates for Boolean Algebras and Generalized Boolean Algebras, M.H. Stone
- Lattice Theory: Foundation, George Grätzer
Tags #
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
Generalized Boolean algebras #
Some of the lemmas in this section are from:
- sup : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
- le_trans : ∀ (a b c : α), a ≤ b → b ≤ c → a ≤ c
- lt_iff_le_not_le : (∀ (a b : α), a < b ↔ a ≤ b ∧ ¬b ≤ a) . "order_laws_tac"
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- le_sup_left : ∀ (a b : α), a ≤ a ⊔ b
- le_sup_right : ∀ (a b : α), b ≤ a ⊔ b
- sup_le : ∀ (a b c : α), a ≤ c → b ≤ c → a ⊔ b ≤ c
- inf : α → α → α
- inf_le_left : ∀ (a b : α), a ⊓ b ≤ a
- inf_le_right : ∀ (a b : α), a ⊓ b ≤ b
- le_inf : ∀ (a b c : α), a ≤ b → a ≤ c → a ≤ b ⊓ c
- le_sup_inf : ∀ (x y z : α), (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ y ⊓ z
- sdiff : α → α → α
- bot : α
- sup_inf_sdiff : ∀ (a b : α), a ⊓ b ⊔ a \ b = a
- inf_inf_sdiff : ∀ (a b : α), a ⊓ b ⊓ a \ b = ⊥
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) = 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
) α
.
Equations
- pi.generalized_boolean_algebra = {sup := λ (ᾰ ᾰ_1 : α → β) (i : α), generalized_boolean_algebra.sup (ᾰ i) (ᾰ_1 i), le := partial_order.le pi.partial_order, lt := partial_order.lt pi.partial_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := λ (ᾰ ᾰ_1 : α → β) (i : α), generalized_boolean_algebra.inf (ᾰ i) (ᾰ_1 i), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := λ (ᾰ ᾰ_1 : α → β) (i : α), generalized_boolean_algebra.sdiff (ᾰ i) (ᾰ_1 i), bot := λ (i : α), generalized_boolean_algebra.bot, sup_inf_sdiff := _, inf_inf_sdiff := _}
Boolean algebras #
- compl : α → α
Set / lattice complement
- sup : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
- le_trans : ∀ (a b c : α), a ≤ b → b ≤ c → a ≤ c
- lt_iff_le_not_le : (∀ (a b : α), a < b ↔ a ≤ b ∧ ¬b ≤ a) . "order_laws_tac"
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- le_sup_left : ∀ (a b : α), a ≤ a ⊔ b
- le_sup_right : ∀ (a b : α), b ≤ a ⊔ b
- sup_le : ∀ (a b c : α), a ≤ c → b ≤ c → a ⊔ b ≤ c
- inf : α → α → α
- inf_le_left : ∀ (a b : α), a ⊓ b ≤ a
- inf_le_right : ∀ (a b : α), a ⊓ b ≤ b
- le_inf : ∀ (a b c : α), a ≤ b → a ≤ c → a ≤ b ⊓ c
- le_sup_inf : ∀ (x y z : α), (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ y ⊓ z
- compl : α → α
- top : α
- bot : α
- inf_compl_le_bot : ∀ (x : α), x ⊓ xᶜ ≤ ⊥
- top_le_sup_compl : ∀ (x : α), ⊤ ≤ x ⊔ xᶜ
- le_top : ∀ (a : α), a ≤ ⊤
- bot_le : ∀ (a : α), ⊥ ≤ a
This class contains the core axioms of a Boolean algebra. The boolean_algebra
class extends
both this class and generalized_boolean_algebra
, see Note [forgetful inheritance].
Since bounded_order
, order_bot
, and order_top
are mixins that require has_le
to be present at define-time, the extends
mechanism does not work with them.
Instead, we extend using the underlying has_bot
and has_top
data typeclasses, and replicate the
order axioms of those classes here. A "forgetful" instance back to bounded_order
is provided.
Instances
Equations
- boolean_algebra.core.to_bounded_order = {top := boolean_algebra.core.top h, le_top := _, bot := boolean_algebra.core.bot h, bot_le := _}
- sup : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
- le_trans : ∀ (a b c : α), a ≤ b → b ≤ c → a ≤ c
- lt_iff_le_not_le : (∀ (a b : α), a < b ↔ a ≤ b ∧ ¬b ≤ a) . "order_laws_tac"
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- le_sup_left : ∀ (a b : α), a ≤ a ⊔ b
- le_sup_right : ∀ (a b : α), b ≤ a ⊔ b
- sup_le : ∀ (a b c : α), a ≤ c → b ≤ c → a ⊔ b ≤ c
- inf : α → α → α
- inf_le_left : ∀ (a b : α), a ⊓ b ≤ a
- inf_le_right : ∀ (a b : α), a ⊓ b ≤ b
- le_inf : ∀ (a b c : α), a ≤ b → a ≤ c → a ≤ b ⊓ c
- le_sup_inf : ∀ (x y z : α), (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ y ⊓ z
- sdiff : α → α → α
- bot : α
- sup_inf_sdiff : ∀ (a b : α), a ⊓ b ⊔ a \ b = a
- inf_inf_sdiff : ∀ (a b : α), a ⊓ b ⊓ a \ b = ⊥
- compl : α → α
- top : α
- inf_compl_le_bot : ∀ (x : α), x ⊓ xᶜ ≤ ⊥
- top_le_sup_compl : ∀ (x : α), ⊤ ≤ x ⊔ xᶜ
- le_top : ∀ (a : α), a ≤ ⊤
- bot_le : ∀ (a : α), ⊥ ≤ a
- sdiff_eq : ∀ (x y : α), x \ y = x ⊓ yᶜ
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 \
satisfying x \ y = x ⊓ yᶜ
.
This is a generalization of (classical) logic of propositions, or the powerset lattice.
Create a has_sdiff
instance from a boolean_algebra.core
instance, defining x \ y
to
be x ⊓ yᶜ
.
For some types, it may be more convenient to create the boolean_algebra
instance by hand in order
to have a simpler sdiff
operation.
See note [reducible non-instances].
Create a boolean_algebra
instance from a boolean_algebra.core
instance, defining x \ y
to
be x ⊓ yᶜ
.
For some types, it may be more convenient to create the boolean_algebra
instance by hand in order
to have a simpler sdiff
operation.
Equations
- boolean_algebra.of_core B = {sup := boolean_algebra.core.sup B, le := boolean_algebra.core.le B, lt := boolean_algebra.core.lt B, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := boolean_algebra.core.inf B, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := λ (x y : α), x ⊓ yᶜ, bot := boolean_algebra.core.bot B, sup_inf_sdiff := _, inf_inf_sdiff := _, compl := boolean_algebra.core.compl B, top := boolean_algebra.core.top B, inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _, sdiff_eq := _}
Equations
- order_dual.boolean_algebra = boolean_algebra.of_core {sup := distrib_lattice.sup (order_dual.distrib_lattice α), le := distrib_lattice.le (order_dual.distrib_lattice α), lt := distrib_lattice.lt (order_dual.distrib_lattice α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := distrib_lattice.inf (order_dual.distrib_lattice α), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, compl := λ (a : order_dual α), ⇑order_dual.to_dual (⇑order_dual.of_dual a)ᶜ, top := bounded_order.top (order_dual.bounded_order α), bot := bounded_order.bot (order_dual.bounded_order α), inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _}
Equations
- Prop.boolean_algebra = boolean_algebra.of_core {sup := distrib_lattice.sup Prop.distrib_lattice, le := distrib_lattice.le Prop.distrib_lattice, lt := distrib_lattice.lt Prop.distrib_lattice, le_refl := Prop.boolean_algebra._proof_1, le_trans := Prop.boolean_algebra._proof_2, lt_iff_le_not_le := Prop.boolean_algebra._proof_3, le_antisymm := Prop.boolean_algebra._proof_4, le_sup_left := Prop.boolean_algebra._proof_5, le_sup_right := Prop.boolean_algebra._proof_6, sup_le := Prop.boolean_algebra._proof_7, inf := distrib_lattice.inf Prop.distrib_lattice, inf_le_left := Prop.boolean_algebra._proof_8, inf_le_right := Prop.boolean_algebra._proof_9, le_inf := Prop.boolean_algebra._proof_10, le_sup_inf := Prop.boolean_algebra._proof_11, compl := not, top := bounded_order.top Prop.bounded_order, bot := bounded_order.bot Prop.bounded_order, inf_compl_le_bot := Prop.boolean_algebra._proof_12, top_le_sup_compl := Prop.boolean_algebra._proof_13, le_top := Prop.boolean_algebra._proof_14, bot_le := Prop.boolean_algebra._proof_15}
Equations
- pi.has_sdiff = {sdiff := λ (x y : Π (i : ι), α i) (i : ι), x i \ y i}
Equations
- pi.has_compl = {compl := λ (x : Π (i : ι), α i) (i : ι), (x i)ᶜ}
Equations
- pi.boolean_algebra = {sup := distrib_lattice.sup pi.distrib_lattice, le := distrib_lattice.le pi.distrib_lattice, lt := distrib_lattice.lt pi.distrib_lattice, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := distrib_lattice.inf pi.distrib_lattice, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := sdiff pi.has_sdiff, bot := bounded_order.bot pi.bounded_order, sup_inf_sdiff := _, inf_inf_sdiff := _, compl := compl pi.has_compl, top := bounded_order.top pi.bounded_order, inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _, sdiff_eq := _}
Equations
- bool.boolean_algebra = boolean_algebra.of_core {sup := bor, le := linear_order.le bool.linear_order, lt := linear_order.lt bool.linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := bool.left_le_bor, le_sup_right := bool.right_le_bor, sup_le := bool.boolean_algebra._proof_1, inf := band, inf_le_left := bool.band_le_left, inf_le_right := bool.band_le_right, le_inf := bool.boolean_algebra._proof_2, le_sup_inf := bool.boolean_algebra._proof_3, compl := bnot, top := bounded_order.top bool.bounded_order, bot := bounded_order.bot bool.bounded_order, inf_compl_le_bot := bool.boolean_algebra._proof_4, top_le_sup_compl := bool.boolean_algebra._proof_5, le_top := bool.boolean_algebra._proof_6, bot_le := bool.boolean_algebra._proof_7}
Pullback a generalized_boolean_algebra
along an injection.
Equations
- function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff = {sup := lattice.sup (function.injective.lattice f hf map_sup map_inf), le := lattice.le (function.injective.lattice f hf map_sup map_inf), lt := lattice.lt (function.injective.lattice f hf map_sup map_inf), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := lattice.inf (function.injective.lattice f hf map_sup map_inf), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := sdiff _inst_4, bot := ⊥, sup_inf_sdiff := _, inf_inf_sdiff := _}
Pullback a boolean_algebra
along an injection.
Equations
- function.injective.boolean_algebra f hf map_sup map_inf map_top map_bot map_compl map_sdiff = {sup := generalized_boolean_algebra.sup (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), le := generalized_boolean_algebra.le (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), lt := generalized_boolean_algebra.lt (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := generalized_boolean_algebra.inf (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := generalized_boolean_algebra.sdiff (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), bot := generalized_boolean_algebra.bot (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), sup_inf_sdiff := _, inf_inf_sdiff := _, compl := compl _inst_5, top := ⊤, inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _, sdiff_eq := _}