Documentation

Mathlib.Lean.Name

Additional functions on Lean.Name. #

We provide allNames and allNamesByModule, as well as assorted utilities on Name such as mapPrefix, fromComponents, splitAt and isPrefixOf?.

Retrieve all names in the environment satisfying a predicate.

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

    Retrieve all names in the environment satisfying a predicate, gathered together into a HashMap according to the module they are defined in.

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

      Determines if the pretty-printed version of the given name would parse as an ident with an underlying name (via getId) equal to the original name. The pretty-printer usually escapes unparsable components of a name with «», but makes exceptions for various names with special meaning, meaning that the result does not round trip. We therefore re-check those conditions here.

      This function is intended to be "safe" in that if it returns true, the name will definitely round trip. (The converse is not guaranteed.) Any deviation from this behavior is a bug which should be fixed.

      Equations
      Instances For
        def Lean.Name.isBlackListed {m : TypeType} [Monad m] [MonadEnv m] (declName : Name) :
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Decapitalize the last component of a name.

          Equations
          Instances For
            @[specialize #[]]

            Find the largest prefix n of a Name such that f n != none, then replace this prefix with the value of f n.

            Equations
            Instances For

              Build a name from components. For example, from_components [`foo, `bar] becomes `foo.bar. It is the inverse of Name.components on list of names that have single components.

              Equations
              Instances For

                Update the last component of a name.

                Equations
                Instances For

                  Get the last field of a name as a string. Doesn't raise an error when the last component is a numeric field.

                  Equations
                  Instances For
                    def Lean.Name.splitAt (nm : Name) (n : Nat) :

                    nm.splitAt n splits a name nm in two parts, such that the second part has depth n, i.e. (nm.splitAt n).2.getNumParts = n (assuming nm.getNumParts ≥ n). Example: splitAt `foo.bar.baz.back.bat 1 = (`foo.bar.baz.back, `bat).

                    Equations
                    Instances For

                      isPrefixOf? pre nm returns some post if nm = pre ++ post. Note that this includes the case where nm has multiple more namespaces. If pre is not a prefix of nm, it returns none.

                      Equations
                      Instances For