Documentation

Mathlib.Lean.Meta.RefinedDiscrTree.Lookup

Matching with a RefinedDiscrTree #

This file defines the matching procedure for the RefinedDiscrTree.

The main definitions are

To find the matches, we first encode the expression as a List Key. Then using this, we find all matches with the tree. When unify == true, we also allow metavariables in the target expression to be assigned.

We use a simple unification algorithm. For all star/metavariable patterns in the RefinedDiscrTree (and in the target if unify == true), we store the assignment, and when it is attempted to be assigned again, we check that it is the same assignment.

A match result contains the results from matching a term against patterns in the discrimination tree.

  • The elements in the match result.

    The Nat in the tree map represents the score of the results. The elements are arrays of arrays, where each sub-array corresponds to one discr tree pattern.

Instances For

    Convert a MatchResult into a Array, with better matches at the start of the array.

    Equations
    Instances For
      def Lean.Meta.RefinedDiscrTree.getMatch {α : Type} (d : RefinedDiscrTree α) (e : Expr) (unify matchRootStar : Bool) :

      Find values that match e in d.

      • If unify == true then metavarables in e can be assigned.
      • If matchRootStar == true then we allow metavariables at the root to unify. Set this to false in order to avoid too many results.
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For