Documentation

Mathlib.Tactic.Translate.UnfoldBoundary

Modify proof terms so that they don't rely on unfolding certain constants #

This file defines a procedure for inserting casts into (proof) terms in order to make them well typed in a setting where certain constants aren't allowed to be unfolded.

We make use of withCanUnfoldPred in order to modify which constants can and cannot be unfolded. This way, whnf and isDefEq do not unfold these constants.

So, the procedure is to check that an expression is well typed, analogous to Meta.check, and at each type mismatch, we try to insert a cast.

There are two kinds of casts:

UnfoldBoundaries stores abstraction boundaries for definitions that shouldn't be unfolded.

  • unfolds : Lean.NameMap Lean.Meta.SimpTheorem

    For propositions and terms of types, we store a rewrite theorem that unfolds it.

  • casts : Lean.NameMap (Lean.Name × Lean.Name)

    For types, we store a cast for translating from and to the type respectively.

  • insertionFuns : Lean.NameSet

    The functions that we want to unfold again after the translation has happened.

Instances For
    def Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.cast (b : UnfoldBoundaries) (e expectedType : Lean.Expr) (attr : Lean.Name) :
    Lean.MetaM Lean.Expr

    Modify e so that it has type expectedType if the constants in b cannot be unfolded.

    Instances For
      def Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaries.insertBoundaries (b : UnfoldBoundaries) (e : Lean.Expr) (attr : Lean.Name) :
      Lean.MetaM Lean.Expr

      Modify e so that it is well typed if the constants in b cannot be unfolded.

      Note: it may be that e contains some constant whose type is not well typed in this setting. We don't make an effort to replace such constants. It seems that this approximation works well enough.

      Instances For

        Unfold all of the auxiliary functions that were inserted as unfold boundaries.

        Instances For

          An entry for the UnfoldBoundaries environment extension.

          • unfold (declName unfold : Lean.Name) : UnfoldEntry
          • cast (declName unfold refold unfold' refold' : Lean.Name) : UnfoldEntry
          Instances For
            @[reducible, inline]

            Extensions for handling abstraction boundaries for definitions that shouldn't be unfolded.

            Instances For