(Generalized) Boolean algebras #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 #
generalized_boolean_algebra
: a type class for generalized Boolean algebrasboolean_algebra
: a type class for Boolean algebras.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
.
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) = ⊥
, 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
) α
.
Instances of this typeclass
Instances of other typeclasses for generalized_boolean_algebra
- generalized_boolean_algebra.has_sizeof_inst
Equations
- generalized_boolean_algebra.to_generalized_coheyting_algebra = {sup := generalized_boolean_algebra.sup _inst_1, le := generalized_boolean_algebra.le _inst_1, lt := generalized_boolean_algebra.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := generalized_boolean_algebra.inf _inst_1, inf_le_left := _, inf_le_right := _, le_inf := _, bot := generalized_boolean_algebra.bot _inst_1, sdiff := has_sdiff.sdiff (generalized_boolean_algebra.to_has_sdiff α), bot_le := _, sdiff_le_iff := _}
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 #
- 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 : α → α
- sdiff : α → α → α
- himp : α → α → α
- top : α
- bot : α
- 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ᶜ) . "obviously"
- himp_eq : (∀ (x y : α), x ⇨ y = y ⊔ xᶜ) . "obviously"
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 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 of this typeclass
Instances of other typeclasses for boolean_algebra
- boolean_algebra.has_sizeof_inst
Equations
- boolean_algebra.to_bounded_order = {top := boolean_algebra.top h, le_top := _, bot := boolean_algebra.bot h, bot_le := _}
A bounded generalized boolean algebra is a boolean algebra.
Equations
- generalized_boolean_algebra.to_boolean_algebra = {sup := generalized_boolean_algebra.sup _inst_1, le := generalized_boolean_algebra.le _inst_1, lt := generalized_boolean_algebra.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := generalized_boolean_algebra.inf _inst_1, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, compl := λ (a : α), ⊤ \ a, sdiff := generalized_boolean_algebra.sdiff _inst_1, himp := λ (x y : α), y ⊔ xᶜ, top := order_top.top _inst_2, bot := generalized_boolean_algebra.bot _inst_1, inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _, sdiff_eq := _, himp_eq := _}
Equations
- boolean_algebra.to_generalized_boolean_algebra = {sup := boolean_algebra.sup _inst_1, le := boolean_algebra.le _inst_1, lt := boolean_algebra.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := boolean_algebra.inf _inst_1, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := boolean_algebra.sdiff _inst_1, bot := boolean_algebra.bot _inst_1, sup_inf_sdiff := _, inf_inf_sdiff := _}
Equations
- boolean_algebra.to_biheyting_algebra = {sup := boolean_algebra.sup _inst_1, le := boolean_algebra.le _inst_1, lt := boolean_algebra.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := boolean_algebra.inf _inst_1, inf_le_left := _, inf_le_right := _, le_inf := _, top := boolean_algebra.top _inst_1, himp := boolean_algebra.himp _inst_1, le_top := _, le_himp_iff := _, bot := boolean_algebra.bot _inst_1, compl := boolean_algebra.compl _inst_1, bot_le := _, himp_bot := _, sdiff := boolean_algebra.sdiff _inst_1, hnot := has_compl.compl (boolean_algebra.to_has_compl α), sdiff_le_iff := _, top_sdiff := _}
Equations
- order_dual.boolean_algebra = {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.to_dual (⇑order_dual.of_dual a)ᶜ, sdiff := λ (a b : αᵒᵈ), ⇑order_dual.to_dual (⇑order_dual.of_dual b ⇨ ⇑order_dual.of_dual a), himp := λ (a b : αᵒᵈ), ⇑order_dual.to_dual (⇑order_dual.of_dual b \ ⇑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 := _, sdiff_eq := _, himp_eq := _}
Equations
- Prop.boolean_algebra = {sup := heyting_algebra.sup Prop.heyting_algebra, le := heyting_algebra.le Prop.heyting_algebra, lt := heyting_algebra.lt Prop.heyting_algebra, 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 := heyting_algebra.inf Prop.heyting_algebra, 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, sdiff := λ (x y : Prop), x ⊓ yᶜ, himp := heyting_algebra.himp Prop.heyting_algebra, top := heyting_algebra.top Prop.heyting_algebra, bot := heyting_algebra.bot Prop.heyting_algebra, inf_compl_le_bot := Prop.boolean_algebra._proof_23, top_le_sup_compl := Prop.boolean_algebra._proof_24, le_top := Prop.boolean_algebra._proof_25, bot_le := Prop.boolean_algebra._proof_26, sdiff_eq := Prop.boolean_algebra._proof_27, himp_eq := Prop.boolean_algebra._proof_28}
Equations
- pi.boolean_algebra = {sup := heyting_algebra.sup pi.heyting_algebra, le := heyting_algebra.le pi.heyting_algebra, lt := heyting_algebra.lt pi.heyting_algebra, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := heyting_algebra.inf pi.heyting_algebra, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, compl := heyting_algebra.compl pi.heyting_algebra, sdiff := has_sdiff.sdiff pi.has_sdiff, himp := heyting_algebra.himp pi.heyting_algebra, top := heyting_algebra.top pi.heyting_algebra, bot := heyting_algebra.bot pi.heyting_algebra, inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _, sdiff_eq := _, himp_eq := _}
Equations
- bool.boolean_algebra = {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, sdiff := λ (x y : bool), x ⊓ yᶜ, himp := λ (x y : bool), y ⊔ xᶜ, top := bounded_order.top bool.bounded_order, bot := bounded_order.bot bool.bounded_order, inf_compl_le_bot := bool.boolean_algebra._proof_7, top_le_sup_compl := bool.boolean_algebra._proof_8, le_top := bool.boolean_algebra._proof_9, bot_le := bool.boolean_algebra._proof_10, sdiff_eq := bool.boolean_algebra._proof_11, himp_eq := bool.boolean_algebra._proof_12}
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 := generalized_coheyting_algebra.sup (function.injective.generalized_coheyting_algebra f hf map_sup map_inf map_bot map_sdiff), le := generalized_coheyting_algebra.le (function.injective.generalized_coheyting_algebra f hf map_sup map_inf map_bot map_sdiff), lt := generalized_coheyting_algebra.lt (function.injective.generalized_coheyting_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_coheyting_algebra.inf (function.injective.generalized_coheyting_algebra f hf map_sup map_inf map_bot map_sdiff), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _, sdiff := generalized_coheyting_algebra.sdiff (function.injective.generalized_coheyting_algebra f hf map_sup map_inf map_bot map_sdiff), bot := generalized_coheyting_algebra.bot (function.injective.generalized_coheyting_algebra f hf map_sup map_inf map_bot map_sdiff), 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 := _, compl := has_compl.compl _inst_5, sdiff := generalized_boolean_algebra.sdiff (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), himp := λ (x y : α), y ⊔ xᶜ, top := ⊤, bot := generalized_boolean_algebra.bot (function.injective.generalized_boolean_algebra f hf map_sup map_inf map_bot map_sdiff), inf_compl_le_bot := _, top_le_sup_compl := _, le_top := _, bot_le := _, sdiff_eq := _, himp_eq := _}
Equations
- punit.boolean_algebra = {sup := biheyting_algebra.sup punit.biheyting_algebra, le := biheyting_algebra.le punit.biheyting_algebra, lt := biheyting_algebra.lt punit.biheyting_algebra, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := biheyting_algebra.inf punit.biheyting_algebra, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := punit.boolean_algebra._proof_1, compl := biheyting_algebra.compl punit.biheyting_algebra, sdiff := biheyting_algebra.sdiff punit.biheyting_algebra, himp := biheyting_algebra.himp punit.biheyting_algebra, top := biheyting_algebra.top punit.biheyting_algebra, bot := biheyting_algebra.bot punit.biheyting_algebra, inf_compl_le_bot := punit.boolean_algebra._proof_2, top_le_sup_compl := punit.boolean_algebra._proof_3, le_top := _, bot_le := _, sdiff_eq := punit.boolean_algebra._proof_4, himp_eq := punit.boolean_algebra._proof_5}