Documentation

Lean.Elab.PreDefinition.EqnsUtils

This module contains helpers useful to prove unfolding and/or equational theorems.

Equations
Instances For
    def Lean.Elab.Eqns.simpIf? (mvarId : MVarId) (useNewSemantics : Bool := false) :

    Simplify if-then-expressions in the goal target. If useNewSemantics is true, the flag backward.split is ignored.

    Equations
    Instances For
      def Lean.Elab.Eqns.tryURefl (mvarId : MVarId) (declNames : Array Name := #[]) :

      Try to close goal using rfl with smart unfolding turned off.

      If both sides are applications of the same function in declNames, the proof is Eq.refl of the left-hand side unfolded once, instead of Eq.refl lhs. Example (#15987):

      def f : Nat → Nat → Nat
        | 0, x => x
        | n+1, x => f n ((x * 1103515245) % 5)
      
      theorem f.eq_2 (x n : Nat) : f (n+1) x = f n (x * 1103515245 % 5)
      

      To check Eq.refl (f (n+1) x), the kernel must show f (n+1) x =?= f n (x * 1103515245 % 5). Since both sides are applications of f, it first tries to show that the arguments are definitionally equal, starting with the last one: x =?= x * 1103515245 % 5. This forces it to reduce x * 1103515245 with a free x, which unfolds Nat.mul once per unit of 1103515245, and fails with deep recursion. That comparison can never succeed anyway, since a recursive call is on a smaller argument (here n vs n+1). The proof Eq.refl (Nat.brecOn (n+1) f._f x) avoids it: the left-hand side is no longer an application of f, so the kernel unfolds both sides instead.

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

        Delta reduce the equation left-hand-side

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

            Apply whnfR to lhs, return none if lhs was not modified

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