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 u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
s : z ⊔ x ⊓ y = x \ y ⊔ x ⊓ y
i : z ⊓ (x ⊓ y) = x \ y ⊓ (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
|
exact (eq_of_inf_eq_sup_eq i s).symm
|
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
|
Mathlib.Order.BooleanAlgebra.127_0.ewE75DLNneOU8G5
|
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y \ x ⊔ x = y \ x ⊔ (x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by
|
rw [sup_inf_self]
|
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by
|
Mathlib.Order.BooleanAlgebra.142_0.ewE75DLNneOU8G5
|
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y \ x ⊔ (x ⊔ x ⊓ y) = y ⊓ x ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by
|
ac_rfl
|
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by
|
Mathlib.Order.BooleanAlgebra.142_0.ewE75DLNneOU8G5
|
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y ⊓ x ⊔ y \ x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by
|
rw [sup_inf_sdiff]
|
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by
|
Mathlib.Order.BooleanAlgebra.142_0.ewE75DLNneOU8G5
|
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ ⊥ = x ⊓ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by
|
rw [inf_inf_sdiff]
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y ⊓ x \ y = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by
|
rw [sup_inf_sdiff]
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by
|
rw [inf_sup_left]
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by
|
ac_rfl
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by
|
rw [inf_idem]
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by
|
rw [inf_sup_right, @inf_comm _ _ x y]
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y = x ⊓ y \ x ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by
|
rw [inf_inf_sdiff, bot_sup_eq]
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ x ⊓ x \ y = x ⊓ x \ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by
|
ac_rfl
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ x \ y ⊓ y \ x = x \ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by
|
rw [inf_of_le_right sdiff_le']
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by
|
Mathlib.Order.BooleanAlgebra.148_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by
|
rw [sup_inf_sdiff]
|
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by
|
Mathlib.Order.BooleanAlgebra.167_0.ewE75DLNneOU8G5
|
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (x ⊓ y ⊔ x \ y) ⊓ y \ x = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by
|
rw [inf_sup_right]
|
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by
|
Mathlib.Order.BooleanAlgebra.167_0.ewE75DLNneOU8G5
|
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by
|
rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
|
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by
|
Mathlib.Order.BooleanAlgebra.167_0.ewE75DLNneOU8G5
|
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by
|
rw [inf_comm, inf_sdiff_self_right]
|
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by
|
Mathlib.Order.BooleanAlgebra.175_0.ewE75DLNneOU8G5
|
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x✝ y✝ z✝ : α
inst✝ : GeneralizedBooleanAlgebra α
src✝¹ : GeneralizedBooleanAlgebra α := inst✝
src✝ : OrderBot α := toOrderBot
y x z : α
h : y \ x ≤ z
⊢ y \ x = x ⊓ y \ x ⊔ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by
|
rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
|
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by
|
Mathlib.Order.BooleanAlgebra.180_0.ewE75DLNneOU8G5
|
instance (priority
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x✝ y✝ z✝ : α
inst✝ : GeneralizedBooleanAlgebra α
src✝¹ : GeneralizedBooleanAlgebra α := inst✝
src✝ : OrderBot α := toOrderBot
y x z : α
h : y \ x ≤ z
⊢ y ⊔ (x ⊔ z) = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by
|
rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
|
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by
|
Mathlib.Order.BooleanAlgebra.180_0.ewE75DLNneOU8G5
|
instance (priority
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x✝ y✝ z✝ : α
inst✝ : GeneralizedBooleanAlgebra α
src✝¹ : GeneralizedBooleanAlgebra α := inst✝
src✝ : OrderBot α := toOrderBot
y x z : α
h : y \ x ≤ z
⊢ y \ x ⊔ x ⊔ z = x ⊔ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by
|
ac_rfl
|
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by
|
Mathlib.Order.BooleanAlgebra.180_0.ewE75DLNneOU8G5
|
instance (priority
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x✝ y✝ z✝ : α
inst✝ : GeneralizedBooleanAlgebra α
src✝¹ : GeneralizedBooleanAlgebra α := inst✝
src✝ : OrderBot α := toOrderBot
y x z : α
h : y ≤ x ⊔ z
⊢ x ⊔ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by
|
rw [sup_assoc, sup_comm, sup_assoc, sup_idem]
|
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by
|
Mathlib.Order.BooleanAlgebra.180_0.ewE75DLNneOU8G5
|
instance (priority
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : x ≤ y ∧ Disjoint x z
⊢ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by
|
rw [← h.2.sdiff_eq_left]
|
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by
|
Mathlib.Order.BooleanAlgebra.217_0.ewE75DLNneOU8G5
|
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : x ≤ y ∧ Disjoint x z
⊢ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left];
|
exact sdiff_le_sdiff_right h.1
|
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left];
|
Mathlib.Order.BooleanAlgebra.217_0.ewE75DLNneOU8G5
|
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hi : Disjoint x z
hs : x ⊔ z = y
h : y ⊓ x = x
⊢ y ⊓ x ⊔ z = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by
|
rw [h, hs]
|
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by
|
Mathlib.Order.BooleanAlgebra.228_0.ewE75DLNneOU8G5
|
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hi : Disjoint x z
hs : x ⊔ z = y
h : y ⊓ x = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by
|
rw [h, hi.eq_bot]
|
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by
|
Mathlib.Order.BooleanAlgebra.228_0.ewE75DLNneOU8G5
|
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hd : Disjoint x z
hz : z ≤ y
hs : y ≤ x ⊔ z
⊢ y ⊓ x ⊔ z = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
|
rw [← inf_eq_right] at hs
|
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
|
Mathlib.Order.BooleanAlgebra.233_0.ewE75DLNneOU8G5
|
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hd : Disjoint x z
hz : z ≤ y
hs : (x ⊔ z) ⊓ y = y
⊢ y ⊓ x ⊔ z = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
|
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left]
|
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
|
Mathlib.Order.BooleanAlgebra.233_0.ewE75DLNneOU8G5
|
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hd : Disjoint x z
hz : z ≤ y
hs : y ≤ x ⊔ z
⊢ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by
|
rw [inf_assoc, hd.eq_bot, inf_bot_eq]
|
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by
|
Mathlib.Order.BooleanAlgebra.233_0.ewE75DLNneOU8G5
|
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : Disjoint z (y \ x)
⊢ z ⊔ y \ x ≤ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
|
rw [sup_sdiff_cancel_right hx]
|
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
|
Mathlib.Order.BooleanAlgebra.244_0.ewE75DLNneOU8G5
|
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : Disjoint z (y \ x)
⊢ z ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
|
refine' le_trans (sup_le_sup_left sdiff_le z) _
|
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
|
Mathlib.Order.BooleanAlgebra.244_0.ewE75DLNneOU8G5
|
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : Disjoint z (y \ x)
⊢ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
|
rw [sup_eq_right.2 hz]
|
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
|
Mathlib.Order.BooleanAlgebra.244_0.ewE75DLNneOU8G5
|
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
⊢ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
|
rw [← disjoint_iff]
|
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
|
Mathlib.Order.BooleanAlgebra.260_0.ewE75DLNneOU8G5
|
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
⊢ Disjoint z (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
|
exact disjoint_sdiff_iff_le hz hx
|
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
|
Mathlib.Order.BooleanAlgebra.260_0.ewE75DLNneOU8G5
|
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ y = z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
|
apply le_antisymm
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
case a
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ y ≤ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
·
|
conv_lhs => rw [← sup_inf_sdiff y x]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
·
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
| 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs =>
|
rw [← sup_inf_sdiff y x]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs =>
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
| 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs =>
|
rw [← sup_inf_sdiff y x]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs =>
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
| 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs =>
|
rw [← sup_inf_sdiff y x]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs =>
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
case a
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ y ⊓ x ⊔ y \ x ≤ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
|
apply sup_le_sup_right
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
case a.h₁
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
|
rwa [inf_eq_right.2 hx]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
case a
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ z ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
·
|
apply le_trans
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
·
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
case a.a
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ z ⊔ y \ x ≤ ?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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
·
|
apply sup_le_sup_right hz
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
·
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
case a.a
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ≤ z
⊢ y ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
·
|
rw [sup_sdiff_left]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
·
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : y = z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
|
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : y = z ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H =>
|
rw [← sup_sdiff_cancel_right hx]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H =>
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : y = z ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H =>
|
rw [← sup_sdiff_cancel_right hx]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H =>
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : y = z ⊔ y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H =>
|
rw [← sup_sdiff_cancel_right hx]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H =>
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ⊔ y \ x = z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
|
refine' le_of_inf_le_sup_le _ H.le
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ⊔ y \ x = z ⊔ y \ x
⊢ x ⊓ y \ x ≤ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
|
rw [inf_sdiff_self_right]
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hz : z ≤ y
hx : x ≤ y
H : x ⊔ y \ x = z ⊔ y \ x
⊢ ⊥ ≤ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
|
exact bot_le
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
|
Mathlib.Order.BooleanAlgebra.266_0.ewE75DLNneOU8G5
|
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by
|
rw [sup_inf_left]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by
|
rw [@inf_sup_left _ _ y]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by
|
ac_rfl
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) = (y ⊓ z ⊔ y) ⊓ (y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by
|
rw [sup_inf_sdiff, sup_inf_sdiff]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) = (y ⊔ y ⊓ z) ⊓ (y ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by
|
ac_rfl
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by
|
rw [sup_inf_self, sup_inf_self, inf_idem]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by
|
rw [inf_sup_left]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by
|
rw [inf_sup_right]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by
|
ac_rfl
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by
|
rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq]
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by
|
Mathlib.Order.BooleanAlgebra.283_0.ewE75DLNneOU8G5
|
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : y \ x = y \ z
⊢ y ⊓ x ⊓ ?m.20748 h = y ⊓ z ⊓ ?m.20748 h
|
/-
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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by
|
rw [inf_inf_sdiff, h, inf_inf_sdiff]
|
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by
|
Mathlib.Order.BooleanAlgebra.301_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : y \ x = y \ z
⊢ y ⊓ x ⊔ y \ x = y ⊓ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by
|
rw [sup_inf_sdiff, h, sup_inf_sdiff]
|
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by
|
Mathlib.Order.BooleanAlgebra.301_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : y ⊓ x = y ⊓ z
⊢ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by
|
rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]
|
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by
|
Mathlib.Order.BooleanAlgebra.301_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x \ y = x ↔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by
|
rw [sdiff_bot]
|
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by
|
Mathlib.Order.BooleanAlgebra.307_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y = x ⊓ ⊥ ↔ Disjoint 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by
|
rw [inf_bot_eq, inf_comm, disjoint_iff]
|
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by
|
Mathlib.Order.BooleanAlgebra.307_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x \ y = x ↔ Disjoint 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
|
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
|
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
|
Mathlib.Order.BooleanAlgebra.314_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hx : y ≤ x
hy : 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
|
refine' sdiff_le.lt_of_ne fun h => hy _
|
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
|
Mathlib.Order.BooleanAlgebra.318_0.ewE75DLNneOU8G5
|
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hx : y ≤ x
hy : y ≠ ⊥
h : x \ y = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
|
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
|
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
|
Mathlib.Order.BooleanAlgebra.318_0.ewE75DLNneOU8G5
|
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hx : y ≤ x
hy : y ≠ ⊥
h : 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
|
rw [← h, inf_eq_right.mpr hx]
|
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
|
Mathlib.Order.BooleanAlgebra.318_0.ewE75DLNneOU8G5
|
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by
|
rw [inf_assoc]
|
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by
|
Mathlib.Order.BooleanAlgebra.334_0.ewE75DLNneOU8G5
|
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y ⊓ z) ⊔ y \ z = (x ⊔ y \ z) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by
|
rw [sup_inf_right, sup_inf_sdiff]
|
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by
|
Mathlib.Order.BooleanAlgebra.334_0.ewE75DLNneOU8G5
|
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (x ⊔ y \ z) ⊓ y = x ⊓ y ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by
|
rw [inf_sup_right, inf_sdiff_left]
|
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by
|
Mathlib.Order.BooleanAlgebra.334_0.ewE75DLNneOU8G5
|
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x \ (y \ z) = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
|
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x \ (y \ z) = z ⊓ x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
|
apply sdiff_unique
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
case s
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ z ⊔ (z ⊓ x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
·
|
calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
·
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by
|
rw [sup_inf_right]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by
|
ac_rfl
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) = x ⊓ (y \ z ⊔ x ⊓ z ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by
|
rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by
|
rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by
|
rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by
|
ac_rfl
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) = x ⊓ (y \ z ⊔ (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by
|
rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊔ (x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by
|
rw [sup_inf_self, sup_comm, inf_sup_self]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
case i
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ z ⊓ (z ⊓ x ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
·
|
calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
·
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by
|
rw [inf_sup_left]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by
|
ac_rfl
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y = x ⊓ y \ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by
|
rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ y \ z ⊓ x \ y = x ⊓ (y \ z ⊓ y) ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by
|
conv_lhs => rw [← inf_sdiff_left]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
| x ⊓ y \ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs =>
|
rw [← inf_sdiff_left]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs =>
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
| x ⊓ y \ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs =>
|
rw [← inf_sdiff_left]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs =>
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
| x ⊓ y \ z ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs =>
|
rw [← inf_sdiff_left]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs =>
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊓ y) ⊓ x \ y = x ⊓ (y \ z ⊓ (y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by
|
ac_rfl
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x ⊓ (y \ z ⊓ (y ⊓ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by
|
rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by
|
Mathlib.Order.BooleanAlgebra.341_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x \ y ⊔ x ⊓ y ⊓ z = z ⊓ x ⊓ y ⊔ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by
|
ac_rfl
|
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by
|
Mathlib.Order.BooleanAlgebra.365_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ z ⊓ x ⊓ y ⊔ x \ y = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by
|
rw [sup_inf_inf_sdiff, sup_comm, inf_comm]
|
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by
|
Mathlib.Order.BooleanAlgebra.365_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : z ≤ x
⊢ x \ (y \ z) = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by rw [sup_inf_inf_sdiff, sup_comm, inf_comm]
#align sdiff_sdiff_right' sdiff_sdiff_right'
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z := by
|
rw [sdiff_sdiff_right', inf_eq_right.2 h]
|
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z := by
|
Mathlib.Order.BooleanAlgebra.372_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
⊢ x \ (x \ y) = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by rw [sup_inf_inf_sdiff, sup_comm, inf_comm]
#align sdiff_sdiff_right' sdiff_sdiff_right'
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z := by
rw [sdiff_sdiff_right', inf_eq_right.2 h]
#align sdiff_sdiff_eq_sdiff_sup sdiff_sdiff_eq_sdiff_sup
@[simp]
theorem sdiff_sdiff_right_self : x \ (x \ y) = x ⊓ y := by
|
rw [sdiff_sdiff_right, inf_idem, sdiff_self, bot_sup_eq]
|
@[simp]
theorem sdiff_sdiff_right_self : x \ (x \ y) = x ⊓ y := by
|
Mathlib.Order.BooleanAlgebra.376_0.ewE75DLNneOU8G5
|
@[simp]
theorem sdiff_sdiff_right_self : x \ (x \ y) = x ⊓ y
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
h : y ≤ x
⊢ x \ (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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by rw [sup_inf_inf_sdiff, sup_comm, inf_comm]
#align sdiff_sdiff_right' sdiff_sdiff_right'
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z := by
rw [sdiff_sdiff_right', inf_eq_right.2 h]
#align sdiff_sdiff_eq_sdiff_sup sdiff_sdiff_eq_sdiff_sup
@[simp]
theorem sdiff_sdiff_right_self : x \ (x \ y) = x ⊓ y := by
rw [sdiff_sdiff_right, inf_idem, sdiff_self, bot_sup_eq]
#align sdiff_sdiff_right_self sdiff_sdiff_right_self
theorem sdiff_sdiff_eq_self (h : y ≤ x) : x \ (x \ y) = y := by
|
rw [sdiff_sdiff_right_self, inf_of_le_right h]
|
theorem sdiff_sdiff_eq_self (h : y ≤ x) : x \ (x \ y) = y := by
|
Mathlib.Order.BooleanAlgebra.381_0.ewE75DLNneOU8G5
|
theorem sdiff_sdiff_eq_self (h : y ≤ x) : x \ (x \ y) = y
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hy : y ≤ x
h : x \ y = z
⊢ x \ z = 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by rw [sup_inf_inf_sdiff, sup_comm, inf_comm]
#align sdiff_sdiff_right' sdiff_sdiff_right'
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z := by
rw [sdiff_sdiff_right', inf_eq_right.2 h]
#align sdiff_sdiff_eq_sdiff_sup sdiff_sdiff_eq_sdiff_sup
@[simp]
theorem sdiff_sdiff_right_self : x \ (x \ y) = x ⊓ y := by
rw [sdiff_sdiff_right, inf_idem, sdiff_self, bot_sup_eq]
#align sdiff_sdiff_right_self sdiff_sdiff_right_self
theorem sdiff_sdiff_eq_self (h : y ≤ x) : x \ (x \ y) = y := by
rw [sdiff_sdiff_right_self, inf_of_le_right h]
#align sdiff_sdiff_eq_self sdiff_sdiff_eq_self
theorem sdiff_eq_symm (hy : y ≤ x) (h : x \ y = z) : x \ z = y := by
|
rw [← h, sdiff_sdiff_eq_self hy]
|
theorem sdiff_eq_symm (hy : y ≤ x) (h : x \ y = z) : x \ z = y := by
|
Mathlib.Order.BooleanAlgebra.385_0.ewE75DLNneOU8G5
|
theorem sdiff_eq_symm (hy : y ≤ x) (h : x \ y = z) : x \ z = y
|
Mathlib_Order_BooleanAlgebra
|
α : Type u
β : Type u_1
w x y z : α
inst✝ : GeneralizedBooleanAlgebra α
hxz : x ≤ z
hyz : y ≤ z
h : z \ x = z \ y
⊢ 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, Bryan Gin-ge Chen
-/
import Mathlib.Order.Heyting.Basic
#align_import order.boolean_algebra from "leanprover-community/mathlib"@"9ac7c0c8c4d7a535ec3e5b34b8859aab9233b2f4"
/-!
# (Generalized) Boolean algebras
A Boolean algebra is a bounded distributive lattice with a complement operator. Boolean algebras
generalize the (classical) logic of propositions and the lattice of subsets of a set.
Generalized Boolean algebras may be less familiar, but they are essentially Boolean algebras which
do not necessarily have a top element (`⊤`) (and hence not all elements may have complements). One
example in mathlib is `Finset α`, the type of all finite subsets of an arbitrary
(not-necessarily-finite) type `α`.
`GeneralizedBooleanAlgebra α` is defined to be a distributive lattice with bottom (`⊥`) admitting
a *relative* complement operator, written using "set difference" notation as `x \ y` (`sdiff x y`).
For convenience, the `BooleanAlgebra` type class is defined to extend `GeneralizedBooleanAlgebra`
so that it is also bundled with a `\` operator.
(A terminological point: `x \ y` is the complement of `y` relative to the interval `[⊥, x]`. We do
not yet have relative complements for arbitrary intervals, as we do not even have lattice
intervals.)
## Main declarations
* `GeneralizedBooleanAlgebra`: a type class for generalized Boolean algebras
* `BooleanAlgebra`: a type class for Boolean algebras.
* `Prop.booleanAlgebra`: the Boolean algebra instance on `Prop`
## Implementation notes
The `sup_inf_sdiff` and `inf_inf_sdiff` axioms for the relative complement operator in
`GeneralizedBooleanAlgebra` are taken from
[Wikipedia](https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations).
[Stone's paper introducing generalized Boolean algebras][Stone1935] does not define a relative
complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amount to an assumption
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
`x`. `Disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
## References
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
* [*Postulates for Boolean Algebras and Generalized Boolean Algebras*, M.H. Stone][Stone1935]
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
## Tags
generalized Boolean algebras, Boolean algebras, lattices, sdiff, compl
-/
open Function OrderDual
universe u v
variable {α : Type u} {β : Type*} {w x y z : α}
/-!
### Generalized Boolean algebras
Some of the lemmas in this section are from:
* [*Lattice Theory: Foundation*, George Grätzer][Gratzer2011]
* <https://ncatlab.org/nlab/show/relative+complement>
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
-/
/-- A generalized Boolean algebra is a distributive lattice with `⊥` and a relative complement
operation `\` (called `sdiff`, after "set difference") satisfying `(a ⊓ b) ⊔ (a \ b) = a` and
`(a ⊓ b) ⊓ (a \ b) = ⊥`, i.e. `a \ b` is the complement of `b` in `a`.
This is a generalization of Boolean algebras which applies to `Finset α` for arbitrary
(not-necessarily-`Fintype`) `α`. -/
class GeneralizedBooleanAlgebra (α : Type u) extends DistribLattice α, SDiff α, Bot α where
/-- For any `a`, `b`, `(a ⊓ b) ⊔ (a / b) = a` -/
sup_inf_sdiff : ∀ a b : α, a ⊓ b ⊔ a \ b = a
/-- For any `a`, `b`, `(a ⊓ b) ⊓ (a / b) = ⊥` -/
inf_inf_sdiff : ∀ a b : α, a ⊓ b ⊓ a \ b = ⊥
#align generalized_boolean_algebra GeneralizedBooleanAlgebra
-- We might want an `IsCompl_of` predicate (for relative complements) generalizing `IsCompl`,
-- however we'd need another type class for lattices with bot, and all the API for that.
section GeneralizedBooleanAlgebra
variable [GeneralizedBooleanAlgebra α]
@[simp]
theorem sup_inf_sdiff (x y : α) : x ⊓ y ⊔ x \ y = x :=
GeneralizedBooleanAlgebra.sup_inf_sdiff _ _
#align sup_inf_sdiff sup_inf_sdiff
@[simp]
theorem inf_inf_sdiff (x y : α) : x ⊓ y ⊓ x \ y = ⊥ :=
GeneralizedBooleanAlgebra.inf_inf_sdiff _ _
#align inf_inf_sdiff inf_inf_sdiff
@[simp]
theorem sup_sdiff_inf (x y : α) : x \ y ⊔ x ⊓ y = x := by rw [sup_comm, sup_inf_sdiff]
#align sup_sdiff_inf sup_sdiff_inf
@[simp]
theorem inf_sdiff_inf (x y : α) : x \ y ⊓ (x ⊓ y) = ⊥ := by rw [inf_comm, inf_inf_sdiff]
#align inf_sdiff_inf inf_sdiff_inf
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toOrderBot : OrderBot α :=
{ GeneralizedBooleanAlgebra.toBot with
bot_le := fun a => by
rw [← inf_inf_sdiff a a, inf_assoc]
exact inf_le_left }
#align generalized_boolean_algebra.to_order_bot GeneralizedBooleanAlgebra.toOrderBot
theorem disjoint_inf_sdiff : Disjoint (x ⊓ y) (x \ y) :=
disjoint_iff_inf_le.mpr (inf_inf_sdiff x y).le
#align disjoint_inf_sdiff disjoint_inf_sdiff
-- TODO: in distributive lattices, relative complements are unique when they exist
theorem sdiff_unique (s : x ⊓ y ⊔ z = x) (i : x ⊓ y ⊓ z = ⊥) : x \ y = z := by
conv_rhs at s => rw [← sup_inf_sdiff x y, sup_comm]
rw [sup_comm] at s
conv_rhs at i => rw [← inf_inf_sdiff x y, inf_comm]
rw [inf_comm] at i
exact (eq_of_inf_eq_sup_eq i s).symm
#align sdiff_unique sdiff_unique
-- Use `sdiff_le`
private theorem sdiff_le' : x \ y ≤ x :=
calc
x \ y ≤ x ⊓ y ⊔ x \ y := le_sup_right
_ = x := sup_inf_sdiff x y
-- Use `sdiff_sup_self`
private theorem sdiff_sup_self' : y \ x ⊔ x = y ⊔ x :=
calc
y \ x ⊔ x = y \ x ⊔ (x ⊔ x ⊓ y) := by rw [sup_inf_self]
_ = y ⊓ x ⊔ y \ x ⊔ x := by ac_rfl
_ = y ⊔ x := by rw [sup_inf_sdiff]
@[simp]
theorem sdiff_inf_sdiff : x \ y ⊓ y \ x = ⊥ :=
Eq.symm <|
calc
⊥ = x ⊓ y ⊓ x \ y := by rw [inf_inf_sdiff]
_ = x ⊓ (y ⊓ x ⊔ y \ x) ⊓ x \ y := by rw [sup_inf_sdiff]
_ = (x ⊓ (y ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_sup_left]
_ = (y ⊓ (x ⊓ x) ⊔ x ⊓ y \ x) ⊓ x \ y := by ac_rfl
_ = (y ⊓ x ⊔ x ⊓ y \ x) ⊓ x \ y := by rw [inf_idem]
_ = x ⊓ y ⊓ x \ y ⊔ x ⊓ y \ x ⊓ x \ y := by rw [inf_sup_right, @inf_comm _ _ x y]
_ = x ⊓ y \ x ⊓ x \ y := by rw [inf_inf_sdiff, bot_sup_eq]
_ = x ⊓ x \ y ⊓ y \ x := by ac_rfl
_ = x \ y ⊓ y \ x := by rw [inf_of_le_right sdiff_le']
#align sdiff_inf_sdiff sdiff_inf_sdiff
theorem disjoint_sdiff_sdiff : Disjoint (x \ y) (y \ x) :=
disjoint_iff_inf_le.mpr sdiff_inf_sdiff.le
#align disjoint_sdiff_sdiff disjoint_sdiff_sdiff
@[simp]
theorem inf_sdiff_self_right : x ⊓ y \ x = ⊥ :=
calc
x ⊓ y \ x = (x ⊓ y ⊔ x \ y) ⊓ y \ x := by rw [sup_inf_sdiff]
_ = x ⊓ y ⊓ y \ x ⊔ x \ y ⊓ y \ x := by rw [inf_sup_right]
_ = ⊥ := by rw [@inf_comm _ _ x y, inf_inf_sdiff, sdiff_inf_sdiff, bot_sup_eq]
#align inf_sdiff_self_right inf_sdiff_self_right
@[simp]
theorem inf_sdiff_self_left : y \ x ⊓ x = ⊥ := by rw [inf_comm, inf_sdiff_self_right]
#align inf_sdiff_self_left inf_sdiff_self_left
-- see Note [lower instance priority]
instance (priority := 100) GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra :
GeneralizedCoheytingAlgebra α :=
{ ‹GeneralizedBooleanAlgebra α›, GeneralizedBooleanAlgebra.toOrderBot with
sdiff := (· \ ·),
sdiff_le_iff := fun y x z =>
⟨fun h =>
le_of_inf_le_sup_le
(le_of_eq
(calc
y ⊓ y \ x = y \ x := inf_of_le_right sdiff_le'
_ = x ⊓ y \ x ⊔ z ⊓ y \ x :=
by rw [inf_eq_right.2 h, inf_sdiff_self_right, bot_sup_eq]
_ = (x ⊔ z) ⊓ y \ x := inf_sup_right.symm))
(calc
y ⊔ y \ x = y := sup_of_le_left sdiff_le'
_ ≤ y ⊔ (x ⊔ z) := le_sup_left
_ = y \ x ⊔ x ⊔ z := by rw [← sup_assoc, ← @sdiff_sup_self' _ x y]
_ = x ⊔ z ⊔ y \ x := by ac_rfl),
fun h =>
le_of_inf_le_sup_le
(calc
y \ x ⊓ x = ⊥ := inf_sdiff_self_left
_ ≤ z ⊓ x := bot_le)
(calc
y \ x ⊔ x = y ⊔ x := sdiff_sup_self'
_ ≤ x ⊔ z ⊔ x := sup_le_sup_right h x
_ ≤ z ⊔ x := by rw [sup_assoc, sup_comm, sup_assoc, sup_idem])⟩ }
#align generalized_boolean_algebra.to_generalized_coheyting_algebra GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra
theorem disjoint_sdiff_self_left : Disjoint (y \ x) x :=
disjoint_iff_inf_le.mpr inf_sdiff_self_left.le
#align disjoint_sdiff_self_left disjoint_sdiff_self_left
theorem disjoint_sdiff_self_right : Disjoint x (y \ x) :=
disjoint_iff_inf_le.mpr inf_sdiff_self_right.le
#align disjoint_sdiff_self_right disjoint_sdiff_self_right
lemma le_sdiff : x ≤ y \ z ↔ x ≤ y ∧ Disjoint x z :=
⟨fun h ↦ ⟨h.trans sdiff_le, disjoint_sdiff_self_left.mono_left h⟩, fun h ↦
by rw [← h.2.sdiff_eq_left]; exact sdiff_le_sdiff_right h.1⟩
#align le_sdiff le_sdiff
@[simp] lemma sdiff_eq_left : x \ y = x ↔ Disjoint x y :=
⟨fun h ↦ disjoint_sdiff_self_left.mono_left h.ge, Disjoint.sdiff_eq_left⟩
#align sdiff_eq_left sdiff_eq_left
/- TODO: we could make an alternative constructor for `GeneralizedBooleanAlgebra` using
`Disjoint x (y \ x)` and `x ⊔ (y \ x) = y` as axioms. -/
theorem Disjoint.sdiff_eq_of_sup_eq (hi : Disjoint x z) (hs : x ⊔ z = y) : y \ x = z :=
have h : y ⊓ x = x := inf_eq_right.2 <| le_sup_left.trans hs.le
sdiff_unique (by rw [h, hs]) (by rw [h, hi.eq_bot])
#align disjoint.sdiff_eq_of_sup_eq Disjoint.sdiff_eq_of_sup_eq
protected theorem Disjoint.sdiff_unique (hd : Disjoint x z) (hz : z ≤ y) (hs : y ≤ x ⊔ z) :
y \ x = z :=
sdiff_unique
(by
rw [← inf_eq_right] at hs
rwa [sup_inf_right, inf_sup_right, @sup_comm _ _ x, inf_sup_self, inf_comm, @sup_comm _ _ z,
hs, sup_eq_left])
(by rw [inf_assoc, hd.eq_bot, inf_bot_eq])
#align disjoint.sdiff_unique Disjoint.sdiff_unique
-- cf. `IsCompl.disjoint_left_iff` and `IsCompl.disjoint_right_iff`
theorem disjoint_sdiff_iff_le (hz : z ≤ y) (hx : x ≤ y) : Disjoint z (y \ x) ↔ z ≤ x :=
⟨fun H =>
le_of_inf_le_sup_le (le_trans H.le_bot bot_le)
(by
rw [sup_sdiff_cancel_right hx]
refine' le_trans (sup_le_sup_left sdiff_le z) _
rw [sup_eq_right.2 hz]),
fun H => disjoint_sdiff_self_right.mono_left H⟩
#align disjoint_sdiff_iff_le disjoint_sdiff_iff_le
-- cf. `IsCompl.le_left_iff` and `IsCompl.le_right_iff`
theorem le_iff_disjoint_sdiff (hz : z ≤ y) (hx : x ≤ y) : z ≤ x ↔ Disjoint z (y \ x) :=
(disjoint_sdiff_iff_le hz hx).symm
#align le_iff_disjoint_sdiff le_iff_disjoint_sdiff
-- cf. `IsCompl.inf_left_eq_bot_iff` and `IsCompl.inf_right_eq_bot_iff`
theorem inf_sdiff_eq_bot_iff (hz : z ≤ y) (hx : x ≤ y) : z ⊓ y \ x = ⊥ ↔ z ≤ x := by
rw [← disjoint_iff]
exact disjoint_sdiff_iff_le hz hx
#align inf_sdiff_eq_bot_iff inf_sdiff_eq_bot_iff
-- cf. `IsCompl.left_le_iff` and `IsCompl.right_le_iff`
theorem le_iff_eq_sup_sdiff (hz : z ≤ y) (hx : x ≤ y) : x ≤ z ↔ y = z ⊔ y \ x :=
⟨fun H => by
apply le_antisymm
· conv_lhs => rw [← sup_inf_sdiff y x]
apply sup_le_sup_right
rwa [inf_eq_right.2 hx]
· apply le_trans
· apply sup_le_sup_right hz
· rw [sup_sdiff_left],
fun H => by
conv_lhs at H => rw [← sup_sdiff_cancel_right hx]
refine' le_of_inf_le_sup_le _ H.le
rw [inf_sdiff_self_right]
exact bot_le⟩
#align le_iff_eq_sup_sdiff le_iff_eq_sup_sdiff
-- cf. `IsCompl.sup_inf`
theorem sdiff_sup : y \ (x ⊔ z) = y \ x ⊓ y \ z :=
sdiff_unique
(calc
y ⊓ (x ⊔ z) ⊔ y \ x ⊓ y \ z = (y ⊓ (x ⊔ z) ⊔ y \ x) ⊓ (y ⊓ (x ⊔ z) ⊔ y \ z) :=
by rw [sup_inf_left]
_ = (y ⊓ x ⊔ y ⊓ z ⊔ y \ x) ⊓ (y ⊓ x ⊔ y ⊓ z ⊔ y \ z) := by rw [@inf_sup_left _ _ y]
_ = (y ⊓ z ⊔ (y ⊓ x ⊔ y \ x)) ⊓ (y ⊓ x ⊔ (y ⊓ z ⊔ y \ z)) := by ac_rfl
_ = (y ⊓ z ⊔ y) ⊓ (y ⊓ x ⊔ y) := by rw [sup_inf_sdiff, sup_inf_sdiff]
_ = (y ⊔ y ⊓ z) ⊓ (y ⊔ y ⊓ x) := by ac_rfl
_ = y := by rw [sup_inf_self, sup_inf_self, inf_idem])
(calc
y ⊓ (x ⊔ z) ⊓ (y \ x ⊓ y \ z) = (y ⊓ x ⊔ y ⊓ z) ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_left]
_ = y ⊓ x ⊓ (y \ x ⊓ y \ z) ⊔ y ⊓ z ⊓ (y \ x ⊓ y \ z) := by rw [inf_sup_right]
_ = y ⊓ x ⊓ y \ x ⊓ y \ z ⊔ y \ x ⊓ (y \ z ⊓ (y ⊓ z)) := by ac_rfl
_ = ⊥ := by rw [inf_inf_sdiff, bot_inf_eq, bot_sup_eq, @inf_comm _ _ (y \ z),
inf_inf_sdiff, inf_bot_eq])
#align sdiff_sup sdiff_sup
theorem sdiff_eq_sdiff_iff_inf_eq_inf : y \ x = y \ z ↔ y ⊓ x = y ⊓ z :=
⟨fun h => eq_of_inf_eq_sup_eq (by rw [inf_inf_sdiff, h, inf_inf_sdiff])
(by rw [sup_inf_sdiff, h, sup_inf_sdiff]),
fun h => by rw [← sdiff_inf_self_right, ← sdiff_inf_self_right z y, inf_comm, h, inf_comm]⟩
#align sdiff_eq_sdiff_iff_inf_eq_inf sdiff_eq_sdiff_iff_inf_eq_inf
theorem sdiff_eq_self_iff_disjoint : x \ y = x ↔ Disjoint y x :=
calc
x \ y = x ↔ x \ y = x \ ⊥ := by rw [sdiff_bot]
_ ↔ x ⊓ y = x ⊓ ⊥ := sdiff_eq_sdiff_iff_inf_eq_inf
_ ↔ Disjoint y x := by rw [inf_bot_eq, inf_comm, disjoint_iff]
#align sdiff_eq_self_iff_disjoint sdiff_eq_self_iff_disjoint
theorem sdiff_eq_self_iff_disjoint' : x \ y = x ↔ Disjoint x y := by
rw [sdiff_eq_self_iff_disjoint, disjoint_comm]
#align sdiff_eq_self_iff_disjoint' sdiff_eq_self_iff_disjoint'
theorem sdiff_lt (hx : y ≤ x) (hy : y ≠ ⊥) : x \ y < x := by
refine' sdiff_le.lt_of_ne fun h => hy _
rw [sdiff_eq_self_iff_disjoint', disjoint_iff] at h
rw [← h, inf_eq_right.mpr hx]
#align sdiff_lt sdiff_lt
@[simp]
theorem le_sdiff_iff : x ≤ y \ x ↔ x = ⊥ :=
⟨fun h => disjoint_self.1 (disjoint_sdiff_self_right.mono_right h), fun h => h.le.trans bot_le⟩
#align le_sdiff_iff le_sdiff_iff
theorem sdiff_lt_sdiff_right (h : x < y) (hz : z ≤ x) : x \ z < y \ z :=
(sdiff_le_sdiff_right h.le).lt_of_not_le
fun h' => h.not_le <| le_sdiff_sup.trans <| sup_le_of_le_sdiff_right h' hz
#align sdiff_lt_sdiff_right sdiff_lt_sdiff_right
theorem sup_inf_inf_sdiff : x ⊓ y ⊓ z ⊔ y \ z = x ⊓ y ⊔ y \ z :=
calc
x ⊓ y ⊓ z ⊔ y \ z = x ⊓ (y ⊓ z) ⊔ y \ z := by rw [inf_assoc]
_ = (x ⊔ y \ z) ⊓ y := by rw [sup_inf_right, sup_inf_sdiff]
_ = x ⊓ y ⊔ y \ z := by rw [inf_sup_right, inf_sdiff_left]
#align sup_inf_inf_sdiff sup_inf_inf_sdiff
theorem sdiff_sdiff_right : x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := by
rw [sup_comm, inf_comm, ← inf_assoc, sup_inf_inf_sdiff]
apply sdiff_unique
· calc
x ⊓ y \ z ⊔ (z ⊓ x ⊔ x \ y) = (x ⊔ (z ⊓ x ⊔ x \ y)) ⊓ (y \ z ⊔ (z ⊓ x ⊔ x \ y)) :=
by rw [sup_inf_right]
_ = (x ⊔ x ⊓ z ⊔ x \ y) ⊓ (y \ z ⊔ (x ⊓ z ⊔ x \ y)) := by ac_rfl
_ = x ⊓ (y \ z ⊔ x ⊓ z ⊔ x \ y) := by rw [sup_inf_self, sup_sdiff_left, ← sup_assoc]
_ = x ⊓ (y \ z ⊓ (z ⊔ y) ⊔ x ⊓ (z ⊔ y) ⊔ x \ y) :=
by rw [sup_inf_left, sdiff_sup_self', inf_sup_right, @sup_comm _ _ y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ x ⊓ y) ⊔ x \ y) :=
by rw [inf_sdiff_sup_right, @inf_sup_left _ _ x z y]
_ = x ⊓ (y \ z ⊔ (x ⊓ z ⊔ (x ⊓ y ⊔ x \ y))) := by ac_rfl
_ = x ⊓ (y \ z ⊔ (x ⊔ x ⊓ z)) := by rw [sup_inf_sdiff, @sup_comm _ _ (x ⊓ z)]
_ = x := by rw [sup_inf_self, sup_comm, inf_sup_self]
· calc
x ⊓ y \ z ⊓ (z ⊓ x ⊔ x \ y) = x ⊓ y \ z ⊓ (z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by rw [inf_sup_left]
_ = x ⊓ (y \ z ⊓ z ⊓ x) ⊔ x ⊓ y \ z ⊓ x \ y := by ac_rfl
_ = x ⊓ y \ z ⊓ x \ y := by rw [inf_sdiff_self_left, bot_inf_eq, inf_bot_eq, bot_sup_eq]
_ = x ⊓ (y \ z ⊓ y) ⊓ x \ y := by conv_lhs => rw [← inf_sdiff_left]
_ = x ⊓ (y \ z ⊓ (y ⊓ x \ y)) := by ac_rfl
_ = ⊥ := by rw [inf_sdiff_self_right, inf_bot_eq, inf_bot_eq]
#align sdiff_sdiff_right sdiff_sdiff_right
theorem sdiff_sdiff_right' : x \ (y \ z) = x \ y ⊔ x ⊓ z :=
calc
x \ (y \ z) = x \ y ⊔ x ⊓ y ⊓ z := sdiff_sdiff_right
_ = z ⊓ x ⊓ y ⊔ x \ y := by ac_rfl
_ = x \ y ⊔ x ⊓ z := by rw [sup_inf_inf_sdiff, sup_comm, inf_comm]
#align sdiff_sdiff_right' sdiff_sdiff_right'
theorem sdiff_sdiff_eq_sdiff_sup (h : z ≤ x) : x \ (y \ z) = x \ y ⊔ z := by
rw [sdiff_sdiff_right', inf_eq_right.2 h]
#align sdiff_sdiff_eq_sdiff_sup sdiff_sdiff_eq_sdiff_sup
@[simp]
theorem sdiff_sdiff_right_self : x \ (x \ y) = x ⊓ y := by
rw [sdiff_sdiff_right, inf_idem, sdiff_self, bot_sup_eq]
#align sdiff_sdiff_right_self sdiff_sdiff_right_self
theorem sdiff_sdiff_eq_self (h : y ≤ x) : x \ (x \ y) = y := by
rw [sdiff_sdiff_right_self, inf_of_le_right h]
#align sdiff_sdiff_eq_self sdiff_sdiff_eq_self
theorem sdiff_eq_symm (hy : y ≤ x) (h : x \ y = z) : x \ z = y := by
rw [← h, sdiff_sdiff_eq_self hy]
#align sdiff_eq_symm sdiff_eq_symm
theorem sdiff_eq_comm (hy : y ≤ x) (hz : z ≤ x) : x \ y = z ↔ x \ z = y :=
⟨sdiff_eq_symm hy, sdiff_eq_symm hz⟩
#align sdiff_eq_comm sdiff_eq_comm
theorem eq_of_sdiff_eq_sdiff (hxz : x ≤ z) (hyz : y ≤ z) (h : z \ x = z \ y) : x = y := by
|
rw [← sdiff_sdiff_eq_self hxz, h, sdiff_sdiff_eq_self hyz]
|
theorem eq_of_sdiff_eq_sdiff (hxz : x ≤ z) (hyz : y ≤ z) (h : z \ x = z \ y) : x = y := by
|
Mathlib.Order.BooleanAlgebra.393_0.ewE75DLNneOU8G5
|
theorem eq_of_sdiff_eq_sdiff (hxz : x ≤ z) (hyz : y ≤ z) (h : z \ x = z \ y) : x = y
|
Mathlib_Order_BooleanAlgebra
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.