Skip to content

Commit

Permalink
chore(Order/*): move SupSet, Set.sUnion etc to a new file (#10232)
Browse files Browse the repository at this point in the history
  • Loading branch information
urkud committed Feb 11, 2024
1 parent 78e6ce7 commit d18f1d0
Show file tree
Hide file tree
Showing 20 changed files with 321 additions and 269 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
Expand Up @@ -3041,6 +3041,7 @@ import Mathlib.Order.RelIso.Group
import Mathlib.Order.RelIso.Set
import Mathlib.Order.RelSeries
import Mathlib.Order.SemiconjSup
import Mathlib.Order.SetNotation
import Mathlib.Order.Sublattice
import Mathlib.Order.SuccPred.Basic
import Mathlib.Order.SuccPred.CompleteLinearOrder
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Module/Torsion.lean
Expand Up @@ -9,6 +9,7 @@ import Mathlib.LinearAlgebra.Isomorphisms
import Mathlib.GroupTheory.Torsion
import Mathlib.RingTheory.Coprime.Ideal
import Mathlib.RingTheory.Finiteness
import Mathlib.Data.Set.Lattice

#align_import algebra.module.torsion from "leanprover-community/mathlib"@"cdc34484a07418af43daf8198beaf5c00324bca8"

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Order/Floor.lean
Expand Up @@ -8,12 +8,12 @@ import Mathlib.Data.Int.Basic
import Mathlib.Data.Int.Lemmas
import Mathlib.Data.Int.CharZero
import Mathlib.Data.Set.Intervals.Group
import Mathlib.Data.Set.Lattice
import Mathlib.Init.Data.Nat.Lemmas
import Mathlib.Tactic.Abel
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Positivity
import Mathlib.Data.Set.Basic
import Mathlib.Order.GaloisConnection

#align_import algebra.order.floor from "leanprover-community/mathlib"@"afdb43429311b885a7988ea15d0bac2aac80f69c"

Expand Down
1 change: 1 addition & 0 deletions Mathlib/Algebra/Order/ToIntervalMod.lean
Expand Up @@ -11,6 +11,7 @@ import Mathlib.Data.Int.SuccPred
import Mathlib.GroupTheory.QuotientGroup
import Mathlib.Order.Circular
import Mathlib.Data.List.TFAE
import Mathlib.Data.Set.Lattice

#align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec"

Expand Down
1 change: 1 addition & 0 deletions Mathlib/Data/ENNReal/Basic.lean
Expand Up @@ -8,6 +8,7 @@ import Mathlib.Algebra.Order.Sub.WithTop
import Mathlib.Data.Set.Intervals.WithBotTop
import Mathlib.Tactic.GCongr.Core
import Mathlib.Algebra.GroupPower.Order
import Mathlib.Data.Set.Lattice

#align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"

Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Data/Set/Intervals/OrdConnected.lean
Expand Up @@ -4,8 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Data.Set.Intervals.OrderEmbedding
import Mathlib.Data.Set.Lattice
import Mathlib.Order.Antichain
import Mathlib.Order.SetNotation

#align_import data.set.intervals.ord_connected from "leanprover-community/mathlib"@"76de8ae01554c3b37d66544866659ff174e66e1f"

Expand Down Expand Up @@ -154,7 +154,7 @@ theorem ordConnected_dual {s : Set α} : OrdConnected (OrderDual.ofDual ⁻¹' s

theorem ordConnected_sInter {S : Set (Set α)} (hS : ∀ s ∈ S, OrdConnected s) :
OrdConnected (⋂₀ S) :=
fun _ hx _ hy => subset_sInter fun s hs => (hS s hs).out (hx s hs) (hy s hs)⟩
fun _x hx _y hy _z hz s hs => (hS s hs).out (hx s hs) (hy s hs) hz
#align set.ord_connected_sInter Set.ordConnected_sInter

theorem ordConnected_iInter {ι : Sort*} {s : ι → Set α} (hs : ∀ i, OrdConnected (s i)) :
Expand Down
1 change: 1 addition & 0 deletions Mathlib/Data/Set/Intervals/OrdConnectedComponent.lean
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Data.Set.Intervals.OrdConnected
import Mathlib.Data.Set.Lattice

#align_import data.set.intervals.ord_connected_component from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"

Expand Down
143 changes: 0 additions & 143 deletions Mathlib/Data/Set/Lattice.lean
Expand Up @@ -67,149 +67,6 @@ namespace Set

/-! ### Complete lattice and complete Boolean algebra instances -/


instance : InfSet (Set α) :=
fun s => { a | ∀ t ∈ s, a ∈ t }⟩

instance : SupSet (Set α) :=
fun s => { a | ∃ t ∈ s, a ∈ t }⟩

/-- Intersection of a set of sets. -/
def sInter (S : Set (Set α)) : Set α :=
sInf S
#align set.sInter Set.sInter

/-- Notation for `Set.sInter` Intersection of a set of sets. -/
prefix:110 "⋂₀ " => sInter

/-- Union of a set of sets. -/
def sUnion (S : Set (Set α)) : Set α :=
sSup S
#align set.sUnion Set.sUnion

/-- Notation for `Set.sUnion`. Union of a set of sets. -/
prefix:110 "⋃₀ " => sUnion

@[simp]
theorem mem_sInter {x : α} {S : Set (Set α)} : x ∈ ⋂₀ S ↔ ∀ t ∈ S, x ∈ t :=
Iff.rfl
#align set.mem_sInter Set.mem_sInter

@[simp]
theorem mem_sUnion {x : α} {S : Set (Set α)} : x ∈ ⋃₀ S ↔ ∃ t ∈ S, x ∈ t :=
Iff.rfl
#align set.mem_sUnion Set.mem_sUnion

/-- Indexed union of a family of sets -/
def iUnion (s : ι → Set β) : Set β :=
iSup s
#align set.Union Set.iUnion

/-- Indexed intersection of a family of sets -/
def iInter (s : ι → Set β) : Set β :=
iInf s
#align set.Inter Set.iInter

/-- Notation for `Set.iUnion`. Indexed union of a family of sets -/
notation3 "⋃ "(...)", "r:60:(scoped f => iUnion f) => r

/-- Notation for `Set.iInter`. Indexed intersection of a family of sets -/
notation3 "⋂ "(...)", "r:60:(scoped f => iInter f) => r

section delaborators

open Lean Lean.PrettyPrinter.Delaborator

/-- Delaborator for indexed unions. -/
@[delab app.Set.iUnion]
def iUnion_delab : Delab := whenPPOption Lean.getPPNotation do
let #[_, ι, f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ← Meta.isProp ι
let dep := f.bindingBody!.hasLooseBVar 0
let ppTypes ← getPPOption getPPFunBinderTypes
let stx ← SubExpr.withAppArg do
let dom ← SubExpr.withBindingDomain delab
withBindingBodyUnusedName fun x => do
let x : TSyntax `ident := .mk x
let body ← delab
if prop && !dep then
`(⋃ (_ : $dom), $body)
else if prop || ppTypes then
`(⋃ ($x:ident : $dom), $body)
else
`(⋃ $x:ident, $body)
-- Cute binders
let stx : Term ←
match stx with
| `(⋃ $x:ident, ⋃ (_ : $y:ident ∈ $s), $body)
| `(⋃ ($x:ident : $_), ⋃ (_ : $y:ident ∈ $s), $body) =>
if x == y then `(⋃ $x:ident ∈ $s, $body) else pure stx
| _ => pure stx
return stx

/-- Delaborator for indexed intersections. -/
@[delab app.Set.iInter]
def sInter_delab : Delab := whenPPOption Lean.getPPNotation do
let #[_, ι, f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ← Meta.isProp ι
let dep := f.bindingBody!.hasLooseBVar 0
let ppTypes ← getPPOption getPPFunBinderTypes
let stx ← SubExpr.withAppArg do
let dom ← SubExpr.withBindingDomain delab
withBindingBodyUnusedName fun x => do
let x : TSyntax `ident := .mk x
let body ← delab
if prop && !dep then
`(⋂ (_ : $dom), $body)
else if prop || ppTypes then
`(⋂ ($x:ident : $dom), $body)
else
`(⋂ $x:ident, $body)
-- Cute binders
let stx : Term ←
match stx with
| `(⋂ $x:ident, ⋂ (_ : $y:ident ∈ $s), $body)
| `(⋂ ($x:ident : $_), ⋂ (_ : $y:ident ∈ $s), $body) =>
if x == y then `(⋂ $x:ident ∈ $s, $body) else pure stx
| _ => pure stx
return stx

end delaborators

@[simp]
theorem sSup_eq_sUnion (S : Set (Set α)) : sSup S = ⋃₀S :=
rfl
#align set.Sup_eq_sUnion Set.sSup_eq_sUnion

@[simp]
theorem sInf_eq_sInter (S : Set (Set α)) : sInf S = ⋂₀ S :=
rfl
#align set.Inf_eq_sInter Set.sInf_eq_sInter

@[simp]
theorem iSup_eq_iUnion (s : ι → Set α) : iSup s = iUnion s :=
rfl
#align set.supr_eq_Union Set.iSup_eq_iUnion

@[simp]
theorem iInf_eq_iInter (s : ι → Set α) : iInf s = iInter s :=
rfl
#align set.infi_eq_Inter Set.iInf_eq_iInter

@[simp]
theorem mem_iUnion {x : α} {s : ι → Set α} : (x ∈ ⋃ i, s i) ↔ ∃ i, x ∈ s i :=
fun ⟨_, ⟨⟨a, (t_eq : s a = _)⟩, (h : x ∈ _)⟩⟩ => ⟨a, t_eq.symm ▸ h⟩, fun ⟨a, h⟩ =>
⟨s a, ⟨⟨a, rfl⟩, h⟩⟩⟩
#align set.mem_Union Set.mem_iUnion

@[simp]
theorem mem_iInter {x : α} {s : ι → Set α} : (x ∈ ⋂ i, s i) ↔ ∀ i, x ∈ s i :=
fun (h : ∀ a ∈ { a : Set α | ∃ i, s i = a }, x ∈ a) a => h (s a) ⟨a, rfl⟩,
fun h _ ⟨a, (eq : s a = _)⟩ => eq ▸ h a⟩
#align set.mem_Inter Set.mem_iInter

theorem mem_iUnion₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋃ (i) (j), s i j) ↔ ∃ i j, x ∈ s i j := by
simp_rw [mem_iUnion]
#align set.mem_Union₂ Set.mem_iUnion₂
Expand Down
1 change: 1 addition & 0 deletions Mathlib/GroupTheory/Archimedean.lean
Expand Up @@ -5,6 +5,7 @@ Authors: Heather Macbeth, Patrick Massot
-/
import Mathlib.Algebra.Order.Archimedean
import Mathlib.GroupTheory.Subgroup.Basic
import Mathlib.Data.Set.Lattice

#align_import group_theory.archimedean from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6"

Expand Down
1 change: 1 addition & 0 deletions Mathlib/GroupTheory/Sylow.lean
Expand Up @@ -9,6 +9,7 @@ import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.PGroup
import Mathlib.GroupTheory.NoncommPiCoprod
import Mathlib.Order.Atoms.Finite
import Mathlib.Data.Set.Lattice

#align_import group_theory.sylow from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef"

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Order/Atoms.lean
Expand Up @@ -3,7 +3,7 @@ Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.Data.Set.Image
import Mathlib.Data.Set.Lattice
import Mathlib.Order.ModularLattice
import Mathlib.Order.WellFounded
import Mathlib.Tactic.Nontriviality
Expand Down
122 changes: 1 addition & 121 deletions Mathlib/Order/CompleteLattice.lean
Expand Up @@ -9,7 +9,7 @@ import Mathlib.Data.Set.Prod
import Mathlib.Data.ULift
import Mathlib.Order.Bounds.Basic
import Mathlib.Order.Hom.Set
import Mathlib.Mathport.Notation
import Mathlib.Order.SetNotation

#align_import order.complete_lattice from "leanprover-community/mathlib"@"5709b0d8725255e76f47debca6400c07b5c2d8e6"

Expand Down Expand Up @@ -51,126 +51,6 @@ open Function OrderDual Set

variable {α β β₂ γ : Type*} {ι ι' : Sort*} {κ : ι → Sort*} {κ' : ι' → Sort*}

/-- Class for the `sSup` operator -/
class SupSet (α : Type*) where
sSup : Set α → α
#align has_Sup SupSet
#align has_Sup.Sup SupSet.sSup


/-- Class for the `sInf` operator -/
class InfSet (α : Type*) where
sInf : Set α → α
#align has_Inf InfSet
#align has_Inf.Inf InfSet.sInf


export SupSet (sSup)

export InfSet (sInf)

/-- Supremum of a set -/
add_decl_doc SupSet.sSup

/-- Infimum of a set -/
add_decl_doc InfSet.sInf

/-- Indexed supremum -/
def iSup [SupSet α] {ι} (s : ι → α) : α :=
sSup (range s)
#align supr iSup

/-- Indexed infimum -/
def iInf [InfSet α] {ι} (s : ι → α) : α :=
sInf (range s)
#align infi iInf

instance (priority := 50) infSet_to_nonempty (α) [InfSet α] : Nonempty α :=
⟨sInf ∅⟩
#align has_Inf_to_nonempty infSet_to_nonempty

instance (priority := 50) supSet_to_nonempty (α) [SupSet α] : Nonempty α :=
⟨sSup ∅⟩
#align has_Sup_to_nonempty supSet_to_nonempty

/-
Porting note: the code below could replace the `notation3` command
open Std.ExtendedBinder in
syntax "⨆ " extBinder ", " term:51 : term
macro_rules
| `(⨆ $x:ident, $p) => `(iSup fun $x:ident ↦ $p)
| `(⨆ $x:ident : $t, $p) => `(iSup fun $x:ident : $t ↦ $p)
| `(⨆ $x:ident $b:binderPred, $p) =>
`(iSup fun $x:ident ↦ satisfies_binder_pred% $x $b ∧ $p) -/

/-- Indexed supremum. -/
notation3 "⨆ "(...)", "r:60:(scoped f => iSup f) => r

/-- Indexed infimum. -/
notation3 "⨅ "(...)", "r:60:(scoped f => iInf f) => r

section delaborators

open Lean Lean.PrettyPrinter.Delaborator

/-- Delaborator for indexed supremum. -/
@[delab app.iSup]
def iSup_delab : Delab := whenPPOption Lean.getPPNotation do
let #[_, _, ι, f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ← Meta.isProp ι
let dep := f.bindingBody!.hasLooseBVar 0
let ppTypes ← getPPOption getPPFunBinderTypes
let stx ← SubExpr.withAppArg do
let dom ← SubExpr.withBindingDomain delab
withBindingBodyUnusedName fun x => do
let x : TSyntax `ident := .mk x
let body ← delab
if prop && !dep then
`(⨆ (_ : $dom), $body)
else if prop || ppTypes then
`(⨆ ($x:ident : $dom), $body)
else
`(⨆ $x:ident, $body)
-- Cute binders
let stx : Term ←
match stx with
| `(⨆ $x:ident, ⨆ (_ : $y:ident ∈ $s), $body)
| `(⨆ ($x:ident : $_), ⨆ (_ : $y:ident ∈ $s), $body) =>
if x == y then `(⨆ $x:ident ∈ $s, $body) else pure stx
| _ => pure stx
return stx

/-- Delaborator for indexed infimum. -/
@[delab app.iInf]
def iInf_delab : Delab := whenPPOption Lean.getPPNotation do
let #[_, _, ι, f] := (← SubExpr.getExpr).getAppArgs | failure
unless f.isLambda do failure
let prop ← Meta.isProp ι
let dep := f.bindingBody!.hasLooseBVar 0
let ppTypes ← getPPOption getPPFunBinderTypes
let stx ← SubExpr.withAppArg do
let dom ← SubExpr.withBindingDomain delab
withBindingBodyUnusedName fun x => do
let x : TSyntax `ident := .mk x
let body ← delab
if prop && !dep then
`(⨅ (_ : $dom), $body)
else if prop || ppTypes then
`(⨅ ($x:ident : $dom), $body)
else
`(⨅ $x:ident, $body)
-- Cute binders
let stx : Term ←
match stx with
| `(⨅ $x:ident, ⨅ (_ : $y:ident ∈ $s), $body)
| `(⨅ ($x:ident : $_), ⨅ (_ : $y:ident ∈ $s), $body) =>
if x == y then `(⨅ $x:ident ∈ $s, $body) else pure stx
| _ => pure stx
return stx
end delaborators

instance OrderDual.supSet (α) [InfSet α] : SupSet αᵒᵈ :=
⟨(sInf : Set α → α)⟩

Expand Down
1 change: 1 addition & 0 deletions Mathlib/Order/ModularLattice.lean
Expand Up @@ -5,6 +5,7 @@ Authors: Aaron Anderson, Yaël Dillies
-/
import Mathlib.Order.Cover
import Mathlib.Order.LatticeIntervals
import Mathlib.Order.GaloisConnection

#align_import order.modular_lattice from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"

Expand Down

0 comments on commit d18f1d0

Please sign in to comment.