Documentation

Lean.Elab.PreDefinition.TerminationHint

Support for termination_by notation #

A single termination_by clause

  • ref : Syntax
  • structural : Bool
  • vars : TSyntaxArray [`ident, `Lean.Parser.Term.hole]
  • body : Term
  • synthetic : Bool

    If synthetic := true, then this termination_by clause was generated by GuessLex, and vars refers to all parameters of the function, not just the “extra parameters”. Cf. Lean.Elab.WF.unpackUnary

Instances For

    A single decreasing_by clause

    Instances For
      Instances For

        A single partial_fixpoint, inductive_fixpoint or coinductive_fixpoint clause

        Instances For

          The termination annotations for a single function. For decreasing_by, we store the whole decreasing_by tacticSeq expression, as this is what Term.runTactic expects.

          • ref : Syntax
          • terminationBy?? : Option Syntax
          • terminationBy? : Option TerminationBy
          • partialFixpoint? : Option PartialFixpoint
          • decreasingBy? : Option DecreasingBy
          • extraParams : Nat

            Here we record the number of parameters past the :. It is set by TerminationHints.rememberExtraParams and used as follows:

            • When we guess the termination measure in GuessLex and want to print it in surface-syntax compatible form.
            • If there are fewer variables in the termination_by annotation than there are extra parameters, we know which parameters they should apply to (TerminationBy.checkVars).
          • warnIfRedundant : Bool

            In cases where pre-definitions are generated programmatically, we may want to provide termination hints but don't want warnings if they turn out to be redundant. For these cases, you can set warnIfRedundant := false.

          Instances For

            Logs warnings when the TerminationHints are unexpectedly present.

            Instances For

              True if any form of termination hint is present.

              Instances For

                Remembers extraParams for later use. Needs to happen early enough where we still know how many parameters came from the function header (headerParams).

                Instances For
                  def Lean.Elab.TerminationBy.checkVars (funName : Name) (extraParams : Nat) (tb : TerminationBy) :

                  Checks that termination_by binds at most as many variables are present in the outermost lambda of value, and throws appropriate errors.

                  Instances For
                    def Lean.Elab.elabTerminationHints {m : Type → Type} [Monad m] [MonadError m] (stx : TSyntax `Lean.Parser.Termination.suffix) :

                    Takes apart a Termination.suffix syntax object

                    Instances For