state
stringlengths
0
159k
srcUpToTactic
stringlengths
387
167k
nextTactic
stringlengths
3
9k
declUpToTactic
stringlengths
22
11.5k
declId
stringlengths
38
95
decl
stringlengths
16
1.89k
file_tag
stringlengths
17
73
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝ : Sup Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) sup_idem : βˆ€ (a : Ξ±), a βŠ” a = a a b c : Ξ± hac : a ≀ c hbc : b ≀ c ⊒ a βŠ” b ≀ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by
show (a βŠ” b) βŠ” c = c
/-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by
Mathlib.Order.Lattice.80_0.wE3igZl9MFbJBfv
/-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝ : Sup Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) sup_idem : βˆ€ (a : Ξ±), a βŠ” a = a a b c : Ξ± hac : a ≀ c hbc : b ≀ c ⊒ a βŠ” b βŠ” c = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c
rwa [sup_assoc, hbc]
/-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c
Mathlib.Order.Lattice.80_0.wE3igZl9MFbJBfv
/-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” b ≀ a ∧ a ≀ a βŠ” b ↔ b ≀ a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by
simp [le_rfl]
@[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by
Mathlib.Order.Lattice.164_0.wE3igZl9MFbJBfv
@[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” b ≀ b ∧ b ≀ a βŠ” b ↔ a ≀ b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by
simp [le_rfl]
@[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by
Mathlib.Order.Lattice.169_0.wE3igZl9MFbJBfv
@[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a ≀ b ↔ βˆƒ c, b = a βŠ” c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by
constructor
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by
Mathlib.Order.Lattice.207_0.wE3igZl9MFbJBfv
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c
Mathlib_Order_Lattice
case mp Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a ≀ b β†’ βˆƒ c, b = a βŠ” c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β·
intro h
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β·
Mathlib.Order.Lattice.207_0.wE3igZl9MFbJBfv
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c
Mathlib_Order_Lattice
case mp Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± h : a ≀ b ⊒ βˆƒ c, b = a βŠ” c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h
exact ⟨b, (sup_eq_right.mpr h).symm⟩
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h
Mathlib.Order.Lattice.207_0.wE3igZl9MFbJBfv
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c
Mathlib_Order_Lattice
case mpr Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ (βˆƒ c, b = a βŠ” c) β†’ a ≀ b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β·
rintro ⟨c, rfl : _ = _ βŠ” _⟩
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β·
Mathlib.Order.Lattice.207_0.wE3igZl9MFbJBfv
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c
Mathlib_Order_Lattice
case mpr.intro Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a c✝ d c : Ξ± ⊒ a ≀ a βŠ” c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩
exact le_sup_left
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩
Mathlib.Order.Lattice.207_0.wE3igZl9MFbJBfv
theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” a = a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by
simp
theorem sup_idem : a βŠ” a = a := by
Mathlib.Order.Lattice.231_0.wE3igZl9MFbJBfv
theorem sup_idem : a βŠ” a = a
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” b = b βŠ” a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by
apply le_antisymm
theorem sup_comm : a βŠ” b = b βŠ” a := by
Mathlib.Order.Lattice.237_0.wE3igZl9MFbJBfv
theorem sup_comm : a βŠ” b = b βŠ” a
Mathlib_Order_Lattice
case a Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” b ≀ b βŠ” a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;>
simp
theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;>
Mathlib.Order.Lattice.237_0.wE3igZl9MFbJBfv
theorem sup_comm : a βŠ” b = b βŠ” a
Mathlib_Order_Lattice
case a Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ b βŠ” a ≀ a βŠ” b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;>
simp
theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;>
Mathlib.Order.Lattice.237_0.wE3igZl9MFbJBfv
theorem sup_comm : a βŠ” b = b βŠ” a
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d x : Ξ± ⊒ a βŠ” b βŠ” c ≀ x ↔ a βŠ” (b βŠ” c) ≀ x
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by
simp only [sup_le_iff]
theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by
Mathlib.Order.Lattice.243_0.wE3igZl9MFbJBfv
theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d x : Ξ± ⊒ (a ≀ x ∧ b ≀ x) ∧ c ≀ x ↔ a ≀ x ∧ b ≀ x ∧ c ≀ x
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff];
rw [and_assoc]
theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff];
Mathlib.Order.Lattice.243_0.wE3igZl9MFbJBfv
theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a✝ b✝ c✝ d a b c : Ξ± ⊒ a βŠ” b βŠ” c = c βŠ” b βŠ” a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by
rw [sup_comm, @sup_comm _ _ a, sup_assoc]
theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by
Mathlib.Order.Lattice.250_0.wE3igZl9MFbJBfv
theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” (a βŠ” b) = a βŠ” b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by
simp
theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by
Mathlib.Order.Lattice.255_0.wE3igZl9MFbJBfv
theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a b c d : Ξ± ⊒ a βŠ” b βŠ” b = a βŠ” b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by
simp
theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by
Mathlib.Order.Lattice.259_0.wE3igZl9MFbJBfv
theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a✝ b✝ c✝ d a b c : Ξ± ⊒ a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by
rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a]
theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by
Mathlib.Order.Lattice.262_0.wE3igZl9MFbJBfv
theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a✝ b✝ c✝ d a b c : Ξ± ⊒ a βŠ” b βŠ” c = a βŠ” c βŠ” b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by
rw [sup_assoc, sup_assoc, @sup_comm _ _ b]
theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by
Mathlib.Order.Lattice.266_0.wE3igZl9MFbJBfv
theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a✝ b✝ c✝ d✝ a b c d : Ξ± ⊒ a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by
rw [sup_assoc, sup_left_comm b, ← sup_assoc]
theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by
Mathlib.Order.Lattice.270_0.wE3igZl9MFbJBfv
theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a✝ b✝ c✝ d a b c : Ξ± ⊒ a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by
rw [sup_sup_sup_comm, sup_idem]
theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by
Mathlib.Order.Lattice.274_0.wE3igZl9MFbJBfv
theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeSup Ξ± a✝ b✝ c✝ d a b c : Ξ± ⊒ a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by
rw [sup_sup_sup_comm, sup_idem]
theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by
Mathlib.Order.Lattice.278_0.wE3igZl9MFbJBfv
theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c)
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c✝ d : α✝ Ξ± : Type u_1 A B : SemilatticeSup Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y x y c : Ξ± ⊒ x βŠ” y ≀ c ↔ x βŠ” y ≀ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by
simp only [sup_le_iff]
theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by
Mathlib.Order.Lattice.311_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c✝ d : α✝ Ξ± : Type u_1 A B : SemilatticeSup Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y x y c : Ξ± ⊒ x βŠ” y ≀ c ↔ x ≀ c ∧ y ≀ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff];
rw [← H, @sup_le_iff Ξ± A, H, H]
theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff];
Mathlib.Order.Lattice.311_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeSup Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ A = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by
have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeSup Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ toSup = toSup
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by
ext
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case sup.h.h α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeSup Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y x✝¹ x✝ : Ξ± ⊒ x✝¹ βŠ” x✝ = x✝¹ βŠ” x✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext;
apply SemilatticeSup.ext_sup H
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext;
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeSup Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toSup = toSup ⊒ A = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H
cases A
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 B : SemilatticeSup Ξ± toSup✝ : Sup Ξ± toPartialOrder✝ : PartialOrder Ξ± 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toSup = toSup ⊒ mk le_sup_left✝ le_sup_right✝ sup_le✝ = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A
cases B
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 toSup✝¹ : Sup Ξ± toPartialOrder✝¹ : PartialOrder Ξ± 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 toSup✝ : Sup Ξ± toPartialOrder✝ : PartialOrder Ξ± 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toSup = toSup ⊒ mk le_sup_left✝¹ le_sup_right✝¹ sup_le✝¹ = mk le_sup_left✝ le_sup_right✝ sup_le✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B
cases PartialOrder.ext H
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk.refl α✝ : Type u Ξ² : Type v inst✝ : SemilatticeSup α✝ a b c d : α✝ Ξ± : Type u_1 toSup✝¹ : Sup Ξ± toPartialOrder✝ : PartialOrder Ξ± 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 toSup✝ : Sup Ξ± 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toSup = toSup ⊒ mk le_sup_left✝¹ le_sup_right✝¹ sup_le✝¹ = mk le_sup_left✝ le_sup_right✝ sup_le✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H
congr
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H
Mathlib.Order.Lattice.318_0.wE3igZl9MFbJBfv
theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeInf Ξ± a b c d : Ξ± ⊒ a βŠ“ b ≀ a ∧ a ≀ a βŠ“ b ↔ a ≀ b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by
simp [le_rfl]
@[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by
Mathlib.Order.Lattice.421_0.wE3igZl9MFbJBfv
@[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : SemilatticeInf Ξ± a b c d : Ξ± ⊒ a βŠ“ b ≀ b ∧ b ≀ a βŠ“ b ↔ b ≀ a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by
simp [le_rfl]
@[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by
Mathlib.Order.Lattice.426_0.wE3igZl9MFbJBfv
@[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c✝ d : α✝ Ξ± : Type u_1 A B : SemilatticeInf Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y x y c : Ξ± ⊒ c ≀ x βŠ“ y ↔ c ≀ x βŠ“ y
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by
simp only [le_inf_iff]
theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by
Mathlib.Order.Lattice.555_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c✝ d : α✝ Ξ± : Type u_1 A B : SemilatticeInf Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y x y c : Ξ± ⊒ c ≀ x βŠ“ y ↔ c ≀ x ∧ c ≀ y
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff];
rw [← H, @le_inf_iff Ξ± A, H, H]
theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff];
Mathlib.Order.Lattice.555_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeInf Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ A = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by
have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeInf Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ toInf = toInf
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by
ext
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case inf.h.h α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeInf Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y x✝¹ x✝ : Ξ± ⊒ x✝¹ βŠ“ x✝ = x✝¹ βŠ“ x✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext;
apply SemilatticeInf.ext_inf H
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext;
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 A B : SemilatticeInf Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toInf = toInf ⊒ A = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H
cases A
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 B : SemilatticeInf Ξ± toInf✝ : Inf Ξ± toPartialOrder✝ : PartialOrder Ξ± 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toInf = toInf ⊒ mk inf_le_left✝ inf_le_right✝ le_inf✝ = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A
cases B
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 toInf✝¹ : Inf Ξ± toPartialOrder✝¹ : PartialOrder Ξ± 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 toInf✝ : Inf Ξ± toPartialOrder✝ : PartialOrder Ξ± 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toInf = toInf ⊒ mk inf_le_left✝¹ inf_le_right✝¹ le_inf✝¹ = mk inf_le_left✝ inf_le_right✝ le_inf✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B
cases PartialOrder.ext H
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk.refl α✝ : Type u Ξ² : Type v inst✝ : SemilatticeInf α✝ a b c d : α✝ Ξ± : Type u_1 toInf✝¹ : Inf Ξ± toPartialOrder✝ : PartialOrder Ξ± 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 toInf✝ : 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ss : toInf = toInf ⊒ mk inf_le_left✝¹ inf_le_right✝¹ le_inf✝¹ = mk inf_le_left✝ inf_le_right✝ le_inf✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H
congr
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H
Mathlib.Order.Lattice.562_0.wE3igZl9MFbJBfv
theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝ : Inf Ξ± inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) inf_idem : βˆ€ (a : Ξ±), a βŠ“ a = a ⊒ SemilatticeInf Ξ±
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by
haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem
/-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by
Mathlib.Order.Lattice.583_0.wE3igZl9MFbJBfv
/-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝ : Inf Ξ± inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) inf_idem : βˆ€ (a : Ξ±), a βŠ“ a = a this : SemilatticeSup Ξ±α΅’α΅ˆ ⊒ SemilatticeInf Ξ±
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem
haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ
/-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem
Mathlib.Order.Lattice.583_0.wE3igZl9MFbJBfv
/-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝ : Inf Ξ± inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) inf_idem : βˆ€ (a : Ξ±), a βŠ“ a = a this : SemilatticeSup Ξ±α΅’α΅ˆ i : SemilatticeInf Ξ±α΅’α΅ˆα΅’α΅ˆ ⊒ SemilatticeInf Ξ±
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ
exact i
/-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ
Mathlib.Order.Lattice.583_0.wE3igZl9MFbJBfv
/-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) sup_idem : βˆ€ (a : Ξ±), a βŠ” a = a inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) inf_idem : βˆ€ (a : Ξ±), a βŠ“ a = a sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a a b : Ξ± h : a βŠ” b = b ⊒ b βŠ“ a = a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by
rw [← h, inf_comm, inf_sup_self]
/-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by
Mathlib.Order.Lattice.609_0.wE3igZl9MFbJBfv
/-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem)
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) sup_idem : βˆ€ (a : Ξ±), a βŠ” a = a inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) inf_idem : βˆ€ (a : Ξ±), a βŠ“ a = a sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a a b : Ξ± h : b βŠ“ a = a ⊒ a βŠ” b = b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by
rw [← h, sup_comm, sup_inf_self]
/-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by
Mathlib.Order.Lattice.609_0.wE3igZl9MFbJBfv
/-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem)
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a b : Ξ± ⊒ b βŠ” b = b βŠ” b βŠ“ (b βŠ” b)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by
rw [inf_sup_self]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a b : Ξ± ⊒ b βŠ” b βŠ“ (b βŠ” b) = b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by
rw [sup_inf_self]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b b : Ξ± ⊒ b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by
rw [sup_inf_self]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b b : Ξ± ⊒ b βŠ“ (b βŠ” b βŠ“ b) = b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by
rw [inf_sup_self]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b inf_idem : βˆ€ (b : Ξ±), b βŠ“ b = b semilatt_inf_inst : SemilatticeInf Ξ± := SemilatticeInf.mk' inf_comm inf_assoc inf_idem semilatt_sup_inst : SemilatticeSup Ξ± := SemilatticeSup.mk' sup_comm sup_assoc sup_idem partial_order_eq : SemilatticeSup.toPartialOrder = SemilatticeInf.toPartialOrder a b : Ξ± ⊒ a βŠ“ b ≀ a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by
rw [partial_order_eq]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b inf_idem : βˆ€ (b : Ξ±), b βŠ“ b = b semilatt_inf_inst : SemilatticeInf Ξ± := SemilatticeInf.mk' inf_comm inf_assoc inf_idem semilatt_sup_inst : SemilatticeSup Ξ± := SemilatticeSup.mk' sup_comm sup_assoc sup_idem partial_order_eq : SemilatticeSup.toPartialOrder = SemilatticeInf.toPartialOrder a b : Ξ± ⊒ a βŠ“ b ≀ a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq]
apply inf_le_left
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq]
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b inf_idem : βˆ€ (b : Ξ±), b βŠ“ b = b semilatt_inf_inst : SemilatticeInf Ξ± := SemilatticeInf.mk' inf_comm inf_assoc inf_idem semilatt_sup_inst : SemilatticeSup Ξ± := SemilatticeSup.mk' sup_comm sup_assoc sup_idem partial_order_eq : SemilatticeSup.toPartialOrder = SemilatticeInf.toPartialOrder a b : Ξ± ⊒ a βŠ“ b ≀ b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by
rw [partial_order_eq]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b inf_idem : βˆ€ (b : Ξ±), b βŠ“ b = b semilatt_inf_inst : SemilatticeInf Ξ± := SemilatticeInf.mk' inf_comm inf_assoc inf_idem semilatt_sup_inst : SemilatticeSup Ξ± := SemilatticeSup.mk' sup_comm sup_assoc sup_idem partial_order_eq : SemilatticeSup.toPartialOrder = SemilatticeInf.toPartialOrder a b : Ξ± ⊒ a βŠ“ b ≀ b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq]
apply inf_le_right
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq]
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b inf_idem : βˆ€ (b : Ξ±), b βŠ“ b = b semilatt_inf_inst : SemilatticeInf Ξ± := SemilatticeInf.mk' inf_comm inf_assoc inf_idem semilatt_sup_inst : SemilatticeSup Ξ± := SemilatticeSup.mk' sup_comm sup_assoc sup_idem partial_order_eq : SemilatticeSup.toPartialOrder = SemilatticeInf.toPartialOrder a b c : Ξ± ⊒ a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by
rw [partial_order_eq]
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v Ξ± : Type u_1 inst✝¹ : Sup Ξ± inst✝ : Inf Ξ± sup_comm : βˆ€ (a b : Ξ±), a βŠ” b = b βŠ” a sup_assoc : βˆ€ (a b c : Ξ±), a βŠ” b βŠ” c = a βŠ” (b βŠ” c) inf_comm : βˆ€ (a b : Ξ±), a βŠ“ b = b βŠ“ a inf_assoc : βˆ€ (a b c : Ξ±), a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) sup_inf_self : βˆ€ (a b : Ξ±), a βŠ” a βŠ“ b = a inf_sup_self : βˆ€ (a b : Ξ±), a βŠ“ (a βŠ” b) = a sup_idem : βˆ€ (b : Ξ±), b βŠ” b = b inf_idem : βˆ€ (b : Ξ±), b βŠ“ b = b semilatt_inf_inst : SemilatticeInf Ξ± := SemilatticeInf.mk' inf_comm inf_assoc inf_idem semilatt_sup_inst : SemilatticeSup Ξ± := SemilatticeSup.mk' sup_comm sup_assoc sup_idem partial_order_eq : SemilatticeSup.toPartialOrder = SemilatticeInf.toPartialOrder a b c : Ξ± ⊒ a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq]
apply le_inf
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq]
Mathlib.Order.Lattice.625_0.wE3igZl9MFbJBfv
/-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ±
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ” b ≀ a βŠ“ b ↔ a = b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by
simp [le_antisymm_iff, and_comm]
theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by
Mathlib.Order.Lattice.671_0.wE3igZl9MFbJBfv
theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ“ b = a βŠ” b ↔ a = b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by
rw [← inf_le_sup.ge_iff_eq, sup_le_inf]
@[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by
Mathlib.Order.Lattice.674_0.wE3igZl9MFbJBfv
@[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ“ b < a βŠ” b ↔ a β‰  b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by
rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup]
@[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by
Mathlib.Order.Lattice.678_0.wE3igZl9MFbJBfv
@[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by
refine' ⟨fun h ↦ _, _⟩
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
case refine'_1 Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± h : a βŠ“ b = c ∧ a βŠ” b = c ⊒ a = c ∧ b = c case refine'_2 Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a = c ∧ b = c β†’ a βŠ“ b = c ∧ a βŠ” b = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩
{ obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h }
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
case refine'_1 Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± h : a βŠ“ b = c ∧ a βŠ” b = c ⊒ a = c ∧ b = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ {
obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm)
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ {
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
case refine'_1 Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a c d : Ξ± h : a βŠ“ a = c ∧ a βŠ” a = c ⊒ a = c ∧ a = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm)
simpa using h
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm)
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
case refine'_2 Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a = c ∧ b = c β†’ a βŠ“ b = c ∧ a βŠ” b = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h }
{ rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ }
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h }
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
case refine'_2 Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a = c ∧ b = c β†’ a βŠ“ b = c ∧ a βŠ” b = c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } {
rintro ⟨rfl, rfl⟩
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } {
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
case refine'_2.intro Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± b d : Ξ± ⊒ b βŠ“ b = b ∧ b βŠ” b = b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩
exact ⟨inf_idem, sup_idem⟩
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩
Mathlib.Order.Lattice.681_0.wE3igZl9MFbJBfv
lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ“ (a βŠ” b) = a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by
simp
theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by
Mathlib.Order.Lattice.703_0.wE3igZl9MFbJBfv
theorem inf_sup_self : a βŠ“ (a βŠ” b) = a
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ” a βŠ“ b = a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by
simp
theorem sup_inf_self : a βŠ” a βŠ“ b = a := by
Mathlib.Order.Lattice.706_0.wE3igZl9MFbJBfv
theorem sup_inf_self : a βŠ” a βŠ“ b = a
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : Lattice Ξ± a b c d : Ξ± ⊒ a βŠ” b = b ↔ a βŠ“ b = a
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by
rw [sup_eq_right, ← inf_eq_left]
theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by
Mathlib.Order.Lattice.709_0.wE3igZl9MFbJBfv
theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a
Mathlib_Order_Lattice
α✝ : Type u Ξ² : Type v inst✝ : Lattice α✝ a b c d : α✝ Ξ± : Type u_1 A B : Lattice Ξ± H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ A = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by
cases A
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by
Mathlib.Order.Lattice.712_0.wE3igZl9MFbJBfv
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk α✝ : Type u Ξ² : Type v inst✝ : Lattice α✝ a b c d : α✝ Ξ± : Type u_1 B : Lattice Ξ± toSemilatticeSup✝ : SemilatticeSup Ξ± toInf✝ : 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ mk inf_le_left✝ inf_le_right✝ le_inf✝ = B
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A
cases B
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A
Mathlib.Order.Lattice.712_0.wE3igZl9MFbJBfv
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk α✝ : Type u Ξ² : Type v inst✝ : Lattice α✝ a b c d : α✝ Ξ± : Type u_1 toSemilatticeSup✝¹ : SemilatticeSup Ξ± toInf✝¹ : 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 toSemilatticeSup✝ : SemilatticeSup Ξ± toInf✝ : 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ mk inf_le_left✝¹ inf_le_right✝¹ le_inf✝¹ = mk inf_le_left✝ inf_le_right✝ le_inf✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B
cases SemilatticeSup.ext H
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B
Mathlib.Order.Lattice.712_0.wE3igZl9MFbJBfv
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk.refl α✝ : Type u Ξ² : Type v inst✝ : Lattice α✝ a b c d : α✝ Ξ± : Type u_1 toSemilatticeSup✝ : SemilatticeSup Ξ± toInf✝¹ : 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 toInf✝ : 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ mk inf_le_left✝¹ inf_le_right✝¹ le_inf✝¹ = mk inf_le_left✝ inf_le_right✝ le_inf✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H
cases SemilatticeInf.ext H
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H
Mathlib.Order.Lattice.712_0.wE3igZl9MFbJBfv
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
case mk.mk.refl.refl α✝ : Type u Ξ² : Type v inst✝ : Lattice α✝ a b c d : α✝ Ξ± : Type u_1 toSemilatticeSup✝ : SemilatticeSup Ξ± toInf✝ : 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 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 H : βˆ€ (x y : Ξ±), x ≀ y ↔ x ≀ y ⊒ mk inf_le_left✝¹ inf_le_right✝¹ le_inf✝¹ = mk inf_le_left✝ inf_le_right✝ le_inf✝
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H
congr
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H
Mathlib.Order.Lattice.712_0.wE3igZl9MFbJBfv
theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by
simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true]
theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by
Mathlib.Order.Lattice.756_0.wE3igZl9MFbJBfv
theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by
rw [inf_sup_self]
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by
Mathlib.Order.Lattice.760_0.wE3igZl9MFbJBfv
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) = x βŠ“ (x βŠ“ y βŠ” z)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by
simp only [inf_assoc, sup_inf_right, eq_self_iff_true]
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by
Mathlib.Order.Lattice.760_0.wE3igZl9MFbJBfv
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ x βŠ“ (x βŠ“ y βŠ” z) = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by
rw [sup_inf_self]
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by
Mathlib.Order.Lattice.760_0.wE3igZl9MFbJBfv
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by
rw [sup_comm]
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by
Mathlib.Order.Lattice.760_0.wE3igZl9MFbJBfv
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by
rw [sup_inf_left]
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by
Mathlib.Order.Lattice.760_0.wE3igZl9MFbJBfv
theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± ⊒ (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by
simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true]
theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by
Mathlib.Order.Lattice.773_0.wE3igZl9MFbJBfv
theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : DistribLattice Ξ± x y z : Ξ± h₁ : x βŠ“ z ≀ y βŠ“ z hβ‚‚ : x βŠ” z ≀ y βŠ” z ⊒ y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (x βŠ” z)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by
rw [sup_inf_right, @sup_comm _ _ x]
theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by
Mathlib.Order.Lattice.777_0.wE3igZl9MFbJBfv
theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a✝ b✝ c d a b : Ξ± p : Ξ± β†’ Prop ha : p a hb : p b h : a ≀ b ⊒ p (a βŠ” b)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by
rwa [sup_eq_right.2 h]
theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by
Mathlib.Order.Lattice.830_0.wE3igZl9MFbJBfv
theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a✝ b✝ c d a b : Ξ± p : Ξ± β†’ Prop ha : p a hb : p b h : b ≀ a ⊒ p (a βŠ” b)
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by
rwa [sup_eq_left.2 h]
theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by
Mathlib.Order.Lattice.830_0.wE3igZl9MFbJBfv
theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a b c d : Ξ± ⊒ a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by
exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩
@[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by
Mathlib.Order.Lattice.835_0.wE3igZl9MFbJBfv
@[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a b c d : Ξ± h : a ≀ b βŠ” c bc : c ≀ b ⊒ a ≀ b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by
rwa [sup_eq_left.2 bc] at h
@[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by
Mathlib.Order.Lattice.835_0.wE3igZl9MFbJBfv
@[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a b c d : Ξ± h : a ≀ b βŠ” c bc : b ≀ c ⊒ a ≀ c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by
rwa [sup_eq_right.2 bc] at h
@[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by
Mathlib.Order.Lattice.835_0.wE3igZl9MFbJBfv
@[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a b c d : Ξ± ⊒ a < b βŠ” c ↔ a < b ∨ a < c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by
exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩
@[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by
Mathlib.Order.Lattice.844_0.wE3igZl9MFbJBfv
@[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a b c d : Ξ± h : a < b βŠ” c bc : c ≀ b ⊒ a < b
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by
rwa [sup_eq_left.2 bc] at h
@[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by
Mathlib.Order.Lattice.844_0.wE3igZl9MFbJBfv
@[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝ : LinearOrder Ξ± a b c d : Ξ± h : a < b βŠ” c bc : b ≀ c ⊒ a < c
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by
rwa [sup_eq_right.2 bc] at h
@[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by
Mathlib.Order.Lattice.844_0.wE3igZl9MFbJBfv
@[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeSup Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 ⊒ (fun x x_1 => x βŠ” x_1) = maxDefault
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by
ext x y
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by
Mathlib.Order.Lattice.891_0.wE3igZl9MFbJBfv
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
case h.h Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeSup Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± ⊒ x βŠ” y = maxDefault x y
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y
unfold maxDefault
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y
Mathlib.Order.Lattice.891_0.wE3igZl9MFbJBfv
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
case h.h Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeSup Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± ⊒ x βŠ” y = if x ≀ y then y else x
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault
split_ifs with h'
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault
Mathlib.Order.Lattice.891_0.wE3igZl9MFbJBfv
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
case pos Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeSup Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± h' : x ≀ y ⊒ x βŠ” y = y case neg Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeSup Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± h' : Β¬x ≀ y ⊒ x βŠ” y = x
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault split_ifs with h'
exacts [sup_of_le_right h', sup_of_le_left $ (total_of (Β· ≀ Β·) x y).resolve_left h']
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault split_ifs with h'
Mathlib.Order.Lattice.891_0.wE3igZl9MFbJBfv
theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeInf Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 ⊒ (fun x x_1 => x βŠ“ x_1) = minDefault
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault split_ifs with h' exacts [sup_of_le_right h', sup_of_le_left $ (total_of (Β· ≀ Β·) x y).resolve_left h'] #align sup_eq_max_default sup_eq_maxDefault theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by
ext x y
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by
Mathlib.Order.Lattice.900_0.wE3igZl9MFbJBfv
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
case h.h Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeInf Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± ⊒ x βŠ“ y = minDefault x y
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault split_ifs with h' exacts [sup_of_le_right h', sup_of_le_left $ (total_of (Β· ≀ Β·) x y).resolve_left h'] #align sup_eq_max_default sup_eq_maxDefault theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y
unfold minDefault
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y
Mathlib.Order.Lattice.900_0.wE3igZl9MFbJBfv
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
case h.h Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeInf Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± ⊒ x βŠ“ y = if x ≀ y then x else y
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault split_ifs with h' exacts [sup_of_le_right h', sup_of_le_left $ (total_of (Β· ≀ Β·) x y).resolve_left h'] #align sup_eq_max_default sup_eq_maxDefault theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold minDefault
split_ifs with h'
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold minDefault
Mathlib.Order.Lattice.900_0.wE3igZl9MFbJBfv
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice
case pos Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeInf Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± h' : x ≀ y ⊒ x βŠ“ y = x case neg Ξ± : Type u Ξ² : Type v inst✝² : SemilatticeInf Ξ± inst✝¹ : DecidableRel fun x x_1 => x ≀ x_1 inst✝ : IsTotal Ξ± fun x x_1 => x ≀ x_1 x y : Ξ± h' : Β¬x ≀ y ⊒ x βŠ“ y = y
/- Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes HΓΆlzl -/ import Mathlib.Data.Bool.Basic import Mathlib.Init.Order.Defs import Mathlib.Order.Monotone.Basic import Mathlib.Order.ULift import Mathlib.Tactic.GCongr.Core #align_import order.lattice from "leanprover-community/mathlib"@"3ba15165bd6927679be7c22d6091a87337e3cd0c" /-! # (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 * `SemilatticeSup`: a type class for join semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeSup` via proofs that `βŠ”` is commutative, associative and idempotent. * `SemilatticeInf`: a type class for meet semilattices * `SemilatticeSup.mk'`: an alternative constructor for `SemilatticeInf` via proofs that `βŠ“` is commutative, associative and idempotent. * `Lattice`: a type class for lattices * `Lattice.mk'`: an alternative constructor for `Lattice` 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 of `a` and `b` * `a βŠ“ b`: the infimum or meet of `a` and `b` ## TODO * (Semi-)lattice homomorphisms * Alternative constructors for distributive lattices from the other distributive properties ## Tags semilattice, lattice -/ universe u v w variable {Ξ± : Type u} {Ξ² : Type v} #align le_antisymm' le_antisymm /-! ### Join-semilattices -/ -- TODO: automatic construction of dual definitions / theorems /-- 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. -/ class SemilatticeSup (Ξ± : Type u) extends Sup Ξ±, PartialOrder Ξ± where /-- The supremum is an upper bound on the first argument -/ protected le_sup_left : βˆ€ a b : Ξ±, a ≀ a βŠ” b /-- The supremum is an upper bound on the second argument -/ protected le_sup_right : βˆ€ a b : Ξ±, b ≀ a βŠ” b /-- The supremum is the *least* upper bound -/ protected sup_le : βˆ€ a b c : Ξ±, a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c #align semilattice_sup SemilatticeSup /-- 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`. -/ def SemilatticeSup.mk' {Ξ± : Type*} [Sup Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) : SemilatticeSup Ξ± where sup := (Β· βŠ” Β·) le a b := a βŠ” b = b le_refl := sup_idem le_trans a b c hab hbc := by -- Porting note: dsimp doesn't work here? -- This is the same issue as discussed at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/unfolding.20earlier.20fields show a βŠ” c = c rw [← hbc, ← sup_assoc, hab] le_antisymm a b hab hba := by rwa [← hba, sup_comm] le_sup_left a b := show a βŠ” (a βŠ” b) = a βŠ” b by rw [← sup_assoc, sup_idem] le_sup_right a b := show b βŠ” (a βŠ” b) = a βŠ” b by rw [sup_comm, sup_assoc, sup_idem] sup_le a b c hac hbc := by show (a βŠ” b) βŠ” c = c rwa [sup_assoc, hbc] #align semilattice_sup.mk' SemilatticeSup.mk' instance instSupOrderDual (Ξ± : Type*) [Inf Ξ±] : Sup Ξ±α΅’α΅ˆ := ⟨((Β· βŠ“ Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ instance instInfOrderDual (Ξ± : Type*) [Sup Ξ±] : Inf Ξ±α΅’α΅ˆ := ⟨((Β· βŠ” Β·) : Ξ± β†’ Ξ± β†’ Ξ±)⟩ section SemilatticeSup variable [SemilatticeSup Ξ±] {a b c d : Ξ±} @[simp] theorem le_sup_left : a ≀ a βŠ” b := SemilatticeSup.le_sup_left a b #align le_sup_left le_sup_left -- Porting note: no ematch attribute --@[ematch] theorem le_sup_left' : a ≀ a βŠ” b := le_sup_left #align le_sup_left' le_sup_left' @[simp] theorem le_sup_right : b ≀ a βŠ” b := SemilatticeSup.le_sup_right a b #align le_sup_right le_sup_right -- Porting note: no ematch attribute --@[ematch] theorem le_sup_right' : b ≀ a βŠ” b := le_sup_right #align le_sup_right' le_sup_right' theorem le_sup_of_le_left (h : c ≀ a) : c ≀ a βŠ” b := le_trans h le_sup_left #align le_sup_of_le_left le_sup_of_le_left theorem le_sup_of_le_right (h : c ≀ b) : c ≀ a βŠ” b := le_trans h le_sup_right #align le_sup_of_le_right le_sup_of_le_right theorem lt_sup_of_lt_left (h : c < a) : c < a βŠ” b := h.trans_le le_sup_left #align lt_sup_of_lt_left lt_sup_of_lt_left theorem lt_sup_of_lt_right (h : c < b) : c < a βŠ” b := h.trans_le le_sup_right #align lt_sup_of_lt_right lt_sup_of_lt_right theorem sup_le : a ≀ c β†’ b ≀ c β†’ a βŠ” b ≀ c := SemilatticeSup.sup_le a b c #align sup_le sup_le @[simp] theorem sup_le_iff : a βŠ” b ≀ c ↔ a ≀ c ∧ b ≀ c := ⟨fun h : a βŠ” b ≀ c => ⟨le_trans le_sup_left h, le_trans le_sup_right h⟩, fun ⟨h₁, hβ‚‚βŸ© => sup_le h₁ hβ‚‚βŸ© #align sup_le_iff sup_le_iff @[simp] theorem sup_eq_left : a βŠ” b = a ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_left sup_eq_left @[simp] theorem sup_eq_right : a βŠ” b = b ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align sup_eq_right sup_eq_right @[simp] theorem left_eq_sup : a = a βŠ” b ↔ b ≀ a := eq_comm.trans sup_eq_left #align left_eq_sup left_eq_sup @[simp] theorem right_eq_sup : b = a βŠ” b ↔ a ≀ b := eq_comm.trans sup_eq_right #align right_eq_sup right_eq_sup alias ⟨_, sup_of_le_left⟩ := sup_eq_left #align sup_of_le_left sup_of_le_left alias ⟨le_of_sup_eq, sup_of_le_right⟩ := sup_eq_right #align sup_of_le_right sup_of_le_right #align le_of_sup_eq le_of_sup_eq attribute [simp] sup_of_le_left sup_of_le_right @[simp] theorem left_lt_sup : a < a βŠ” b ↔ Β¬b ≀ a := le_sup_left.lt_iff_ne.trans $ not_congr left_eq_sup #align left_lt_sup left_lt_sup @[simp] theorem right_lt_sup : b < a βŠ” b ↔ Β¬a ≀ b := le_sup_right.lt_iff_ne.trans $ not_congr right_eq_sup #align right_lt_sup right_lt_sup theorem left_or_right_lt_sup (h : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := h.not_le_or_not_le.symm.imp left_lt_sup.2 right_lt_sup.2 #align left_or_right_lt_sup left_or_right_lt_sup theorem le_iff_exists_sup : a ≀ b ↔ βˆƒ c, b = a βŠ” c := by constructor Β· intro h exact ⟨b, (sup_eq_right.mpr h).symm⟩ Β· rintro ⟨c, rfl : _ = _ βŠ” _⟩ exact le_sup_left #align le_iff_exists_sup le_iff_exists_sup @[gcongr] theorem sup_le_sup (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ” c ≀ b βŠ” d := sup_le (le_sup_of_le_left h₁) (le_sup_of_le_right hβ‚‚) #align sup_le_sup sup_le_sup @[gcongr] theorem sup_le_sup_left (h₁ : a ≀ b) (c) : c βŠ” a ≀ c βŠ” b := sup_le_sup le_rfl h₁ #align sup_le_sup_left sup_le_sup_left @[gcongr] theorem sup_le_sup_right (h₁ : a ≀ b) (c) : a βŠ” c ≀ b βŠ” c := sup_le_sup h₁ le_rfl #align sup_le_sup_right sup_le_sup_right -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_idem : a βŠ” a = a := by simp #align sup_idem sup_idem instance : IsIdempotent Ξ± (Β· βŠ” Β·) := ⟨@sup_idem _ _⟩ theorem sup_comm : a βŠ” b = b βŠ” a := by apply le_antisymm <;> simp #align sup_comm sup_comm instance : IsCommutative Ξ± (Β· βŠ” Β·) := ⟨@sup_comm _ _⟩ theorem sup_assoc : a βŠ” b βŠ” c = a βŠ” (b βŠ” c) := eq_of_forall_ge_iff $ fun x => by simp only [sup_le_iff]; rw [and_assoc] #align sup_assoc sup_assoc instance : IsAssociative Ξ± (Β· βŠ” Β·) := ⟨@sup_assoc _ _⟩ theorem sup_left_right_swap (a b c : Ξ±) : a βŠ” b βŠ” c = c βŠ” b βŠ” a := by rw [sup_comm, @sup_comm _ _ a, sup_assoc] #align sup_left_right_swap sup_left_right_swap -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_left_idem : a βŠ” (a βŠ” b) = a βŠ” b := by simp #align sup_left_idem sup_left_idem -- Porting note: was @[simp], but now proved by simp so not needed. theorem sup_right_idem : a βŠ” b βŠ” b = a βŠ” b := by simp #align sup_right_idem sup_right_idem theorem sup_left_comm (a b c : Ξ±) : a βŠ” (b βŠ” c) = b βŠ” (a βŠ” c) := by rw [← sup_assoc, ← sup_assoc, @sup_comm Ξ± _ a] #align sup_left_comm sup_left_comm theorem sup_right_comm (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” b := by rw [sup_assoc, sup_assoc, @sup_comm _ _ b] #align sup_right_comm sup_right_comm theorem sup_sup_sup_comm (a b c d : Ξ±) : a βŠ” b βŠ” (c βŠ” d) = a βŠ” c βŠ” (b βŠ” d) := by rw [sup_assoc, sup_left_comm b, ← sup_assoc] #align sup_sup_sup_comm sup_sup_sup_comm theorem sup_sup_distrib_left (a b c : Ξ±) : a βŠ” (b βŠ” c) = a βŠ” b βŠ” (a βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_left sup_sup_distrib_left theorem sup_sup_distrib_right (a b c : Ξ±) : a βŠ” b βŠ” c = a βŠ” c βŠ” (b βŠ” c) := by rw [sup_sup_sup_comm, sup_idem] #align sup_sup_distrib_right sup_sup_distrib_right theorem sup_congr_left (hb : b ≀ a βŠ” c) (hc : c ≀ a βŠ” b) : a βŠ” b = a βŠ” c := (sup_le le_sup_left hb).antisymm $ sup_le le_sup_left hc #align sup_congr_left sup_congr_left theorem sup_congr_right (ha : a ≀ b βŠ” c) (hb : b ≀ a βŠ” c) : a βŠ” c = b βŠ” c := (sup_le ha le_sup_right).antisymm $ sup_le hb le_sup_right #align sup_congr_right sup_congr_right theorem sup_eq_sup_iff_left : a βŠ” b = a βŠ” c ↔ b ≀ a βŠ” c ∧ c ≀ a βŠ” b := ⟨fun h => ⟨h β–Έ le_sup_right, h.symm β–Έ le_sup_right⟩, fun h => sup_congr_left h.1 h.2⟩ #align sup_eq_sup_iff_left sup_eq_sup_iff_left theorem sup_eq_sup_iff_right : a βŠ” c = b βŠ” c ↔ a ≀ b βŠ” c ∧ b ≀ a βŠ” c := ⟨fun h => ⟨h β–Έ le_sup_left, h.symm β–Έ le_sup_left⟩, fun h => sup_congr_right h.1 h.2⟩ #align sup_eq_sup_iff_right sup_eq_sup_iff_right theorem Ne.lt_sup_or_lt_sup (hab : a β‰  b) : a < a βŠ” b ∨ b < a βŠ” b := hab.symm.not_le_or_not_le.imp left_lt_sup.2 right_lt_sup.2 #align ne.lt_sup_or_lt_sup Ne.lt_sup_or_lt_sup /-- If `f` is monotone, `g` is antitone, and `f ≀ g`, then for all `a`, `b` we have `f a ≀ g b`. -/ theorem Monotone.forall_le_of_antitone {Ξ² : Type*} [Preorder Ξ²] {f g : Ξ± β†’ Ξ²} (hf : Monotone f) (hg : Antitone g) (h : f ≀ g) (m n : Ξ±) : f m ≀ g n := calc f m ≀ f (m βŠ” n) := hf le_sup_left _ ≀ g (m βŠ” n) := h _ _ ≀ g n := hg le_sup_right #align monotone.forall_le_of_antitone Monotone.forall_le_of_antitone theorem SemilatticeSup.ext_sup {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ” y) = x βŠ” y := eq_of_forall_ge_iff $ fun c => by simp only [sup_le_iff]; rw [← H, @sup_le_iff Ξ± A, H, H] #align semilattice_sup.ext_sup SemilatticeSup.ext_sup theorem SemilatticeSup.ext {Ξ±} {A B : SemilatticeSup Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toSup = B.toSup := by ext; apply SemilatticeSup.ext_sup H cases A cases B cases PartialOrder.ext H congr #align semilattice_sup.ext SemilatticeSup.ext theorem ite_le_sup (s s' : Ξ±) (P : Prop) [Decidable P] : ite P s s' ≀ s βŠ” s' := if h : P then (if_pos h).trans_le le_sup_left else (if_neg h).trans_le le_sup_right #align ite_le_sup ite_le_sup end SemilatticeSup /-! ### 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. -/ class SemilatticeInf (Ξ± : Type u) extends Inf Ξ±, PartialOrder Ξ± where /-- The infimum is a lower bound on the first argument -/ protected inf_le_left : βˆ€ a b : Ξ±, a βŠ“ b ≀ a /-- The infimum is a lower bound on the second argument -/ protected inf_le_right : βˆ€ a b : Ξ±, a βŠ“ b ≀ b /-- The infimum is the *greatest* lower bound -/ protected le_inf : βˆ€ a b c : Ξ±, a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c #align semilattice_inf SemilatticeInf instance OrderDual.semilatticeSup (Ξ±) [SemilatticeInf Ξ±] : SemilatticeSup Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Sup Ξ±α΅’α΅ˆ) le_sup_left := @SemilatticeInf.inf_le_left Ξ± _ le_sup_right := @SemilatticeInf.inf_le_right Ξ± _ sup_le := fun _ _ _ hca hcb => @SemilatticeInf.le_inf Ξ± _ _ _ _ hca hcb instance OrderDual.semilatticeInf (Ξ±) [SemilatticeSup Ξ±] : SemilatticeInf Ξ±α΅’α΅ˆ where __ := inferInstanceAs (PartialOrder Ξ±α΅’α΅ˆ) __ := inferInstanceAs (Inf Ξ±α΅’α΅ˆ) inf_le_left := @le_sup_left Ξ± _ inf_le_right := @le_sup_right Ξ± _ le_inf := fun _ _ _ hca hcb => @sup_le Ξ± _ _ _ _ hca hcb theorem SemilatticeSup.dual_dual (Ξ± : Type*) [H : SemilatticeSup Ξ±] : OrderDual.semilatticeSup Ξ±α΅’α΅ˆ = H := SemilatticeSup.ext $ fun _ _ => Iff.rfl #align semilattice_sup.dual_dual SemilatticeSup.dual_dual section SemilatticeInf variable [SemilatticeInf Ξ±] {a b c d : Ξ±} @[simp] theorem inf_le_left : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left inf_le_left -- Porting note: no ematch attribute --@[ematch] theorem inf_le_left' : a βŠ“ b ≀ a := SemilatticeInf.inf_le_left a b #align inf_le_left' inf_le_left' @[simp] theorem inf_le_right : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right inf_le_right -- Porting note: no ematch attribute --@[ematch] theorem inf_le_right' : a βŠ“ b ≀ b := SemilatticeInf.inf_le_right a b #align inf_le_right' inf_le_right' theorem le_inf : a ≀ b β†’ a ≀ c β†’ a ≀ b βŠ“ c := SemilatticeInf.le_inf a b c #align le_inf le_inf theorem inf_le_of_left_le (h : a ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_left h #align inf_le_of_left_le inf_le_of_left_le theorem inf_le_of_right_le (h : b ≀ c) : a βŠ“ b ≀ c := le_trans inf_le_right h #align inf_le_of_right_le inf_le_of_right_le theorem inf_lt_of_left_lt (h : a < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_left h #align inf_lt_of_left_lt inf_lt_of_left_lt theorem inf_lt_of_right_lt (h : b < c) : a βŠ“ b < c := lt_of_le_of_lt inf_le_right h #align inf_lt_of_right_lt inf_lt_of_right_lt @[simp] theorem le_inf_iff : a ≀ b βŠ“ c ↔ a ≀ b ∧ a ≀ c := @sup_le_iff Ξ±α΅’α΅ˆ _ _ _ _ #align le_inf_iff le_inf_iff @[simp] theorem inf_eq_left : a βŠ“ b = a ↔ a ≀ b := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_left inf_eq_left @[simp] theorem inf_eq_right : a βŠ“ b = b ↔ b ≀ a := le_antisymm_iff.trans $ by simp [le_rfl] #align inf_eq_right inf_eq_right @[simp] theorem left_eq_inf : a = a βŠ“ b ↔ a ≀ b := eq_comm.trans inf_eq_left #align left_eq_inf left_eq_inf @[simp] theorem right_eq_inf : b = a βŠ“ b ↔ b ≀ a := eq_comm.trans inf_eq_right #align right_eq_inf right_eq_inf alias ⟨le_of_inf_eq, inf_of_le_left⟩ := inf_eq_left #align inf_of_le_left inf_of_le_left #align le_of_inf_eq le_of_inf_eq alias ⟨_, inf_of_le_right⟩ := inf_eq_right #align inf_of_le_right inf_of_le_right attribute [simp] inf_of_le_left inf_of_le_right @[simp] theorem inf_lt_left : a βŠ“ b < a ↔ Β¬a ≀ b := @left_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_left inf_lt_left @[simp] theorem inf_lt_right : a βŠ“ b < b ↔ Β¬b ≀ a := @right_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align inf_lt_right inf_lt_right theorem inf_lt_left_or_right (h : a β‰  b) : a βŠ“ b < a ∨ a βŠ“ b < b := @left_or_right_lt_sup Ξ±α΅’α΅ˆ _ _ _ h #align inf_lt_left_or_right inf_lt_left_or_right @[gcongr] theorem inf_le_inf (h₁ : a ≀ b) (hβ‚‚ : c ≀ d) : a βŠ“ c ≀ b βŠ“ d := @sup_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ h₁ hβ‚‚ #align inf_le_inf inf_le_inf @[gcongr] theorem inf_le_inf_right (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : b βŠ“ a ≀ c βŠ“ a := inf_le_inf h le_rfl #align inf_le_inf_right inf_le_inf_right @[gcongr] theorem inf_le_inf_left (a : Ξ±) {b c : Ξ±} (h : b ≀ c) : a βŠ“ b ≀ a βŠ“ c := inf_le_inf le_rfl h #align inf_le_inf_left inf_le_inf_left -- Porting note: was @[simp] theorem inf_idem : a βŠ“ a = a := @sup_idem Ξ±α΅’α΅ˆ _ _ #align inf_idem inf_idem instance : IsIdempotent Ξ± (Β· βŠ“ Β·) := ⟨@inf_idem _ _⟩ theorem inf_comm : a βŠ“ b = b βŠ“ a := @sup_comm Ξ±α΅’α΅ˆ _ _ _ #align inf_comm inf_comm instance : IsCommutative Ξ± (Β· βŠ“ Β·) := ⟨@inf_comm _ _⟩ theorem inf_assoc : a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c) := @sup_assoc Ξ±α΅’α΅ˆ _ a b c #align inf_assoc inf_assoc instance : IsAssociative Ξ± (Β· βŠ“ Β·) := ⟨@inf_assoc _ _⟩ theorem inf_left_right_swap (a b c : Ξ±) : a βŠ“ b βŠ“ c = c βŠ“ b βŠ“ a := @sup_left_right_swap Ξ±α΅’α΅ˆ _ _ _ _ #align inf_left_right_swap inf_left_right_swap -- Porting note: was @[simp] theorem inf_left_idem : a βŠ“ (a βŠ“ b) = a βŠ“ b := @sup_left_idem Ξ±α΅’α΅ˆ _ a b #align inf_left_idem inf_left_idem -- Porting note: was @[simp] theorem inf_right_idem : a βŠ“ b βŠ“ b = a βŠ“ b := @sup_right_idem Ξ±α΅’α΅ˆ _ a b #align inf_right_idem inf_right_idem theorem inf_left_comm (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = b βŠ“ (a βŠ“ c) := @sup_left_comm Ξ±α΅’α΅ˆ _ a b c #align inf_left_comm inf_left_comm theorem inf_right_comm (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ b := @sup_right_comm Ξ±α΅’α΅ˆ _ a b c #align inf_right_comm inf_right_comm theorem inf_inf_inf_comm (a b c d : Ξ±) : a βŠ“ b βŠ“ (c βŠ“ d) = a βŠ“ c βŠ“ (b βŠ“ d) := @sup_sup_sup_comm Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_inf_inf_comm inf_inf_inf_comm theorem inf_inf_distrib_left (a b c : Ξ±) : a βŠ“ (b βŠ“ c) = a βŠ“ b βŠ“ (a βŠ“ c) := @sup_sup_distrib_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_left inf_inf_distrib_left theorem inf_inf_distrib_right (a b c : Ξ±) : a βŠ“ b βŠ“ c = a βŠ“ c βŠ“ (b βŠ“ c) := @sup_sup_distrib_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_inf_distrib_right inf_inf_distrib_right theorem inf_congr_left (hb : a βŠ“ c ≀ b) (hc : a βŠ“ b ≀ c) : a βŠ“ b = a βŠ“ c := @sup_congr_left Ξ±α΅’α΅ˆ _ _ _ _ hb hc #align inf_congr_left inf_congr_left theorem inf_congr_right (h1 : b βŠ“ c ≀ a) (h2 : a βŠ“ c ≀ b) : a βŠ“ c = b βŠ“ c := @sup_congr_right Ξ±α΅’α΅ˆ _ _ _ _ h1 h2 #align inf_congr_right inf_congr_right theorem inf_eq_inf_iff_left : a βŠ“ b = a βŠ“ c ↔ a βŠ“ c ≀ b ∧ a βŠ“ b ≀ c := @sup_eq_sup_iff_left Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_left inf_eq_inf_iff_left theorem inf_eq_inf_iff_right : a βŠ“ c = b βŠ“ c ↔ b βŠ“ c ≀ a ∧ a βŠ“ c ≀ b := @sup_eq_sup_iff_right Ξ±α΅’α΅ˆ _ _ _ _ #align inf_eq_inf_iff_right inf_eq_inf_iff_right theorem Ne.inf_lt_or_inf_lt : a β‰  b β†’ a βŠ“ b < a ∨ a βŠ“ b < b := @Ne.lt_sup_or_lt_sup Ξ±α΅’α΅ˆ _ _ _ #align ne.inf_lt_or_inf_lt Ne.inf_lt_or_inf_lt theorem SemilatticeInf.ext_inf {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) (x y : Ξ±) : (haveI := A; x βŠ“ y) = x βŠ“ y := eq_of_forall_le_iff $ fun c => by simp only [le_inf_iff]; rw [← H, @le_inf_iff Ξ± A, H, H] #align semilattice_inf.ext_inf SemilatticeInf.ext_inf theorem SemilatticeInf.ext {Ξ±} {A B : SemilatticeInf Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by have ss : A.toInf = B.toInf := by ext; apply SemilatticeInf.ext_inf H cases A cases B cases PartialOrder.ext H congr #align semilattice_inf.ext SemilatticeInf.ext theorem SemilatticeInf.dual_dual (Ξ± : Type*) [H : SemilatticeInf Ξ±] : OrderDual.semilatticeInf Ξ±α΅’α΅ˆ = H := SemilatticeInf.ext $ fun _ _ => Iff.rfl #align semilattice_inf.dual_dual SemilatticeInf.dual_dual theorem inf_le_ite (s s' : Ξ±) (P : Prop) [Decidable P] : s βŠ“ s' ≀ ite P s s' := @ite_le_sup Ξ±α΅’α΅ˆ _ _ _ _ _ #align inf_le_ite inf_le_ite end SemilatticeInf /-- 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`. -/ def SemilatticeInf.mk' {Ξ± : Type*} [Inf Ξ±] (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) : SemilatticeInf Ξ± := by haveI : SemilatticeSup Ξ±α΅’α΅ˆ := SemilatticeSup.mk' inf_comm inf_assoc inf_idem haveI i := OrderDual.semilatticeInf Ξ±α΅’α΅ˆ exact i #align semilattice_inf.mk' SemilatticeInf.mk' /-! ### Lattices -/ /-- A lattice is a join-semilattice which is also a meet-semilattice. -/ class Lattice (Ξ± : Type u) extends SemilatticeSup Ξ±, SemilatticeInf Ξ± #align lattice Lattice instance OrderDual.lattice (Ξ±) [Lattice Ξ±] : Lattice Ξ±α΅’α΅ˆ := { OrderDual.semilatticeSup Ξ±, OrderDual.semilatticeInf Ξ± with } /-- 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`). -/ theorem semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (sup_idem : βˆ€ a : Ξ±, a βŠ” a = a) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (inf_idem : βˆ€ a : Ξ±, a βŠ“ a = a) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : @SemilatticeSup.toPartialOrder _ (SemilatticeSup.mk' sup_comm sup_assoc sup_idem) = @SemilatticeInf.toPartialOrder _ (SemilatticeInf.mk' inf_comm inf_assoc inf_idem) := PartialOrder.ext $ fun a b => show a βŠ” b = b ↔ b βŠ“ a = a from ⟨fun h => by rw [← h, inf_comm, inf_sup_self], fun h => by rw [← h, sup_comm, sup_inf_self]⟩ #align semilattice_sup_mk'_partial_order_eq_semilattice_inf_mk'_partial_order semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder /-- 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`. -/ def Lattice.mk' {Ξ± : Type*} [Sup Ξ±] [Inf Ξ±] (sup_comm : βˆ€ a b : Ξ±, a βŠ” b = b βŠ” a) (sup_assoc : βˆ€ a b c : Ξ±, a βŠ” b βŠ” c = a βŠ” (b βŠ” c)) (inf_comm : βˆ€ a b : Ξ±, a βŠ“ b = b βŠ“ a) (inf_assoc : βˆ€ a b c : Ξ±, a βŠ“ b βŠ“ c = a βŠ“ (b βŠ“ c)) (sup_inf_self : βˆ€ a b : Ξ±, a βŠ” a βŠ“ b = a) (inf_sup_self : βˆ€ a b : Ξ±, a βŠ“ (a βŠ” b) = a) : Lattice Ξ± := have sup_idem : βˆ€ b : Ξ±, b βŠ” b = b := fun b => calc b βŠ” b = b βŠ” b βŠ“ (b βŠ” b) := by rw [inf_sup_self] _ = b := by rw [sup_inf_self] have inf_idem : βˆ€ b : Ξ±, b βŠ“ b = b := fun b => calc b βŠ“ b = b βŠ“ (b βŠ” b βŠ“ b) := by rw [sup_inf_self] _ = b := by rw [inf_sup_self] let semilatt_inf_inst := SemilatticeInf.mk' inf_comm inf_assoc inf_idem let semilatt_sup_inst := SemilatticeSup.mk' sup_comm sup_assoc sup_idem have partial_order_eq : @SemilatticeSup.toPartialOrder _ semilatt_sup_inst = @SemilatticeInf.toPartialOrder _ semilatt_inf_inst := semilatticeSup_mk'_partialOrder_eq_semilatticeInf_mk'_partialOrder _ _ _ _ _ _ sup_inf_self inf_sup_self { semilatt_sup_inst, semilatt_inf_inst with inf_le_left := fun a b => by rw [partial_order_eq] apply inf_le_left, inf_le_right := fun a b => by rw [partial_order_eq] apply inf_le_right, le_inf := fun a b c => by rw [partial_order_eq] apply le_inf } #align lattice.mk' Lattice.mk' section Lattice variable [Lattice Ξ±] {a b c d : Ξ±} theorem inf_le_sup : a βŠ“ b ≀ a βŠ” b := inf_le_left.trans le_sup_left #align inf_le_sup inf_le_sup -- Porting note: was @[simp] theorem sup_le_inf : a βŠ” b ≀ a βŠ“ b ↔ a = b := by simp [le_antisymm_iff, and_comm] #align sup_le_inf sup_le_inf @[simp] lemma inf_eq_sup : a βŠ“ b = a βŠ” b ↔ a = b := by rw [← inf_le_sup.ge_iff_eq, sup_le_inf] #align inf_eq_sup inf_eq_sup @[simp] lemma sup_eq_inf : a βŠ” b = a βŠ“ b ↔ a = b := eq_comm.trans inf_eq_sup #align sup_eq_inf sup_eq_inf @[simp] lemma inf_lt_sup : a βŠ“ b < a βŠ” b ↔ a β‰  b := by rw [inf_le_sup.lt_iff_ne, Ne.def, inf_eq_sup] #align inf_lt_sup inf_lt_sup lemma inf_eq_and_sup_eq_iff : a βŠ“ b = c ∧ a βŠ” b = c ↔ a = c ∧ b = c := by refine' ⟨fun h ↦ _, _⟩ { obtain rfl := sup_eq_inf.1 (h.2.trans h.1.symm) simpa using h } { rintro ⟨rfl, rfl⟩ exact ⟨inf_idem, sup_idem⟩ } #align inf_eq_and_sup_eq_iff inf_eq_and_sup_eq_iff /-! #### Distributivity laws -/ -- TODO: better names? theorem sup_inf_le : a βŠ” b βŠ“ c ≀ (a βŠ” b) βŠ“ (a βŠ” c) := le_inf (sup_le_sup_left inf_le_left _) (sup_le_sup_left inf_le_right _) #align sup_inf_le sup_inf_le theorem le_inf_sup : a βŠ“ b βŠ” a βŠ“ c ≀ a βŠ“ (b βŠ” c) := sup_le (inf_le_inf_left _ le_sup_left) (inf_le_inf_left _ le_sup_right) #align le_inf_sup le_inf_sup theorem inf_sup_self : a βŠ“ (a βŠ” b) = a := by simp #align inf_sup_self inf_sup_self theorem sup_inf_self : a βŠ” a βŠ“ b = a := by simp #align sup_inf_self sup_inf_self theorem sup_eq_iff_inf_eq : a βŠ” b = b ↔ a βŠ“ b = a := by rw [sup_eq_right, ← inf_eq_left] #align sup_eq_iff_inf_eq sup_eq_iff_inf_eq theorem Lattice.ext {Ξ±} {A B : Lattice Ξ±} (H : βˆ€ x y : Ξ±, (haveI := A; x ≀ y) ↔ x ≀ y) : A = B := by cases A cases B cases SemilatticeSup.ext H cases SemilatticeInf.ext H congr #align lattice.ext Lattice.ext end Lattice /-! ### 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. -/ class DistribLattice (Ξ±) extends Lattice Ξ± where /-- The infimum distributes over the supremum -/ protected le_sup_inf : βˆ€ x y z : Ξ±, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z #align distrib_lattice DistribLattice section DistribLattice variable [DistribLattice Ξ±] {x y z : Ξ±} theorem le_sup_inf : βˆ€ {x y z : Ξ±}, (x βŠ” y) βŠ“ (x βŠ” z) ≀ x βŠ” y βŠ“ z := fun {x y z} => DistribLattice.le_sup_inf x y z #align le_sup_inf le_sup_inf theorem sup_inf_left : x βŠ” y βŠ“ z = (x βŠ” y) βŠ“ (x βŠ” z) := le_antisymm sup_inf_le le_sup_inf #align sup_inf_left sup_inf_left theorem sup_inf_right : y βŠ“ z βŠ” x = (y βŠ” x) βŠ“ (z βŠ” x) := by simp only [sup_inf_left, fun y : Ξ± => @sup_comm Ξ± _ y x, eq_self_iff_true] #align sup_inf_right sup_inf_right theorem inf_sup_left : x βŠ“ (y βŠ” z) = x βŠ“ y βŠ” x βŠ“ z := calc x βŠ“ (y βŠ” z) = x βŠ“ (x βŠ” z) βŠ“ (y βŠ” z) := by rw [inf_sup_self] _ = x βŠ“ (x βŠ“ y βŠ” z) := by simp only [inf_assoc, sup_inf_right, eq_self_iff_true] _ = (x βŠ” x βŠ“ y) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_inf_self] _ = (x βŠ“ y βŠ” x) βŠ“ (x βŠ“ y βŠ” z) := by rw [sup_comm] _ = x βŠ“ y βŠ” x βŠ“ z := by rw [sup_inf_left] #align inf_sup_left inf_sup_left instance OrderDual.distribLattice (Ξ± : Type*) [DistribLattice Ξ±] : DistribLattice Ξ±α΅’α΅ˆ where __ := inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) le_sup_inf := fun _ _ _ => le_of_eq (@inf_sup_left Ξ±).symm theorem inf_sup_right : (y βŠ” z) βŠ“ x = y βŠ“ x βŠ” z βŠ“ x := by simp only [inf_sup_left, fun y : Ξ± => @inf_comm Ξ± _ y x, eq_self_iff_true] #align inf_sup_right inf_sup_right theorem le_of_inf_le_sup_le (h₁ : x βŠ“ z ≀ y βŠ“ z) (hβ‚‚ : x βŠ” z ≀ y βŠ” z) : x ≀ y := calc x ≀ y βŠ“ z βŠ” x := le_sup_right _ = (y βŠ” x) βŠ“ (x βŠ” z) := by rw [sup_inf_right, @sup_comm _ _ x] _ ≀ (y βŠ” x) βŠ“ (y βŠ” z) := inf_le_inf_left _ hβ‚‚ _ = y βŠ” x βŠ“ z := sup_inf_left.symm _ ≀ y βŠ” y βŠ“ z := sup_le_sup_left h₁ _ _ ≀ _ := sup_le (le_refl y) inf_le_left #align le_of_inf_le_sup_le le_of_inf_le_sup_le theorem eq_of_inf_eq_sup_eq {Ξ± : Type u} [DistribLattice Ξ±] {a b c : Ξ±} (h₁ : b βŠ“ a = c βŠ“ a) (hβ‚‚ : b βŠ” a = c βŠ” a) : b = c := le_antisymm (le_of_inf_le_sup_le (le_of_eq h₁) (le_of_eq hβ‚‚)) (le_of_inf_le_sup_le (le_of_eq h₁.symm) (le_of_eq hβ‚‚.symm)) #align eq_of_inf_eq_sup_eq eq_of_inf_eq_sup_eq end DistribLattice -- See note [reducible non-instances] /-- Prove distributivity of an existing lattice from the dual distributive law. -/ @[reducible] def DistribLattice.ofInfSupLe [Lattice Ξ±] (inf_sup_le : βˆ€ a b c : Ξ±, a βŠ“ (b βŠ” c) ≀ a βŠ“ b βŠ” a βŠ“ c) : DistribLattice Ξ± := { le_sup_inf := (@OrderDual.distribLattice Ξ±α΅’α΅ˆ {inferInstanceAs (Lattice Ξ±α΅’α΅ˆ) with le_sup_inf := inf_sup_le}).le_sup_inf, } #align distrib_lattice.of_inf_sup_le DistribLattice.ofInfSupLe /-! ### Lattices derived from linear orders -/ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.toLattice {Ξ± : Type u} [o : LinearOrder Ξ±] : Lattice Ξ± := { o with sup := max, le_sup_left := le_max_left, le_sup_right := le_max_right, sup_le := fun _ _ _ => max_le, inf := min, inf_le_left := min_le_left, inf_le_right := min_le_right, le_inf := fun _ _ _ => le_min } section LinearOrder variable [LinearOrder Ξ±] {a b c d : Ξ±} theorem sup_eq_max : a βŠ” b = max a b := rfl #align sup_eq_max sup_eq_max theorem inf_eq_min : a βŠ“ b = min a b := rfl #align inf_eq_min inf_eq_min theorem sup_ind (a b : Ξ±) {p : Ξ± β†’ Prop} (ha : p a) (hb : p b) : p (a βŠ” b) := (IsTotal.total a b).elim (fun h : a ≀ b => by rwa [sup_eq_right.2 h]) fun h => by rwa [sup_eq_left.2 h] #align sup_ind sup_ind @[simp] theorem le_sup_iff : a ≀ b βŠ” c ↔ a ≀ b ∨ a ≀ c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim le_sup_of_le_left le_sup_of_le_right⟩ #align le_sup_iff le_sup_iff @[simp] theorem lt_sup_iff : a < b βŠ” c ↔ a < b ∨ a < c := by exact ⟨fun h => (le_total c b).imp (fun bc => by rwa [sup_eq_left.2 bc] at h) (fun bc => by rwa [sup_eq_right.2 bc] at h), fun h => h.elim lt_sup_of_lt_left lt_sup_of_lt_right⟩ #align lt_sup_iff lt_sup_iff -- Porting note: why does sup_ind need an explicit motive? @[simp] theorem sup_lt_iff : b βŠ” c < a ↔ b < a ∧ c < a := ⟨fun h => ⟨le_sup_left.trans_lt h, le_sup_right.trans_lt h⟩, fun h => @sup_ind Ξ± _ b c (fun x => x < a) h.1 h.2⟩ #align sup_lt_iff sup_lt_iff theorem inf_ind (a b : Ξ±) {p : Ξ± β†’ Prop} : p a β†’ p b β†’ p (a βŠ“ b) := @sup_ind Ξ±α΅’α΅ˆ _ _ _ _ #align inf_ind inf_ind @[simp] theorem inf_le_iff : b βŠ“ c ≀ a ↔ b ≀ a ∨ c ≀ a := @le_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_le_iff inf_le_iff @[simp] theorem inf_lt_iff : b βŠ“ c < a ↔ b < a ∨ c < a := @lt_sup_iff Ξ±α΅’α΅ˆ _ _ _ _ #align inf_lt_iff inf_lt_iff @[simp] theorem lt_inf_iff : a < b βŠ“ c ↔ a < b ∧ a < c := @sup_lt_iff Ξ±α΅’α΅ˆ _ _ _ _ #align lt_inf_iff lt_inf_iff variable (a b c d) theorem max_max_max_comm : max (max a b) (max c d) = max (max a c) (max b d) := sup_sup_sup_comm _ _ _ _ #align max_max_max_comm max_max_max_comm theorem min_min_min_comm : min (min a b) (min c d) = min (min a c) (min b d) := inf_inf_inf_comm _ _ _ _ #align min_min_min_comm min_min_min_comm end LinearOrder theorem sup_eq_maxDefault [SemilatticeSup Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ” Β·) = (maxDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold maxDefault split_ifs with h' exacts [sup_of_le_right h', sup_of_le_left $ (total_of (Β· ≀ Β·) x y).resolve_left h'] #align sup_eq_max_default sup_eq_maxDefault theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold minDefault split_ifs with h'
exacts [inf_of_le_left h', inf_of_le_right $ (total_of (Β· ≀ Β·) x y).resolve_left h']
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±) := by ext x y unfold minDefault split_ifs with h'
Mathlib.Order.Lattice.900_0.wE3igZl9MFbJBfv
theorem inf_eq_minDefault [SemilatticeInf Ξ±] [DecidableRel ((Β· ≀ Β·) : Ξ± β†’ Ξ± β†’ Prop)] [IsTotal Ξ± (Β· ≀ Β·)] : (Β· βŠ“ Β·) = (minDefault : Ξ± β†’ Ξ± β†’ Ξ±)
Mathlib_Order_Lattice