An API for premise selection algorithms. #
This module provides a basic API for premise selection algorithms, which are used to suggest identifiers that should be introduced in a proof.
The core interface is the Selector
type, which is a function from a metavariable
and a configuration to a list of suggestions.
The Selector
is registered as an environment extension, and the trivial (no suggestions) implementation
is Lean.PremiseSelection.empty
.
Lean does not provide a default premise selector, so this module is intended to be used in conjunction with a downstream package which registers a premise selector.
A Suggestion
is essentially just an identifier and a confidence score that the identifier is relevant.
If the premise selection request included information about the intended use (e.g. in the simplifier, in grind
, etc.)
the score may be adjusted for that application.
- name : Name
- score : Float
The score of the suggestion, as a probability that this suggestion should be used.
Instances For
The maximum number of suggestions to return.
The tactic that is calling the premise selection, e.g.
simp
,grind
, oraesop
. This may be used to adjust the score of the suggestionsA filter on suggestions; only suggestions returning
true
should be returned. (It can be better to filter on the premise selection side, to ensure that enough suggestions are returned.)An optional arbitrary "hint" to the premise selection algorithm. There is no guarantee that the algorithm will make any use of the hint.
Potential use cases include a natural language comment provided by the user (e.g. allowing use of the premise selector as a search engine) or including context from the current proof and/or file.
We may later split these use cases into separate fields if necessary.
Instances For
Equations
Instances For
The trivial premise selector, which returns no suggestions.
Equations
- Lean.PremiseSelection.empty x✝¹ x✝ = pure #[]
Instances For
A random premise selection algorithm, provided solely for testing purposes.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Generate premise suggestions for the given metavariable, using the currently registered premise selector.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Currently the registration mechanism is just global state. This means that if multiple modules register premise selectors, the behaviour will be dependent on the order of loading modules.
We should replace this with a mechanism so that
premise selectors are configured via options in the lakefile
, and
commands are only used to override in a single declaration or file.
Set the current premise selector.
Equations
- Lean.PremiseSelection.registerPremiseSelector selector = Lean.modifyEnv fun (env : Lean.Environment) => Lean.PremiseSelection.premiseSelectorExt.setState env (some selector)
Instances For
Specify a premise selection engine. Note that Lean does not ship a default premise selection engine, so this is only useful in conjunction with a downstream package which provides one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.