ruc-ai4math/mathlib_handler_benchmark_410 huggingface dataset:
File: Mathlib/Tactic/TypeStar.lean

full_name: «_aux_Mathlib_Tactic_TypeStar___elabRules_termSort*_1»
code: /-- The syntax `variable (X Y ... Z : Sort*)` creates a new distinct implicit universe variable
for each variable in the sequence. -/
elab "Sort*" : term => do
  let u ← Lean.Meta.mkFreshLevelMVar
  Elab.Term.levelMVarToParam (.sort u)
goal: Lean.Elab.Term.TermElab

full_name: «termSort*»
code: /-- The syntax `variable (X Y ... Z : Sort*)` creates a new distinct implicit universe variable
for each variable in the sequence. -/
elab "Sort*" : term => do
  let u ← Lean.Meta.mkFreshLevelMVar
  Elab.Term.levelMVarToParam (.sort u)
goal: Lean.ParserDescr

full_name: «termType*»
code: /-- The syntax `variable (X Y ... Z : Type*)` creates a new distinct implicit universe variable
`> 0` for each variable in the sequence. -/
elab "Type*" : term => do
  let u ← Lean.Meta.mkFreshLevelMVar
  Elab.Term.levelMVarToParam (.sort (.succ u))
goal: Lean.ParserDescr

full_name: «_aux_Mathlib_Tactic_TypeStar___elabRules_termType*_1»
code: /-- The syntax `variable (X Y ... Z : Type*)` creates a new distinct implicit universe variable
`> 0` for each variable in the sequence. -/
elab "Type*" : term => do
  let u ← Lean.Meta.mkFreshLevelMVar
  Elab.Term.levelMVarToParam (.sort (.succ u))
goal: Lean.Elab.Term.TermElab
File: Mathlib/Tactic/Rify.lean

full_name: Mathlib.Tactic.Rify.rify
code: /--
The `rify` tactic is used to shift propositions from `ℕ`, `ℤ` or `ℚ` to `ℝ`.
Although less useful than its cousins `zify` and `qify`, it can be useful when your
goal or context already involves real numbers.

In the example below, assumption `hn` is about natural numbers, `hk` is about integers
and involves casting a natural number to `ℤ`, and the conclusion is about real numbers.
The proof uses `rify` to lift both assumptions to `ℝ` before calling `linarith`.
```
example {n : ℕ} {k : ℤ} (hn : 8 ≤ n) (hk : 2 * k ≤ n + 2) :
    (0 : ℝ) < n - k - 1 := by
  rify at hn hk /- Now have hn : 8 ≤ (n : ℝ)   hk : 2 * (k : ℝ) ≤ (n : ℝ) + 2-/
  linarith
```

`rify` makes use of the `@[zify_simps]`, `@[qify_simps]` and `@[rify_simps]` attributes to move
propositions, and the `push_cast` tactic to simplify the `ℝ`-valued expressions.

`rify` can be given extra lemmas to use in simplification. This is especially useful in the
presence of nat subtraction: passing `≤` arguments will allow `push_cast` to do more work.
```
example (a b c : ℕ) (h : a - b < c) (hab : b ≤ a) : a < b + c := by
  rify [hab] at h ⊢
  linarith
```
Note that `zify` or `qify` would work just as well in the above example (and `zify` is the natural
choice since it is enough to get rid of the pathological `ℕ` subtraction). -/
syntax (name := rify) "rify" (simpArgs)? (location)? : tactic
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.Rify._aux_Mathlib_Tactic_Rify___macroRules_Mathlib_Tactic_Rify_rify_1
code: macro_rules
| `(tactic| rify $[[$simpArgs,*]]? $[at $location]?) =>
  let args := simpArgs.map (·.getElems) |>.getD #[]
  `(tactic|
    simp (config := {decide := false}) only [zify_simps, qify_simps, rify_simps, push_cast, $args,*]
      $[at $location]?)
goal: Lean.Macro

full_name: Mathlib.Tactic.Rify.ratCast_eq
code: @[rify_simps] lemma ratCast_eq (a b : ℚ) : a = b ↔ (a : ℝ) = (b : ℝ) 
goal: a = b ↔ ↑a = ↑b

