Documentation

Mathlib.Tactic.Translate.ToDual

The @[to_dual] attribute. #

The @[to_dual] attribute is used to translate declarations to their dual equivalent. See the docstrings of to_dual and to_additive for more information.

Known limitations:

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.

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

    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.

    Equations
    Instances For

      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.

      Equations
      Instances For

        The attribute to_dual can be used to automatically transport theorems and definitions (but not inductive types and structures) to their dual version. It uses the same implementation as to_additive.

        To use this attribute, just write:

        @[to_dual]
        theorem max_comm' {α} [LinearOrder α] (x y : α) : max x y = max y x := max_comm x y
        

        This code will generate a theorem named min_comm'. It is also possible to manually specify the name of the new declaration:

        @[to_dual le_max_left]
        lemma min_le_left (a b : α) : min a b ≤ a := sorry
        

        An existing documentation string will not be automatically used, so if the theorem or definition has a doc string, a doc string for the dual version should be passed explicitly to to_dual.

        /-- The maximum is commutative. -/
        @[to_dual /-- The minimum is commutative. -/]
        theorem max_comm' {α} [LinearOrder α] (x y : α) : max x y = max y x := max_comm x y
        

        Use the (reorder := ...) syntax to reorder the arguments compared to the dual declaration. This is specified using cycle notation. For example (reorder := α β, 5 6) swaps the arguments α and β with each other and the fifth and the sixth argument and (reorder := 3 4 5) will move the fifth argument before the third argument. For example, this is used when tagging LE.le with to_dual self (reorder := 3 4), so that a ≤ b gets transformed into b ≤ a.

        Use the to_dual self syntax to mark the lemma as its own dual. This is needed if the lemma is its own dual, up to a reordering of its arguments. to_dual self (and to_dual existing) tries to autogenerate the (reorder := ...) argument, so it is usually not necessary to give it explicitly.

        Use the to_dual existing syntax to use an existing dual declaration, instead of automatically generating it.

        Use the (attr := ...) syntax to apply attributes to both the original and the dual version:

        @[to_dual (attr := simp)] lemma min_self (a : α) : min a a = a := sorry
        
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The attribute to_dual can be used to automatically transport theorems and definitions (but not inductive types and structures) to their dual version. It uses the same implementation as to_additive.

          To use this attribute, just write:

          @[to_dual]
          theorem max_comm' {α} [LinearOrder α] (x y : α) : max x y = max y x := max_comm x y
          

          This code will generate a theorem named min_comm'. It is also possible to manually specify the name of the new declaration:

          @[to_dual le_max_left]
          lemma min_le_left (a b : α) : min a b ≤ a := sorry
          

          An existing documentation string will not be automatically used, so if the theorem or definition has a doc string, a doc string for the dual version should be passed explicitly to to_dual.

          /-- The maximum is commutative. -/
          @[to_dual /-- The minimum is commutative. -/]
          theorem max_comm' {α} [LinearOrder α] (x y : α) : max x y = max y x := max_comm x y
          

          Use the (reorder := ...) syntax to reorder the arguments compared to the dual declaration. This is specified using cycle notation. For example (reorder := α β, 5 6) swaps the arguments α and β with each other and the fifth and the sixth argument and (reorder := 3 4 5) will move the fifth argument before the third argument. For example, this is used when tagging LE.le with to_dual self (reorder := 3 4), so that a ≤ b gets transformed into b ≤ a.

          Use the to_dual self syntax to mark the lemma as its own dual. This is needed if the lemma is its own dual, up to a reordering of its arguments. to_dual self (and to_dual existing) tries to autogenerate the (reorder := ...) argument, so it is usually not necessary to give it explicitly.

          Use the to_dual existing syntax to use an existing dual declaration, instead of automatically generating it.

          Use the (attr := ...) syntax to apply attributes to both the original and the dual version:

          @[to_dual (attr := simp)] lemma min_self (a : α) : min a a = a := sorry
          
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            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.

            argInfoAttr stores the declarations that need some extra information to be translated.

            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.

            Maps names to their dual counterparts.

            Dictionary used by guessName to autogenerate names. This only transforms single name components, unlike abbreviationDict.

            Note: guessName capitalizes the output according to the capitalization of the input. In order for this to work, the input should always start with a lower case letter, and the output should always start with an upper case letter.

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

              We need to fix a few abbreviations after applying nameDict, i.e. replacing ZeroLE by Nonneg. This dictionary contains these fixes. The input should contain entries that is in lowerCamelCase (e.g. ltzero; the initial sequence of capital letters should be lower-cased) and the output should be in UpperCamelCase (e.g. LTZero). When applying the dictionary, we lower-case the output if the input was also given in lower-case.

              Equations
              Instances For

                The bundle of environment extensions for to_dual

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