File: Mathlib/Tactic/Use.lean

full_name: Mathlib.Tactic.initFn._@.Mathlib.Tactic.Use._hyg.6
code: initialize registerTraceClass `tactic.use
goal: IO Unit

full_name: Mathlib.Tactic.applyTheConstructor
code: /--
When the goal `mvarId` is an inductive datatype with a single constructor,
this applies that constructor, then returns metavariables for the non-parameter explicit arguments
along with metavariables for the parameters and implicit arguments.

The first list of returned metavariables correspond to the arguments that `⟨x,y,...⟩` notation uses.
The second list corresponds to everything else: the parameters and implicit arguments.
The third list consists of those implicit arguments that are instance implicits, which one can
try to synthesize. The third list is a sublist of the second list.

Returns metavariables for all arguments whether or not the metavariables are assigned.
-/
def applyTheConstructor (mvarId : MVarId) :
    MetaM (List MVarId × List MVarId × List MVarId) 
goal: Lean.MetaM (List Lean.MVarId × List Lean.MVarId × List Lean.MVarId)

full_name: Mathlib.Tactic.useLoop
code: /-- Use the `args` to refine the goals `gs` in order, but whenever there is a single
goal remaining then first try applying a single constructor if it's for a single-constructor
inductive type. In `eager` mode, instead we always first try to refine, and if that fails we
always try to apply such a constructor no matter if it's the last goal.

Returns the remaining explicit goals `gs`, any goals `acc` due to `refine`, and a sublist of these
of instance arguments that we should try synthesizing after the loop.
The new set of goals should be `gs ++ acc`. -/
partial
def useLoop (eager : Bool) (gs : List MVarId) (args : List Term) (acc insts : List MVarId) :
    TermElabM (List MVarId × List MVarId × List MVarId) 
goal: Lean.Elab.TermElabM (List Lean.MVarId × List Lean.MVarId × List Lean.MVarId)

full_name: Mathlib.Tactic.runUse
code: /-- Run the `useLoop` on the main goal then discharge remaining explicit `Prop` arguments. -/
def runUse (eager : Bool) (discharger : TacticM Unit) (args : List Term) : TacticM Unit 
goal: Lean.Elab.Tactic.TacticM Unit

full_name: Mathlib.Tactic.tacticUse_discharger
code: /-- Default discharger to try to use for the `use` and `use!` tactics.
This is similar to the `trivial` tactic but doesn't do things like `contradiction` or `decide`. -/
syntax "use_discharger" : tactic
goal: Lean.ParserDescr

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Use___macroRules_Mathlib_Tactic_tacticUse_discharger_1
code: macro_rules | `(tactic| use_discharger) => `(tactic| apply exists_prop.mpr <;> use_discharger)
goal: Lean.Macro

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Use___macroRules_Mathlib_Tactic_tacticUse_discharger_2
code: macro_rules | `(tactic| use_discharger) => `(tactic| apply And.intro <;> use_discharger)
goal: Lean.Macro

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Use___macroRules_Mathlib_Tactic_tacticUse_discharger_3
code: macro_rules | `(tactic| use_discharger) => `(tactic| rfl)
goal: Lean.Macro

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Use___macroRules_Mathlib_Tactic_tacticUse_discharger_4
code: macro_rules | `(tactic| use_discharger) => `(tactic| assumption)
goal: Lean.Macro

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Use___macroRules_Mathlib_Tactic_tacticUse_discharger_5
code: macro_rules | `(tactic| use_discharger) => `(tactic| apply True.intro)
goal: Lean.Macro

full_name: Mathlib.Tactic.mkUseDischarger
code: /-- Returns a `TacticM Unit` that either runs the tactic sequence from `discharger?` if it's
non-`none`, or it does `try with_reducible use_discharger`. -/
def mkUseDischarger (discharger? : Option (TSyntax ``Parser.Tactic.discharger)) :
    TacticM (TacticM Unit) 
goal: Lean.Elab.Tactic.TacticM (Lean.Elab.Tactic.TacticM Unit)

full_name: Mathlib.Tactic._aux_Mathlib_Tactic_Use___elabRules_Mathlib_Tactic_useSyntax_1
code: /--
`use e₁, e₂, ⋯` is similar to `exists`, but unlike `exists` it is equivalent to applying the tactic
`refine ⟨e₁, e₂, ⋯, ?_, ⋯, ?_⟩` with any number of placeholders (rather than just one) and
then trying to close goals associated to the placeholders with a configurable discharger (rather
than just `try trivial`).

Examples:

```lean
example : ∃ x : Nat, x = x := by use 42

