The areas / V34. The tactics of Mathlib
Mathlib.Tactic.ClickSuggestions.Util
69 declarations. Mathlib docs · Source
Various utilities used in #click_suggestions
theorem Mathlib.Tactic.ClickSuggestions.State.mk.inj E1 #
∀ {status : Std.HashMap String ℕ} {progress : Bool} {solvedSuggestions : Array ProofWidgets.Html}
{status_1 : Std.HashMap String ℕ} {progress_1 : Bool} {solvedSuggestions_1 : Array ProofWidgets.Html},
{ status := status, progress := progress, solvedSuggestions := solvedSuggestions } =
{ status := status_1, progress := progress_1, solvedSuggestions := solvedSuggestions_1 } →
status = status_1 ∧ progress = progress_1 ∧ solvedSuggestions = solvedSuggestions_1
def Mathlib.Tactic.ClickSuggestions.RwKind.ctorIdx E1 #
Mathlib.Tactic.ClickSuggestions.RwKind → ℕ
def Mathlib.Tactic.ClickSuggestions.instInhabitedPremise.default E1 #
Mathlib.Tactic.ClickSuggestions.Premise
theorem Mathlib.Tactic.ClickSuggestions.RwKind.valid.inj E1 #
∀ {motiveTypeCorrect : Bool} {occ : Option ℕ} {motiveTypeCorrect_1 : Bool} {occ_1 : Option ℕ},
Mathlib.Tactic.ClickSuggestions.RwKind.valid motiveTypeCorrect occ =
Mathlib.Tactic.ClickSuggestions.RwKind.valid motiveTypeCorrect_1 occ_1 →
motiveTypeCorrect = motiveTypeCorrect_1 ∧ occ = occ_1
theorem Mathlib.Tactic.ClickSuggestions.Premise.fvar.inj E1 #
∀ {fvarId fvarId_1 : Lean.FVarId},
Mathlib.Tactic.ClickSuggestions.Premise.fvar fvarId = Mathlib.Tactic.ClickSuggestions.Premise.fvar fvarId_1 →
fvarId = fvarId_1
def Mathlib.Tactic.ClickSuggestions.Premise.ctorIdx E1 #
Mathlib.Tactic.ClickSuggestions.Premise → ℕ
theorem Mathlib.Tactic.ClickSuggestions.RwKind.valid.injEq E0 #
∀ (motiveTypeCorrect : Bool) (occ : Option ℕ) (motiveTypeCorrect_1 : Bool) (occ_1 : Option ℕ),
(Mathlib.Tactic.ClickSuggestions.RwKind.valid motiveTypeCorrect occ =
Mathlib.Tactic.ClickSuggestions.RwKind.valid motiveTypeCorrect_1 occ_1) =
(motiveTypeCorrect = motiveTypeCorrect_1 ∧ occ = occ_1)
theorem Mathlib.Tactic.ClickSuggestions.Premise.const.injEq E0 #
∀ (declName declName_1 : Lean.Name),
(Mathlib.Tactic.ClickSuggestions.Premise.const declName = Mathlib.Tactic.ClickSuggestions.Premise.const declName_1) =
(declName = declName_1)
theorem Mathlib.Tactic.ClickSuggestions.Premise.fvar.injEq E0 #
∀ (fvarId fvarId_1 : Lean.FVarId),
(Mathlib.Tactic.ClickSuggestions.Premise.fvar fvarId = Mathlib.Tactic.ClickSuggestions.Premise.fvar fvarId_1) =
(fvarId = fvarId_1)
theorem Mathlib.Tactic.ClickSuggestions.State.mk.injEq E0 #
∀ (status : Std.HashMap String ℕ) (progress : Bool) (solvedSuggestions : Array ProofWidgets.Html)
(status_1 : Std.HashMap String ℕ) (progress_1 : Bool) (solvedSuggestions_1 : Array ProofWidgets.Html),
({ status := status, progress := progress, solvedSuggestions := solvedSuggestions } =
{ status := status_1, progress := progress_1, solvedSuggestions := solvedSuggestions_1 }) =
(status = status_1 ∧ progress = progress_1 ∧ solvedSuggestions = solvedSuggestions_1)
theorem Mathlib.Tactic.ClickSuggestions.Context.mk.inj E1 #
∀ {«meta» : Lean.Server.DocumentMeta} {cursorPos : Lean.Lsp.Position} {onGoal : Option ℕ} {focus : Bool}
{stx : Option (Lean.TSyntax `tactic)} {masterToken statusToken solvedToken : ProofWidgets.RefreshToken}
{goal : Lean.MVarId} {hyp? : Option Lean.FVarId} {pos : Lean.SubExpr.Pos} {meta_1 : Lean.Server.DocumentMeta}
{cursorPos_1 : Lean.Lsp.Position} {onGoal_1 : Option ℕ} {focus_1 : Bool} {stx_1 : Option (Lean.TSyntax `tactic)}
{masterToken_1 statusToken_1 solvedToken_1 : ProofWidgets.RefreshToken} {goal_1 : Lean.MVarId}
{hyp?_1 : Option Lean.FVarId} {pos_1 : Lean.SubExpr.Pos},
{ «meta» := «meta», cursorPos := cursorPos, onGoal := onGoal, focus := focus, stx := stx, masterToken := masterToken,
statusToken := statusToken, solvedToken := solvedToken, goal := goal, hyp? := hyp?, pos := pos } =
{ «meta» := meta_1, cursorPos := cursorPos_1, onGoal := onGoal_1, focus := focus_1, stx := stx_1,
masterToken := masterToken_1, statusToken := statusToken_1, solvedToken := solvedToken_1, goal := goal_1,
hyp? := hyp?_1, pos := pos_1 } →
«meta» = meta_1 ∧
cursorPos = cursorPos_1 ∧
onGoal = onGoal_1 ∧
focus = focus_1 ∧
stx = stx_1 ∧
masterToken = masterToken_1 ∧
statusToken = statusToken_1 ∧ solvedToken = solvedToken_1 ∧ goal = goal_1 ∧ hyp? = hyp?_1 ∧ pos = pos_1
abbrev Mathlib.Tactic.ClickSuggestions.Premise.ctorElimType E1 #
{motive : Mathlib.Tactic.ClickSuggestions.Premise → Sort u} → ℕ → Sort (max 1 u)
abbrev Mathlib.Tactic.ClickSuggestions.RwKind.ctorElimType E1 #
{motive : Mathlib.Tactic.ClickSuggestions.RwKind → Sort u} → ℕ → Sort (max 1 u)
def Mathlib.Tactic.ClickSuggestions.State.ctorIdx E1 #
Mathlib.Tactic.ClickSuggestions.State → ℕ
theorem Mathlib.Tactic.ClickSuggestions.Premise.const.inj E1 #
∀ {declName declName_1 : Lean.Name},
Mathlib.Tactic.ClickSuggestions.Premise.const declName = Mathlib.Tactic.ClickSuggestions.Premise.const declName_1 →
declName = declName_1
theorem Mathlib.Tactic.ClickSuggestions.Context.mk.injEq E0 #
∀ («meta» : Lean.Server.DocumentMeta) (cursorPos : Lean.Lsp.Position) (onGoal : Option ℕ) (focus : Bool)
(stx : Option (Lean.TSyntax `tactic)) (masterToken statusToken solvedToken : ProofWidgets.RefreshToken)
(goal : Lean.MVarId) (hyp? : Option Lean.FVarId) (pos : Lean.SubExpr.Pos) (meta_1 : Lean.Server.DocumentMeta)
(cursorPos_1 : Lean.Lsp.Position) (onGoal_1 : Option ℕ) (focus_1 : Bool) (stx_1 : Option (Lean.TSyntax `tactic))
(masterToken_1 statusToken_1 solvedToken_1 : ProofWidgets.RefreshToken) (goal_1 : Lean.MVarId)
(hyp?_1 : Option Lean.FVarId) (pos_1 : Lean.SubExpr.Pos),
({ «meta» := «meta», cursorPos := cursorPos, onGoal := onGoal, focus := focus, stx := stx, masterToken := masterToken,
statusToken := statusToken, solvedToken := solvedToken, goal := goal, hyp? := hyp?, pos := pos } =
{ «meta» := meta_1, cursorPos := cursorPos_1, onGoal := onGoal_1, focus := focus_1, stx := stx_1,
masterToken := masterToken_1, statusToken := statusToken_1, solvedToken := solvedToken_1, goal := goal_1,
hyp? := hyp?_1, pos := pos_1 }) =
(«meta» = meta_1 ∧
cursorPos = cursorPos_1 ∧
onGoal = onGoal_1 ∧
focus = focus_1 ∧
stx = stx_1 ∧
masterToken = masterToken_1 ∧
statusToken = statusToken_1 ∧ solvedToken = solvedToken_1 ∧ goal = goal_1 ∧ hyp? = hyp?_1 ∧ pos = pos_1)
def Mathlib.Tactic.ClickSuggestions.Context.ctorIdx E1 #
Mathlib.Tactic.ClickSuggestions.Context → ℕ
def Mathlib.Tactic.ClickSuggestions.exprToHtml E1 #
Lean.Expr → Lean.MetaM ProofWidgets.Html
Turn an Expr into an HTML with hover info.
def Mathlib.Tactic.ClickSuggestions.constToHtml E1 #
Lean.Name → Lean.MetaM ProofWidgets.Html
Turn a constant into an HTML with hover info.
This avoids the @ that may appear when using exprToHtml.
def Mathlib.Tactic.ClickSuggestions.formatToHtmlWithDoc E1 #
Std.Format → Lean.Name → Lean.MetaM ProofWidgets.Html
Display fmt with a docstring as if it is the constant n.
def Mathlib.Tactic.ClickSuggestions.tacticToHtml E1 #
Lean.TSyntax `tactic → Lean.MetaM ProofWidgets.Html
Pretty print a tactic with its docstring as hover info.
I would love to print tac with another colour, e.g. the keyword highlighting used by the editor,
but I have no idea how to do this.
opaque Mathlib.Tactic.ClickSuggestions.click_suggestions.debug E1 #
Lean.Option Bool
Let #click_suggestions show the candidate lemmas that failed to apply.
inductive Mathlib.Tactic.ClickSuggestions.Premise E1 #
Type
A global constant or a free variable. Library search can return either.
ctor Mathlib.Tactic.ClickSuggestions.Premise.const E0 #
Lean.Name → Mathlib.Tactic.ClickSuggestions.Premise
A global constant.
ctor Mathlib.Tactic.ClickSuggestions.Premise.fvar E0 #
Lean.FVarId → Mathlib.Tactic.ClickSuggestions.Premise
A free variable.
instance Mathlib.Tactic.ClickSuggestions.instInhabitedPremise E0 #
Inhabited Mathlib.Tactic.ClickSuggestions.Premise
def Mathlib.Tactic.ClickSuggestions.Premise.toString E1 #
Mathlib.Tactic.ClickSuggestions.Premise → String
Print a premise as a string.
def Mathlib.Tactic.ClickSuggestions.Premise.length E1 #
Mathlib.Tactic.ClickSuggestions.Premise → ℕ
The name length of a premise.
def Mathlib.Tactic.ClickSuggestions.Premise.getType E1 #
Mathlib.Tactic.ClickSuggestions.Premise → Lean.MetaM Lean.Expr
Get the type of a premise.
def Mathlib.Tactic.ClickSuggestions.Premise.forallMetaTelescopeReducing E1 #
Mathlib.Tactic.ClickSuggestions.Premise → Lean.MetaM (Lean.Expr × Array Lean.Expr × Array Lean.BinderInfo × Lean.Expr)
Fill the premise in with fresh universe and expression metavariables.
def Mathlib.Tactic.ClickSuggestions.Premise.unresolveName E1 #
Mathlib.Tactic.ClickSuggestions.Premise → Lean.MetaM Lean.Name
Return the user-facing name of the premise, relative to the current namespace.
def Mathlib.Tactic.ClickSuggestions.Premise.toMessageData E1 #
Mathlib.Tactic.ClickSuggestions.Premise → Lean.MessageData
Print a premise using message data.
def Mathlib.Tactic.ClickSuggestions.Premise.toHtml E1 #
Mathlib.Tactic.ClickSuggestions.Premise → Lean.MetaM ProofWidgets.Html
Print a premise using HTML.
structure Mathlib.Tactic.ClickSuggestions.State E1 #
Type
The global state that is shared between all threads.
ctor Mathlib.Tactic.ClickSuggestions.State.mk E0 #
Std.HashMap String ℕ → Bool → Array ProofWidgets.Html → Mathlib.Tactic.ClickSuggestions.State
abbrev Mathlib.Tactic.ClickSuggestions.State.status E1 #
Mathlib.Tactic.ClickSuggestions.State → Std.HashMap String ℕ
The ongoing computations.
abbrev Mathlib.Tactic.ClickSuggestions.State.progress E1 #
Mathlib.Tactic.ClickSuggestions.State → Bool
Whether any progress has been made at all. If all computations have been finished and no progress has been made, then inform the user.
abbrev Mathlib.Tactic.ClickSuggestions.State.solvedSuggestions E1 #
Mathlib.Tactic.ClickSuggestions.State → Array ProofWidgets.Html
The suggestions that close the goal.
structure Mathlib.Tactic.ClickSuggestions.Context E1 #
Type
The information required for pasting a suggestion into the editor.
ctor Mathlib.Tactic.ClickSuggestions.Context.mk E0 #
Lean.Server.DocumentMeta →
Lean.Lsp.Position →
Option ℕ →
Bool →
Option (Lean.TSyntax `tactic) →
ProofWidgets.RefreshToken →
ProofWidgets.RefreshToken →
ProofWidgets.RefreshToken →
Lean.MVarId → Option Lean.FVarId → Lean.SubExpr.Pos → Mathlib.Tactic.ClickSuggestions.Context
abbrev Mathlib.Tactic.ClickSuggestions.Context.meta E1 #
Mathlib.Tactic.ClickSuggestions.Context → Lean.Server.DocumentMeta
The current document
abbrev Mathlib.Tactic.ClickSuggestions.Context.cursorPos E1 #
Mathlib.Tactic.ClickSuggestions.Context → Lean.Lsp.Position
The range that should be replaced. In tactic mode, this should be the range of the suggestion tactic. In infoview mode, the start and end of the range should both be the cursor position.
abbrev Mathlib.Tactic.ClickSuggestions.Context.onGoal E1 #
Mathlib.Tactic.ClickSuggestions.Context → Option ℕ
Whether to use the on_goal n => combinator.
abbrev Mathlib.Tactic.ClickSuggestions.Context.focus E1 #
Mathlib.Tactic.ClickSuggestions.Context → Bool
Whether to use the · combinator.
abbrev Mathlib.Tactic.ClickSuggestions.Context.stx E1 #
Mathlib.Tactic.ClickSuggestions.Context → Option (Lean.TSyntax `tactic)
The preceding piece of syntax, if available. It is not available if the cursor is
at the start of the next tactic. This is used for merging consecutive rw tactics.
abbrev Mathlib.Tactic.ClickSuggestions.Context.masterToken E1 #
Mathlib.Tactic.ClickSuggestions.Context → ProofWidgets.RefreshToken
The token for updating the main HTML body of suggestions. This is used for displaying a message that no progress has happened.
abbrev Mathlib.Tactic.ClickSuggestions.Context.statusToken E1 #
Mathlib.Tactic.ClickSuggestions.Context → ProofWidgets.RefreshToken
The token for the ⏳️ HTML that represents the state of the ongoing computations.
abbrev Mathlib.Tactic.ClickSuggestions.Context.solvedToken E1 #
Mathlib.Tactic.ClickSuggestions.Context → ProofWidgets.RefreshToken
The token for the solved goals.
abbrev Mathlib.Tactic.ClickSuggestions.Context.goal E1 #
Mathlib.Tactic.ClickSuggestions.Context → Lean.MVarId
The main goal.
abbrev Mathlib.Tactic.ClickSuggestions.Context.hyp? E1 #
Mathlib.Tactic.ClickSuggestions.Context → Option Lean.FVarId
The selected hypothesis, if any.
abbrev Mathlib.Tactic.ClickSuggestions.Context.pos E1 #
Mathlib.Tactic.ClickSuggestions.Context → Lean.SubExpr.Pos
The position of the selected subexpression.
abbrev Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM E1 #
Type → Type
The monad used in #click_suggestions.
instance Mathlib.Tactic.ClickSuggestions.instMonadStateOfStateClickSuggestionsM E0 #
MonadStateOf Mathlib.Tactic.ClickSuggestions.State Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM
def Mathlib.Tactic.ClickSuggestions.markProgress E1 #
Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM Unit
Signify that at least one suggestion has been made.
def Mathlib.Tactic.ClickSuggestions.getHypIdent? E1 #
Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM (Option Lean.Ident)
Get the syntax of the variable whose type the user selected.
def Mathlib.Tactic.ClickSuggestions.getHypIdent! E1 #
Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM Lean.Ident
Get the variable whose type the user selected.
def Mathlib.Tactic.ClickSuggestions.trackingComputation E1 #
{α : Type} →
String → Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM α → Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM α
Run a computation in such a way that we can keep track of it.
opaque Mathlib.Tactic.ClickSuggestions.isExplicitEq E1 #
Lean.Expr → Lean.Expr → Lean.MetaM Bool
Determine whether the explicit parts of two expressions are equal,
and the implicit parts are definitionally equal, up to implicit transparency.
This says whether two expressions are 'morally equal', and is used for deduplicating suggestions.
inductive Mathlib.Tactic.ClickSuggestions.RwKind E1 #
Type
Information about the rewrite position. This is used to determine whether to suggest
rw, rw!, nth_rw, or simp_rw.
ctor Mathlib.Tactic.ClickSuggestions.RwKind.hasBVars E0 #
Mathlib.Tactic.ClickSuggestions.RwKind
rw cannot rewrite here, because the subexpression contains bound variables.
So, we suggest simp_rw.
ctor Mathlib.Tactic.ClickSuggestions.RwKind.valid E0 #
Bool → Option ℕ → Mathlib.Tactic.ClickSuggestions.RwKind
If motiveTypeCorrect := true, we suggest rw! instead of rw.
If occ := some n, we suggest nth_rw n instead of rw.
def Mathlib.Tactic.ClickSuggestions.mkRewrite E1 #
Mathlib.Tactic.ClickSuggestions.RwKind →
Bool → Lean.Term → Option Lean.Ident → optParam Bool false → Lean.CoreM (Lean.TSyntax `tactic)
Construct the syntax for a rewrite tactic.
opaque Mathlib.Tactic.ClickSuggestions.mergeTactics? E1 #
{m : Type → Type} →
[Monad m] → [Lean.MonadQuotation m] → Lean.TSyntax `tactic → Lean.TSyntax `tactic → m (Option (Lean.TSyntax `tactic))
Try to combine the suggested tactic with the preceding tactic in the tactic sequence.
In particular, we merge sequences of rw, simp_rw and grw.
def Mathlib.Tactic.ClickSuggestions.tacticPasteString E1 #
Lean.TSyntax `tactic → Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM String
Given tactic syntax tac that we want to paste into the editor, return it as a string.
This function respects the 100 character limit for long lines.
def Mathlib.Tactic.ClickSuggestions.mkInsertion E1 #
Lean.TSyntax `tactic → Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM (Lean.Lsp.Range × String)
Given tactic syntax tac, compute the text edit that will paste it into the editor.
We return the range that should be replaced, and the new text that will replace it.
def Mathlib.Tactic.ClickSuggestions.mkSuggestion E1 #
Lean.TSyntax `tactic →
String → ProofWidgets.Html → Bool → Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM ProofWidgets.Html
Generate a suggestion for inserting tac, with message html.
button will be used as the text on the clickable button.
If solves := true, then a 🎉️ emoji is added.
def Mathlib.Tactic.ClickSuggestions.addSolvingSuggestion E1 #
Lean.TSyntax `tactic → Mathlib.Tactic.ClickSuggestions.ClickSuggestionsM Unit
Add suggestion tac to the list of tactics that solve the goal.
def Mathlib.Tactic.ClickSuggestions.kabstractFindsPositions E1 #
Lean.Expr → Lean.Expr → Lean.SubExpr.Pos → Lean.MetaM Bool
Return whether kabstract uniquely finds pattern p in e at position targetPos.
def Mathlib.Tactic.ClickSuggestions.hasUnhelpfulMVars E1 #
Array Lean.MVarId → Array Lean.Expr → Array Lean.Expr → Lean.MetaM Bool
Determine which metavariables count as "unhelpful", given the old and new metavariables.
This is used in suggestions of e.g. apply, to filter out suggestions with unhelpful metavariables.
A metavariable is unhelpful if it was freshly introduced, and is not used in the assignment of a previously appearing metavariable.