full_name: Mathlib.Tactic.Rify.ratCast_le
code: @[rify_simps] lemma ratCast_le (a b : ℚ) : a ≤ b ↔ (a : ℝ) ≤ (b : ℝ) 
goal: a ≤ b ↔ ↑a ≤ ↑b

full_name: Mathlib.Tactic.Rify.ratCast_lt
code: @[rify_simps] lemma ratCast_lt (a b : ℚ) : a < b ↔ (a : ℝ) < (b : ℝ) 
goal: a < b ↔ ↑a < ↑b

full_name: Mathlib.Tactic.Rify.ratCast_ne
code: @[rify_simps] lemma ratCast_ne (a b : ℚ) : a ≠ b ↔ (a : ℝ) ≠ (b : ℝ) 
goal: a ≠ b ↔ ↑a ≠ ↑b

full_name: Mathlib.Tactic.Rify.ofNat_rat_real
code: @[rify_simps] lemma ofNat_rat_real (a : ℕ) [a.AtLeastTwo] :
    ((no_index (OfNat.ofNat a : ℚ)) : ℝ) = (OfNat.ofNat a : ℝ) 
goal: ↑(OfNat.ofNat a) = OfNat.ofNat a
File: Mathlib/Tactic/FunProp/ToBatteries.lean

full_name: Mathlib.Meta.FunProp.isOrderedSubsetOf
code: /-- Check if `a` can be obtained by removing elements from `b`. -/
def isOrderedSubsetOf {α} [Inhabited α] [DecidableEq α] (a b : Array α) : Bool 
goal: Bool

full_name: _private.Mathlib.Tactic.FunProp.ToBatteries.0.Mathlib.Meta.FunProp.letTelescopeImpl
code: private def letTelescopeImpl {α} (e : Expr) (k : Array Expr → Expr → MetaM α) :
    MetaM α 
goal: Lean.MetaM α

full_name: Mathlib.Meta.FunProp.letTelescope
code: /-- Telescope consuming only let bindings -/
def letTelescope {α n} [MonadControlT MetaM n] [Monad n] (e : Expr)
    (k : Array Expr → Expr → n α) : n α 
goal: n α

full_name: Lean.Expr.swapBVars
code: /--
  Swaps bvars indices `i` and `j`

  NOTE: the indices `i` and `j` do not correspond to the `n` in `bvar n`. Rather
  they behave like indices in `Expr.lowerLooseBVars`, `Expr.liftLooseBVars`, etc.

  TODO: This has to have a better implementation, but I'm still beyond confused with how bvar
  indices work
-/
def _root_.Lean.Expr.swapBVars (e : Expr) (i j : Nat) : Expr 
goal: Lean.Expr

