(Semi-)lattices #
Semilattices are partially ordered sets with join (greatest lower bound, or sup
) or
meet (least upper bound, or inf
) operations. Lattices are posets that are both
join-semilattices and meet-semilattices.
Distributive lattices are lattices which satisfy any of four equivalent distributivity properties,
of sup
over inf
, on the left or on the right.
Main declarations #
-
has_sup
: type class for the⊔
notation -
has_inf
: type class for the⊓
notation -
semilattice_sup
: a type class for join semilattices -
semilattice_sup.mk'
: an alternative constructor forsemilattice_sup
via proofs that⊔
is commutative, associative and idempotent. -
semilattice_inf
: a type class for meet semilattices -
semilattice_sup.mk'
: an alternative constructor forsemilattice_inf
via proofs that⊓
is commutative, associative and idempotent. -
lattice
: a type class for lattices -
lattice.mk'
: an alternative constructor forlattice
via profs that⊔
and⊓
are commutative, associative and satisfy a pair of "absorption laws". -
distrib_lattice
: a type class for distributive lattices.
Notations #
a ⊔ b
: the supremum or join ofa
andb
a ⊓ b
: the infimum or meet ofa
andb
TODO #
- (Semi-)lattice homomorphisms
- Alternative constructors for distributive lattices from the other distributive properties
Tags #
semilattice, lattice
- sup : α → α → α
Typeclass for the ⊔
(\lub
) notation
- inf : α → α → α
Typeclass for the ⊓
(\glb
) notation
Join-semilattices #
- 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
A semilattice_sup
is a join-semilattice, that is, a partial order
with a join (a.k.a. lub / least upper bound, sup / supremum) operation
⊔
which is the least element larger than both factors.
Instances
- lattice.to_semilattice_sup
- canonically_linear_ordered_monoid.semilattice_sup
- canonically_linear_ordered_add_monoid.semilattice_sup
- order_dual.semilattice_sup
- pi.semilattice_sup
- prod.semilattice_sup
- with_bot.semilattice_sup
- with_top.semilattice_sup
- nat.subtype.semilattice_sup
- rat.semilattice_sup
- real.semilattice_sup
- set.Ioc.semilattice_sup
- set.Iio.set.Ioi.semilattice_sup
- set.Iic.semilattice_sup
- set.Ici.semilattice_sup
- set.Icc.semilattice_sup
- enat.semilattice_sup
- order_hom.semilattice_sup
A type with a commutative, associative and idempotent binary sup
operation has the structure of a
join-semilattice.
The partial order is defined so that a ≤ b
unfolds to a ⊔ b = b
; cf. sup_eq_right
.
Equations
- semilattice_sup.mk' sup_comm sup_assoc sup_idem = {sup := has_sup.sup _inst_1, le := λ (a b : α), a ⊔ b = b, lt := partial_order.lt._default (λ (a b : α), a ⊔ b = b), le_refl := sup_idem, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _}
Equations
- order_dual.has_sup α = {sup := has_inf.inf _inst_1}
Equations
- order_dual.has_inf α = {inf := has_sup.sup _inst_1}
If f
is monotone, g
is antitone, and f ≤ g
, then for all a
, b
we have f a ≤ g b
.
Meet-semilattices #
- inf : α → α → α
- 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
- 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
A semilattice_inf
is a meet-semilattice, that is, a partial order
with a meet (a.k.a. glb / greatest lower bound, inf / infimum) operation
⊓
which is the greatest element smaller than both factors.
Instances
- lattice.to_semilattice_inf
- order_dual.semilattice_inf
- pi.semilattice_inf
- prod.semilattice_inf
- with_bot.semilattice_inf
- with_top.semilattice_inf
- rat.semilattice_inf
- real.semilattice_inf
- set.Ico.semilattice_inf
- set.Iio.semilattice_inf
- set.Iic.semilattice_inf
- set.Ici.semilattice_inf
- set.Icc.semilattice_inf
- order_hom.semilattice_inf
- nonneg.semilattice_inf
- nnreal.semilattice_inf
Equations
- order_dual.semilattice_sup α = {sup := has_sup.sup (order_dual.has_sup α), le := partial_order.le (order_dual.partial_order α), lt := partial_order.lt (order_dual.partial_order α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _}
Equations
- order_dual.semilattice_inf α = {inf := has_inf.inf (order_dual.has_inf α), le := partial_order.le (order_dual.partial_order α), lt := partial_order.lt (order_dual.partial_order α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, inf_le_left := _, inf_le_right := _, le_inf := _}
A type with a commutative, associative and idempotent binary inf
operation has the structure of a
meet-semilattice.
The partial order is defined so that a ≤ b
unfolds to b ⊓ a = a
; cf. inf_eq_right
.
Equations
- semilattice_inf.mk' inf_comm inf_assoc inf_idem = order_dual.semilattice_inf (order_dual α)
Lattices #
- 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
A lattice is a join-semilattice which is also a meet-semilattice.
Instances
- distrib_lattice.to_lattice
- lattice_of_linear_order
- complete_lattice.to_lattice
- conditionally_complete_lattice.to_lattice
- order_dual.lattice
- pi.lattice
- prod.lattice
- with_bot.lattice
- with_top.lattice
- with_zero.lattice
- multiset.lattice
- fin.lattice
- finset.lattice
- rat.lattice
- real.lattice
- set.Iic.lattice
- set.Ici.lattice
- set.Icc.lattice
- enat.lattice
- nat.lattice
- order_hom.lattice
Equations
- order_dual.lattice α = {sup := semilattice_sup.sup (order_dual.semilattice_sup α), le := semilattice_sup.le (order_dual.semilattice_sup α), lt := semilattice_sup.lt (order_dual.semilattice_sup α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := semilattice_inf.inf (order_dual.semilattice_inf α), inf_le_left := _, inf_le_right := _, le_inf := _}
The partial orders from semilattice_sup_mk'
and semilattice_inf_mk'
agree
if sup
and inf
satisfy the lattice absorption laws sup_inf_self
(a ⊔ a ⊓ b = a
)
and inf_sup_self
(a ⊓ (a ⊔ b) = a
).
A type with a pair of commutative and associative binary operations which satisfy two absorption laws relating the two operations has the structure of a lattice.
The partial order is defined so that a ≤ b
unfolds to a ⊔ b = b
; cf. sup_eq_right
.
Equations
- lattice.mk' sup_comm sup_assoc inf_comm inf_assoc sup_inf_self inf_sup_self = have sup_idem : ∀ (b : α), b ⊔ b = b, from _, have inf_idem : ∀ (b : α), b ⊓ b = b, from _, let semilatt_inf_inst : semilattice_inf α := semilattice_inf.mk' inf_comm inf_assoc inf_idem, semilatt_sup_inst : semilattice_sup α := semilattice_sup.mk' sup_comm sup_assoc sup_idem, partial_order_inst : partial_order α := semilattice_sup.to_partial_order α in have partial_order_eq : partial_order_inst = semilattice_inf.to_partial_order α, from _, {sup := semilattice_sup.sup semilatt_sup_inst, le := partial_order.le partial_order_inst, lt := partial_order.lt partial_order_inst, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := semilattice_inf.inf semilatt_inf_inst, inf_le_left := _, inf_le_right := _, le_inf := _}
Distributivity laws #
Distributive lattices #
- 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
A distributive lattice is a lattice that satisfies any of four
equivalent distributive properties (of sup
over inf
or inf
over sup
,
on the left or right).
The definition here chooses le_sup_inf
: (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ (y ⊓ z)
.
A classic example of a distributive lattice is the lattice of subsets of a set, and in fact this example is generic in the sense that every distributive lattice is realizable as a sublattice of a powerset lattice.
Instances
- distrib_lattice_of_linear_order
- generalized_boolean_algebra.to_distrib_lattice
- boolean_algebra.core.to_distrib_lattice
- complete_distrib_lattice.to_distrib_lattice
- order_dual.distrib_lattice
- nat.distrib_lattice
- pi.distrib_lattice
- prod.distrib_lattice
- Prop.distrib_lattice
- multiset.distrib_lattice
- finset.distrib_lattice
- rat.distrib_lattice
- real.distrib_lattice
Equations
- order_dual.distrib_lattice α = {sup := lattice.sup (order_dual.lattice α), le := lattice.le (order_dual.lattice α), lt := lattice.lt (order_dual.lattice α), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := lattice.inf (order_dual.lattice α), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _}
Lattices derived from linear orders #
Equations
- lattice_of_linear_order = {sup := max o, le := linear_order.le o, lt := linear_order.lt o, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := min o, inf_le_left := _, inf_le_right := _, le_inf := _}
A lattice with total order is a linear order.
See note [reducible non-instances].
Equations
- lattice.to_linear_order α h = {le := lattice.le _inst_1, lt := lattice.lt _inst_1, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_total := h, decidable_le := _inst_3, decidable_eq := _inst_2, decidable_lt := _inst_4, max := has_sup.sup (semilattice_sup.to_has_sup α), max_def := _, min := has_inf.inf (semilattice_inf.to_has_inf α), min_def := _}
Equations
- distrib_lattice_of_linear_order = {sup := lattice.sup lattice_of_linear_order, le := lattice.le lattice_of_linear_order, lt := lattice.lt lattice_of_linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := lattice.inf lattice_of_linear_order, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _}
Function lattices #
Equations
- pi.has_sup = {sup := λ (f g : Π (i : ι), α' i) (i : ι), f i ⊔ g i}
Equations
- pi.has_inf = {inf := λ (f g : Π (i : ι), α' i) (i : ι), f i ⊓ g i}
Equations
- pi.semilattice_sup = {sup := has_sup.sup pi.has_sup, 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 := _}
Equations
- pi.semilattice_inf = {inf := has_inf.inf pi.has_inf, 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 := _, inf_le_left := _, inf_le_right := _, le_inf := _}
Equations
- pi.lattice = {sup := semilattice_sup.sup pi.semilattice_sup, le := semilattice_sup.le pi.semilattice_sup, lt := semilattice_sup.lt pi.semilattice_sup, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := semilattice_inf.inf pi.semilattice_inf, inf_le_left := _, inf_le_right := _, le_inf := _}
Equations
- pi.distrib_lattice = {sup := lattice.sup pi.lattice, le := lattice.le pi.lattice, lt := lattice.lt pi.lattice, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := lattice.inf pi.lattice, inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _}
Monotone functions and lattices #
Pointwise supremum of two monotone functions is a monotone function.
Pointwise infimum of two monotone functions is a monotone function.
Pointwise maximum of two monotone functions is a monotone function.
Pointwise minimum of two monotone functions is a monotone function.
Products of (semi-)lattices #
Equations
- prod.semilattice_sup α β = {sup := has_sup.sup (prod.has_sup α β), le := partial_order.le (prod.partial_order α β), lt := partial_order.lt (prod.partial_order α β), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _}
Equations
- prod.semilattice_inf α β = {inf := has_inf.inf (prod.has_inf α β), le := partial_order.le (prod.partial_order α β), lt := partial_order.lt (prod.partial_order α β), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, inf_le_left := _, inf_le_right := _, le_inf := _}
Equations
- prod.lattice α β = {sup := semilattice_sup.sup (prod.semilattice_sup α β), le := semilattice_inf.le (prod.semilattice_inf α β), lt := semilattice_inf.lt (prod.semilattice_inf α β), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := semilattice_inf.inf (prod.semilattice_inf α β), inf_le_left := _, inf_le_right := _, le_inf := _}
Equations
- prod.distrib_lattice α β = {sup := lattice.sup (prod.lattice α β), le := lattice.le (prod.lattice α β), lt := lattice.lt (prod.lattice α β), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := lattice.inf (prod.lattice α β), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _}
Subtypes of (semi-)lattices #
A subtype forms a ⊔
-semilattice if ⊔
preserves the property.
See note [reducible non-instances].
Equations
- subtype.semilattice_sup Psup = {sup := λ (x y : {x // P x}), ⟨x.val ⊔ y.val, _⟩, le := partial_order.le (subtype.partial_order P), lt := partial_order.lt (subtype.partial_order P), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _}
A subtype forms a ⊓
-semilattice if ⊓
preserves the property.
See note [reducible non-instances].
Equations
- subtype.semilattice_inf Pinf = {inf := λ (x y : {x // P x}), ⟨x.val ⊓ y.val, _⟩, le := partial_order.le (subtype.partial_order P), lt := partial_order.lt (subtype.partial_order P), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, inf_le_left := _, inf_le_right := _, le_inf := _}
A subtype forms a lattice if ⊔
and ⊓
preserve the property.
See note [reducible non-instances].
Equations
- subtype.lattice Psup Pinf = {sup := semilattice_sup.sup (subtype.semilattice_sup Psup), le := semilattice_inf.le (subtype.semilattice_inf Pinf), lt := semilattice_inf.lt (subtype.semilattice_inf Pinf), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := semilattice_inf.inf (subtype.semilattice_inf Pinf), inf_le_left := _, inf_le_right := _, le_inf := _}
A type endowed with ⊔
is a semilattice_sup
, if it admits an injective map that
preserves ⊔
to a semilattice_sup
.
See note [reducible non-instances].
Equations
- function.injective.semilattice_sup f hf_inj map_sup = {sup := has_sup.sup _inst_1, le := partial_order.le (partial_order.lift f hf_inj), lt := partial_order.lt (partial_order.lift f hf_inj), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _}
A type endowed with ⊓
is a semilattice_inf
, if it admits an injective map that
preserves ⊓
to a semilattice_inf
.
See note [reducible non-instances].
Equations
- function.injective.semilattice_inf f hf_inj map_inf = {inf := has_inf.inf _inst_1, le := partial_order.le (partial_order.lift f hf_inj), lt := partial_order.lt (partial_order.lift f hf_inj), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, inf_le_left := _, inf_le_right := _, le_inf := _}
A type endowed with ⊔
and ⊓
is a lattice
, if it admits an injective map that
preserves ⊔
and ⊓
to a lattice
.
See note [reducible non-instances].
Equations
- function.injective.lattice f hf_inj map_sup map_inf = {sup := semilattice_sup.sup (function.injective.semilattice_sup f hf_inj map_sup), le := semilattice_sup.le (function.injective.semilattice_sup f hf_inj map_sup), lt := semilattice_sup.lt (function.injective.semilattice_sup f hf_inj map_sup), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := semilattice_inf.inf (function.injective.semilattice_inf f hf_inj map_inf), inf_le_left := _, inf_le_right := _, le_inf := _}
A type endowed with ⊔
and ⊓
is a distrib_lattice
, if it admits an injective map that
preserves ⊔
and ⊓
to a distrib_lattice
.
See note [reducible non-instances].
Equations
- function.injective.distrib_lattice f hf_inj map_sup map_inf = {sup := lattice.sup (function.injective.lattice f hf_inj map_sup map_inf), le := lattice.le (function.injective.lattice f hf_inj map_sup map_inf), lt := lattice.lt (function.injective.lattice f hf_inj 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_inj map_sup map_inf), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _}