Library search #
This file defines tactics std_exact?
and std_apply?
,
(formerly known as library_search
)
and a term elaborator std_exact?%
that tries to find a lemma
solving the current goal
(subgoals are solved using solveByElim
).
example : x < x + 1 := std_exact?%
example : Nat := by std_exact?
These functions will likely lose their std_
prefix once
we are ready to replace the corresponding implementations in Mathlib.
Configuration for DiscrTree
.
Equations
- Std.Tactic.LibrarySearch.discrTreeConfig = { iota := true, beta := true, proj := Lean.Meta.ProjReductionKind.yesWithDelta, zeta := true }
Instances For
A "modifier" for a declaration.
none
indicates the original declaration,mp
indicates that (possibly after binders) the declaration is an↔
, and we want to consider the forward direction,mpr
similarly, but for the backward direction.
- none: Std.Tactic.LibrarySearch.DeclMod
the original declaration
- mp: Std.Tactic.LibrarySearch.DeclMod
the forward direction of an
iff
- mpr: Std.Tactic.LibrarySearch.DeclMod
the backward direction of an
iff
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
LibrarySearch has an extension mechanism for replacing the function used to find candidate lemmas.
Equations
Instances For
Once we reach Mathlib, and have cache
available,
we may still want to load a precomputed cache for exact?
from a .olean
file.
This makes no sense here in Std, where there is no caching mechanism.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Constructs an discriminator tree from the current environment.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return matches from local constants.
N.B. The efficiency of this could likely be considerably improved by caching in environment extension.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Candidate finding function that uses strict discrimination tree for resolution.
Equations
- Std.Tactic.LibrarySearch.DiscrTreeFinder.mkImportFinder config importTree ty = do let __do_lift ← Lean.Meta.DiscrTree.getMatch importTree ty config pure (Array.reverse __do_lift)
Instances For
Candidate finding function that uses strict discrimination tree for resolution.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The preferred candidate finding function.
Update the candidate finder used by library search.
Equations
Instances For
Create lemma from name and mod.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A library search candidate using symmetry includes the goal to solve, the metavar context for that goal, and the name and orientation of a rule to try using with goal.
Equations
Instances For
Interleave x y interleaves the elements of x and y until one is empty and then returns final elements in other list.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run searchFn
on both the goal and symm
applied to the goal.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A type synonym for our subgoal ranking algorithm.
Instances For
Equations
- Std.Tactic.LibrarySearch.instOrdSubgoalRankType = let_fun this := lexOrd; lexOrd
Count how many local hypotheses appear in an expression.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns a tuple:
- are there no remaining goals?
- how many local hypotheses were used?
- how many goals remain, negated?
Larger values (i.e. no remaining goals, more local hypotheses, fewer remaining goals) are better.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Called to abort speculative execution in library search.
Equations
- Std.Tactic.LibrarySearch.abortSpeculation = throw (Lean.Exception.internal Std.Tactic.LibrarySearch.abortSpeculationId)
Instances For
Returns true if this is an abort speculation exception.
Equations
- Std.Tactic.LibrarySearch.isAbortSpeculation x = match x with | Lean.Exception.internal id extra => id == Std.Tactic.LibrarySearch.abortSpeculationId | x => false
Instances For
Sequentially invokes a tactic act
on each value in candidates on the current state.
The tactic act
should return a list of meta-variables that still need to be resolved.
If this list is empty, then no variables remain to be solved, and tryOnEach
returns
none
with the environment set so each goal is resolved.
If the action throws an internal exception with the abortSpeculationId
id then
further computation is stopped and intermediate results returned. If any other
exception is thrown, then it is silently discarded.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return an action that returns true when the remaining heartbeats is less than the currently remaining heartbeats * leavePercent / 100.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Shortcut for calling solveByElim
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Try to solve the goal either by:
- calling
tactic true
- or applying a library lemma then calling
tactic false
on the resulting goals.
Typically here tactic
is solveByElim
,
with the Bool
flag indicating whether it may retry with exfalso
.
If it successfully closes the goal, returns none
.
Otherwise, it returns some a
, where a : Array (List MVarId × MetavarContext)
,
with an entry for each library lemma which was successfully applied,
containing a list of the subsidiary goals, and the metavariable context after the application.
(Always succeeds, and the metavariable context stored in the monad is reverted, unless the goal was completely solved.)
(Note that if solveByElim
solves some but not all subsidiary goals,
this is not currently tracked.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Syntax for std_exact?
Equations
- One or more equations did not get rendered due to their size.
Instances For
Syntax for std_apply?
Equations
- One or more equations did not get rendered due to their size.
Instances For
Implementation of the exact?
tactic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Term elaborator using the exact?
tactic.
Equations
- Std.Tactic.LibrarySearch.«termStd_exact?%» = Lean.ParserDescr.node `Std.Tactic.LibrarySearch.termStd_exact?% 1024 (Lean.ParserDescr.symbol "std_exact?%")