Skip to content

Commit

Permalink
chore: remove autoImplicit from more files (#11798)
Browse files Browse the repository at this point in the history
and reduce its scope in a few other instances.
Mostly in `CategoryTheory` and `Data` this time; some `Combinatorics` also.



Co-authored-by: Richard Osborn <richardosborn@mac.com>
  • Loading branch information
grunweg and rosborn committed Apr 14, 2024
1 parent 97558f9 commit 3bb1d61
Show file tree
Hide file tree
Showing 54 changed files with 243 additions and 317 deletions.
3 changes: 1 addition & 2 deletions Mathlib/Algebra/Category/ModuleCat/Free.lean
Expand Up @@ -81,7 +81,6 @@ end LinearIndependent

section Span

set_option autoImplicit true in
/-- In the commutative diagram
```
f g
Expand All @@ -92,7 +91,7 @@ v| u| w|
```
where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and
`Sum.inr`. If `v` spans `X₁` and `w` spans `X₃`, then `u` spans `X₂`. -/
theorem span_exact (huv : u ∘ Sum.inl = S.f ∘ v)
theorem span_exact {β : Type*} {u : ι ⊕ β → S.X₂} (huv : u ∘ Sum.inl = S.f ∘ v)
(hv : ⊤ ≤ span R (range v))
(hw : ⊤ ≤ span R (range (S.g ∘ u ∘ Sum.inr))) :
⊤ ≤ span R (range u) := by
Expand Down
8 changes: 3 additions & 5 deletions Mathlib/Algebra/Category/Ring/Basic.lean
Expand Up @@ -134,12 +134,11 @@ theorem ofHom_apply {R S : Type u} [Semiring R] [Semiring S] (f : R →+* S) (x
set_option linter.uppercaseLean3 false in
#align SemiRing.of_hom_apply SemiRingCat.ofHom_apply

set_option autoImplicit true in
/--
Ring equivalence are isomorphisms in category of semirings
-/
@[simps]
def _root_.RingEquiv.toSemiRingCatIso [Semiring X] [Semiring Y] (e : X ≃+* Y) :
def _root_.RingEquiv.toSemiRingCatIso {X Y : Type u} [Semiring X] [Semiring Y] (e : X ≃+* Y) :
SemiRingCat.of X ≅ SemiRingCat.of Y where
hom := e.toRingHom
inv := e.symm.toRingHom
Expand Down Expand Up @@ -355,13 +354,12 @@ instance hasForgetToCommMonCat : HasForget₂ CommSemiRingCat CommMonCat :=
set_option linter.uppercaseLean3 false in
#align CommSemiRing.has_forget_to_CommMon CommSemiRingCat.hasForgetToCommMonCat

set_option autoImplicit true in
/--
Ring equivalence are isomorphisms in category of commutative semirings
-/
@[simps]
def _root_.RingEquiv.toCommSemiRingCatIso [CommSemiring X] [CommSemiring Y] (e : X ≃+* Y) :
CommSemiRingCat.of X ≅ CommSemiRingCat.of Y where
def _root_.RingEquiv.toCommSemiRingCatIso {X Y : Type u} [CommSemiring X] [CommSemiring Y]
(e : X ≃+* Y) : CommSemiRingCat.of X ≅ CommSemiRingCat.of Y where
hom := e.toRingHom
inv := e.symm.toRingHom

Expand Down
5 changes: 1 addition & 4 deletions Mathlib/Algebra/Homology/HomotopyCategory.lean
Expand Up @@ -17,9 +17,6 @@ import Mathlib.CategoryTheory.Quotient.Preadditive
with chain maps identified when they are homotopic.
-/

set_option autoImplicit true


universe v u

open scoped Classical
Expand Down Expand Up @@ -51,7 +48,7 @@ def HomotopyCategory :=
CategoryTheory.Quotient (homotopic V c)
#align homotopy_category HomotopyCategory

instance : Category (HomotopyCategory V v) := by
instance {v : ComplexShape ι} : Category (HomotopyCategory V v) := by
dsimp only [HomotopyCategory]
infer_instance

Expand Down
6 changes: 2 additions & 4 deletions Mathlib/Algebra/Module/Torsion.lean
Expand Up @@ -170,13 +170,12 @@ def torsionBySet (s : Set R) : Submodule R M :=
sInf (torsionBy R M '' s)
#align submodule.torsion_by_set Submodule.torsionBySet

set_option autoImplicit true in
-- Porting note: torsion' had metavariables and factoring out this fixed it
-- perhaps there is a better fix
/-- The additive submonoid of all elements `x` of `M` such that `a • x = 0`
for some `a` in `S`. -/
@[simps!]
def torsion'AddSubMonoid (S : Type w) [CommMonoid S] [DistribMulAction S M] :
def torsion'AddSubMonoid (S : Type*) [CommMonoid S] [DistribMulAction S M] :
AddSubmonoid M where
carrier := { x | ∃ a : S, a • x = 0 }
add_mem' := by
Expand All @@ -185,11 +184,10 @@ def torsion'AddSubMonoid (S : Type w) [CommMonoid S] [DistribMulAction S M] :
rw [smul_add, mul_smul, mul_comm, mul_smul, hx, hy, smul_zero, smul_zero, add_zero]
zero_mem' := ⟨1, smul_zero 1

set_option autoImplicit true in
/-- The `S`-torsion submodule, containing all elements `x` of `M` such that `a • x = 0` for some
`a` in `S`. -/
@[simps!]
def torsion' (S : Type w) [CommMonoid S] [DistribMulAction S M] [SMulCommClass S R M] :
def torsion' (S : Type*) [CommMonoid S] [DistribMulAction S M] [SMulCommClass S R M] :
Submodule R M :=
{ torsion'AddSubMonoid M S with
smul_mem' := fun a x ⟨b, h⟩ => ⟨b, by rw [smul_comm, h, smul_zero]⟩}
Expand Down
9 changes: 4 additions & 5 deletions Mathlib/Algebra/MvPolynomial/Basic.lean
Expand Up @@ -70,8 +70,6 @@ polynomial, multivariate polynomial, multivariable polynomial
-/

set_option autoImplicit true

noncomputable section

open Set Function Finsupp AddMonoidAlgebra
Expand Down Expand Up @@ -505,7 +503,8 @@ theorem algHom_ext {A : Type*} [Semiring A] [Algebra R A] {f g : MvPolynomial σ
#align mv_polynomial.alg_hom_ext MvPolynomial.algHom_ext

@[simp]
theorem algHom_C (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (r : R) : f (C r) = C r :=
theorem algHom_C {τ : Type*} (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (r : R) :
f (C r) = C r :=
f.commutes r
#align mv_polynomial.alg_hom_C MvPolynomial.algHom_C

Expand Down Expand Up @@ -1207,11 +1206,11 @@ theorem eval_assoc {τ} (f : σ → MvPolynomial τ R) (g : τ → R) (p : MvPol
#align mv_polynomial.eval_assoc MvPolynomial.eval_assoc

@[simp]
theorem eval₂_id (p : MvPolynomial σ R) : eval₂ (RingHom.id _) g p = eval g p :=
theorem eval₂_id {g : σ → R} (p : MvPolynomial σ R) : eval₂ (RingHom.id _) g p = eval g p :=
rfl
#align mv_polynomial.eval₂_id MvPolynomial.eval₂_id

theorem eval_eval₂ [CommSemiring R] [CommSemiring S]
theorem eval_eval₂ {S τ : Type*} {x : τ → S} [CommSemiring R] [CommSemiring S]
(f : R →+* MvPolynomial τ S) (g : σ → MvPolynomial τ S) (p : MvPolynomial σ R) :
eval x (eval₂ f g p) = eval₂ ((eval x).comp f) (fun s => eval x (g s)) p := by
apply induction_on p
Expand Down
8 changes: 4 additions & 4 deletions Mathlib/Algebra/MvPolynomial/Polynomial.lean
Expand Up @@ -12,12 +12,12 @@ import Mathlib.Algebra.Polynomial.Eval
# Some lemmas relating polynomials and multivariable polynomials.
-/

set_option autoImplicit true

namespace MvPolynomial

variable {R S σ : Type*}

theorem polynomial_eval_eval₂ [CommSemiring R] [CommSemiring S]
(f : R →+* Polynomial S) (g : σ → Polynomial S) (p : MvPolynomial σ R) :
{x : S} (f : R →+* Polynomial S) (g : σ → Polynomial S) (p : MvPolynomial σ R) :
Polynomial.eval x (eval₂ f g p) =
eval₂ ((Polynomial.evalRingHom x).comp f) (fun s => Polynomial.eval x (g s)) p := by
apply induction_on p
Expand All @@ -27,7 +27,7 @@ theorem polynomial_eval_eval₂ [CommSemiring R] [CommSemiring S]
· intro p n hp
simp [hp]

theorem eval_polynomial_eval_finSuccEquiv
theorem eval_polynomial_eval_finSuccEquiv {n : ℕ} {x : Fin n → R}
[CommSemiring R] (f : MvPolynomial (Fin (n + 1)) R) (q : MvPolynomial (Fin n) R) :
(eval x) (Polynomial.eval q (finSuccEquiv R n f)) = eval (Fin.cases (eval x q) x) f := by
simp only [finSuccEquiv_apply, coe_eval₂Hom, polynomial_eval_eval₂, eval_eval₂]
Expand Down
4 changes: 1 addition & 3 deletions Mathlib/Algebra/Polynomial/Degree/Definitions.lean
Expand Up @@ -26,8 +26,6 @@ Results include
The leading_coefficient of a sum is determined by the leading coefficients and degrees
-/

set_option autoImplicit true

-- Porting note: `Mathlib.Data.Nat.Cast.WithTop` should be imported for `Nat.cast_withBot`.

set_option linter.uppercaseLean3 false
Expand Down Expand Up @@ -1129,7 +1127,7 @@ theorem coeff_pow_mul_natDegree (p : R[X]) (n : ℕ) :
exact coeff_mul_degree_add_degree _ _
#align polynomial.coeff_pow_mul_nat_degree Polynomial.coeff_pow_mul_natDegree

theorem coeff_mul_add_eq_of_natDegree_le {df dg : ℕ} {g : R[X]}
theorem coeff_mul_add_eq_of_natDegree_le {df dg : ℕ} {f g : R[X]}
(hdf : natDegree f ≤ df) (hdg : natDegree g ≤ dg) :
(f * g).coeff (df + dg) = f.coeff df * g.coeff dg := by
rw [coeff_mul, Finset.sum_eq_single_of_mem (df, dg)]
Expand Down
5 changes: 1 addition & 4 deletions Mathlib/Algebra/Polynomial/RingDivision.lean
Expand Up @@ -30,9 +30,6 @@ This file starts looking like the ring theory of $R[X]$
-/

set_option autoImplicit true


noncomputable section

open Polynomial
Expand Down Expand Up @@ -738,7 +735,7 @@ theorem isRoot_of_mem_roots (h : a ∈ p.roots) : IsRoot p a :=
#align polynomial.is_root_of_mem_roots Polynomial.isRoot_of_mem_roots

-- Porting note: added during port.
lemma mem_roots_iff_aeval_eq_zero (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by
lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by
rw [mem_roots w, IsRoot.def, aeval_def, eval₂_eq_eval_map]
simp

Expand Down
7 changes: 3 additions & 4 deletions Mathlib/Analysis/Complex/UpperHalfPlane/Basic.lean
Expand Up @@ -301,14 +301,13 @@ def coe' : SL(2, ℤ) → GL(2, ℝ)⁺ := fun g => ((g : SL(2, ℝ)) : GL(2,
instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ :=
⟨coe'⟩

set_option autoImplicit true in
@[simp]
theorem coe'_apply_complex : (Units.val <| Subtype.val <| coe' g) i j = (Subtype.val g i j : ℂ) :=
theorem coe'_apply_complex {g : SL(2, ℤ)} {i j : Fin 2} :
(Units.val <| Subtype.val <| coe' g) i j = (Subtype.val g i j : ℂ) :=
rfl

set_option autoImplicit true in
@[simp]
theorem det_coe' : det (Units.val <| Subtype.val <| coe' g) = 1 := by
theorem det_coe' {g : SL(2, ℤ)} : det (Units.val <| Subtype.val <| coe' g) = 1 := by
simp only [SpecialLinearGroup.coe_GLPos_coe_GL_coe_matrix, SpecialLinearGroup.det_coe, coe']

instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ :=
Expand Down
5 changes: 1 addition & 4 deletions Mathlib/Analysis/RCLike/Basic.lean
Expand Up @@ -40,9 +40,6 @@ their counterparts in `Mathlib/Analysis/Complex/Basic.lean` (which causes linter
A few lemmas requiring heavier imports are in `Mathlib/Data/RCLike/Lemmas.lean`.
-/

set_option autoImplicit true


open BigOperators

section
Expand Down Expand Up @@ -74,7 +71,7 @@ class RCLike (K : semiOutParam (Type*)) extends DenselyNormedField K, StarRing K
mul_im_I_ax : ∀ z : K, im z * im I = im z
/-- only an instance in the `ComplexOrder` locale -/
[toPartialOrder : PartialOrder K]
le_iff_re_im : z ≤ w ↔ re z ≤ re w ∧ im z = im w
le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w
-- note we cannot put this in the `extends` clause
[toDecidableEq : DecidableEq K]
#align is_R_or_C RCLike
Expand Down
12 changes: 4 additions & 8 deletions Mathlib/Analysis/SpecialFunctions/Log/Basic.lean
Expand Up @@ -509,33 +509,29 @@ lemma log_pos_of_isNegNat {n : ℕ} (h : NormNum.IsInt e (.negOfNat n)) (w : Nat
apply Real.log_pos
simpa using w

set_option autoImplicit true in
lemma log_pos_of_isRat :
lemma log_pos_of_isRat {n : ℤ} :
(NormNum.IsRat e n d) → (decide ((1 : ℚ) < n / d)) → (0 < Real.log (e : ℝ))
| ⟨inv, eq⟩, h => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have : 1 < (n : ℝ) / d := by exact_mod_cast of_decide_eq_true h
exact Real.log_pos this

set_option autoImplicit true in
lemma log_pos_of_isRat_neg :
lemma log_pos_of_isRat_neg {n : ℤ} :
(NormNum.IsRat e n d) → (decide (n / d < (-1 : ℚ))) → (0 < Real.log (e : ℝ))
| ⟨inv, eq⟩, h => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have : (n : ℝ) / d < -1 := by exact_mod_cast of_decide_eq_true h
exact Real.log_pos_of_lt_neg_one this

set_option autoImplicit true in
lemma log_nz_of_isRat : (NormNum.IsRat e n d) → (decide ((0 : ℚ) < n / d))
lemma log_nz_of_isRat {n : ℤ} : (NormNum.IsRat e n d) → (decide ((0 : ℚ) < n / d))
→ (decide (n / d < (1 : ℚ))) → (Real.log (e : ℝ) ≠ 0)
| ⟨inv, eq⟩, h₁, h₂ => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have h₁' : 0 < (n : ℝ) / d := by exact_mod_cast of_decide_eq_true h₁
have h₂' : (n : ℝ) / d < 1 := by exact_mod_cast of_decide_eq_true h₂
exact ne_of_lt <| Real.log_neg h₁' h₂'

set_option autoImplicit true in
lemma log_nz_of_isRat_neg : (NormNum.IsRat e n d) → (decide (n / d < (0 : ℚ)))
lemma log_nz_of_isRat_neg {n : ℤ} : (NormNum.IsRat e n d) → (decide (n / d < (0 : ℚ)))
→ (decide ((-1 : ℚ) < n / d)) → (Real.log (e : ℝ) ≠ 0)
| ⟨inv, eq⟩, h₁, h₂ => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
Expand Down
10 changes: 4 additions & 6 deletions Mathlib/CategoryTheory/Bicategory/NaturalTransformation.lean
Expand Up @@ -24,9 +24,6 @@ transformations.
between `F` and `G`
-/

set_option autoImplicit true


namespace CategoryTheory

open Category Bicategory
Expand Down Expand Up @@ -290,12 +287,13 @@ lemma ext {F G : OplaxFunctor B C} {α β : F ⟶ G} {m n : α ⟶ β} (w : ∀
apply w

@[simp]
lemma Modification.id_app' {F G : OplaxFunctor B C} (α : F ⟶ G) :
lemma Modification.id_app' {X : B} {F G : OplaxFunctor B C} (α : F ⟶ G) :
Modification.app (𝟙 α) X = 𝟙 (α.app X) := rfl

@[simp]
lemma Modification.comp_app' {F G : OplaxFunctor B C} {α β γ : F ⟶ G} (m : α ⟶ β) (n : β ⟶ γ) :
(m ≫ n).app X = m.app X ≫ n.app X := rfl
lemma Modification.comp_app' {X : B} {F G : OplaxFunctor B C} {α β γ : F ⟶ G}
(m : α ⟶ β) (n : β ⟶ γ) : (m ≫ n).app X = m.app X ≫ n.app X :=
rfl

/-- Construct a modification isomorphism between oplax natural transformations
by giving object level isomorphisms, and checking naturality only in the forward direction.
Expand Down
9 changes: 3 additions & 6 deletions Mathlib/CategoryTheory/ConnectedComponents.lean
Expand Up @@ -48,8 +48,7 @@ def Component (j : ConnectedComponents J) : Type u₁ :=
FullSubcategory fun k => Quotient.mk'' k = j
#align category_theory.component CategoryTheory.Component

set_option autoImplicit true in
instance : Category (Component (j : ConnectedComponents J)) :=
instance {j : ConnectedComponents J} : Category (Component j) :=
FullSubcategory.category _

-- Porting note: it was originally @[simps (config := { rhsMd := semireducible })]
Expand All @@ -59,12 +58,10 @@ def Component.ι (j : ConnectedComponents J) : Component j ⥤ J :=
fullSubcategoryInclusion _
#align category_theory.component.ι CategoryTheory.Component.ι

set_option autoImplicit true in
instance : Functor.Full (Component.ι (j : ConnectedComponents J)) :=
instance {j : ConnectedComponents J} : Functor.Full (Component.ι j) :=
FullSubcategory.full _

set_option autoImplicit true in
instance : Functor.Faithful (Component.ι (j : ConnectedComponents J)) :=
instance {j : ConnectedComponents J} : Functor.Faithful (Component.ι j) :=
FullSubcategory.faithful _

/-- Each connected component of the category is nonempty. -/
Expand Down
5 changes: 2 additions & 3 deletions Mathlib/CategoryTheory/EqToHom.lean
Expand Up @@ -26,9 +26,6 @@ This file introduces various `simp` lemmas which in favourable circumstances
result in the various `eqToHom` morphisms to drop out at the appropriate moment!
-/

set_option autoImplicit true


universe v₁ v₂ v₃ u₁ u₂ u₃

-- morphism levels before object levels. See note [CategoryTheory universes].
Expand Down Expand Up @@ -71,6 +68,8 @@ theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y)
mpr := fun h => h ▸ by simp [whisker_eq _ h] }
#align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff

variable {β : Sort*}

/-- We can push `eqToHom` to the left through families of morphisms. -/
-- The simpNF linter incorrectly claims that this will never apply.
-- https://github.com/leanprover-community/mathlib4/issues/5049
Expand Down
6 changes: 2 additions & 4 deletions Mathlib/CategoryTheory/GradedObject.lean
Expand Up @@ -33,8 +33,6 @@ have a functor `map : GradedObject I C ⥤ GradedObject J C`.
-/

set_option autoImplicit true

namespace CategoryTheory

open Category Limits
Expand Down Expand Up @@ -72,7 +70,7 @@ instance categoryOfGradedObjects (β : Type w) : Category.{max w v} (GradedObjec

-- Porting note (#10688): added to ease automation
@[ext]
lemma hom_ext {X Y : GradedObject β C} (f g : X ⟶ Y) (h : ∀ x, f x = g x) : f = g := by
lemma hom_ext {β : Type*} {X Y : GradedObject β C} (f g : X ⟶ Y) (h : ∀ x, f x = g x) : f = g := by
funext
apply h

Expand Down Expand Up @@ -128,7 +126,7 @@ abbrev comap {I J : Type*} (h : J → I) : GradedObject I C ⥤ GradedObject J C

-- Porting note: added to ease the port, this is a special case of `Functor.eqToHom_proj`
@[simp]
theorem eqToHom_proj {x x' : GradedObject I C} (h : x = x') (i : I) :
theorem eqToHom_proj {I : Type*} {x x' : GradedObject I C} (h : x = x') (i : I) :
(eqToHom h : x ⟶ x') i = eqToHom (Function.funext_iff.mp h i) := by
subst h
rfl
Expand Down
5 changes: 1 addition & 4 deletions Mathlib/CategoryTheory/Limits/Presheaf.lean
Expand Up @@ -41,9 +41,6 @@ colimit, representable, presheaf, free cocompletion
* https://ncatlab.org/nlab/show/Yoneda+extension
-/

set_option autoImplicit true


namespace CategoryTheory

open Category Limits
Expand Down Expand Up @@ -151,7 +148,7 @@ theorem extendAlongYoneda_obj (P : Cᵒᵖ ⥤ Type u₁) :
-- `(extendAlongYoneda A).obj P` is definitionally a colimit, and the ext lemma is just
-- a special case of `CategoryTheory.Limits.colimit.hom_ext`.
-- See https://github.com/leanprover-community/mathlib4/issues/5229
@[ext] lemma extendAlongYoneda_obj.hom_ext {P : Cᵒᵖ ⥤ Type u₁}
@[ext] lemma extendAlongYoneda_obj.hom_ext {X : ℰ} {P : Cᵒᵖ ⥤ Type u₁}
{f f' : (extendAlongYoneda A).obj P ⟶ X}
(w : ∀ j, colimit.ι ((CategoryOfElements.π P).leftOp ⋙ A) j ≫ f =
colimit.ι ((CategoryOfElements.π P).leftOp ⋙ A) j ≫ f') : f = f' :=
Expand Down

0 comments on commit 3bb1d61

Please sign in to comment.