Skip to content

Commit 643e0fa

Browse files
committed
chore(Tactic): reduce use of autoImplicit, part 3 (#14770)
1 parent f972435 commit 643e0fa

13 files changed

+36
-45
lines changed

Mathlib/Tactic/Basic.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import Mathlib.Tactic.Lemma
1111
import Mathlib.Tactic.TypeStar
1212
import Mathlib.Tactic.Linter.OldObtain
1313

14-
set_option autoImplicit true
15-
1614
namespace Mathlib.Tactic
1715
open Lean Parser.Tactic Elab Command Elab.Tactic Meta
1816

@@ -30,7 +28,7 @@ Recall that variables linked this way should be considered to be semantically id
3028
3129
The effect of this is, for example, the unused variable linter will see that variables
3230
from the first array are used if corresponding variables in the second array are used. -/
33-
def pushFVarAliasInfo [Monad m] [MonadInfoTree m]
31+
def pushFVarAliasInfo {m : TypeType} [Monad m] [MonadInfoTree m]
3432
(oldFVars newFVars : Array FVarId) (newLCtx : LocalContext) : m Unit := do
3533
for old in oldFVars, new in newFVars do
3634
if old != new then

Mathlib/Tactic/CategoryTheory/BicategoryCoherence.lean

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ tactic is given in `Mathlib.Tactic.CategoryTheory.Coherence` at the same time as
2424
tactic for monoidal categories.
2525
-/
2626

27-
set_option autoImplicit true
28-
29-
3027
noncomputable section
3128

3229
universe w v u
@@ -246,7 +243,7 @@ theorem bicategoricalComp_refl {f g h : a ⟶ b} (η : f ⟶ g) (θ : g ⟶ h) :
246243
open Lean Elab Tactic Meta
247244

248245
/-- Helper function for throwing exceptions. -/
249-
def exception (g : MVarId) (msg : MessageData) : MetaM α :=
246+
def exception {α : Type} (g : MVarId) (msg : MessageData) : MetaM α :=
250247
throwTacticEx `bicategorical_coherence g msg
251248

252249
/-- Helper function for throwing exceptions with respect to the main goal. -/

Mathlib/Tactic/CategoryTheory/Coherence.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ are equal.
2525
2626
-/
2727

28-
set_option autoImplicit true
29-
3028
-- Porting note: restore when ported
3129
-- import Mathlib.CategoryTheory.Bicategory.CoherenceTactic
3230

@@ -103,7 +101,8 @@ end lifting
103101
open Lean Meta Elab Tactic
104102

105103
/-- Helper function for throwing exceptions. -/
106-
def exception (g : MVarId) (msg : MessageData) : MetaM α := throwTacticEx `monoidal_coherence g msg
104+
def exception {α : Type} (g : MVarId) (msg : MessageData) : MetaM α :=
105+
throwTacticEx `monoidal_coherence g msg
107106

108107
/-- Helper function for throwing exceptions with respect to the main goal. -/
109108
def exception' (msg : MessageData) : TacticM Unit := do

Mathlib/Tactic/CategoryTheory/Elementwise.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ This closely follows the implementation of the `@[reassoc]` attribute, due to Si
3232
reimplemented by Scott Morrison in Lean 4.
3333
-/
3434

35-
set_option autoImplicit true
36-
3735
open Lean Meta Elab Tactic
3836
open Mathlib.Tactic
3937

@@ -42,14 +40,16 @@ open CategoryTheory
4240

4341
section theorems
4442

43+
universe u
44+
4545
theorem forall_congr_forget_Type (α : Type u) (p : α → Prop) :
4646
(∀ (x : (forget (Type u)).obj α), p x) ↔ ∀ (x : α), p x := Iff.rfl
4747

4848
attribute [local instance] ConcreteCategory.instFunLike ConcreteCategory.hasCoeToSort
4949

5050
theorem forget_hom_Type (α β : Type u) (f : α ⟶ β) : DFunLike.coe f = f := rfl
5151

52-
theorem hom_elementwise [Category C] [ConcreteCategory C]
52+
theorem hom_elementwise {C : Type*} [Category C] [ConcreteCategory C]
5353
{X Y : C} {f g : X ⟶ Y} (h : f = g) (x : X) : f x = g x := by rw [h]
5454

5555
end theorems

Mathlib/Tactic/FieldSimp.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import Qq
1818
Tactic to clear denominators in algebraic expressions, based on `simp` with a specific simpset.
1919
-/
2020

21-
set_option autoImplicit true
22-
2321
namespace Mathlib.Tactic.FieldSimp
2422

2523
open Lean Elab.Tactic Parser.Tactic Lean.Meta
@@ -28,7 +26,8 @@ open Qq
2826
initialize registerTraceClass `Tactic.field_simp
2927

3028
/-- Constructs a trace message for the `discharge` function. -/
31-
private def dischargerTraceMessage (prop: Expr) : Except ε (Option Expr) → SimpM MessageData
29+
private def dischargerTraceMessage {ε : Type*} (prop: Expr) :
30+
Except ε (Option Expr) → SimpM MessageData
3231
| .error _ | .ok none => return m!"{crossEmoji} discharge {prop}"
3332
| .ok (some _) => return m!"{checkEmoji} discharge {prop}"
3433

Mathlib/Tactic/IntervalCases.lean

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ where the hypotheses should be of the form `hl : a ≤ n` and `hu : n < b`. In t
2222
`interval_cases` calls `fin_cases` on the resulting hypothesis `h : n ∈ Set.Ico a b`.
2323
-/
2424

25-
set_option autoImplicit true
26-
27-
-- In this file we would like to be able to use multi-character auto-implicits.
28-
set_option relaxedAutoImplicit true
29-
3025
namespace Mathlib.Tactic
3126

3227
open Lean Meta Elab Tactic Term Qq Int
@@ -123,6 +118,8 @@ structure Methods where
123118
/-- Construct the canonical numeral for integer `z`, or fail if `z` is out of range. -/
124119
mkNumeral : Int → MetaM Expr
125120

121+
variable {α : Type*} {a b a' b' : α}
122+
126123
theorem of_not_lt_left [LinearOrder α] (h : ¬(a:α) < b) (eq : a = a') : b ≤ a' := eq ▸ not_lt.1 h
127124
theorem of_not_lt_right [LinearOrder α] (h : ¬(a:α) < b) (eq : b = b') : b' ≤ a := eq ▸ not_lt.1 h
128125
theorem of_not_le_left [LE α] (h : ¬(a:α) ≤ b) (eq : a = a') : ¬a' ≤ b := eq ▸ h
@@ -159,7 +156,8 @@ def Methods.getBound (m : Methods) (e : Expr) (pf : Expr) (lb : Bool) :
159156
let .true ← withNewMCtxDepth <| withReducible <| isDefEq e e' | failure
160157
pure c
161158

162-
theorem le_of_not_le_of_le [LinearOrder α] (h1 : ¬hi ≤ n) (h2 : hi ≤ lo) : (n:α) ≤ lo :=
159+
theorem le_of_not_le_of_le {hi n lo : α} [LinearOrder α] (h1 : ¬hi ≤ n) (h2 : hi ≤ lo) :
160+
(n:α) ≤ lo :=
163161
le_trans (le_of_not_le h1) h2
164162

165163
/--

Mathlib/Tactic/LinearCombination.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ Lastly, calls a normalization tactic on this target.
3030
3131
-/
3232

33-
set_option autoImplicit true
34-
3533
namespace Mathlib.Tactic.LinearCombination
3634
open Lean hiding Rat
3735
open Elab Meta Term
3836

37+
variable {α : Type*} {a a' a₁ a₂ b b' b₁ b₂ c : α}
38+
3939
theorem pf_add_c [Add α] (p : a = b) (c : α) : a + c = b + c := p ▸ rfl
4040
theorem c_add_pf [Add α] (p : b = c) (a : α) : a + b = a + c := p ▸ rfl
4141
theorem add_pf [Add α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ + a₂ = b₁ + b₂ := p₁ ▸ p₂ ▸ rfl

Mathlib/Tactic/ModCases.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ The `mod_cases` tactic does case disjunction on `e % n`, where `e : ℤ` or `e :
1111
to yield `n` new subgoals corresponding to the possible values of `e` modulo `n`.
1212
-/
1313

14-
set_option autoImplicit true
15-
1614
namespace Mathlib.Tactic.ModCases
1715
open Lean Meta Elab Tactic Term Qq
1816

@@ -62,7 +60,7 @@ and the `a ≡ b (mod n) → p` case becomes a subgoal.
6260
Proves an expression of the form `OnModCases n a b p` where `n` and `b` are raw nat literals
6361
and `b ≤ n`. Returns the list of subgoals `?gi : a ≡ i [ZMOD n] → p`.
6462
-/
65-
partial def proveOnModCases (n : Q(ℕ)) (a : Q(ℤ)) (b : Q(ℕ)) (p : Q(Sort u)) :
63+
partial def proveOnModCases {u : Level} (n : Q(ℕ)) (a : Q(ℤ)) (b : Q(ℕ)) (p : Q(Sort u)) :
6664
MetaM (Q(OnModCases $n $a $b $p) × List MVarId) := do
6765
if n.natLit! ≤ b.natLit! then
6866
haveI' : $b =Q $n := ⟨⟩
@@ -138,7 +136,7 @@ and the `a ≡ b (mod n) → p` case becomes a subgoal.
138136
Proves an expression of the form `OnModCases n a b p` where `n` and `b` are raw nat literals
139137
and `b ≤ n`. Returns the list of subgoals `?gi : a ≡ i [MOD n] → p`.
140138
-/
141-
partial def proveOnModCases (n : Q(ℕ)) (a : Q(ℕ)) (b : Q(ℕ)) (p : Q(Sort u)) :
139+
partial def proveOnModCases {u : Level} (n : Q(ℕ)) (a : Q(ℕ)) (b : Q(ℕ)) (p : Q(Sort u)) :
142140
MetaM (Q(OnModCases $n $a $b $p) × List MVarId) := do
143141
if n.natLit! ≤ b.natLit! then
144142
pure ((q(onModCases_stop $p $n $a) : Expr), [])

Mathlib/Tactic/Polyrith.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ remember to force recompilation of any files that call `polyrith`.
6060
6161
-/
6262

63-
set_option autoImplicit true
64-
6563
namespace Mathlib.Tactic.Polyrith
6664
open Lean hiding Rat
6765
open Meta Ring Qq PrettyPrinter AtomM
@@ -131,7 +129,7 @@ def Poly.toSyntax : Poly → Unhygienic Syntax.Term
131129
| .neg p => do `(-$(← p.toSyntax))
132130

133131
/-- Reifies a ring expression of type `α` as a `Poly`. -/
134-
partial def parse {u} {α : Q(Type u)} (sα : Q(CommSemiring $α))
132+
partial def parse {u : Level} {α : Q(Type u)} (sα : Q(CommSemiring $α))
135133
(c : Ring.Cache sα) (e : Q($α)) : AtomM Poly := do
136134
let els := do
137135
try pure <| Poly.const (← (← NormNum.derive e).toRat)
@@ -244,7 +242,7 @@ def Poly.pow' : ℕ → ℕ → Poly
244242
| i, k => .pow (.var i) (.const k)
245243

246244
/-- Constructs a sum from a monadic function supplying the monomials. -/
247-
def Poly.sumM [Monad m] (a : Array α) (f : α → m Poly) : m Poly :=
245+
def Poly.sumM {m : TypeType*} {α : Type*} [Monad m] (a : Array α) (f : α → m Poly) : m Poly :=
248246
a.foldlM (init := .const 0) fun p a => return p.add' (← f a)
249247

250248
instance : FromJson Poly where

Mathlib/Tactic/ReduceModChar.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ open Lean.Elab
3636
open Tactic
3737
open Qq
3838

39-
set_option autoImplicit true
40-
4139
namespace Tactic
4240

4341
namespace ReduceModChar
4442

4543
open Mathlib.Meta.NormNum
4644

45+
variable {u : Level}
46+
4747
lemma CharP.intCast_eq_mod (R : Type _) [Ring R] (p : ℕ) [CharP R p] (k : ℤ) :
4848
(k : R) = (k % p : ℤ) := by
4949
calc
5050
(k : R) = ↑(k % p + p * (k / p)) := by rw [Int.emod_add_ediv]
5151
_ = ↑(k % p) := by simp [CharP.cast_eq_zero R]
5252

53-
lemma CharP.isInt_of_mod {α : Type _} [Ring α] {n n' : ℕ} (inst : CharP α n) {e : α}
53+
lemma CharP.isInt_of_mod {e' r : ℤ} {α : Type _} [Ring α] {n n' : ℕ} (inst : CharP α n) {e : α}
5454
(he : IsInt e e') (hn : IsNat n n') (h₂ : IsInt (e' % n') r) : IsInt e r :=
5555
by rw [he.out, CharP.intCast_eq_mod α n, show n = n' from hn.out, h₂.out, Int.cast_id]⟩
5656

@@ -127,7 +127,7 @@ inductive TypeToCharPResult (α : Q(Type u))
127127
| intLike (n : Q(ℕ)) (instRing : Q(Ring $α)) (instCharP : Q(CharP $α $n))
128128
| failure
129129

130-
instance : Inhabited (TypeToCharPResult α) := ⟨.failure⟩
130+
instance {α : Q(Type u)} : Inhabited (TypeToCharPResult α) := ⟨.failure⟩
131131

132132
/-- Determine the characteristic of a ring from the type.
133133
This should be fast, so this pattern-matches on the type, rather than searching for a

0 commit comments

Comments
 (0)