Documentation

Lean.Meta.Match.SimpH

def Lean.Meta.Match.simpH (mvarId : MVarId) (numEqs : Nat) :

Simplifies an overlap hypothesis of an equation for a match alternative.

The equation for an alternative has one hypothesis for each previous alternative that overlaps it. The hypothesis states that the previous alternative does not match. Before it is simplified, it has the form ∀ xs, eqs → False, where xs are the pattern variables of the previous alternative, and eqs are numEqs equations p = q or p ≍ q between the patterns of the two alternatives.

The type of the goal mvarId must be a hypothesis of this form. This function returns

  • none if the hypothesis is redundant: the equations eqs are contradictory, and mvarId has been closed. Example: none = some 0 → False.
  • some mvarId' otherwise. The type of mvarId' is the simplified hypothesis, and mvarId has been proved using mvarId'.

The equations are processed one at a time.

  • p = q is removed if p and q are definitionally equal.
  • p = x, where x is one of the variables xs, is removed, and x is replaced with p.
  • p ≍ q is replaced with p = q if p and q have the same type.
  • An equation between constructor applications is replaced with the equations between their fields. If the constructors are different, the hypothesis is redundant.
  • Any other equation is kept.

The simplified hypothesis is ∀ xs', eqs' → False, where eqs' are the equations that were kept, and xs' are the variables in xs that occur in them.

Examples, where n : Nat and x : Nat × Nat are variables of the alternative being processed:

  • some n = some 0 → False is simplified to n = 0 → False.
  • ∀ m, some n = some (m + 1) → False is simplified to ∀ m, n = m + 1 → False.
  • ∀ a, n = a → x = (a, 0) → False is simplified to x = (n, 0) → False.
  • ∀ m, some n = some m → False is simplified to False: the previous alternative always matches.
Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Returns the simplified form of the overlap hypothesis h of an equation for a match alternative, or none if h is redundant. h must be of the form ∀ xs, eqs → False, where eqs are numEqs equations. See simpH for the simplification steps and examples.

    Only the statement is computed: h is the type of the hypothesis as generated from the patterns, and the result is the type used in the statement of the equation.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For