Skip to content

Commit 7947165

Browse files
committed
chore: use IsLUB IsGLB in CompleteLattice (#35328)
1 parent 8f787c6 commit 7947165

File tree

41 files changed

+348
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+348
-433
lines changed

Mathlib/Algebra/Group/Submonoid/Saturation.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ theorem mem_sInf {f : Set (SaturatedSubmonoid M)} {x : M} : x ∈ sInf f ↔ ∀
168168
variable (M) in
169169
@[to_additive]
170170
instance : CompleteSemilatticeInf (SaturatedSubmonoid M) where
171-
sInf_le f s hs x hx := mem_sInf.1 hx s hs
172-
le_sInf f s ih x hx := mem_sInf.2 <| by tauto
171+
isGLB_sInf _ := .of_image SetLike.coe_subset_coe isGLB_biInf
173172

174173
end SaturatedSubmonoid
175174

Mathlib/Algebra/Module/Submodule/Lattice.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ set_option backward.privateInPublic true in
192192
private theorem le_sInf' {S : Set (Submodule R M)} {p} : (∀ q ∈ S, p ≤ q) → p ≤ sInf S :=
193193
Set.subset_iInter₂
194194

195+
protected theorem isGLB_sInf {S : Set (Submodule R M)} : IsGLB S (sInf S) :=
196+
.of_image SetLike.coe_subset_coe isGLB_biInf
197+
195198
instance : Min (Submodule R M) :=
196199
fun p q ↦
197200
{ carrier := p ∩ q
@@ -213,10 +216,8 @@ instance completeLattice : CompleteLattice (Submodule R M) :=
213216
inf_le_left := fun _ _ ↦ Set.inter_subset_left
214217
inf_le_right := fun _ _ ↦ Set.inter_subset_right
215218
sSup S := sInf {sm | ∀ s ∈ S, s ≤ sm}
216-
le_sSup := fun _ _ hs ↦ le_sInf' fun _ hq ↦ by exact hq _ hs
217-
sSup_le := fun _ _ hs ↦ sInf_le' hs
218-
le_sInf := fun _ _ ↦ le_sInf'
219-
sInf_le := fun _ _ ↦ sInf_le' }
219+
isLUB_sSup _ := isGLB_upperBounds.mp Submodule.isGLB_sInf
220+
isGLB_sInf _ := Submodule.isGLB_sInf }
220221

221222
@[simp]
222223
theorem coe_inf : ↑(p ⊓ q) = (p ∩ q : Set M) :=

Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ instance : CompleteSemilatticeSup (IdealSheafData X) where
9898
conv_lhs => rw [← Subtype.range_val (s := s), ← Set.range_comp]
9999
rfl
100100
simp only [this, iSup_apply, Ideal.map_iSup, map_ideal_basicOpen, implies_true] }
101-
le_sSup s x hxs := le_sSup (s := ideal '' s) ⟨_, hxs, rfl⟩
102-
sSup_le s i hi := sSup_le (s := ideal '' s) (Set.forall_mem_image.mpr hi)
101+
isLUB_sSup _ := .of_image (f := ideal) le_def (isLUB_sSup _)
103102

104103
/-- The largest ideal sheaf contained in a family of ideals. -/
105104
def ofIdeals (I : ∀ U : X.affineOpens, Ideal Γ(X, U)) : IdealSheafData X :=

Mathlib/AlgebraicTopology/SimplicialComplex/Basic.lean

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ instance : LE (PreAbstractSimplicialComplex ι) where
7777
instance : LT (PreAbstractSimplicialComplex ι) where
7878
lt K L := K.faces ⊂ L.faces
7979

80+
instance : IsConcreteLE (PreAbstractSimplicialComplex ι) (Finset ι) where
81+
coe_subset_coe' := .rfl
82+
8083
instance : PartialOrder (PreAbstractSimplicialComplex ι) :=
8184
PartialOrder.lift (fun K => K.faces) (fun _ _ => PreAbstractSimplicialComplex.ext)
8285

@@ -102,12 +105,12 @@ instance : Bot (PreAbstractSimplicialComplex ι) where
102105
isRelLowerSet_faces := isRelLowerSet_empty }
103106

