Assign mvarId := sorry
Equations
- Lean.Elab.admitGoal mvarId = mvarId.withContext do let mvarType ← Lean.Meta.inferType (Lean.mkMVar mvarId) let __do_lift ← Lean.Meta.mkSorry mvarType true mvarId.assign __do_lift
Instances For
Equations
- Lean.Elab.goalsToMessageData goals = Lean.MessageData.joinSep (List.map Lean.MessageData.ofGoal goals) (Lean.toMessageData "\n\n")
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
- elaborator : Lean.Name
Declaration name of the executing elaborator, used by
mkTacticInfo
to persist it in the info tree - recover : Bool
If
true
, enable "error recovery" in some tactics. For example,cases
tactic admits unsolved alternatives whenrecover == true
. The combinatorwithoutRecover <tac>
disables "error recovery" while executing<tac>
. This is useful for tactics such asfirst | ... | ...
.
Instances For
Equations
Instances For
Returns the list of goals. Goals may or may not already be assigned.
Instances For
Instances For
Equations
- Lean.Elab.Tactic.pruneSolvedGoals = do let gs ← Lean.Elab.Tactic.getGoals let gs ← List.filterM (fun (g : Lean.MVarId) => not <$> g.isAssigned) gs Lean.Elab.Tactic.setGoals gs
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Elab.Tactic.saveState = do let __do_lift ← liftM Lean.Elab.Term.saveState let __do_lift_1 ← get pure { term := __do_lift, tactic := __do_lift_1 }
Instances For
Instances For
Like Meta.withRestoreOrSaveFull
for TermElabM
, but also takes a tacSnap?
that
- when running
act
, is set asContext.tacSnap?
- otherwise (i.e. on restore) is used to update the new snapshot promise to the old task's
value.
This extra restore step is necessary because while
reusableResult?
can be used to replay any effects onState
,Context.tacSnap?
is not part of it but changed via anIO
side effect, so it needs to be replayed separately.
We use an explicit parameter instead of accessing Context.tacSnap?
directly because this prevents
withRestoreOrSaveFull
and withReader
from being used in the wrong order.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Instances For
Equations
- Lean.Elab.Tactic.mkInitialTacticInfo stx = do let mctxBefore ← Lean.getMCtx let goalsBefore ← Lean.Elab.Tactic.getUnsolvedGoals pure (Lean.Elab.Tactic.mkTacticInfo mctxBefore goalsBefore stx)
Instances For
Equations
- Lean.Elab.Tactic.withTacticInfoContext stx x = do let __do_lift ← Lean.Elab.Tactic.mkInitialTacticInfo stx Lean.Elab.withInfoContext x __do_lift
Instances For
Important: we must define evalTactic
before we define
the instance MonadExcept
for TacticM
since it backtracks the state including error messages,
and this is bad when rethrowing the exception at the catch
block in these methods.
We marked these places with a (*)
in these methods.
Auxiliary datastructure for capturing exceptions at evalTactic
.
- exception : Lean.Exception
- state : Lean.Elab.Tactic.SavedState
Instances For
Instances For
Instances For
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instances For
Instances For
Close the main goal using the given tactic. If it fails, log the error and admit
Equations
- One or more equations did not get rendered due to their size.
Instances For
Non-backtracking try
/catch
.
Instances For
Backtracking try
/catch
. This is used for the MonadExcept
instance for TacticM
.
Equations
- Lean.Elab.Tactic.tryCatchRestore x h = do let b ← Lean.saveState tryCatch x fun (ex : Lean.Exception) => do b.restore h ex
Instances For
Execute x
with error recovery disabled
Instances For
Instances For
Equations
- Lean.Elab.Tactic.instAlternativeTacticM = Alternative.mk (fun {x : Type} => Lean.throwError (Lean.toMessageData "failed")) fun {α : Type} => Lean.Elab.Tactic.orElse
Save the current tactic state for a token stx
.
This method is a no-op if stx
has no position information.
We use this method to save the tactic state at punctuation such as ;
Equations
- Lean.Elab.Tactic.saveTacticInfoForToken stx = if stx.getPos?.isNone = true then pure PUnit.unit else Lean.Elab.Tactic.withTacticInfoContext stx (pure ())
Instances For
Elaborate x
with stx
on the macro stack
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adapt a syntax transformation to a regular tactic evaluator.
Instances For
Add the given goal to the front of the current list of goals.
Instances For
Add the given goals to the front of the current list of goals.
Equations
- Lean.Elab.Tactic.pushGoals mvarIds = modify fun (s : Lean.Elab.Tactic.State) => { goals := mvarIds ++ s.goals }
Instances For
Add the given goals at the end of the current list of goals.
Instances For
Discard the first goal and replace it by the given list of goals,
keeping the other goals. This is used in conjunction with getMainGoal
.
Contract: between getMainGoal
and replaceMainGoal
, nothing manipulates the goal list.
See also Lean.Elab.Tactic.popMainGoal
and Lean.Elab.Tactic.pushGoal
/Lean.Elab.Tactic.pushGoal
for another interface.
Instances For
Return the first goal.
Equations
- Lean.Elab.Tactic.getMainGoal = do let __do_lift ← Lean.Elab.Tactic.getGoals Lean.Elab.Tactic.getMainGoal.loop __do_lift
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Elab.Tactic.getMainGoal.loop [] = Lean.Elab.Tactic.throwNoGoalsToBeSolved
Instances For
Return the first goal, and remove it from the goal list.
See also: Lean.Elab.Tactic.pushGoal
and Lean.Elab.Tactic.pushGoals
.
Equations
- Lean.Elab.Tactic.popMainGoal = do let mvarId ← Lean.Elab.Tactic.getMainGoal Lean.Elab.Tactic.replaceMainGoal [] pure mvarId
Instances For
Return the main goal metavariable declaration.
Equations
- Lean.Elab.Tactic.getMainDecl = do let __do_lift ← Lean.Elab.Tactic.getMainGoal liftM __do_lift.getDecl
Instances For
Return the main goal tag.
Instances For
Return expected type for the main goal.
Equations
- Lean.Elab.Tactic.getMainTarget = do let __do_lift ← Lean.Elab.Tactic.getMainDecl Lean.instantiateMVars __do_lift.type
Instances For
Execute x
using the main goal local context and instances
Instances For
Evaluate tac
at mvarId
, and return the list of resulting subgoals.
Instances For
Like evalTacticAt
, but without restoring the goal list or pruning solved goals.
Useful when these tasks are already being done in an outer loop.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Closes main goal using the given expression.
If checkUnassigned == true
, then val
must not contain unassigned metavariables.
Returns true
if val
was successfully used to close the goal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Elab.Tactic.liftMetaMAtMain x = Lean.Elab.Tactic.withMainContext do let __do_lift ← Lean.Elab.Tactic.getMainGoal liftM (x __do_lift)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Get the mvarid of the main goal, run the given tactic
,
then set the new goals to be the resulting goal list.
Equations
- Lean.Elab.Tactic.liftMetaTactic tactic = Lean.Elab.Tactic.liftMetaTacticAux fun (mvarId : Lean.MVarId) => do let gs ← tactic mvarId pure ((), gs)
Instances For
Instances For
Analogue of liftMetaTactic
for tactics that do not return any goals.
Equations
- Lean.Elab.Tactic.liftMetaFinishingTactic tac = Lean.Elab.Tactic.liftMetaTactic fun (g : Lean.MVarId) => do tac g pure []
Instances For
Instances For
Instances For
Use parentTag
to tag untagged goals at newGoals
.
If there are multiple new untagged goals, they are named using <parentTag>.<newSuffix>_<idx>
where idx > 0
.
If there is only one new untagged goal, then we just use parentTag
Equations
- One or more equations did not get rendered due to their size.
Instances For
Use position of => $body
for error messages.
If there is a line break before body
, the message will be displayed on =>
only,
but the "full range" for the info view will still include body
.