Documentation

Lean.Attributes

Instances For
    @[reducible, inline]
    abbrev Lean.AttrM (α : Type) :
    Equations
    Instances For
      @[instance_reducible]
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        You can tag attributes with the 'local' or 'scoped' kind. For example: attribute [local myattr, scoped yourattr, theirattr].

        This is used to indicate how an attribute should be scoped.

        • local means that the attribute should only be applied in the current scope and forgotten once the current section, namespace, or file is closed.
        • scoped means that the attribute should only be applied while the namespace is open.
        • global means that the attribute should always be applied.

        Note that the attribute handler (AttributeImpl.add) is responsible for interpreting the kind and making sure that these kinds are respected.

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

            Low level attribute registration function.

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

              Names of the attributes, such as simp and grind, that add a declaration to a set of lemmas used by automation. Deprecated declarations should not be added to such sets.

              def Lean.registerAutomationAttr (attrName : Name) (isGuardedBy : (Name → Bool) → Name → Syntax → CoreM Bool := fun (x : Name → Bool) (x_1 : Name) (x_2 : Syntax) => pure false) :

              Registers attrName as an attribute that adds declarations to a set used by automation.

              isGuardedBy p declName stx should return whether automation only uses declName, as added by the attribute syntax stx, on terms that contain a constant satisfying p, for example because such a constant occurs in every discrimination tree key of declName.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Lean.isAutomationAttr (attrName : Name) :

                Returns whether attrName adds declarations to a set used by automation.

                Equations
                Instances For
                  def Lean.isAutomationAttrGuardedBy (attrName : Name) (p : Name → Bool) (declName : Name) (stx : Syntax) :

                  Returns whether automation only uses declName, as added by the automation attribute attrName with syntax stx, on terms that contain a constant satisfying p (see registerAutomationAttr).

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

                    Helper methods for decoding the parameters of builtin attributes that are defined before Lean.Parser. We have the following ones:

                    @[builtin_attr_parser] def simple     := leading_parser ident >> optional (ppSpace >> (priorityParser <|> ident))
                    @[builtin_attr_parser] def «macro»    := leading_parser "macro " >> ident
                    @[builtin_attr_parser] def «export»   := leading_parser "export " >> ident
                    

                    Note that we need the parsers for class, instance, export and macros because they are keywords.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Equations
                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Lean.throwAttrMustBeGlobal {m : Type → Type} [Monad m] [MonadError m] {α : Type} (name : Name) (kind : AttributeKind) :
                                m α
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  def Lean.throwAttrDeclInImportedModule {m : Type → Type} [Monad m] [MonadError m] {α : Type} (attrName declName : Name) :
                                  m α
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    def Lean.throwAttrNotInAsyncCtx {m : Type → Type} [Monad m] [MonadError m] {α : Type} (attrName declName : Name) (asyncPrefix? : Option Name) :
                                    m α
                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      def Lean.throwAttrDeclNotOfExpectedType {m : Type → Type} [Monad m] [MonadError m] {α : Type} (attrName declName : Name) (givenType expectedType : Expr) :
                                      m α
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        def Lean.ensureAttrDeclIsPublic (attrName declName : Name) (attrKind : AttributeKind) :
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          def Lean.ensureAttrDeclIsMeta (attrName declName : Name) (attrKind : AttributeKind) :
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Tag attributes are simple and efficient. They are useful for marking declarations in the modules where they were defined.

                                            The startup cost for this kind of attribute is very small since addImportedFn is a constant function.

                                            They provide the predicate tagAttr.hasTag env decl which returns true iff declaration decl is tagged in the environment env.

                                            Instances For
                                              def Lean.registerTagAttribute (name : Name) (descr : String) (validate : Name → AttrM Unit := fun (x : Name) => pure ()) (ref : Name := by exact decl_name%) (applicationTime : AttributeApplicationTime := AttributeApplicationTime.afterTypeChecking) (asyncMode : EnvExtension.AsyncMode := EnvExtension.AsyncMode.mainOnly) (logWrites : Bool := false) :
                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                def Lean.TagAttribute.setTag {m : Type → Type} [Monad m] [MonadError m] [MonadEnv m] (attr : TagAttribute) (decl : Name) :

                                                Sets the attribute (without running validate)

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

                                                    A TagAttribute variant where we can attach parameters to attributes. It is slightly more expensive and consumes a little bit more memory than TagAttribute.

                                                    They provide the function pAttr.getParam env decl which returns some p iff declaration decl contains the attribute pAttr with parameter p.

                                                    Instances For
                                                      Instances For
                                                        def Lean.registerParametricAttributeExt {α : Type} (ref : Name) (preserveOrder : Bool := false) (filterExport : Environment → Name → α → Bool := fun (env : Environment) (n : Name) (x : α) => env.contains n false) (logWrites : Bool := false) :
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            def Lean.ParametricAttribute.getParamFromExt? {α : Type} [Inhabited α] (ext : PersistentEnvExtension (Name × α) (Name × α) (List Name × NameMap α)) (preserveOrder : Bool) (env : Environment) (decl : Name) :
                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              Equations
                                                              Instances For
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  Equations
                                                                  Instances For
                                                                    structure Lean.EnumAttributes (α : Type) :

                                                                    Given a list [a₁, ..., a_n] of elements of type α, EnumAttributes provides an attribute Attr_i for associating a value a_i with an declaration. α is usually an enumeration type. Note that whenever we register an EnumAttributes, we create n attributes, but only one environment extension.

                                                                    Instances For
                                                                      def Lean.registerEnumAttributes {α : Type} (attrDescrs : List (Name × String × α)) (validate : Name → α → AttrM Unit := fun (x : Name) (x_1 : α) => pure ()) (applicationTime : AttributeApplicationTime := AttributeApplicationTime.afterTypeChecking) (ref : Name := by exact decl_name%) :
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        def Lean.EnumAttributes.getValue {α : Type} [Inhabited α] (attr : EnumAttributes α) (env : Environment) (decl : Name) :
                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For
                                                                          def Lean.EnumAttributes.setValue {α : Type} (attrs : EnumAttributes α) (env : Environment) (decl : Name) (val : α) :
                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For

                                                                            Attribute extension and builders. We use builders to implement attribute factories for parser categories.

                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For
                                                                              Instances For
                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For
                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For
                                                                                    @[implemented_by Lean.mkAttributeImplOfConstantUnsafe]

                                                                                    Return true iff n is the name of a registered attribute.

                                                                                    Equations
                                                                                    Instances For

                                                                                      Return the name of all registered attributes.

                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For
                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For
                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For
                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For
                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                def Lean.Attribute.add (declName attrName : Name) (stx : Syntax) (kind : AttributeKind := AttributeKind.global) :
                                                                                                Equations
                                                                                                Instances For
                                                                                                  def Lean.Attribute.erase (declName attrName : Name) :
                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    @[export lean_update_env_attributes]

                                                                                                    updateEnvAttributes implementation

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      @[export lean_get_num_attributes]

                                                                                                      getNumBuiltinAttributes implementation

                                                                                                      Equations
                                                                                                      Instances For