Documentation

Mathlib.Tactic.CrossRefAttribute

Cross-reference attributes #

This file provides attributes for tagging Mathlib results with cross-references to entries in external mathematical databases:

Each attribute records the cross-reference in an environment extension and appends a link to the declaration's docstring.

The shared infrastructure (Database, Tag, tagExt, addCrossRefDoc, traceCrossRefs) is database-agnostic; per-database code defines a parser, the attribute syntax, and the trace command.

The supported external databases

Instances For
    @[implicit_reducible]

    The base URL for an external database's tag pages. Always ends with /.

    Instances For

      The display label used in docstring links and trace output.

      Instances For

        A cross-reference from a Mathlib declaration to an entry in an external database.

        • declName : Lean.Name

          The name of the declaration carrying the cross-reference.

        • database : Database

          The external database the entry belongs to.

        • tag : String

          The database identifier.

        • comment : String

          An optional comment supplied with the attribute.

        Instances For
          @[implicit_reducible]
          @[implicit_reducible]

          The environment extension storing all cross-references. addImportedFn is a constant function to avoid a performance overhead during initialization.

          def Mathlib.CrossRef.addTagEntry {m : TypeType} [Lean.MonadEnv m] (declName : Lean.Name) (db : Database) (tag comment : String) :

          addTagEntry declName db tag comment records a cross-reference for declName in tagExt.

          Instances For

            Append a cross-reference link to the docstring of decl and record it in tagExt. This is the database-agnostic core of every cross-reference attribute's add handler.

            Instances For

              Stacks (and Kerodon) parser #

              @[reducible, inline]

              stacksTag is the node kind of Stacks Project Tags: a sequence of digits and uppercase letters.

              Instances For

                The main parser for Stacks Project Tags: it accepts any sequence of 4 digits or uppercase letters.

                Instances For

                  The main parser for Stacks Project Tags: it accepts any sequence of 4 digits or uppercase letters.

                  Instances For

                    The main parser for Stacks Project Tags: it accepts any sequence of 4 digits or uppercase letters.

                    Instances For

                      Wikidata parser #

                      @[reducible, inline]

                      wikidataId is the node kind of Wikidata identifiers: the letter Q followed by digits.

                      Instances For

                        The main parser for Wikidata identifiers: it accepts Q followed by one or more digits.

                        Instances For

                          The main parser for Wikidata identifiers: it accepts Q followed by one or more digits.

                          Instances For

                            The main parser for Wikidata identifiers: it accepts Q followed by one or more digits.

                            Instances For

                              Extract the underlying tag as a string from a stacksTag node.

                              Instances For

                                Extract the underlying identifier as a string from a wikidataId node.

                                Instances For

                                  The formatter for Stacks Project Tags syntax.

                                  Instances For

                                    The formatter for Wikidata identifier syntax.

                                    Instances For

                                      The parenthesizer for Stacks Project Tags syntax.

                                      Instances For

                                        The parenthesizer for Wikidata identifier syntax.

                                        Instances For

                                          Stacks / Kerodon attribute #

                                          The syntax category for the database name.

                                          Instances For

                                            The syntax for a "kerodon" database identifier in a @[kerodon] attribute.

                                            Instances For

                                              The syntax for a "stacks" database identifier in a @[stacks] attribute.

                                              Instances For

                                                The stacksTag attribute. Use it as @[kerodon TAG "Optional comment"] or @[stacks TAG "Optional comment"] depending on the database you are referencing.

                                                The TAG is mandatory and should be a sequence of 4 digits or uppercase letters.

                                                See the Tags page in the Stacks project or Tags page in the Kerodon project for more details.

                                                Instances For

                                                  Wikidata attribute #

                                                  The wikidata attribute. Use it as @[wikidata Q12345 "Optional comment"] to associate a Mathlib declaration with the corresponding Wikidata item.

                                                  The identifier must be the letter Q followed by one or more digits.

                                                  Instances For

                                                    traceCrossRefs db verbose prints the cross-references of database db and inlines the declaration types if verbose is true.

                                                    Instances For

                                                      #stacks_tags retrieves all declarations that have the stacks attribute.

                                                      For each found declaration, it prints a line

                                                      'declaration_name' corresponds to tag 'declaration_tag'.
                                                      

                                                      The variant #stacks_tags! also adds the theorem statement (for theorems) or declaration type (for definitions, structures, instances, etc.) after each summary line.

                                                      Instances For

                                                        The #kerodon_tags command retrieves all declarations that have the kerodon attribute.

                                                        For each found declaration, it prints a line

                                                        'declaration_name' corresponds to tag 'declaration_tag'.
                                                        

                                                        The variant #kerodon_tags! also adds the theorem statement (for theorems) or declaration type (for definitions, structures, instances, etc.) after each summary line.

                                                        Instances For

                                                          The #wikidata_tags command retrieves all declarations that have the wikidata attribute.

                                                          For each found declaration, it prints a line

                                                          'declaration_name' corresponds to tag 'declaration_tag'.
                                                          

                                                          The variant #wikidata_tags! also adds the theorem statement (for theorems) or declaration type (for definitions, structures, instances, etc.) after each summary line.

                                                          Instances For