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.Meta.RefinedDiscrTree.Encode

6 declarations. Mathlib docs · Source

Encoding an Expr as a sequence of Keys

We compute the encoding of an expression in a lazy way. This means computing only one Key at a time and storing the state of the remaining computation in a LazyEntry.

Each step is computed by evalLazyEntryWithEta : LazyEntry → MetaM (Option (List (Key × LazyEntry))). It returns none when the last Key has already been reached.

The first step, which is used when initializing the tree, is computed by initializeLazyEntryWithEta.

To compute all the keys at once, we have

  • encodeExprWithEta, which computes all possible key sequences.
  • encodeExpr, which computes the canonical key sequence. This will be used for expressions that are looked up in a RefinedDiscrTree using getMatch.

def Lean.Meta.RefinedDiscrTree.initializeLazyEntryWithEtaAux E0 #

Lean.Expr → Bool → Lean.MetaM (List (Lean.Meta.RefinedDiscrTree.Key × Lean.Meta.RefinedDiscrTree.LazyEntry))

Encode e as a sequence of keys, computing only the first Key.

def Lean.Meta.RefinedDiscrTree.initializeLazyEntryWithEta E1 #

Lean.Expr →
  optParam Bool true → Lean.MetaM (List (Lean.Meta.RefinedDiscrTree.Key × Lean.Meta.RefinedDiscrTree.LazyEntry))

Encode e as a sequence of keys, computing only the first Key.

def Lean.Meta.RefinedDiscrTree.evalLazyEntry E1 #

Lean.Meta.RefinedDiscrTree.LazyEntry →
  Bool → Lean.MetaM (Option (List (Lean.Meta.RefinedDiscrTree.Key × Lean.Meta.RefinedDiscrTree.LazyEntry)))

A single step in evaluating a LazyEntry. Allow multiple different outcomes.

def Lean.Meta.RefinedDiscrTree.encodeExprWithEta E1 #

Lean.Expr → Bool → Lean.MetaM (Array (Array Lean.Meta.RefinedDiscrTree.Key))

Return all encodings of e as a Array Key. This is used for testing.

opaque Lean.Meta.RefinedDiscrTree.LazyEntry.toList E1 #

Lean.Meta.RefinedDiscrTree.LazyEntry →
  optParam (List Lean.Meta.RefinedDiscrTree.Key) [] → Lean.MetaM (List Lean.Meta.RefinedDiscrTree.Key)

Completely evaluate a LazyEntry.

def Lean.Meta.RefinedDiscrTree.encodeExpr E1 #

Lean.Expr → Bool → Lean.MetaM (Lean.Meta.RefinedDiscrTree.Key × List Lean.Meta.RefinedDiscrTree.Key)

Return the canonical encoding of e as a Array Key. This is used for looking up e in a RefinedDiscrTree.