(Semi-)lattices #
Semilattices are partially ordered sets with join (least upper bound, or sup
) or meet (greatest
lower 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 #
SemilatticeSup
: a type class for join semilatticesSemilatticeSup.mk'
: an alternative constructor forSemilatticeSup
via proofs that⊔
is commutative, associative and idempotent.SemilatticeInf
: a type class for meet semilatticesSemilatticeSup.mk'
: an alternative constructor forSemilatticeInf
via proofs that⊓
is commutative, associative and idempotent.Lattice
: a type class for latticesLattice.mk'
: an alternative constructor forLattice
via proofs that⊔
and⊓
are commutative, associative and satisfy a pair of "absorption laws".DistribLattice
: 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
See if the term is a ⊂ b
and the goal is a ⊆ b
.
Equations
- exactSubsetOfSSubset = { eval := fun (h : Lean.Expr) (goal : Lean.MVarId) => do let __do_lift ← Lean.Meta.mkAppM `subset_of_ssubset #[h] goal.assignIfDefeq __do_lift }
Instances For
Join-semilattices #
A SemilatticeSup
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.
- sup : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
The supremum is an upper bound on the first argument
The supremum is an upper bound on the second argument
The supremum is the least upper bound
Instances
The supremum is an upper bound on the first argument
The supremum is an upper bound on the second argument
The supremum is the least upper bound
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
- SemilatticeSup.mk' sup_comm sup_assoc sup_idem = SemilatticeSup.mk ⋯ ⋯ ⋯
Instances For
Equations
- OrderDual.instSup α = { sup := fun (x1 x2 : α) => x1 ⊓ x2 }
Equations
- OrderDual.instInf α = { inf := fun (x1 x2 : α) => x1 ⊔ x2 }
Alias of le_sup_left
.
Alias of le_sup_right
.
Alias of the reverse direction of sup_eq_left
.
Alias of the reverse direction of sup_eq_right
.
Alias of the forward direction of sup_eq_right
.
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
If f
is monotone, g
is antitone, and f ≤ g
, then for all a
, b
we have f a ≤ g b
.
Meet-semilattices #
A SemilatticeInf
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.
- inf : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
The infimum is a lower bound on the first argument
The infimum is a lower bound on the second argument
The infimum is the greatest lower bound
Instances
The infimum is a lower bound on the first argument
The infimum is a lower bound on the second argument
The infimum is the greatest lower bound
Equations
Equations
Alias of inf_le_left
.
Alias of inf_le_right
.
Alias of the forward direction of inf_eq_left
.
Alias of the reverse direction of inf_eq_left
.
Alias of the reverse direction of inf_eq_right
.
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
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
- SemilatticeInf.mk' inf_comm inf_assoc inf_idem = OrderDual.instSemilatticeInf αᵒᵈ
Instances For
Lattices #
A lattice is a join-semilattice which is also a meet-semilattice.
- sup : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
- inf : α → α → α
The infimum is a lower bound on the first argument
The infimum is a lower bound on the second argument
The infimum is the greatest lower bound
Instances
Equations
- OrderDual.instLattice α = Lattice.mk ⋯ ⋯ ⋯
The partial orders from SemilatticeSup_mk'
and SemilatticeInf_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 = Lattice.mk ⋯ ⋯ ⋯
Instances For
Distributivity laws #
Distributive lattices #
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)
. To prove distributivity
from the dual law, use DistribLattice.of_inf_sup_le
.
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.
- sup : α → α → α
- le : α → α → Prop
- lt : α → α → Prop
- le_refl : ∀ (a : α), a ≤ a
- inf : α → α → α
The infimum distributes over the supremum
Instances
The infimum distributes over the supremum
Equations
Prove distributivity of an existing lattice from the dual distributive law.
Equations
- DistribLattice.ofInfSupLe inf_sup_le = DistribLattice.mk ⋯
Instances For
Lattices derived from linear orders #
Equations
- LinearOrder.toLattice = Lattice.mk ⋯ ⋯ ⋯
A lattice with total order is a linear order.
See note [reducible non-instances].
Equations
- Lattice.toLinearOrder α = LinearOrder.mk ⋯ inst✝¹ inst✝² inst✝ ⋯ ⋯ ⋯
Instances For
Equations
- instDistribLatticeOfLinearOrder = DistribLattice.mk ⋯
Equations
- instDistribLatticeNat = inferInstance
Dual order #
Function lattices #
Equations
- Pi.instSemilatticeSup = SemilatticeSup.mk ⋯ ⋯ ⋯
Equations
- Pi.instSemilatticeInf = SemilatticeInf.mk ⋯ ⋯ ⋯
Equations
- Pi.instLattice = Lattice.mk ⋯ ⋯ ⋯
Equations
- Pi.instDistribLattice = DistribLattice.mk ⋯
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.
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.
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.
Pointwise supremum of two antitone functions is an antitone function.
Pointwise infimum of two antitone functions is an antitone function.
Pointwise maximum of two antitone functions is an antitone function.
Pointwise minimum of two antitone functions is an antitone function.
Products of (semi-)lattices #
Equations
- Prod.instSemilatticeSup α β = SemilatticeSup.mk ⋯ ⋯ ⋯
Equations
- Prod.instSemilatticeInf α β = SemilatticeInf.mk ⋯ ⋯ ⋯
Equations
- Prod.instLattice α β = Lattice.mk ⋯ ⋯ ⋯
Equations
Subtypes of (semi-)lattices #
A subtype forms a ⊔
-semilattice if ⊔
preserves the property.
See note [reducible non-instances].
Equations
- Subtype.semilatticeSup Psup = SemilatticeSup.mk ⋯ ⋯ ⋯
Instances For
A subtype forms a ⊓
-semilattice if ⊓
preserves the property.
See note [reducible non-instances].
Equations
- Subtype.semilatticeInf Pinf = SemilatticeInf.mk ⋯ ⋯ ⋯
Instances For
A subtype forms a lattice if ⊔
and ⊓
preserve the property.
See note [reducible non-instances].
Equations
- Subtype.lattice Psup Pinf = Lattice.mk ⋯ ⋯ ⋯
Instances For
A type endowed with ⊔
is a SemilatticeSup
, if it admits an injective map that
preserves ⊔
to a SemilatticeSup
.
See note [reducible non-instances].
Equations
- Function.Injective.semilatticeSup f hf_inj map_sup = SemilatticeSup.mk ⋯ ⋯ ⋯
Instances For
A type endowed with ⊓
is a SemilatticeInf
, if it admits an injective map that
preserves ⊓
to a SemilatticeInf
.
See note [reducible non-instances].
Equations
- Function.Injective.semilatticeInf f hf_inj map_inf = SemilatticeInf.mk ⋯ ⋯ ⋯
Instances For
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 = Lattice.mk ⋯ ⋯ ⋯
Instances For
A type endowed with ⊔
and ⊓
is a DistribLattice
, if it admits an injective map that
preserves ⊔
and ⊓
to a DistribLattice
.
See note [reducible non-instances].
Equations
- Function.Injective.distribLattice f hf_inj map_sup map_inf = DistribLattice.mk ⋯
Instances For
Equations
- ULift.instSemilatticeSup = Function.Injective.semilatticeSup ULift.down ⋯ ⋯
Equations
- ULift.instSemilatticeInf = Function.Injective.semilatticeInf ULift.down ⋯ ⋯
Equations
- ULift.instLattice = Function.Injective.lattice ULift.down ⋯ ⋯ ⋯
Equations
- ULift.instDistribLattice = Function.Injective.distribLattice ULift.down ⋯ ⋯ ⋯
Equations
- ULift.instLinearOrder = LinearOrder.liftWithOrd ULift.down ⋯ ⋯ ⋯ ⋯
Equations
- Bool.instDistribLattice = inferInstance