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.

A topic identifying a π-Base project.

Instances For

    The string such that https://{topic.urlSubdomain}.pi-base.org is the base URL of the π-Base project identified by this topic.

    Instances For

      The display label used in docstring links and trace output. Used in Database.label.

      Instances For

        A lowercase short name for the given database. Used in Database.shortName. Useful when exporting to JSON.

        Instances For

          The supported external databases

          Instances For
            @[instance_reducible]
            @[instance_reducible]

            The URL for an external database entry, where id is the identifier recorded in Tag.tag.

            Instances For

              The display label used in docstring links and trace output.

              Instances For

                A lowercase short name for the given database. Useful when exporting to JSON.

                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
                    @[instance_reducible]
                    @[instance_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

                                        LMFDB parser #

                                        @[reducible, inline]

                                        lmfdbId is the node kind of LMFDB identifiers: lower case words with . in between. The words can also contain underscores and digits.

                                        Instances For

                                          The main parser for LMFDB identifiers: it accepts lower case words with . in between. The words can also contain underscores and digits.

                                          Instances For

                                            The main parser for LMFDB identifiers: it accepts lower case words with . in between. The words can also contain underscores and digits.

                                            Instances For

                                              The main parser for LMFDB identifiers: it accepts lower case words with . in between. The words can also contain underscores and digits.

                                              Instances For

                                                π-Base parser #

                                                @[reducible, inline]

                                                pibaseId is the node kind of π-Base identifiers: one of the letters P, S, or T, followed by exactly six digits.

                                                Instances For

                                                  The main parser for π-Base identifiers: it accepts canonical property, space, and theorem identifiers, such as P000001, S000023, and T000010.

                                                  Instances For

                                                    The main parser for π-Base identifiers: it accepts canonical property, space, and theorem identifiers, such as P000001, S000023, and T000010.

                                                    Instances For

                                                      The main parser for π-Base identifiers: it accepts canonical property, space, and theorem identifiers, such as P000001, S000023, and T000010.

                                                      Instances For

                                                        DLMF parser #

                                                        @[reducible, inline]

                                                        dlmfId is the node kind of DLMF references: generally <chapter_no>.<section_no>.E<equation_no> (e.g. 5.4.E1). See https://dlmf.nist.gov/help/cite for more details on the permalink format. Note that while underscores are not mentioned in the DLMF permalink table, they are supported and present in some actual links for equations.

                                                        Instances For

                                                          The main parser for DLMF references: generally <chapter_no>.<section_no>.E<equation_no> (e.g. 5.4.E1). See https://dlmf.nist.gov/help/cite for more details on the permalink format. Note that while underscores are not mentioned in the DLMF permalink table, they are supported and present in some actual links for equations.

                                                          Instances For

                                                            The main parser for DLMF references: generally <chapter_no>.<section_no>.E<equation_no> (e.g. 5.4.E1). See https://dlmf.nist.gov/help/cite for more details on the permalink format. Note that while underscores are not mentioned in the DLMF permalink table, they are supported and present in some actual links for equations.

                                                            Instances For

                                                              The main parser for DLMF references: generally <chapter_no>.<section_no>.E<equation_no> (e.g. 5.4.E1). See https://dlmf.nist.gov/help/cite for more details on the permalink format. Note that while underscores are not mentioned in the DLMF permalink table, they are supported and present in some actual links for equations.

                                                              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

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

                                                                    Instances For

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

                                                                      Instances For

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

                                                                        Instances For

                                                                          The formatter for Stacks Project Tags syntax.

                                                                          Instances For

                                                                            The formatter for Wikidata identifier syntax.

                                                                            Instances For

                                                                              The formatter for LMFDB identifier syntax.

                                                                              Instances For

                                                                                The formatter for π-Base identifier syntax.

                                                                                Instances For

                                                                                  The formatter for DLMF identifier syntax.

                                                                                  Instances For

                                                                                    The parenthesizer for Stacks Project Tags syntax.

                                                                                    Instances For

                                                                                      The parenthesizer for Wikidata identifier syntax.

                                                                                      Instances For

                                                                                        The parenthesizer for LMFDB identifier syntax.

                                                                                        Instances For

                                                                                          The parenthesizer for π-Base identifier syntax.

                                                                                          Instances For

                                                                                            The parenthesizer for DLMF 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

                                                                                                        LMFDB attribute #

                                                                                                        The lmfdb attribute. Use it as @[lmfdb foo.bar "Optional comment"] to associate a Mathlib declaration with the corresponding LMFDB item.

                                                                                                        Instances For

                                                                                                          π-Base attribute #

                                                                                                          The topic identifying a π-Base database. Possible values:

                                                                                                          This list will be expanded in the future.

                                                                                                          Instances For
                                                                                                            def Mathlib.CrossRef.getPiBaseTopic? :
                                                                                                            Lean.TSyntax `Mathlib.CrossRef.pibaseTopicOption PiBaseTopic

                                                                                                            Get the PiBaseTopic from a syntax key.

                                                                                                            Instances For

                                                                                                              The pibase attribute. Use it as @[pibase <topic> P000001 "Optional comment"] to associate a Mathlib declaration with the corresponding π-Base property, space, or theorem.

                                                                                                              Each <topic> identifies a different π-Base database. The possible values of <topic> are:

                                                                                                              This list will be expanded in the future.

                                                                                                              The identifier must start with P, S, or T, followed by exactly six digits.

                                                                                                              Instances For

                                                                                                                DLMF attribute #

                                                                                                                The dlmf attribute. Use it as @[dlmf 5.4.E1 "Optional comment"] to associate a Mathlib declaration with the corresponding DLMF item.

                                                                                                                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

                                                                                                                          The #lmfdb_tags command retrieves all declarations that have the lmfdb attribute.

                                                                                                                          For each found declaration, it prints a line

                                                                                                                          'declaration_name' corresponds to tag 'declaration_tag'.
                                                                                                                          

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

                                                                                                                          Instances For

                                                                                                                            The #pibase_tags topic command retrieves all declarations that have the pibase attribute with the given topic.

                                                                                                                            For each found declaration, it prints a line

                                                                                                                            'declaration_name' corresponds to tag 'declaration_tag'.
                                                                                                                            

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

                                                                                                                            Instances For

                                                                                                                              The #dlmf_tags command retrieves all declarations that have the dlmf attribute.

                                                                                                                              For each found declaration, it prints a line

                                                                                                                              'declaration_name' corresponds to tag 'declaration_tag'.
                                                                                                                              

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

                                                                                                                              Instances For