Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit b2ba27c

Browse files
committed
move(order/{boolean_algebra → basic}): move has_compl and trivial instances (#15602)
We move the trivial `pi.has_sdiff`, `pi.has_compl`, and `Prop.has_compl` instances to `order/basic.lean`. The main effect of this is that `rᶜ` for the complement of a relation is now available basically anywhere.
1 parent 0b1e039 commit b2ba27c

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed

src/order/basic.lean

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ classes and allows to transfer order instances.
2929
3030
* `has_sup`: type class for the `⊔` notation
3131
* `has_inf`: type class for the `⊓` notation
32+
* `has_compl`: type class for the `ᶜ` notation
3233
* `densely_ordered`: An order with no gap, i.e. for any two elements `a < b` there exists `c` such
3334
that `a < c < b`.
3435
@@ -446,6 +447,31 @@ linear_order.ext $ λ _ _, iff.rfl
446447

447448
end order_dual
448449

450+
/-! ### `has_compl` -/
451+
452+
/-- Set / lattice complement -/
453+
@[notation_class] class has_compl (α : Type*) := (compl : α → α)
454+
455+
export has_compl (compl)
456+
457+
postfix `ᶜ`:(max+1) := compl
458+
459+
instance Prop.has_compl : has_compl Prop := ⟨not⟩
460+
461+
instance pi.has_compl {ι : Type u} {α : ι → Type v} [∀ i, has_compl (α i)] :
462+
has_compl (Π i, α i) :=
463+
⟨λ x i, (x i)ᶜ⟩
464+
465+
lemma pi.compl_def {ι : Type u} {α : ι → Type v} [∀ i, has_compl (α i)] (x : Π i, α i) :
466+
xᶜ = λ i, (x i)ᶜ := rfl
467+
468+
@[simp]
469+
lemma pi.compl_apply {ι : Type u} {α : ι → Type v} [∀ i, has_compl (α i)] (x : Π i, α i) (i : ι) :
470+
xᶜ i = (x i)ᶜ := rfl
471+
472+
instance is_irrefl.compl (r) [is_irrefl α r] : is_refl α rᶜ := ⟨@irrefl α r _⟩
473+
instance is_refl.compl (r) [is_refl α r] : is_irrefl α rᶜ := ⟨λ a, not_not_intro (refl a)⟩
474+
449475
/-! ### Order instances on the function space -/
450476

451477
instance pi.has_le {ι : Type u} {α : ι → Type v} [∀ i, has_le (α i)] : has_le (Π i, α i) :=
@@ -484,6 +510,17 @@ instance pi.partial_order {ι : Type u} {α : ι → Type v} [∀ i, partial_ord
484510
{ le_antisymm := λ f g h1 h2, funext (λ b, (h1 b).antisymm (h2 b)),
485511
..pi.preorder }
486512

513+
instance pi.has_sdiff {ι : Type u} {α : ι → Type v} [∀ i, has_sdiff (α i)] :
514+
has_sdiff (Π i, α i) :=
515+
⟨λ x y i, x i \ y i⟩
516+
517+
lemma pi.sdiff_def {ι : Type u} {α : ι → Type v} [∀ i, has_sdiff (α i)] (x y : Π i, α i) :
518+
(x \ y) = λ i, x i \ y i := rfl
519+
520+
@[simp]
521+
lemma pi.sdiff_apply {ι : Type u} {α : ι → Type v} [∀ i, has_sdiff (α i)] (x y : Π i, α i) (i : ι) :
522+
(x \ y) i = x i \ y i := rfl
523+
487524
/-! ### `min`/`max` recursors -/
488525

489526
section min_max_rec

src/order/boolean_algebra.lean

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ intervals.)
2626
2727
## Main declarations
2828
29-
* `has_compl`: a type class for the complement operator
3029
* `generalized_boolean_algebra`: a type class for generalized Boolean algebras
3130
* `boolean_algebra`: a type class for Boolean algebras.
3231
* `Prop.boolean_algebra`: the Boolean algebra instance on `Prop`
@@ -42,11 +41,6 @@ complement operator `a \ b` for all `a`, `b`. Instead, the postulates there amou
4241
that for all `a, b : α` where `a ≤ b`, the equations `x ⊔ a = b` and `x ⊓ a = ⊥` have a solution
4342
`x`. `disjoint.sdiff_unique` proves that this `x` is in fact `b \ a`.
4443
45-
## Notations
46-
47-
* `xᶜ` is notation for `compl x`
48-
* `x \ y` is notation for `sdiff x y`.
49-
5044
## References
5145
5246
* <https://en.wikipedia.org/wiki/Boolean_algebra_(structure)#Generalizations>
@@ -586,14 +580,6 @@ end generalized_boolean_algebra
586580
### Boolean algebras
587581
-/
588582

589-
590-
/-- Set / lattice complement -/
591-
@[notation_class] class has_compl (α : Type*) := (compl : α → α)
592-
593-
export has_compl (compl)
594-
595-
postfix `ᶜ`:(max+1) := compl
596-
597583
/-- A Boolean algebra is a bounded distributive lattice with a complement operator `ᶜ` such that
598584
`x ⊓ xᶜ = ⊥` and `x ⊔ xᶜ = ⊤`. For convenience, it must also provide a set difference operation `\`
599585
satisfying `x \ y = x ⊓ yᶜ`.
@@ -773,37 +759,12 @@ by rw [sdiff_eq, compl_inf, compl_compl]
773759
end boolean_algebra
774760

775761
instance Prop.boolean_algebra : boolean_algebra Prop :=
776-
{ compl := not,
777-
inf_compl_le_bot := λ p ⟨Hp, Hpc⟩, Hpc Hp,
762+
{ inf_compl_le_bot := λ p ⟨Hp, Hpc⟩, Hpc Hp,
778763
top_le_sup_compl := λ p H, classical.em p,
764+
.. Prop.has_compl,
779765
.. Prop.distrib_lattice,
780766
.. Prop.bounded_order }
781767

782-
instance pi.has_sdiff {ι : Type u} {α : ι → Type v} [∀ i, has_sdiff (α i)] :
783-
has_sdiff (Π i, α i) :=
784-
⟨λ x y i, x i \ y i⟩
785-
786-
lemma pi.sdiff_def {ι : Type u} {α : ι → Type v} [∀ i, has_sdiff (α i)] (x y : Π i, α i) :
787-
(x \ y) = λ i, x i \ y i := rfl
788-
789-
@[simp]
790-
lemma pi.sdiff_apply {ι : Type u} {α : ι → Type v} [∀ i, has_sdiff (α i)] (x y : Π i, α i) (i : ι) :
791-
(x \ y) i = x i \ y i := rfl
792-
793-
instance pi.has_compl {ι : Type u} {α : ι → Type v} [∀ i, has_compl (α i)] :
794-
has_compl (Π i, α i) :=
795-
⟨λ x i, (x i)ᶜ⟩
796-
797-
lemma pi.compl_def {ι : Type u} {α : ι → Type v} [∀ i, has_compl (α i)] (x : Π i, α i) :
798-
xᶜ = λ i, (x i)ᶜ := rfl
799-
800-
instance is_irrefl.compl (r) [is_irrefl α r] : is_refl α rᶜ := ⟨@irrefl α r _⟩
801-
instance is_refl.compl (r) [is_refl α r] : is_irrefl α rᶜ := ⟨λ a, not_not_intro (refl a)⟩
802-
803-
@[simp]
804-
lemma pi.compl_apply {ι : Type u} {α : ι → Type v} [∀ i, has_compl (α i)] (x : Π i, α i) (i : ι) :
805-
xᶜ i = (x i)ᶜ := rfl
806-
807768
instance pi.boolean_algebra {ι : Type u} {α : ι → Type v} [∀ i, boolean_algebra (α i)] :
808769
boolean_algebra (Π i, α i) :=
809770
{ sdiff_eq := λ x y, funext $ λ i, sdiff_eq,

0 commit comments

Comments
 (0)