Skip to content

Commit f7e1ccd

Browse files
kmilldagurtomas
authored andcommitted
feat: subsingleton tactic (#12525)
The `subsingleton` tactic tries to close equality goals by arguing that the underlying type is a subsingleton type. It might be via a `Subsingleton` instance (via `Subsingleton.elim`), but it also handles some cases where morally the types are subsingletons; for example, it can prove that two `BEq` instances are equal if they both have `LawfulBEq` instances. For heterogeneous equality, it tries the `HEq` version of proof irrelevance. This tactic avoids the issue where ```lean example (α : Sort _) (x y : α) : x = y := by apply Subsingleton.elim ``` is a "proof" that every type is trivial. Changing this to `by subsingleton` prevents it from assigning the universe level metavariable in `Sort _` to `0`. This tactic can accept a list of instances `subsingleton [inst1, inst2, ...]` to do something like `have := inst1; have := inst2; ...; subsingleton`, but it elaborates them in a lenient way (like `simp` arguments), and they can even be universe polymorphic. For example, `subsingleton [CharP.CharOne.subsingleton]` is allowed even though the type of `CharP.CharOne.subsingleton` is `Subsingleton ?R` with a number of pending instance problems. This PR also eliminates a number of uses of `Subsingleton.elim`, either by switching a `congr` to `congr!` or by using this new tactic.
1 parent 76d9db6 commit f7e1ccd

Some content is hidden

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

56 files changed

+479
-158
lines changed

Mathlib.lean

+1
Original file line numberDiff line numberDiff line change
@@ -4023,6 +4023,7 @@ import Mathlib.Tactic.Simps.NotationClass
40234023
import Mathlib.Tactic.SlimCheck
40244024
import Mathlib.Tactic.SplitIfs
40254025
import Mathlib.Tactic.Spread
4026+
import Mathlib.Tactic.Subsingleton
40264027
import Mathlib.Tactic.Substs
40274028
import Mathlib.Tactic.SuccessIfFailWithMsg
40284029
import Mathlib.Tactic.SudoSetOption

Mathlib/Algebra/BigOperators/Fin.lean

+3-4
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ def finFunctionFinEquiv {m n : ℕ} : (Fin n → Fin m) ≃ Fin (m ^ n) :=
342342
fun a => by
343343
dsimp
344344
induction' n with n ih
345-
· haveI : Subsingleton (Fin (m ^ 0)) := (finCongr <| pow_zero _).subsingleton
346-
exact Subsingleton.elim _ _
345+
· subsingleton [(finCongr <| pow_zero _).subsingleton]
347346
simp_rw [Fin.forall_iff, Fin.ext_iff] at ih
348347
ext
349348
simp_rw [Fin.sum_univ_succ, Fin.val_zero, Fin.val_succ, pow_zero, Nat.div_one,
@@ -398,9 +397,9 @@ def finPiFinEquiv {m : ℕ} {n : Fin m → ℕ} : (∀ i : Fin m, Fin (n i)) ≃
398397
intro a; revert a; dsimp only [Fin.val_mk]
399398
refine Fin.consInduction ?_ ?_ n
400399
· intro a
401-
haveI : Subsingleton (Fin (∏ i : Fin 0, i.elim0)) :=
400+
have : Subsingleton (Fin (∏ i : Fin 0, i.elim0)) :=
402401
(finCongr <| prod_empty).subsingleton
403-
exact Subsingleton.elim _ _
402+
subsingleton
404403
· intro n x xs ih a
405404
simp_rw [Fin.forall_iff, Fin.ext_iff] at ih
406405
ext

Mathlib/Algebra/BigOperators/Group/Finset.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,7 @@ theorem prod_empty {α β : Type*} [CommMonoid β] [IsEmpty α] [Fintype α] (f
23242324
@[to_additive]
23252325
theorem prod_subsingleton {α β : Type*} [CommMonoid β] [Subsingleton α] [Fintype α] (f : α → β)
23262326
(a : α) : ∏ x : α, f x = f a := by
2327-
haveI : Unique α := uniqueOfSubsingleton a
2327+
have : Unique α := uniqueOfSubsingleton a
23282328
rw [prod_unique f, Subsingleton.elim default a]
23292329
#align fintype.prod_subsingleton Fintype.prod_subsingleton
23302330
#align fintype.sum_subsingleton Fintype.sum_subsingleton

Mathlib/Algebra/Category/Grp/Zero.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ theorem isZero_of_subsingleton (G : Grp) [Subsingleton G] : IsZero G := by
3131
have : x = 1 := Subsingleton.elim _ _
3232
rw [this, map_one, map_one]
3333
· ext
34-
apply Subsingleton.elim
34+
subsingleton
3535
set_option linter.uppercaseLean3 false in
3636
#align Group.is_zero_of_subsingleton Grp.isZero_of_subsingleton
3737
set_option linter.uppercaseLean3 false in
@@ -52,7 +52,7 @@ theorem isZero_of_subsingleton (G : CommGrp) [Subsingleton G] : IsZero G := by
5252
have : x = 1 := Subsingleton.elim _ _
5353
rw [this, map_one, map_one]
5454
· ext
55-
apply Subsingleton.elim
55+
subsingleton
5656
set_option linter.uppercaseLean3 false in
5757
#align CommGroup.is_zero_of_subsingleton CommGrp.isZero_of_subsingleton
5858
set_option linter.uppercaseLean3 false in

Mathlib/Algebra/Category/ModuleCat/Basic.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ theorem isZero_of_subsingleton (M : ModuleCat R) [Subsingleton M] : IsZero M whe
206206
simp⟩⟩
207207
unique_from X := ⟨⟨⟨(0 : X →ₗ[R] M)⟩, fun f => by
208208
ext x
209-
apply Subsingleton.elim⟩⟩
209+
subsingleton⟩⟩
210210
#align Module.is_zero_of_subsingleton ModuleCat.isZero_of_subsingleton
211211

212212
instance : HasZeroObject (ModuleCat.{v} R) :=

Mathlib/Algebra/DirectLimit.lean

+6-6
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def map (g : (i : ι) → G i →ₗ[R] G' i) (hg : ∀ i j h, g j ∘ₗ f i j
200200
DirectLimit G f →ₗ[R] DirectLimit G' f' :=
201201
lift _ _ _ _ (fun i ↦ of _ _ _ _ _ ∘ₗ g i) fun i j h g ↦ by
202202
cases isEmpty_or_nonempty ι
203-
· exact Subsingleton.elim _ _
203+
· subsingleton
204204
· have eq1 := LinearMap.congr_fun (hg i j h) g
205205
simp only [LinearMap.coe_comp, Function.comp_apply] at eq1 ⊢
206206
rw [eq1, of_f]
@@ -213,7 +213,7 @@ def map (g : (i : ι) → G i →ₗ[R] G' i) (hg : ∀ i j h, g j ∘ₗ f i j
213213

214214
@[simp] lemma map_id [IsDirected ι (· ≤ ·)] :
215215
map (fun i ↦ LinearMap.id) (fun _ _ _ ↦ rfl) = LinearMap.id (R := R) (M := DirectLimit G f) :=
216-
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦
216+
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (by subsingleton) fun _ ↦
217217
x.induction_on fun i g ↦ by simp
218218

219219
lemma map_comp [IsDirected ι (· ≤ ·)]
@@ -225,7 +225,7 @@ lemma map_comp [IsDirected ι (· ≤ ·)]
225225
(map (fun i ↦ g₂ i ∘ₗ g₁ i) fun i j h ↦ by
226226
rw [LinearMap.comp_assoc, hg₁ i, ← LinearMap.comp_assoc, hg₂ i, LinearMap.comp_assoc] :
227227
DirectLimit G f →ₗ[R] DirectLimit G'' f'') :=
228-
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦
228+
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (by subsingleton) fun _ ↦
229229
x.induction_on fun i g ↦ by simp
230230

231231
open LinearEquiv LinearMap in
@@ -473,7 +473,7 @@ def map (g : (i : ι) → G i →+ G' i)
473473
DirectLimit G f →+ DirectLimit G' f' :=
474474
lift _ _ _ (fun i ↦ (of _ _ _).comp (g i)) fun i j h g ↦ by
475475
cases isEmpty_or_nonempty ι
476-
· exact Subsingleton.elim _ _
476+
· subsingleton
477477
· have eq1 := DFunLike.congr_fun (hg i j h) g
478478
simp only [AddMonoidHom.coe_comp, Function.comp_apply] at eq1 ⊢
479479
rw [eq1, of_f]
@@ -486,7 +486,7 @@ def map (g : (i : ι) → G i →+ G' i)
486486

487487
@[simp] lemma map_id [IsDirected ι (· ≤ ·)] :
488488
map (fun i ↦ AddMonoidHom.id _) (fun _ _ _ ↦ rfl) = AddMonoidHom.id (DirectLimit G f) :=
489-
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦
489+
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (by subsingleton) fun _ ↦
490490
x.induction_on fun i g ↦ by simp
491491

492492
lemma map_comp [IsDirected ι (· ≤ ·)]
@@ -499,7 +499,7 @@ lemma map_comp [IsDirected ι (· ≤ ·)]
499499
rw [AddMonoidHom.comp_assoc, hg₁ i, ← AddMonoidHom.comp_assoc, hg₂ i,
500500
AddMonoidHom.comp_assoc] :
501501
DirectLimit G f →+ DirectLimit G'' f'') :=
502-
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦
502+
DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (by subsingleton) fun _ ↦
503503
x.induction_on fun i g ↦ by simp
504504

505505
/--

Mathlib/Algebra/Group/Units.lean

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Mathlib.Algebra.Group.Commute.Defs
88
import Mathlib.Logic.Unique
99
import Mathlib.Tactic.Nontriviality
1010
import Mathlib.Tactic.Lift
11+
import Mathlib.Tactic.Subsingleton
1112

1213
#align_import algebra.group.units from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
1314

@@ -672,7 +673,7 @@ theorem isUnit_iff_exists_and_exists [Monoid M] {a : M} :
672673

673674
@[to_additive (attr := nontriviality)]
674675
theorem isUnit_of_subsingleton [Monoid M] [Subsingleton M] (a : M) : IsUnit a :=
675-
⟨⟨a, a, Subsingleton.elim _ _, Subsingleton.elim _ _⟩, rfl⟩
676+
⟨⟨a, a, by subsingleton, by subsingleton⟩, rfl⟩
676677
#align is_unit_of_subsingleton isUnit_of_subsingleton
677678
#align is_add_unit_of_subsingleton isAddUnit_of_subsingleton
678679

@@ -683,7 +684,7 @@ instance [Monoid M] : CanLift M Mˣ Units.val IsUnit :=
683684
/-- A subsingleton `Monoid` has a unique unit. -/
684685
@[to_additive "A subsingleton `AddMonoid` has a unique additive unit."]
685686
instance [Monoid M] [Subsingleton M] : Unique Mˣ where
686-
uniq a := Units.val_eq_one.mp <| Subsingleton.elim (a : M) 1
687+
uniq _ := Units.val_eq_one.mp (by subsingleton)
687688

688689
@[to_additive (attr := simp)]
689690
protected theorem Units.isUnit [Monoid M] (u : Mˣ) : IsUnit (u : M) :=
@@ -735,8 +736,7 @@ lemma IsUnit.exists_left_inv {a : M} (h : IsUnit a) : ∃ b, b * a = 1 := by
735736
#align is_unit.pow IsUnit.pow
736737
#align is_add_unit.nsmul IsAddUnit.nsmul
737738

738-
theorem units_eq_one [Unique Mˣ] (u : Mˣ) : u = 1 :=
739-
Subsingleton.elim u 1
739+
theorem units_eq_one [Unique Mˣ] (u : Mˣ) : u = 1 := by subsingleton
740740
#align units_eq_one units_eq_one
741741

742742
@[to_additive] lemma isUnit_iff_eq_one [Unique Mˣ] {x : M} : IsUnit x ↔ x = 1 :=

Mathlib/Algebra/Homology/HomologicalComplex.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ theorem isZero_zero [HasZeroObject V] : IsZero (zero : HomologicalComplex V c) :
317317
refine ⟨fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩, fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩⟩
318318
all_goals
319319
ext
320-
dsimp [zero]
321-
apply Subsingleton.elim
320+
dsimp only [zero]
321+
subsingleton
322322
#align homological_complex.is_zero_zero HomologicalComplex.isZero_zero
323323

324324
instance [HasZeroObject V] : HasZeroObject (HomologicalComplex V c) :=

Mathlib/Algebra/Lie/Engel.lean

+1-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ theorem LieAlgebra.isEngelian_of_subsingleton [Subsingleton L] : LieAlgebra.IsEn
166166
intro M _i1 _i2 _i3 _i4 _h
167167
use 1
168168
suffices (⊤ : LieIdeal R L) = ⊥ by simp [this]
169-
haveI := (LieSubmodule.subsingleton_iff R L L).mpr inferInstance
170-
apply Subsingleton.elim
169+
subsingleton [(LieSubmodule.subsingleton_iff R L L).mpr inferInstance]
171170
#align lie_algebra.is_engelian_of_subsingleton LieAlgebra.isEngelian_of_subsingleton
172171

173172
theorem Function.Surjective.isEngelian {f : L →ₗ⁅R⁆ L₂} (hf : Function.Surjective f)

Mathlib/Algebra/Order/Antidiag/Prod.lean

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ attribute [simp] mem_antidiagonal
6464
variable {A : Type*}
6565

6666
/-- All `HasAntidiagonal` instances are equal -/
67-
instance [AddMonoid A] : Subsingleton (HasAntidiagonal A) :=
68-
by
67+
instance [AddMonoid A] : Subsingleton (HasAntidiagonal A) where
68+
allEq := by
6969
rintro ⟨a, ha⟩ ⟨b, hb⟩
7070
congr with n xy
71-
rw [ha, hb]
71+
rw [ha, hb]
7272

7373
-- The goal of this lemma is to allow to rewrite antidiagonal
7474
-- when the decidability instances obsucate Lean
7575
lemma hasAntidiagonal_congr (A : Type*) [AddMonoid A]
7676
[H1 : HasAntidiagonal A] [H2 : HasAntidiagonal A] :
77-
H1.antidiagonal = H2.antidiagonal := by congr!; apply Subsingleton.elim
77+
H1.antidiagonal = H2.antidiagonal := by congr!; subsingleton
7878

7979
theorem swap_mem_antidiagonal [AddCommMonoid A] [HasAntidiagonal A] {n : A} {xy : A × A}:
8080
xy.swap ∈ antidiagonal n ↔ xy ∈ antidiagonal n := by

Mathlib/Algebra/PUnitInstances.lean

+15-15
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ instance normalizedGCDMonoid : NormalizedGCDMonoid PUnit where
8787
normUnit_zero := rfl
8888
normUnit_mul := by intros; rfl
8989
normUnit_coe_units := by intros; rfl
90-
gcd_dvd_left _ _ := ⟨unit, Subsingleton.elim _ _
91-
gcd_dvd_right _ _ := ⟨unit, Subsingleton.elim _ _
92-
dvd_gcd {_ _} _ _ _ := ⟨unit, Subsingleton.elim _ _
93-
gcd_mul_lcm _ _ := ⟨1, Subsingleton.elim _ _
90+
gcd_dvd_left _ _ := ⟨unit, by subsingleton
91+
gcd_dvd_right _ _ := ⟨unit, by subsingleton
92+
dvd_gcd {_ _} _ _ _ := ⟨unit, by subsingleton
93+
gcd_mul_lcm _ _ := ⟨1, by subsingleton
9494
lcm_zero_left := by intros; rfl
9595
lcm_zero_right := by intros; rfl
9696
normalize_gcd := by intros; rfl
@@ -112,7 +112,7 @@ theorem norm_unit_eq {x : PUnit} : normUnit x = 1 :=
112112
#align punit.norm_unit_eq PUnit.norm_unit_eq
113113

114114
instance canonicallyOrderedAddCommMonoid : CanonicallyOrderedAddCommMonoid PUnit where
115-
exists_add_of_le {_ _} _ := ⟨unit, Subsingleton.elim _ _
115+
exists_add_of_le {_ _} _ := ⟨unit, by subsingleton
116116
add_le_add_left _ _ _ _ := trivial
117117
le_self_add _ _ := trivial
118118

@@ -150,23 +150,23 @@ instance instIsScalarTowerOfSMul [SMul R S] : IsScalarTower R S PUnit :=
150150

151151
instance smulWithZero [Zero R] : SMulWithZero R PUnit where
152152
__ := PUnit.smul
153-
smul_zero _ := Subsingleton.elim _ _
154-
zero_smul _ := Subsingleton.elim _ _
153+
smul_zero := by subsingleton
154+
zero_smul := by subsingleton
155155

156156
instance mulAction [Monoid R] : MulAction R PUnit where
157157
__ := PUnit.smul
158-
one_smul _ := Subsingleton.elim _ _
159-
mul_smul _ _ _ := Subsingleton.elim _ _
158+
one_smul := by subsingleton
159+
mul_smul := by subsingleton
160160

161161
instance distribMulAction [Monoid R] : DistribMulAction R PUnit where
162162
__ := PUnit.mulAction
163-
smul_zero _ := Subsingleton.elim _ _
164-
smul_add _ _ _ := Subsingleton.elim _ _
163+
smul_zero := by subsingleton
164+
smul_add := by subsingleton
165165

166166
instance mulDistribMulAction [Monoid R] : MulDistribMulAction R PUnit where
167167
__ := PUnit.mulAction
168-
smul_mul _ _ _ := Subsingleton.elim _ _
169-
smul_one _ := Subsingleton.elim _ _
168+
smul_mul := by subsingleton
169+
smul_one := by subsingleton
170170

171171
instance mulSemiringAction [Semiring R] : MulSemiringAction R PUnit :=
172172
{ PUnit.distribMulAction, PUnit.mulDistribMulAction with }
@@ -176,7 +176,7 @@ instance mulActionWithZero [MonoidWithZero R] : MulActionWithZero R PUnit :=
176176

177177
instance module [Semiring R] : Module R PUnit where
178178
__ := PUnit.distribMulAction
179-
add_smul _ _ _ := Subsingleton.elim _ _
180-
zero_smul _ := Subsingleton.elim _ _
179+
add_smul := by subsingleton
180+
zero_smul := by subsingleton
181181

182182
end PUnit

Mathlib/AlgebraicTopology/CechNerve.lean

+3-4
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,11 @@ def wideCospan.limitCone [Finite ι] (X : C) : LimitCone (wideCospan ι X) where
378378
cases f
379379
· cases i
380380
all_goals dsimp; simp
381-
· dsimp
382-
simp only [terminal.comp_from]
383-
exact Subsingleton.elim _ _ } }
381+
· simp only [Functor.const_obj_obj, Functor.const_obj_map, terminal.comp_from]
382+
subsingleton } }
384383
isLimit :=
385384
{ lift := fun s => Limits.Pi.lift fun j => s.π.app (some j)
386-
fac := fun s j => Option.casesOn j (Subsingleton.elim _ _) fun j => limit.lift_π _ _
385+
fac := fun s j => Option.casesOn j (by subsingleton) fun j => limit.lift_π _ _
387386
uniq := fun s f h => by
388387
dsimp
389388
ext j

Mathlib/AlgebraicTopology/ExtraDegeneracy.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ protected noncomputable def extraDegeneracy (Δ : SimplexCategory) :
198198
(shift (objEquiv _ _ f))
199199
s'_comp_ε := by
200200
dsimp
201-
apply Subsingleton.elim
201+
subsingleton
202202
s₀_comp_δ₁ := by
203203
dsimp
204204
ext1 x

Mathlib/CategoryTheory/Filtered/Basic.lean

+8-14
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ class IsFiltered extends IsFilteredOrEmpty C : Prop where
9797
instance (priority := 100) isFilteredOrEmpty_of_semilatticeSup (α : Type u) [SemilatticeSup α] :
9898
IsFilteredOrEmpty α where
9999
cocone_objs X Y := ⟨X ⊔ Y, homOfLE le_sup_left, homOfLE le_sup_right, trivial⟩
100-
cocone_maps X Y f g := ⟨Y, 𝟙 _, by
101-
apply ULift.ext
102-
apply Subsingleton.elim⟩
100+
cocone_maps X Y f g := ⟨Y, 𝟙 _, by subsingleton⟩
103101
#align category_theory.is_filtered_or_empty_of_semilattice_sup CategoryTheory.isFilteredOrEmpty_of_semilatticeSup
104102

105103
instance (priority := 100) isFiltered_of_semilatticeSup_nonempty (α : Type u) [SemilatticeSup α]
@@ -111,9 +109,7 @@ instance (priority := 100) isFilteredOrEmpty_of_directed_le (α : Type u) [Preor
111109
cocone_objs X Y :=
112110
let ⟨Z, h1, h2⟩ := exists_ge_ge X Y
113111
⟨Z, homOfLE h1, homOfLE h2, trivial⟩
114-
cocone_maps X Y f g := ⟨Y, 𝟙 _, by
115-
apply ULift.ext
116-
apply Subsingleton.elim⟩
112+
cocone_maps X Y f g := ⟨Y, 𝟙 _, by subsingleton⟩
117113
#align category_theory.is_filtered_or_empty_of_directed_le CategoryTheory.isFilteredOrEmpty_of_directed_le
118114

119115
instance (priority := 100) isFiltered_of_directed_le_nonempty (α : Type u) [Preorder α]
@@ -126,10 +122,8 @@ example (α : Type u) [SemilatticeSup α] [OrderBot α] : IsFiltered α := by in
126122
example (α : Type u) [SemilatticeSup α] [OrderTop α] : IsFiltered α := by infer_instance
127123

128124
instance : IsFiltered (Discrete PUnit) where
129-
cocone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, ⟨⟨Subsingleton.elim _ _⟩⟩, trivial⟩
130-
cocone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, by
131-
apply ULift.ext
132-
apply Subsingleton.elim⟩
125+
cocone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, ⟨⟨by subsingleton⟩⟩, trivial⟩
126+
cocone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, by subsingleton⟩
133127

134128
namespace IsFiltered
135129

@@ -568,7 +562,7 @@ instance (priority := 100) isCofilteredOrEmpty_of_semilatticeInf (α : Type u) [
568562
cone_objs X Y := ⟨X ⊓ Y, homOfLE inf_le_left, homOfLE inf_le_right, trivial⟩
569563
cone_maps X Y f g := ⟨X, 𝟙 _, by
570564
apply ULift.ext
571-
apply Subsingleton.elim
565+
subsingleton
572566
#align category_theory.is_cofiltered_or_empty_of_semilattice_inf CategoryTheory.isCofilteredOrEmpty_of_semilatticeInf
573567

574568
instance (priority := 100) isCofiltered_of_semilatticeInf_nonempty (α : Type u) [SemilatticeInf α]
@@ -582,7 +576,7 @@ instance (priority := 100) isCofilteredOrEmpty_of_directed_ge (α : Type u) [Pre
582576
⟨Z, homOfLE hX, homOfLE hY, trivial⟩
583577
cone_maps X Y f g := ⟨X, 𝟙 _, by
584578
apply ULift.ext
585-
apply Subsingleton.elim
579+
subsingleton
586580
#align category_theory.is_cofiltered_or_empty_of_directed_ge CategoryTheory.isCofilteredOrEmpty_of_directed_ge
587581

588582
instance (priority := 100) isCofiltered_of_directed_ge_nonempty (α : Type u) [Preorder α]
@@ -595,10 +589,10 @@ example (α : Type u) [SemilatticeInf α] [OrderBot α] : IsCofiltered α := by
595589
example (α : Type u) [SemilatticeInf α] [OrderTop α] : IsCofiltered α := by infer_instance
596590

597591
instance : IsCofiltered (Discrete PUnit) where
598-
cone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, ⟨⟨Subsingleton.elim _ _⟩⟩, trivial⟩
592+
cone_objs X Y := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, ⟨⟨by subsingleton⟩⟩, trivial⟩
599593
cone_maps X Y f g := ⟨⟨PUnit.unit⟩, ⟨⟨by trivial⟩⟩, by
600594
apply ULift.ext
601-
apply Subsingleton.elim
595+
subsingleton
602596

603597
namespace IsCofiltered
604598

Mathlib/CategoryTheory/Filtered/Final.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ theorem Functor.final_iff_of_isFiltered [IsFilteredOrEmpty C] :
182182
· intro d c s s'
183183
have : colimit.ι (F ⋙ coyoneda.obj (op d)) c s = colimit.ι (F ⋙ coyoneda.obj (op d)) c s' := by
184184
apply (Final.colimitCompCoyonedaIso F d).toEquiv.injective
185-
exact Subsingleton.elim _ _
185+
subsingleton
186186
obtain ⟨c', t₁, t₂, h⟩ := (Types.FilteredColimit.colimit_eq_iff.{v₁, v₁, v₁} _).mp this
187187
refine ⟨IsFiltered.coeq t₁ t₂, t₁ ≫ IsFiltered.coeqHom t₁ t₂, ?_⟩
188188
conv_rhs => rw [IsFiltered.coeq_condition t₁ t₂]

Mathlib/CategoryTheory/Functor/Flat.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ noncomputable def preservesFiniteLimitsIffFlat [HasFiniteLimits C] (F : C ⥤ D)
218218
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
219219
congr
220220
-- Porting note: this next line wasn't needed in lean 3
221-
apply Subsingleton.elim
221+
subsingleton
222222

223223
#align category_theory.preserves_finite_limits_iff_flat CategoryTheory.preservesFiniteLimitsIffFlat
224224

@@ -319,15 +319,15 @@ noncomputable def preservesFiniteLimitsIffLanPreservesFiniteLimits (F : C ⥤ D)
319319
-- indicates that it was doing the same as `dsimp only`
320320
dsimp only [preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]; congr
321321
-- Porting note: next line wasn't necessary in lean 3
322-
apply Subsingleton.elim
322+
subsingleton
323323
right_inv x := by
324324
-- cases x; -- Porting note: not necessary in lean 4
325325
dsimp only [lanPreservesFiniteLimitsOfPreservesFiniteLimits,
326326
lanPreservesFiniteLimitsOfFlat,
327327
preservesFiniteLimitsOfPreservesFiniteLimitsOfSize]
328328
congr
329329
-- Porting note: next line wasn't necessary in lean 3
330-
apply Subsingleton.elim
330+
subsingleton
331331
set_option linter.uppercaseLean3 false in
332332
#align category_theory.preserves_finite_limits_iff_Lan_preserves_finite_limits CategoryTheory.preservesFiniteLimitsIffLanPreservesFiniteLimits
333333

0 commit comments

Comments
 (0)