104107
instance : CompleteSemilatticeSup (PreAbstractSimplicialComplex ι) where
105-
le_sSup _ _ hK := Set.subset_biUnion_of_mem hK
106-
sSup_le _ _ hK := Set.iUnion₂_subset hK
108+
isLUB_sSup _ := .of_image SetLike.coe_subset_coe isLUB_biSup
107109

108110
instance : CompleteSemilatticeInf (PreAbstractSimplicialComplex ι) where
109-
sInf_le _ _ hK := Set.inter_subset_left.trans (Set.biInter_subset_of_mem hK)
110-
le_sInf _ K hK _ ht := ⟨Set.mem_iInter₂.mpr fun L hL => hK L hL ht, (K.isRelLowerSet_faces ht).1
111+
isGLB_sInf _ :=
112+
fun _ hK ↦ Set.inter_subset_left.trans (Set.biInter_subset_of_mem hK),
113+
fun K hK _ ht ↦ ⟨Set.mem_iInter₂.mpr fun _ hL => hK hL ht, (K.isRelLowerSet_faces ht).1⟩⟩
111114

112115
instance : CompleteLattice (PreAbstractSimplicialComplex ι) where
113116
inf := min
@@ -198,6 +201,9 @@ instance : LE (AbstractSimplicialComplex ι) where
198201
instance : LT (AbstractSimplicialComplex ι) where
199202
lt K L := K.faces ⊂ L.faces
200203

204+
instance : IsConcreteLE (AbstractSimplicialComplex ι) (Finset ι) where
205+
coe_subset_coe' := .rfl
206+
201207
instance : PartialOrder (AbstractSimplicialComplex ι) :=
202208
PartialOrder.lift (fun K => K.faces) (fun _ _ => AbstractSimplicialComplex.ext)
203209

@@ -260,20 +266,24 @@ instance : Bot (AbstractSimplicialComplex ι) where
260266
singleton_mem v := ⟨v, rfl⟩ }
261267

262268
instance : CompleteSemilatticeSup (AbstractSimplicialComplex ι) where
263-
le_sSup _ K hK _ ht := Or.inl (Set.mem_biUnion hK ht)
264-
sSup_le _ L hL _ ht := by
265-
cases ht with
266-
| inl ht =>
267-
simp only [Set.mem_iUnion] at ht
268-
obtain ⟨K, hK, htK⟩ := ht
269-
exact hL K hK htK
270-
| inr ht =>
271-
obtain ⟨v, hv⟩ := ht
272-
exact hv ▸ L.singleton_mem v
269+
isLUB_sSup _ := by
270+
constructor
271+
· intro K hK _ ht
272+
exact Or.inl (Set.mem_biUnion hK ht)
273+
· intro L hL _ ht
274+
cases ht with
275+
| inl ht =>
276+
simp only [Set.mem_iUnion] at ht
277+
obtain ⟨K, hK, htK⟩ := ht
278+
exact hL hK htK
279+
| inr ht =>
280+
obtain ⟨v, hv⟩ := ht
281+
exact hv ▸ L.singleton_mem v
273282

274283
instance : CompleteSemilatticeInf (AbstractSimplicialComplex ι) where
275-
sInf_le _ _ hK := Set.inter_subset_left.trans (Set.biInter_subset_of_mem hK)
276-
le_sInf _ K hK _ ht := ⟨Set.mem_iInter₂.mpr fun L hL => hK L hL ht, (K.isRelLowerSet_faces ht).1
284+
isGLB_sInf _ :=
285+
fun _ hK ↦ Set.inter_subset_left.trans (Set.biInter_subset_of_mem hK),
286+
fun K hK _ ht ↦ ⟨Set.mem_iInter₂.mpr fun _ hL => hK hL ht, (K.isRelLowerSet_faces ht).1⟩⟩
277287

278288
instance : CompleteLattice (AbstractSimplicialComplex ι) where
279289
inf := min