example : ∃ x : Nat, ∃ y : Nat, x = y := by use 42, 42

example : ∃ x : String × String, x.1 = x.2 := by use ("forty-two", "forty-two")
```

`use! e₁, e₂, ⋯` is similar but it applies constructors everywhere rather than just for
goals that correspond to the last argument of a constructor. This gives the effect that
nested constructors are being flattened out, with the supplied values being used along the
leaves and nodes of the tree of constructors.
With `use!` one can feed in each `42` one at a time:

```lean
example : ∃ p : Nat × Nat, p.1 = p.2 := by use! 42, 42

example : ∃ p : Nat × Nat, p.1 = p.2 := by use! (42, 42)
```

The second line makes use of the fact that `use!` tries refining with the argument before
applying a constructor. Also note that `use`/`use!` by default uses a tactic
called `use_discharger` to discharge goals, so `use! 42` will close the goal in this example since
`use_discharger` applies `rfl`, which as a consequence solves for the other `Nat` metavariable.

These tactics take an optional discharger to handle remaining explicit `Prop` constructor arguments.
By default it is `use (discharger := try with_reducible use_discharger) e₁, e₂, ⋯`.
To turn off the discharger and keep all goals, use `(discharger := skip)`.
To allow "heavy refls", use `(discharger := try use_discharger)`.
-/
elab (name := useSyntax)
    "use" discharger?:(Parser.Tactic.discharger)? ppSpace args:term,+ : tactic => do
  runUse false (← mkUseDischarger discharger?) args.getElems.toList
goal: Lean.Elab.Tactic.Tactic

full_name: Mathlib.Tactic.useSyntax
code: /--
`use e₁, e₂, ⋯` is similar to `exists`, but unlike `exists` it is equivalent to applying the tactic
`refine ⟨e₁, e₂, ⋯, ?_, ⋯, ?_⟩` with any number of placeholders (rather than just one) and
then trying to close goals associated to the placeholders with a configurable discharger (rather
than just `try trivial`).

Examples:

```lean
example : ∃ x : Nat, x = x := by use 42

example : ∃ x : Nat, ∃ y : Nat, x = y := by use 42, 42

example : ∃ x : String × String, x.1 = x.2 := by use ("forty-two", "forty-two")
```

`use! e₁, e₂, ⋯` is similar but it applies constructors everywhere rather than just for
goals that correspond to the last argument of a constructor. This gives the effect that
nested constructors are being flattened out, with the supplied values being used along the
leaves and nodes of the tree of constructors.
With `use!` one can feed in each `42` one at a time:

```lean
example : ∃ p : Nat × Nat, p.1 = p.2 := by use! 42, 42

example : ∃ p : Nat × Nat, p.1 = p.2 := by use! (42, 42)
```

The second line makes use of the fact that `use!` tries refining with the argument before
applying a constructor. Also note that `use`/`use!` by default uses a tactic
called `use_discharger` to discharge goals, so `use! 42` will close the goal in this example since
`use_discharger` applies `rfl`, which as a consequence solves for the other `Nat` metavariable.

These tactics take an optional discharger to handle remaining explicit `Prop` constructor arguments.
By default it is `use (discharger := try with_reducible use_discharger) e₁, e₂, ⋯`.
To turn off the discharger and keep all goals, use `(discharger := skip)`.
To allow "heavy refls", use `(discharger := try use_discharger)`.
-/
elab (name := useSyntax)
    "use" discharger?:(Parser.Tactic.discharger)? ppSpace args:term,+ : tactic => do
  runUse false (← mkUseDischarger discharger?) args.getElems.toList
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.«tacticUse!___,,»
code: @[inherit_doc useSyntax]
elab "use!" discharger?:(Parser.Tactic.discharger)? ppSpace args:term,+ : tactic => do
  runUse true (← mkUseDischarger discharger?) args.getElems.toList
goal: Lean.ParserDescr

full_name: Mathlib.Tactic.«_aux_Mathlib_Tactic_Use___elabRules_Mathlib_Tactic_tacticUse!___,,_1»
code: @[inherit_doc useSyntax]
elab "use!" discharger?:(Parser.Tactic.discharger)? ppSpace args:term,+ : tactic => do
  runUse true (← mkUseDischarger discharger?) args.getElems.toList
goal: Lean.Elab.Tactic.Tactic