Expression translation for the translation attribute. #
This file implements the translation of expressions, and all of the infrastructure that is needed for it.
TranslateDatacontains the information specific to the translation attribute (to_additiveorto_dual)shouldTranslateimplements the heuristic for whether or not to translate an expression.applyReplacementForall/applyReplacementLambdaimplement the expression translation.
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
nneeds to be checked. This is specified with(relevant_arg := n).
Instances For
Equations
- Mathlib.Tactic.Translate.instBEqRelevantArg.beq Mathlib.Tactic.Translate.RelevantArg.noArg Mathlib.Tactic.Translate.RelevantArg.noArg = true
- Mathlib.Tactic.Translate.instBEqRelevantArg.beq (Mathlib.Tactic.Translate.RelevantArg.arg a) (Mathlib.Tactic.Translate.RelevantArg.arg b) = (a == b)
- Mathlib.Tactic.Translate.instBEqRelevantArg.beq x✝¹ x✝ = false
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
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.
- unfold : Bool
Whether
translationshould be unfolded. This is used byto_dual_for.
Instances For
TranslateData is a structure that holds all data required for a translation attribute.
- dontTranslateAttr : Lean.NameMapExtension Unit
The global
do_translate/dont_translateattributes specify whether operations on a given type should be translated.dont_translatecan be used for types that are translated, such asMonoidAlgebra->AddMonoidAlgebra, or for fixed types, such asFin n/ZMod n.do_translateis for types without arguments, likeUnitandEmpty, 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. - unfoldBoundaries? : Option UnfoldBoundary.UnfoldBoundaryExt
The
insert_cast/insert_cast_funattributes create an abstraction boundary for the tagged constant when translating it. For example,Set.Icc,Monotone,DecidableLT,WCovByare 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 : Lean.NameMapExtension TranslationInfo
translationsstores 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_additiveorto_dual. - changeNumeral : Bool
If
changeNumeral := true, then try to translate the number1to0. - isDual : Bool
When
isDual := true, every translationA ↦ Bwill also give a translationB ↦ A. - guessNameExt : GuessName.GuessNameExt
Environment extension used for guessing the translation of a name.
Instances For
Get the translation for the given name.
Equations
- Mathlib.Tactic.Translate.findTranslation? env t = t.translations.find? env
Instances For
Get the translation name for the given name.
Equations
- Mathlib.Tactic.Translate.findTranslationName? env t n = Option.map (fun (x : Mathlib.Tactic.Translate.TranslationInfo) => x.translation) (Mathlib.Tactic.Translate.findTranslation? env t n)
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.