The areas / V34. The tactics of Mathlib
Mathlib.Tactic.Translate.Expr
39 declarations. Mathlib docs · Source
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.
theorem Mathlib.Tactic.Translate.TranslationInfo.mk.inj E1 #
∀ {translation : Lean.Name} {reorder : Mathlib.Tactic.Translate.Reorder}
{relevantArg : Mathlib.Tactic.Translate.RelevantArg} {unfold : Bool} {translation_1 : Lean.Name}
{reorder_1 : Mathlib.Tactic.Translate.Reorder} {relevantArg_1 : Mathlib.Tactic.Translate.RelevantArg}
{unfold_1 : Bool},
{ translation := translation, reorder := reorder, relevantArg := relevantArg, unfold := unfold } =
{ translation := translation_1, reorder := reorder_1, relevantArg := relevantArg_1, unfold := unfold_1 } →
translation = translation_1 ∧ reorder = reorder_1 ∧ relevantArg = relevantArg_1 ∧ unfold = unfold_1
theorem Mathlib.Tactic.Translate.TranslationInfo.mk.injEq E0 #
∀ (translation : Lean.Name) (reorder : Mathlib.Tactic.Translate.Reorder)
(relevantArg : Mathlib.Tactic.Translate.RelevantArg) (unfold : Bool) (translation_1 : Lean.Name)
(reorder_1 : Mathlib.Tactic.Translate.Reorder) (relevantArg_1 : Mathlib.Tactic.Translate.RelevantArg)
(unfold_1 : Bool),
({ translation := translation, reorder := reorder, relevantArg := relevantArg, unfold := unfold } =
{ translation := translation_1, reorder := reorder_1, relevantArg := relevantArg_1, unfold := unfold_1 }) =
(translation = translation_1 ∧ reorder = reorder_1 ∧ relevantArg = relevantArg_1 ∧ unfold = unfold_1)
def Mathlib.Tactic.Translate.TranslateData.ctorIdx E1 #
Mathlib.Tactic.Translate.TranslateData → ℕ
theorem Mathlib.Tactic.Translate.TranslateData.mk.injEq E0 #
∀ (dontTranslateAttr : Lean.NameMapExtension Unit)
(unfoldBoundaries? : Option Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt)
(translations : Lean.NameMapExtension Mathlib.Tactic.Translate.TranslationInfo) (attrName : Lean.Name)
(changeNumeral isDual : Bool) (guessNameExt : Mathlib.Tactic.GuessName.GuessNameExt)
(dontTranslateAttr_1 : Lean.NameMapExtension Unit)
(unfoldBoundaries?_1 : Option Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt)
(translations_1 : Lean.NameMapExtension Mathlib.Tactic.Translate.TranslationInfo) (attrName_1 : Lean.Name)
(changeNumeral_1 isDual_1 : Bool) (guessNameExt_1 : Mathlib.Tactic.GuessName.GuessNameExt),
({ dontTranslateAttr := dontTranslateAttr, unfoldBoundaries? := unfoldBoundaries?, translations := translations,
attrName := attrName, changeNumeral := changeNumeral, isDual := isDual, guessNameExt := guessNameExt } =
{ dontTranslateAttr := dontTranslateAttr_1, unfoldBoundaries? := unfoldBoundaries?_1,
translations := translations_1, attrName := attrName_1, changeNumeral := changeNumeral_1, isDual := isDual_1,
guessNameExt := guessNameExt_1 }) =
(dontTranslateAttr = dontTranslateAttr_1 ∧
unfoldBoundaries? = unfoldBoundaries?_1 ∧
translations = translations_1 ∧
attrName = attrName_1 ∧ changeNumeral = changeNumeral_1 ∧ isDual = isDual_1 ∧ guessNameExt = guessNameExt_1)
def Mathlib.Tactic.Translate.TranslationInfo.ctorIdx E1 #
Mathlib.Tactic.Translate.TranslationInfo → ℕ
def Mathlib.Tactic.Translate.RelevantArg.ctorIdx E1 #
Mathlib.Tactic.Translate.RelevantArg → ℕ
def Mathlib.Tactic.Translate.instInhabitedRelevantArg.default E1 #
Mathlib.Tactic.Translate.RelevantArg
abbrev Mathlib.Tactic.Translate.RelevantArg.ctorElimType E1 #
{motive : Mathlib.Tactic.Translate.RelevantArg → Sort u} → ℕ → Sort (max 1 u)
theorem Mathlib.Tactic.Translate.TranslateData.mk.inj E1 #
∀ {dontTranslateAttr : Lean.NameMapExtension Unit}
{unfoldBoundaries? : Option Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt}
{translations : Lean.NameMapExtension Mathlib.Tactic.Translate.TranslationInfo} {attrName : Lean.Name}
{changeNumeral isDual : Bool} {guessNameExt : Mathlib.Tactic.GuessName.GuessNameExt}
{dontTranslateAttr_1 : Lean.NameMapExtension Unit}
{unfoldBoundaries?_1 : Option Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt}
{translations_1 : Lean.NameMapExtension Mathlib.Tactic.Translate.TranslationInfo} {attrName_1 : Lean.Name}
{changeNumeral_1 isDual_1 : Bool} {guessNameExt_1 : Mathlib.Tactic.GuessName.GuessNameExt},
{ dontTranslateAttr := dontTranslateAttr, unfoldBoundaries? := unfoldBoundaries?, translations := translations,
attrName := attrName, changeNumeral := changeNumeral, isDual := isDual, guessNameExt := guessNameExt } =
{ dontTranslateAttr := dontTranslateAttr_1, unfoldBoundaries? := unfoldBoundaries?_1,
translations := translations_1, attrName := attrName_1, changeNumeral := changeNumeral_1, isDual := isDual_1,
guessNameExt := guessNameExt_1 } →
dontTranslateAttr = dontTranslateAttr_1 ∧
unfoldBoundaries? = unfoldBoundaries?_1 ∧
translations = translations_1 ∧
attrName = attrName_1 ∧ changeNumeral = changeNumeral_1 ∧ isDual = isDual_1 ∧ guessNameExt = guessNameExt_1
theorem Mathlib.Tactic.Translate.RelevantArg.arg.inj E1 #
∀ {n n_1 : ℕ}, Mathlib.Tactic.Translate.RelevantArg.arg n = Mathlib.Tactic.Translate.RelevantArg.arg n_1 → n = n_1
theorem Mathlib.Tactic.Translate.RelevantArg.arg.injEq E0 #
∀ (n n_1 : ℕ), (Mathlib.Tactic.Translate.RelevantArg.arg n = Mathlib.Tactic.Translate.RelevantArg.arg n_1) = (n = n_1)
inductive Mathlib.Tactic.Translate.RelevantArg E1 #
Type
RelevantArg represents an optional argument that should be checked to determine
whether or not to translate the given constant.
ctor Mathlib.Tactic.Translate.RelevantArg.noArg E0 #
Mathlib.Tactic.Translate.RelevantArg
No argument needs to be checked. This is specified with (relevant_arg := _).
ctor Mathlib.Tactic.Translate.RelevantArg.arg E0 #
ℕ → Mathlib.Tactic.Translate.RelevantArg
Argument n needs to be checked. This is specified with (relevant_arg := n).
def Mathlib.Tactic.Translate.instBEqRelevantArg.beq E1 #
Mathlib.Tactic.Translate.RelevantArg → Mathlib.Tactic.Translate.RelevantArg → Bool
instance Mathlib.Tactic.Translate.instInhabitedRelevantArg E0 #
Inhabited Mathlib.Tactic.Translate.RelevantArg
instance Mathlib.Tactic.Translate.instBEqRelevantArg E0 #
BEq Mathlib.Tactic.Translate.RelevantArg
def Mathlib.Tactic.Translate.RelevantArg.min E1 #
Mathlib.Tactic.Translate.RelevantArg → Mathlib.Tactic.Translate.RelevantArg → Mathlib.Tactic.Translate.RelevantArg
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.
instance Mathlib.Tactic.Translate.instToMessageDataRelevantArg E0 #
Lean.ToMessageData Mathlib.Tactic.Translate.RelevantArg
structure Mathlib.Tactic.Translate.TranslationInfo E1 #
Type
TranslationInfo stores the information of how to translate a constant.
ctor Mathlib.Tactic.Translate.TranslationInfo.mk E0 #
Lean.Name →
Mathlib.Tactic.Translate.Reorder →
Mathlib.Tactic.Translate.RelevantArg → Bool → Mathlib.Tactic.Translate.TranslationInfo
abbrev Mathlib.Tactic.Translate.TranslationInfo.translation E1 #
Mathlib.Tactic.Translate.TranslationInfo → Lean.Name
The name that we are translating to.
abbrev Mathlib.Tactic.Translate.TranslationInfo.reorder E1 #
Mathlib.Tactic.Translate.TranslationInfo → Mathlib.Tactic.Translate.Reorder
The arguments that should be reordered when translating, using disjoint cycle notation.
abbrev Mathlib.Tactic.Translate.TranslationInfo.relevantArg E1 #
Mathlib.Tactic.Translate.TranslationInfo → Mathlib.Tactic.Translate.RelevantArg
The argument used to determine whether this constant should be translated.
abbrev Mathlib.Tactic.Translate.TranslationInfo.unfold E1 #
Mathlib.Tactic.Translate.TranslationInfo → Bool
Whether translation should be unfolded. This is used by to_dual_for.
structure Mathlib.Tactic.Translate.TranslateData E1 #
Type
TranslateData is a structure that holds all data required for a translation attribute.
ctor Mathlib.Tactic.Translate.TranslateData.mk E0 #
Lean.NameMapExtension Unit →
Option Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt →
Lean.NameMapExtension Mathlib.Tactic.Translate.TranslationInfo →
Lean.Name → Bool → Bool → Mathlib.Tactic.GuessName.GuessNameExt → Mathlib.Tactic.Translate.TranslateData
abbrev Mathlib.Tactic.Translate.TranslateData.dontTranslateAttr E1 #
Mathlib.Tactic.Translate.TranslateData → Lean.NameMapExtension Unit
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.
abbrev Mathlib.Tactic.Translate.TranslateData.unfoldBoundaries? E1 #
Mathlib.Tactic.Translate.TranslateData → Option Mathlib.Tactic.UnfoldBoundary.UnfoldBoundaryExt
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.
abbrev Mathlib.Tactic.Translate.TranslateData.translations E1 #
Mathlib.Tactic.Translate.TranslateData → Lean.NameMapExtension Mathlib.Tactic.Translate.TranslationInfo
translations stores all of the constants that have been tagged with this attribute,
and maps them to their translation.
abbrev Mathlib.Tactic.Translate.TranslateData.attrName E1 #
Mathlib.Tactic.Translate.TranslateData → Lean.Name
The name of the attribute, for example to_additive or to_dual.
abbrev Mathlib.Tactic.Translate.TranslateData.changeNumeral E1 #
Mathlib.Tactic.Translate.TranslateData → Bool
If changeNumeral := true, then try to translate the number 1 to 0.
abbrev Mathlib.Tactic.Translate.TranslateData.isDual E1 #
Mathlib.Tactic.Translate.TranslateData → Bool
When isDual := true, every translation A ↦ B will also give a translation B ↦ A.
abbrev Mathlib.Tactic.Translate.TranslateData.guessNameExt E1 #
Mathlib.Tactic.Translate.TranslateData → Mathlib.Tactic.GuessName.GuessNameExt
Environment extension used for guessing the translation of a name.
def Mathlib.Tactic.Translate.findTranslation? E1 #
Lean.Environment → Mathlib.Tactic.Translate.TranslateData → Lean.Name → Option Mathlib.Tactic.Translate.TranslationInfo
Get the translation for the given name.
def Mathlib.Tactic.Translate.findTranslationName? E1 #
Lean.Environment → Mathlib.Tactic.Translate.TranslateData → Lean.Name → Option Lean.Name
Get the translation name for the given name.
def Mathlib.Tactic.Translate.realizeGlobalConst E1 #
Lean.Name → Lean.CoreM Bool
Check if the given constant exists in the environment, also checking for reserved names.
This function is based on Lean.realizeGlobalName.
def Mathlib.Tactic.Translate.applyReplacementForall E1 #
Mathlib.Tactic.Translate.TranslateData →
List ℕ → Lean.Expr → Lean.MetaM (Lean.Expr × Mathlib.Tactic.Translate.RelevantArg)
Run applyReplacementFun on an expression ∀ x₁ .. xₙ, e,
making sure not to translate type-classes on xᵢ if i is in dontTranslate.
def Mathlib.Tactic.Translate.applyReplacementLambda E1 #
Mathlib.Tactic.Translate.TranslateData →
List ℕ → Lean.Expr → Lean.MetaM (Lean.Expr × Mathlib.Tactic.Translate.RelevantArg)
Run applyReplacementFun on an expression fun x₁ .. xₙ ↦ e,
making sure not to translate type-classes on xᵢ if i is in dontTranslate.