- elaborator : 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
The tactic monad, which extends the term elaboration monad TermElabM
with state that contains the
current goals (Lean.Elab.Tactic.State
, accessible via MonadStateOf
) and local information about
the current tactic's name and whether error recovery is enabled (Lean.Elab.Tactic.Context
,
accessible via MonadReaderOf
).
Equations
Instances For
A tactic is a function from syntax to an action in the tactic monad.
A given tactic syntax kind may have multiple Tactic
s associated with it, all of which will be
attempted until one succeeds.
Equations
Instances For
Returns the list of goals. Goals may or may not already be assigned.
Equations
Instances For
Equations
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
Instances For
Registers a tactic elaborator for the given syntax node kind.
A tactic elaborator should have type Lean.Elab.Tactic.Tactic
(which is
Lean.Syntax → Lean.Elab.Tactic.TacticM Unit
), i.e. should take syntax of the given syntax
node kind as a parameter and alter the tactic state.
The elab_rules
and elab
commands should usually be preferred over using this attribute
directly.
Equations
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 : Exception
- state : SavedState
Instances For
Equations
Instances For
Equations
Instances For
Runs x
with only the first unsolved goal as the goal.
Fails if there are no goal to be solved.
Equations
Instances For
Runs tactic
with only the first unsolved goal as the goal, and expects it leave no goals.
Fails if there are no goal to be solved.
Equations
Instances For
Backtracking try
/catch
. This is used for the MonadExcept
instance for TacticM
.
Equations
Instances For
Equations
Execute x
with error recovery disabled
Equations
Instances For
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
Instances For
Add the given goal to the front of the current list of goals.
Equations
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.
Equations
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
Instances For
Return the main goal metavariable declaration.
Equations
Instances For
Return expected type for the main goal.
Equations
Instances For
Execute x
using the main goal local context and instances
Equations
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.
Equations
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
Instances For
Analogue of liftMetaTactic
for tactics that do not return any goals.
Equations
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
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
.