Documentation

Mathlib.Tactic.ToAdditive.GuessName

Name generation APIs for to_additive #

A set of strings of names that end in a capital letter.

  • If the string contains a lowercase letter, the string should be split between the first occurrence of a lower-case letter followed by an upper-case letter.
  • If multiple strings have the same prefix, they should be grouped by prefix
  • In this case, the second list should be prefix-free (no element can be a prefix of a later element)

Todo: automate the translation from String to an element in this TreeMap (but this would require having something similar to the rb_lmap from Lean 3).

Equations
Instances For
    partial def String.splitCase (s : String) (i₀ : Pos := 0) (r : List String := []) :

    This function takes a String and splits it into separate parts based on the following naming conventions.

    E.g. #eval "InvHMulLEConjugate₂SMul_ne_top".splitCase yields ["Inv", "HMul", "LE", "Conjugate₂", "SMul", "_", "ne", "_", "top"].

    partial def ToAdditive.capitalizeLikeAux (s : String) (i : String.Pos := 0) (p : String) :

    Helper for capitalizeLike.

    Capitalizes s char-by-char like r. If s is longer, it leaves the tail untouched.

    Equations
    Instances For

      Capitalize First element of a list like s. Note that we need to capitalize multiple characters in some cases, in examples like HMul or hAdd.

      Equations
      Instances For

        Dictionary used by guessName to autogenerate names.

        Note: guessName capitalizes first element of the output according to capitalization of the input. Input and first element should therefore be lower-case, 2nd element should be capitalized properly.

        Instances For

          Turn each element to lower-case, apply the nameDict and capitalize the output like the input.

          Equations
          Instances For

            There are a few abbreviations we use. For example "Nonneg" instead of "ZeroLE" or "addComm" instead of "commAdd". Note: The input to this function is case sensitive! Todo: A lot of abbreviations here are manual fixes and there might be room to improve the naming logic to reduce the size of fixAbbreviation.

            Instances For

              Autogenerate additive name. This runs in several steps:

              1. Split according to capitalisation rule and at _.
              2. Apply word-by-word translation rules.
              3. Fix up abbreviations that are not word-by-word translations, like "addComm" or "Nonneg".
              Equations
              Instances For