Mathlib/CategoryTheory/Sites/Sieves.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,8 @@ instance : CompleteLattice (Sieve X) where
573573
inf := Sieve.inter
574574
sSup := Sieve.sup
575575
sInf := Sieve.inf
576-
le_sSup _ S hS _ _ hf := ⟨S, hS, hf⟩
577-
sSup_le := fun _ _ ha _ _ ⟨b, hb, hf⟩ => (ha b hb) _ hf
578-
sInf_le _ _ hS _ _ h := h _ hS
579-
le_sInf _ _ hS _ _ hf _ hR := hS _ hR _ hf
576+
isLUB_sSup _ := ⟨fun S hS _ _ hf ↦ ⟨S, hS, hf⟩, fun _ ha _ _ ⟨b, hb, hf⟩ ↦ ha hb _ hf⟩
577+
isGLB_sInf _ := ⟨fun S hS _ _ h ↦ h _ hS, fun _ hS _ _ hf _ hR ↦ hS hR _ hf⟩
580578
le_sup_left _ _ _ _ := Or.inl
581579
le_sup_right _ _ _ _ := Or.inr
582580
sup_le _ _ _ h₁ h₂ _ f := by

Mathlib/CategoryTheory/Subfunctor/Basic.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ instance : CompleteLattice (Subfunctor F) where
7575
simp only [Set.sSup_eq_sUnion, Set.sUnion_image, Set.preimage_iUnion,
7676
Set.mem_iUnion, Set.mem_preimage, exists_prop]
7777
exact ⟨_, h, F.map f h'⟩ }
78-
le_sSup _ _ _ _ _ := by aesop
79-
sSup_le _ _ _ _ _ := by aesop
78+
isLUB_sSup _ := ⟨fun _ _ _ _ ↦ by aesop, fun _ _ _ ↦ by aesop⟩
8079
sInf S :=
8180
{ obj U := sInf (Set.image (fun T ↦ T.obj U) S)
8281
map f x hx := by
8382
rintro _ ⟨F, h, rfl⟩
8483
exact F.map f (hx _ ⟨_, h, rfl⟩) }
85-
sInf_le _ _ _ _ _ := by aesop
86-
le_sInf _ _ _ _ _ := by aesop
84+
isGLB_sInf _ := ⟨fun _ _ _ _ ↦ by aesop, fun _ _ _ ↦ by aesop⟩
8785
bot :=
8886
{ obj U := ⊥
8987
map := by simp }

