The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V01. The language of Mathlib

Mathlib.Lean.Elab.InfoTree

7 declarations and 2 deprecated aliases. Mathlib docs · Source

def Lean.Elab.collectTryThisSuggestions E1 #

Lean.PersistentArray Lean.Elab.InfoTree → Array Lean.Meta.Tactic.TryThis.Suggestion

Collects all suggestions from all TryThisInfos in trees. Does not require context - works with context-free trees.

def Lean.Elab.InfoTree.findSomeM? E1 #

{m : Type → Type} →
  [Monad m] →
    {α : Type} →
      (Lean.Elab.ContextInfo → Lean.Elab.Info → Lean.PersistentArray Lean.Elab.InfoTree → m (Option α)) →
        Lean.Elab.InfoTree → optParam (Option Lean.Elab.ContextInfo) none → m (Option α)

Finds the first result of ← f ctx info children which is some a, descending the tree from the top. Merges and updates contexts as it descends the tree.

f is only evaluated on nodes when some context is present. An initial context should be provided via the ctx? argument if invoking findSomeM? during a larger traversal of the infotree. A failure to provide ctx? := some ctx when t is not the outermost InfoTree is thus likely to cause findSomeM? to always return none.

def Lean.Elab.InfoTree.findSome? E1 #

{α : Type} →
  (Lean.Elab.ContextInfo → Lean.Elab.Info → Lean.PersistentArray Lean.Elab.InfoTree → Option α) →
    Lean.Elab.InfoTree → optParam (Option Lean.Elab.ContextInfo) none → Option α

Finds the first result of f ctx info children which is some a, descending the tree from the top. Merges and updates contexts as it descends the tree.

f is only evaluated on nodes when some context is present. An initial context should be provided via the ctx? argument if invoking findSome? during a larger traversal of the infotree. A failure to provide ctx? := some ctx when t is not the outermost InfoTree is thus likely to cause findSome? to always return none.

def Lean.Elab.InfoTree.onHighestNode? E1 #

{α : Type} →
  Lean.Elab.InfoTree →
    Option Lean.Elab.ContextInfo →
      (Lean.Elab.ContextInfo → Lean.Elab.Info → Lean.PersistentArray Lean.Elab.InfoTree → α) → Option α

Returns the value of f ctx info children on the outermost .node info children which has context, having merged and updated contexts appropriately.

If ctx? is some ctx, ctx is used as an initial context. A ctx? of none should only be used when operating on the first node of the entire infotree. Otherwise, it is likely that no context will be found.

def Lean.Elab.InfoTree.getHighestInfo? E1 #

Lean.Elab.InfoTree → Option Lean.Elab.ContextInfo → Option (Lean.Elab.ContextInfo × Lean.Elab.Info)

Returns the context and info on the outermost .node info _ which has context, having merged and updated contexts appropriately.

If ctx? is some ctx, ctx is used as an initial context. A ctx? of none should only be used when operating on the first node of the entire infotree. Otherwise, it is likely that no context will be found.

def Lean.Elab.InfoTree.getDeclBodyInfos E1 #

Lean.Elab.InfoTree → List (Lean.Syntax × Lean.Elab.ContextInfo × Lean.Elab.Info)

Gets the first child info of each Lean.Elab.BodyInfo, which should be the only child, and should be a TermInfo, PartialTermInfo, or TacticInfo. getDeclBodyInfos does not validate either of these conditions.

def Lean.Elab.Info.getLCtx? E1 #

Lean.Elab.Info → Option (Lean.LocalContext × Option Lean.Expr)

Gets the local context, and the expected type of the Info. Handles TacticInfos (looking at the first goal), TermInfos, and PartialTermInfos. Does not get the metavariable context; assumes that the caller has accumulated an ambient ContextInfo at this point which is sufficient.

Deprecated aliases

NameNew nameSince
Lean.Elab.InfoTree.getDeclsByBodyLean.Elab.InfoTree.getDeclBodyInfos2026-10-02
Lean.Elab.InfoTree.getTheoremsLean.Elab.InfoTree.getDeclBodyInfos2026-10-02