Documentation

Mathlib.Tactic.Translate.Expr

Expression translation for the translation attribute. #

This file implements the translation of expressions, and all of the infrastructure that is needed for it.

RelevantArg represents an optional argument that should be checked to determine whether or not to translate the given constant.

  • noArg : RelevantArg

    No argument needs to be checked. This is specified with (relevant_arg := _).

  • arg (n : Nat) : RelevantArg

    Argument n needs to be checked. This is specified with (relevant_arg := n).

Instances For

    Combine two known RelevantArgs by taking the smallest value of the two. Recall that if there are multiple relevant arguments, relevant_arg is set to the smallest one.

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

      TranslationInfo stores the information of how to translate a constant.

      • translation : Lean.Name

        The name that we are translating to.

      • reorder : Reorder

        The arguments that should be reordered when translating, using disjoint cycle notation.

      • relevantArg : RelevantArg

        The argument used to determine whether this constant should be translated.

      Instances For

        TranslateData is a structure that holds all data required for a translation attribute.

        • ignoreArgsAttr : Lean.NameMapExtension (List Nat)

          An attribute that tells that certain arguments of this definition are not involved when translating. This helps the translation heuristic by also transforming definitions if ℕ or another fixed type occurs as one of these arguments.

        • doTranslateAttr : Lean.NameMapExtension Bool

          The global do_translate/dont_translate attributes specify whether operations on a given type should be translated. dont_translate can be used for types that are translated, such as MonoidAlgebra -> AddMonoidAlgebra, or for fixed types, such as Fin n/ZMod n. do_translate is for types without arguments, like Unit and Empty, where the structure on it can be translated.

          Note: The name generation is not aware of dont_translate, so if some part of a lemma is not translated thanks to this, you generally have to specify the translated name manually.

        • The insert_cast/insert_cast_fun attributes create an abstraction boundary for the tagged constant when translating it. For example, Set.Icc, Monotone, DecidableLT, WCovBy are all morally self-dual, but their definition is not self-dual. So, in order to allow these constants to be self-dual, we need to not unfold their definition in the proof term that we translate.

        • translations stores all of the constants that have been tagged with this attribute, and maps them to their translation.

        • attrName : Lean.Name

          The name of the attribute, for example to_additive or to_dual.

        • changeNumeral : Bool

          If changeNumeral := true, then try to translate the number 1 to 0.

        • isDual : Bool

          When isDual := true, every translation A ↦ B will also give a translation B ↦ A.

        • guessNameExt : GuessName.GuessNameExt

          Environment extension used for guessing the translation of a name.

        Instances For

          Check if the given constant exists in the environment, also checking for reserved names. This function is based on Lean.realizeGlobalName.

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

            Run applyReplacementFun on an expression ∀ x₁ .. xₙ, e, making sure not to translate type-classes on xᵢ if i is in dontTranslate.

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

              Run applyReplacementFun on an expression fun x₁ .. xₙ ↦ e, making sure not to translate type-classes on xᵢ if i is in dontTranslate.

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