(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.
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- sup : α → α → α
The binary supremum, used to derive
Max α
- le_sup_left : ∀ (a b : α), a ≤ SemilatticeSup.sup a b
The supremum is an upper bound on the first argument
- le_sup_right : ∀ (a b : α), b ≤ SemilatticeSup.sup a b
The supremum is an upper bound on the second argument
- sup_le : ∀ (a b c : α), a ≤ c → b ≤ c → SemilatticeSup.sup a b ≤ c
The supremum is the least upper bound
Instances
Equations
- SemilatticeSup.toMax = { max := fun (a b : α) => SemilatticeSup.sup a b }
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 (fun (x1 x2 : α) => x1 ⊔ x2) ⋯ ⋯ ⋯
Instances For
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
.
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.
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- inf : α → α → α
The binary infimum, used to derive
Min α
- inf_le_left : ∀ (a b : α), SemilatticeInf.inf a b ≤ a
The infimum is a lower bound on the first argument
- inf_le_right : ∀ (a b : α), SemilatticeInf.inf a b ≤ b
The infimum is a lower bound on the second argument
- le_inf : ∀ (a b c : α), a ≤ b → a ≤ c → a ≤ SemilatticeInf.inf b c
The infimum is the greatest lower bound
Instances
Equations
- SemilatticeInf.toMin = { min := fun (a b : α) => SemilatticeInf.inf a b }
Equations
- OrderDual.instSemilatticeSup α = SemilatticeSup.mk SemilatticeInf.inf ⋯ ⋯ ⋯
Equations
- OrderDual.instSemilatticeInf α = SemilatticeInf.mk max ⋯ ⋯ ⋯
Alias of inf_le_left
.
Alias of inf_le_right
.
Alias of the reverse direction of inf_eq_left
.
Alias of the forward direction of inf_eq_left
.
Alias of the reverse direction of inf_eq_right
.
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.
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- sup : α → α → α
- le_sup_left : ∀ (a b : α), a ≤ SemilatticeSup.sup a b
- le_sup_right : ∀ (a b : α), b ≤ SemilatticeSup.sup a b
- sup_le : ∀ (a b c : α), a ≤ c → b ≤ c → SemilatticeSup.sup a b ≤ c
- inf : α → α → α
- inf_le_left : ∀ (a b : α), Lattice.inf a b ≤ a
- inf_le_right : ∀ (a b : α), Lattice.inf a b ≤ b
- le_inf : ∀ (a b c : α), a ≤ b → a ≤ c → a ≤ Lattice.inf b c
Instances
Equations
- OrderDual.instLattice α = Lattice.mk SemilatticeInf.inf ⋯ ⋯ ⋯
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 SemilatticeInf.inf ⋯ ⋯ ⋯
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.
- le_antisymm : ∀ (a b : α), a ≤ b → b ≤ a → a = b
- sup : α → α → α
- le_sup_left : ∀ (a b : α), a ≤ SemilatticeSup.sup a b
- le_sup_right : ∀ (a b : α), b ≤ SemilatticeSup.sup a b
- sup_le : ∀ (a b c : α), a ≤ c → b ≤ c → SemilatticeSup.sup a b ≤ c
- inf : α → α → α
- inf_le_left : ∀ (a b : α), Lattice.inf a b ≤ a
- inf_le_right : ∀ (a b : α), Lattice.inf a b ≤ b
- le_inf : ∀ (a b c : α), a ≤ b → a ≤ c → a ≤ Lattice.inf b c
The infimum distributes over the supremum
Instances
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 min ⋯ ⋯ ⋯
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 (fun (x x_1 : (i : ι) → α' i) (x_2 : ι) => x x_2 ⊔ x_1 x_2) ⋯ ⋯ ⋯
Equations
- Pi.instSemilatticeInf = SemilatticeInf.mk (fun (x x_1 : (i : ι) → α' i) (x_2 : ι) => x x_2 ⊓ x_1 x_2) ⋯ ⋯ ⋯
Equations
- Pi.instLattice = Lattice.mk SemilatticeInf.inf ⋯ ⋯ ⋯
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 (fun (a b : α × β) => (a.fst ⊔ b.fst, a.snd ⊔ b.snd)) ⋯ ⋯ ⋯
Equations
- Prod.instSemilatticeInf α β = SemilatticeInf.mk (fun (a b : α × β) => (a.fst ⊓ b.fst, a.snd ⊓ b.snd)) ⋯ ⋯ ⋯
Equations
- Prod.instLattice α β = Lattice.mk SemilatticeInf.inf ⋯ ⋯ ⋯
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 (fun (x y : { x : α // P x }) => ⟨↑x ⊔ ↑y, ⋯⟩) ⋯ ⋯ ⋯
Instances For
A subtype forms a ⊓
-semilattice if ⊓
preserves the property.
See note [reducible non-instances].
Equations
- Subtype.semilatticeInf Pinf = SemilatticeInf.mk (fun (x y : { x : α // P x }) => ⟨↑x ⊓ ↑y, ⋯⟩) ⋯ ⋯ ⋯
Instances For
A subtype forms a lattice if ⊔
and ⊓
preserve the property.
See note [reducible non-instances].
Equations
- Subtype.lattice Psup Pinf = Lattice.mk SemilatticeInf.inf ⋯ ⋯ ⋯
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 (fun (a b : α) => a ⊔ b) ⋯ ⋯ ⋯
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 (fun (a b : α) => a ⊓ b) ⋯ ⋯ ⋯
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 SemilatticeInf.inf ⋯ ⋯ ⋯
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