full_name: Mathlib.Meta.FunProp.mkProdElem
code: /--
For `#[x₁, .., xₙ]` create `(x₁, .., xₙ)`.
-/
def mkProdElem (xs : Array Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Mathlib.Meta.FunProp.mkProdProj
code: /--
For `(x₀, .., xₙ₋₁)` return `xᵢ` but as a product projection.

We need to know the total size of the product to be considered.

For example for `xyz : X × Y × Z`
  - `mkProdProj xyz 1 3` returns `xyz.snd.fst`.
  - `mkProdProj xyz 1 2` returns `xyz.snd`.
-/
def mkProdProj (x : Expr) (i : Nat) (n : Nat) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Mathlib.Meta.FunProp.mkProdSplitElem
code: /-- For an element of a product type(of size`n`) `xs` create an array of all possible projections
i.e. `#[xs.1, xs.2.1, xs.2.2.1, ..., xs.2..2]` -/
def mkProdSplitElem (xs : Expr) (n : Nat) : MetaM (Array Expr) 
goal: Lean.MetaM (Array Lean.Expr)

full_name: Mathlib.Meta.FunProp.mkUncurryFun
code: /-- Uncurry function `f` in `n` arguments. -/
def mkUncurryFun (n : Nat) (f : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: Mathlib.Meta.FunProp.etaExpand1
code: /-- Eta expand `f` in only one variable and reduce in others.

Examples:
```
  f                ==> fun x => f x
  fun x y => f x y ==> fun x => f x
  HAdd.hAdd y      ==> fun x => HAdd.hAdd y x
  HAdd.hAdd        ==> fun x => HAdd.hAdd x
``` -/
def etaExpand1 (f : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr
File: Mathlib/Tactic/FunProp/ContDiff.lean

full_name: contDiff_id'
code: theorem contDiff_id' : ContDiff K n (fun x : E => x) 
goal: ContDiff K n fun x => x

full_name: contDiffAt_id'
code: theorem contDiffAt_id' : ContDiffAt K n (fun x : E => x) x 
goal: ContDiffAt K n (fun x => x) x

full_name: contDiffOn_id'
code: theorem contDiffOn_id' : ContDiffOn K n (fun x : E => x) s 
goal: ContDiffOn K n (fun x => x) s

full_name: ContDiff.comp'
code: theorem ContDiff.comp' {g : F → G} (hg : ContDiff K n g) (hf : ContDiff K n f) :
    ContDiff K n (fun x => g (f x)) 
goal: ContDiff K n fun x => g (f x)

full_name: ContDiffAt.comp'
code: theorem ContDiffAt.comp' {f : E → F} {g : F → G} (hg : ContDiffAt K n g (f x))
    (hf : ContDiffAt K n f x) : ContDiffAt K n (fun x => g (f x)) x 
goal: ContDiffAt K n (fun x => g (f x)) x

full_name: contDiff_pi'
code: theorem contDiff_pi' (hΦ : ∀ i, ContDiff K n fun x => Φ x i) : ContDiff K n Φ 
goal: ContDiff K n Φ

full_name: contDiffOn_pi'
code: theorem contDiffOn_pi' (hΦ : ∀ i, ContDiffOn K n (fun x => Φ x i) s) : ContDiffOn K n Φ s 
goal: ContDiffOn K n Φ s

full_name: contDiffAt_pi'
code: theorem contDiffAt_pi' (hΦ : ∀ i, ContDiffAt K n (fun x => Φ x i) x) : ContDiffAt K n Φ x 
goal: ContDiffAt K n Φ x

full_name: ContDiffOn.div'
code: theorem ContDiffOn.div' [CompleteSpace K] {f g : E → K} {n} (hf : ContDiffOn K n f s)
    (hg : ContDiffOn K n g s) (h₀ : ∀ x ∈ s, g x ≠ 0) : ContDiffOn K n (fun x => f x / g x) s 
goal: ContDiffOn K n (fun x => f x / g x) s

full_name: ContDiff.differentiable_iteratedDeriv'
code: /-- Original version `ContDiff.differentiable_iteratedDeriv` introduces a new variable `(n:ℕ∞)`
and `funProp` can't work with such theorem. The theorem should be state where `n` is explicitly
the smallest possible value i.e. `n=m+1`.

In conjunction with `ContDiff.of_le` we can recover the full power of the original theorem.  -/
theorem ContDiff.differentiable_iteratedDeriv' {m : ℕ} {f : K → F}
    (hf : ContDiff K (m+1) f) : Differentiable K (iteratedDeriv m f) 
goal: Differentiable K (iteratedDeriv m f)
File: Mathlib/Tactic/FunProp/Attr.lean

full_name: _private.Mathlib.Tactic.FunProp.Attr.0.Mathlib.Meta.FunProp.funPropHelpString
code: private def funPropHelpString : String 
goal: String

full_name: Mathlib.Meta.FunProp.initFn._@.Mathlib.Tactic.FunProp.Attr._hyg.11
code: /-- Initialization of `funProp` attribute -/
initialize funPropAttr : Unit ←
  registerBuiltinAttribute {
    name  := `fun_prop
    descr := funPropHelpString
    applicationTime := AttributeApplicationTime.afterCompilation
    add   := fun declName _stx attrKind =>
       discard <| MetaM.run do
       let info ← getConstInfo declName

       forallTelescope info.type fun _ b => do
         if b.isProp then
           addFunPropDecl declName
         else
           addTheorem declName attrKind
    erase := fun _declName =>
      throwError "can't remove `funProp` attribute (not implemented yet)"
  }
goal: IO Unit

full_name: Mathlib.Meta.FunProp.funPropAttr
code: /-- Initialization of `funProp` attribute -/
initialize funPropAttr : Unit ←
  registerBuiltinAttribute {
    name  := `fun_prop
    descr := funPropHelpString
    applicationTime := AttributeApplicationTime.afterCompilation
    add   := fun declName _stx attrKind =>
       discard <| MetaM.run do
       let info ← getConstInfo declName

       forallTelescope info.type fun _ b => do
         if b.isProp then
           addFunPropDecl declName
         else
           addTheorem declName attrKind
    erase := fun _declName =>
      throwError "can't remove `funProp` attribute (not implemented yet)"
  }
goal: Unit
File: Mathlib/Tactic/Trace.lean

full_name: Lean.Parser.Tactic.trace
code: /-- Evaluates a term to a string (when possible), and prints it as a trace message. -/
elab (name := Lean.Parser.Tactic.trace) tk:"trace " val:term : tactic => do
  let e ← elabTerm (← `(toString $val)) (some (mkConst `String))
  logInfoAt tk <|← unsafe evalExpr String (mkConst `String) e
goal: Lean.ParserDescr

full_name: _aux_Mathlib_Tactic_Trace___elabRules_Lean_Parser_Tactic_trace_1
code: /-- Evaluates a term to a string (when possible), and prints it as a trace message. -/
elab (name := Lean.Parser.Tactic.trace) tk:"trace " val:term : tactic => do
  let e ← elabTerm (← `(toString $val)) (some (mkConst `String))
  logInfoAt tk <|← unsafe evalExpr String (mkConst `String) e
goal: Lean.Elab.Tactic.Tactic
File: Mathlib/Tactic/ClearExcept.lean

full_name: Lean.Elab.Tactic.clearExcept
code: /-- Clears all hypotheses it can besides those provided -/
syntax (name := clearExcept) "clear " "*" " -" (ppSpace colGt ident)* : tactic
goal: Lean.ParserDescr

full_name: Lean.Elab.Tactic._aux_Mathlib_Tactic_ClearExcept___elabRules_Lean_Elab_Tactic_clearExcept_1
code: elab_rules : tactic
  | `(tactic| clear * - $hs:ident*) => do
    let fvarIds ← getFVarIds hs
    liftMetaTactic1 fun goal ↦ do
      let mut toClear : Array FVarId := #[]
      for decl in ← getLCtx do
        unless fvarIds.contains decl.fvarId do
          if let none ← isClass? decl.type then
            toClear := toClear.push decl.fvarId
      goal.tryClearMany toClear
goal: Lean.Elab.Tactic.Tactic
File: Mathlib/Tactic/FunProp/Differentiable.lean

full_name: differentiableOn_id'
code: theorem differentiableOn_id' : DifferentiableOn K (fun x : E => x) s 
goal: DifferentiableOn K (fun x => x) s

full_name: Differentiable.comp'
code: theorem Differentiable.comp' {g : F → G} (hg : Differentiable K g) (hf : Differentiable K f) :
    Differentiable K (fun x => g (f x)) 
goal: Differentiable K fun x => g (f x)

full_name: DifferentiableAt.comp'
code: theorem DifferentiableAt.comp' {f : E → F} {g : F → G} (hg : DifferentiableAt K g (f x))
    (hf : DifferentiableAt K f x) : DifferentiableAt K (fun x => g (f x)) x 
goal: DifferentiableAt K (fun x => g (f x)) x

full_name: DifferentiableOn.comp'
code: theorem DifferentiableOn.comp' {g : F → G} {t : Set F} (hg : DifferentiableOn K g t)
    (hf : DifferentiableOn K f s) (st : Set.MapsTo f s t) :
    DifferentiableOn K (fun x => g (f x)) s 
goal: DifferentiableOn K (fun x => g (f x)) s
File: Mathlib/Tactic/FunProp/Elab.lean

full_name: Mathlib.Meta.FunProp.funPropTacStx
code: /-- Tactic to prove function properties -/
syntax (name := funPropTacStx)
  "fun_prop" (discharger)? (" [" withoutPosition(ident,*,?) "]")? : tactic
goal: Lean.ParserDescr

full_name: _private.Mathlib.Tactic.FunProp.Elab.0.Mathlib.Meta.FunProp.emptyDischarge
code: private def emptyDischarge : Expr → MetaM (Option Expr) 
goal: Lean.Expr → Lean.MetaM (Option Lean.Expr)

full_name: Mathlib.Meta.FunProp.funPropTac
code: /-- Tactic to prove function properties -/
@[tactic funPropTacStx]
def funPropTac : Tactic
  
goal: Lean.Elab.Tactic.Tactic
File: Mathlib/Tactic/ProjectionNotation.lean

full_name: Mathlib.ProjectionNotation.mkExtendedFieldNotationUnexpander
code: /-- Given a function `f` that is either a true projection or a generalized projection
(i.e., a function that works using extended field notation, a.k.a. "dot notation"), generates
an `app_unexpander` for it to get it to pretty print using dot notation.

See also the docstring of the `pp_dot` attribute. -/
def mkExtendedFieldNotationUnexpander (f : Name) : CommandElabM Unit 
goal: Lean.Elab.Command.CommandElabM Unit

full_name: Mathlib.ProjectionNotation.ppDotAttr
code: /--
Adding the `@[pp_dot]` attribute defines an `app_unexpander` for the given function to
support pretty printing the function using extended field notation ("dot notation").
This particular attribute is *only* for functions whose first explicit argument is the
receiver of the generalized field notation. That is to say, it is only meant for
transforming `C.f c x y z ...` to `c.f x y z ...` for `c : C`.

It can be used to help get projection notation to work for function-valued structure fields,
since the built-in projection delaborator cannot handle excess arguments.

Example for generalized field notation:
```
structure A where
  n : Nat

@[pp_dot]
def A.foo (a : A) (m : Nat) : Nat := a.n + m
```
Now, `A.foo x m` pretty prints as `x.foo m`. If `A` is a structure, it also adds a rule that
`A.foo x.toA m` pretty prints as `x.foo m`. This rule is meant to combine with core's
the projection collapse delaborator, where together `A.foo x.toB.toA m`
will pretty print as `x.foo m`.

Since the mentioned rule is a purely syntactic transformation,
it might lead to output that does not round trip, though this can only occur if
there exists an `A`-valued `toA` function that is not a parent projection that
happens to be pretty printable using dot notation.

Here is an example to illustrate the round tripping issue:
```lean
import Mathlib.Tactic.ProjectionNotation

structure A where n : Int

@[pp_dot]
def A.inc (a : A) (k : Int) : Int := a.n + k

structure B where n : Nat

def B.toA (b : B) : A := ⟨b.n⟩

variable (b : B)

#check A.inc b.toA 1
-- (B.toA b).inc 1 : Int

attribute [pp_dot] B.toA
#check A.inc b.toA 1
-- b.inc 1 : Int

#check b.inc 1
-- invalid field 'inc', the environment does not contain 'B.inc'
```
To avoid this, don't use `pp_dot` for coercion functions
such as `B.toA`.
-/
syntax (name := ppDotAttr) "pp_dot" : attr
goal: Lean.ParserDescr

full_name: Mathlib.ProjectionNotation.initFn._@.Mathlib.Tactic.ProjectionNotation._hyg.1006
code: initialize registerBuiltinAttribute {
  name := `ppDotAttr
  descr := ""
  applicationTime := .afterCompilation
  add := fun src ref kind => match ref with
  | `(attr| pp_dot) => do
    logWarning "\
      The @[pp_dot] attribute is deprecated now that dot notation is the default \
      with the introduction of `pp.fieldNotation.generalized` in Lean v4.8.0."
    if (kind != AttributeKind.global) then
      throwError "`pp_dot` can only be used as a global attribute"
    liftCommandElabM <| withRef ref <| mkExtendedFieldNotationUnexpander src
  | _ => throwUnsupportedSyntax }
goal: IO Unit
File: Mathlib/Tactic/ExistsI.lean

full_name: Mathlib.Tactic.«_aux_Mathlib_Tactic_ExistsI___macroRules_Mathlib_Tactic_tacticExistsi_,,_1»
code: macro "existsi " es:term,+ : tactic =>
  `(tactic| refine ⟨$es,*, ?_⟩)
goal: Lean.Macro

full_name: Mathlib.Tactic.«tacticExistsi_,,»
code: macro "existsi " es:term,+ : tactic =>
  `(tactic| refine ⟨$es,*, ?_⟩)
goal: Lean.ParserDescr
File: Mathlib/Tactic/SetLike.lean

full_name: initFn._@.Mathlib.Tactic.SetLike._hyg.5
code: declare_aesop_rule_sets [SetLike] (default := true)
goal: IO Unit
File: Mathlib/Tactic/Recover.lean

full_name: Mathlib.Tactic.getUnassignedGoalMVarDependencies
code: /--
Get all metavariables which `mvarId` depends on. These are the metavariables
which occur in the target or local context or delayed assignment (if any) of
`mvarId`, plus the metavariables which occur in these metavariables, etc.
-/
partial def getUnassignedGoalMVarDependencies (mvarId : MVarId) :
    MetaM (HashSet MVarId) 
goal: Lean.MetaM (Lean.HashSet Lean.MVarId)

full_name: Mathlib.Tactic.getUnassignedGoalMVarDependencies.addMVars
code: /--
Get all metavariables which `mvarId` depends on. These are the metavariables
which occur in the target or local context or delayed assignment (if any) of
`mvarId`, plus the metavariables which occur in these metavariables, etc.
-/
partial def getUnassignedGoalMVarDependencies (mvarId : MVarId) :
    MetaM (HashSet MVarId) 
goal: StateRefT' IO.RealWorld (Lean.HashSet Lean.MVarId) Lean.MetaM Unit

full_name: Mathlib.Tactic.getUnassignedGoalMVarDependencies.go
code: /--
Get all metavariables which `mvarId` depends on. These are the metavariables
which occur in the target or local context or delayed assignment (if any) of
`mvarId`, plus the metavariables which occur in these metavariables, etc.
-/
partial def getUnassignedGoalMVarDependencies (mvarId : MVarId) :
    MetaM (HashSet MVarId) 
goal: StateRefT' IO.RealWorld (Lean.HashSet Lean.MVarId) Lean.MetaM Unit

full_name: Mathlib.Tactic.tacticRecover_
code: /-- Modifier `recover` for a tactic (sequence) to debug cases where goals are closed incorrectly.
The tactic `recover tacs` for a tactic (sequence) `tacs` applies the tactics and then adds goals
that are not closed, starting from the original goal. -/
elab "recover " tacs:tacticSeq : tactic => do
  let originalGoals ← getGoals
  evalTactic tacs
  let mut unassigned : HashSet MVarId := {}
  for mvarId in originalGoals do
    unless ← mvarId.isAssigned <||> mvarId.isDelayedAssigned do
      unassigned := unassigned.insert mvarId
    let unassignedMVarDependencies ← getUnassignedGoalMVarDependencies mvarId
    unassigned := unassigned.insertMany unassignedMVarDependencies.toList
  setGoals <| ((← getGoals) ++ unassigned.toList).eraseDups
goal: Lean.ParserDescr

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Recover___elabRules_Mathlib_Tactic_tacticRecover__1
code: /-- Modifier `recover` for a tactic (sequence) to debug cases where goals are closed incorrectly.
The tactic `recover tacs` for a tactic (sequence) `tacs` applies the tactics and then adds goals
that are not closed, starting from the original goal. -/
elab "recover " tacs:tacticSeq : tactic => do
  let originalGoals ← getGoals
  evalTactic tacs
  let mut unassigned : HashSet MVarId := {}
  for mvarId in originalGoals do
    unless ← mvarId.isAssigned <||> mvarId.isDelayedAssigned do
      unassigned := unassigned.insert mvarId
    let unassignedMVarDependencies ← getUnassignedGoalMVarDependencies mvarId
    unassigned := unassigned.insertMany unassignedMVarDependencies.toList
  setGoals <| ((← getGoals) ++ unassigned.toList).eraseDups
goal: Lean.Elab.Tactic.Tactic
File: Mathlib/Tactic/TypeCheck.lean

full_name: tacticType_check_
code: /-- Type check the given expression, and trace its type. -/
elab tk:"type_check " e:term : tactic => do
  let e ← Lean.Elab.Term.elabTerm e none
  check e
  let type ← inferType e
  Lean.logInfoAt tk f!"{← Lean.instantiateMVars type}"
goal: Lean.ParserDescr

full_name: _aux_Mathlib_Tactic_TypeCheck___elabRules_tacticType_check__1
code: /-- Type check the given expression, and trace its type. -/
elab tk:"type_check " e:term : tactic => do
  let e ← Lean.Elab.Term.elabTerm e none
  check e
  let type ← inferType e
  Lean.logInfoAt tk f!"{← Lean.instantiateMVars type}"
goal: Lean.Elab.Tactic.Tactic
File: Mathlib/Tactic/GuardHypNums.lean

full_name: _aux_Mathlib_Tactic_GuardHypNums___elabRules_guardHypNums_1
code: /--
`guard_hyp_nums n` succeeds if there are exactly `n` hypotheses and fails otherwise.

Note that, depending on what options are set, some hypotheses in the local context might
not be printed in the goal view. This tactic computes the total number of hypotheses,
not the number of visible hypotheses.
-/
elab (name := guardHypNums) "guard_hyp_nums " n:num : tactic => do
  let numHyps := (← getLCtx).size
  guard (numHyps = n.getNat) <|>
    throwError "expected {n.getNat} hypotheses but found {numHyps}"
goal: Lean.Elab.Tactic.Tactic

full_name: guardHypNums
code: /--
`guard_hyp_nums n` succeeds if there are exactly `n` hypotheses and fails otherwise.

Note that, depending on what options are set, some hypotheses in the local context might
not be printed in the goal view. This tactic computes the total number of hypotheses,
not the number of visible hypotheses.
-/
elab (name := guardHypNums) "guard_hyp_nums " n:num : tactic => do
  let numHyps := (← getLCtx).size
  guard (numHyps = n.getNat) <|>
    throwError "expected {n.getNat} hypotheses but found {numHyps}"
goal: Lean.ParserDescr
File: Mathlib/Tactic/Change.lean

full_name: change?
code: /-- `change? term` unifies `term` with the current goal, then suggests explicit `change` syntax
that uses the resulting unified term.

If `term` is not present, `change?` suggests the current goal itself. This is useful after tactics
which transform the goal while maintaining definitional equality, such as `dsimp`; those preceding
tactic calls can then be deleted.
```lean
example : (fun x : Nat => x) 0 = 1 := by
  change? 0 = _  -- `Try this: change 0 = 1`
```
-/
syntax (name := change?) "change?" (ppSpace colGt term)? : tactic
goal: Lean.ParserDescr

full_name: _aux_Mathlib_Tactic_Change___elabRules_change?_1
code: elab_rules : tactic
| `(tactic|change?%$tk $[$sop:term]?) => withMainContext do
  let stx ← getRef
  let expr ← match sop with
    | none => getMainTarget
    | some sop => do
      let tgt ← getMainTarget
      let ex ← withRef sop <| elabTermEnsuringType sop (← inferType tgt)
      if !(← isDefEq ex tgt) then throwErrorAt sop "\
        The term{indentD ex}\n\
        is not defeq to the goal:{indentD tgt}"
      instantiateMVars ex
  let dstx ← delabToRefinableSyntax expr
  addSuggestion tk (← `(tactic| change $dstx)) (origSpan? := stx)
goal: Lean.Elab.Tactic.Tactic
File: Mathlib/Tactic/Replace.lean

full_name: Mathlib.Tactic.replace'
code: /--
Acts like `have`, but removes a hypothesis with the same name as
this one if possible. For example, if the state is:

Then after `replace h : β` the state will be:

```lean
case h
f : α → β
h : α
⊢ β

f : α → β
h : β
⊢ goal
```

whereas `have h : β` would result in:

```lean
case h
f : α → β
h : α
⊢ β

f : α → β
h✝ : α
h : β
⊢ goal
```
-/
syntax (name := replace') "replace" haveIdLhs' : tactic
goal: Lean.ParserDescr

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Replace___elabRules_Mathlib_Tactic_replace'_1
code: elab_rules : tactic
| `(tactic| replace $n:optBinderIdent $bs* $[: $t:term]?) => withMainContext do
    let (goal1, goal2) ← haveLetCore (← getMainGoal) n bs t false
    let name := optBinderIdent.name n
    let hId? := (← getLCtx).findFromUserName? name |>.map fun d ↦ d.fvarId
    match hId? with
    | some hId => replaceMainGoal [goal1, (← observing? <| goal2.clear hId).getD goal2]
    | none     => replaceMainGoal [goal1, goal2]
goal: Lean.Elab.Tactic.Tactic