Mathlib/CategoryTheory/Subobject/Lattice.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,7 @@ theorem le_sInf {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈
626626

627627
instance completeSemilatticeInf {B : C} : CompleteSemilatticeInf (Subobject B) where
628628
sInf := sInf
629-
sInf_le := sInf_le
630-
le_sInf := le_sInf
629+
isGLB_sInf _ := ⟨sInf_le _, le_sInf _⟩
631630

632631
end Inf
633632

@@ -679,8 +678,7 @@ theorem sSup_le {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : ∀ g ∈
679678

680679
instance completeSemilatticeSup {B : C} : CompleteSemilatticeSup (Subobject B) where
681680
sSup := sSup
682-
le_sSup := le_sSup
683-
sSup_le := sSup_le
681+
isLUB_sSup _ := ⟨le_sSup _, sSup_le _⟩
684682

685683
end Sup
686684

Mathlib/Combinatorics/Digraph/Basic.lean

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,8 @@ instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Digraph V)
181181
bot_le _ _ _ h := h.elim
182182
inf_compl_le_bot _ _ _ h := absurd h.1 h.2
183183
top_le_sup_compl G v w _ := by tauto
184-
le_sSup _ G hG _ _ hab := ⟨G, hG, hab⟩
185-
sSup_le s G hG a b := by
186-
rintro ⟨H, hH, hab⟩
187-
exact hG _ hH hab
188-
sInf_le _ _ hG _ _ hab := hab hG
189-
le_sInf _ _ hG _ _ hab _ hH := hG _ hH hab
184+
isLUB_sSup _ := ⟨fun G hG _ _ hab ↦ ⟨G, hG, hab⟩, fun _ hG _ _ ⟨_, hH, hab⟩ ↦ hG hH hab⟩
185+
isGLB_sInf _ := ⟨fun _ hG _ _ hab ↦ hab hG, fun _ hG _ _ hab _ hH ↦ hG hH hab⟩
190186
iInf_iSup_eq f := by ext; simp [Classical.skolem]
191187

192188
@[simp] theorem top_adj (v w : V) : (⊤ : Digraph V).Adj v w := trivial

Mathlib/Combinatorics/SimpleGraph/Basic.lean

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,8 @@ instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (SimpleGrap
321321
by_cases h : G.Adj v w
322322
· exact Or.inl h
323323
· exact Or.inr ⟨hvw, h⟩
324-
le_sSup _ G hG _ _ hab := ⟨G, hG, hab⟩
325-
sSup_le s G hG a b := by
326-
rintro ⟨H, hH, hab⟩
327-
exact hG _ hH hab
328-
sInf_le _ _ hG _ _ hab := hab.1 hG
329-
le_sInf _ _ hG _ _ hab := ⟨fun _ hH => hG _ hH hab, hab.ne⟩
324+
isLUB_sSup _ := ⟨fun G hG _ _ hab ↦ ⟨G, hG, hab⟩, fun _ hG _ _ ⟨_, hH, hab⟩ ↦ hG hH hab⟩
325+
isGLB_sInf _ := ⟨fun _ hG _ _ hab ↦ hab.1 hG, fun _ hG _ _ hab ↦ ⟨fun _ hH => hG hH hab, hab.ne⟩⟩
330326
iInf_iSup_eq f := by ext; simp [Classical.skolem]
331327
/-- The complete graph on a type `V` is the simple graph with all pairs of distinct vertices. -/
332328
abbrev completeGraph (V : Type u) : SimpleGraph V := ⊤

Mathlib/Combinatorics/SimpleGraph/Subgraph.lean

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,15 @@ instance : BoundedOrder (Subgraph G) where
474474
def completelyDistribLatticeMinimalAxioms : CompletelyDistribLattice.MinimalAxioms G.Subgraph where
475475
le_top G' := ⟨Set.subset_univ _, fun _ _ => G'.adj_sub⟩
476476
bot_le _ := ⟨Set.empty_subset _, fun _ _ => False.elim⟩
477-
-- Porting note: needed `apply` here to modify elaboration; previously the term itself was fine.
478-
le_sSup s G' hG' := ⟨by apply Set.subset_iUnion₂ G' hG', fun _ _ hab => ⟨G', hG', hab⟩⟩
479-
sSup_le s G' hG' :=
480-
⟨Set.iUnion₂_subset fun _ hH => (hG' _ hH).1, by
481-
rintro a b ⟨H, hH, hab⟩
482-
exact (hG' _ hH).2 hab⟩
483-
sInf_le _ G' hG' := ⟨Set.iInter₂_subset G' hG', fun _ _ hab => hab.1 hG'⟩
484-
le_sInf _ G' hG' :=
485-
⟨Set.subset_iInter₂ fun _ hH => (hG' _ hH).1, fun _ _ hab =>
486-
fun _ hH => (hG' _ hH).2 hab, G'.adj_sub hab⟩⟩
477+
isLUB_sSup _ :=
478+
fun G' hG' ↦ ⟨Set.subset_biUnion_of_mem hG', fun _ _ hab => ⟨G', hG', hab⟩⟩,
479+
fun G' hG' ↦
480+
⟨Set.iUnion₂_subset fun _ hH => (hG' hH).1, fun a b ⟨H, hH, hab⟩ ↦ (hG' hH).2 hab⟩⟩
481+
isGLB_sInf _ :=
482+
fun G' hG' ↦ ⟨Set.iInter₂_subset G' hG', fun _ _ hab => hab.1 hG'⟩,
483+
fun G' hG' ↦
484+
⟨Set.subset_iInter₂ fun _ hH => (hG' hH).1, fun _ _ hab =>
485+
fun _ hH => (hG' hH).2 hab, G'.adj_sub hab⟩⟩⟩
487486
iInf_iSup_eq f := Subgraph.ext (by simpa using iInf_iSup_eq)
488487
(by ext; simp [Classical.skolem])
489488

0 commit comments

Comments
 (0)