Cross-reference attributes #
This file provides attributes for tagging Mathlib results with cross-references to entries in external mathematical databases:
@[stacks TAG]— Stacks Project@[kerodon TAG]— Kerodon@[wikidata QID]— Wikidata
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.
Equations
- Mathlib.CrossRef.instBEqDatabase.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
Instances For
Equations
The base URL for an external database's tag pages. Always ends with /.
Equations
- Mathlib.CrossRef.databaseURL Mathlib.CrossRef.Database.kerodon = "https://kerodon.net/tag/"
- Mathlib.CrossRef.databaseURL Mathlib.CrossRef.Database.stacks = "https://stacks.math.columbia.edu/tag/"
- Mathlib.CrossRef.databaseURL Mathlib.CrossRef.Database.wikidata = "https://www.wikidata.org/wiki/"
Instances For
The display label used in docstring links and trace output.
Equations
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
Equations
Equations
- One or more equations did not get rendered due to their size.
- Mathlib.CrossRef.instBEqTag.beq x✝¹ x✝ = false
Instances For
Equations
The environment extension storing all cross-references.
addImportedFn is a constant function to avoid a performance overhead during initialization.
addTagEntry declName db tag comment records a cross-reference for declName in tagExt.
Equations
- One or more equations did not get rendered due to their size.
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stacks (and Kerodon) parser #
stacksTag is the node kind of Stacks Project Tags: a sequence of digits and
uppercase letters.
Equations
- Mathlib.CrossRef.stacksTagKind = `stacksTag
Instances For
The main parser for Stacks Project Tags: it accepts any sequence of 4 digits or uppercase letters.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The main parser for Stacks Project Tags: it accepts any sequence of 4 digits or uppercase letters.
Equations
- Mathlib.CrossRef.stacksTagNoAntiquot = { info := Lean.Parser.mkAtomicInfo "stacksTag", fn := Mathlib.CrossRef.stacksTagFn }
Instances For
The main parser for Stacks Project Tags: it accepts any sequence of 4 digits or uppercase letters.
Equations
Instances For
Wikidata parser #
wikidataId is the node kind of Wikidata identifiers: the letter Q followed by digits.
Equations
- Mathlib.CrossRef.wikidataIdKind = `wikidataId
Instances For
The main parser for Wikidata identifiers: it accepts Q followed by one or more digits.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The main parser for Wikidata identifiers: it accepts Q followed by one or more digits.
Equations
- Mathlib.CrossRef.wikidataIdNoAntiquot = { info := Lean.Parser.mkAtomicInfo "wikidataId", fn := Mathlib.CrossRef.wikidataIdFn }
Instances For
The main parser for Wikidata identifiers: it accepts Q followed by one or more digits.
Equations
Instances For
Extract the underlying tag as a string from a stacksTag node.
Equations
- stx.getStacksTag = match Lean.Syntax.isLit? Mathlib.CrossRef.stacksTagKind stx.raw with | some val => pure val | x => Lean.throwError (Lean.toMessageData "Malformed Stacks tag")
Instances For
Extract the underlying identifier as a string from a wikidataId node.
Equations
- stx.getWikidataId = match Lean.Syntax.isLit? Mathlib.CrossRef.wikidataIdKind stx.raw with | some val => pure val | x => Lean.throwError (Lean.toMessageData "Malformed Wikidata id")
Instances For
The formatter for Stacks Project Tags syntax.
Equations
Instances For
The formatter for Wikidata identifier syntax.
Equations
Instances For
The parenthesizer for Stacks Project Tags syntax.
Equations
Instances For
The parenthesizer for Wikidata identifier syntax.
Equations
Instances For
Stacks / Kerodon attribute #
The syntax category for the database name.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The syntax for a "kerodon" database identifier in a @[kerodon] attribute.
Equations
- Mathlib.CrossRef.stacksTagDBKerodon = Lean.ParserDescr.node `Mathlib.CrossRef.stacksTagDBKerodon 1024 (Lean.ParserDescr.symbol "kerodon")
Instances For
The syntax for a "stacks" database identifier in a @[stacks] attribute.
Equations
- Mathlib.CrossRef.stacksTagDBStacks = Lean.ParserDescr.node `Mathlib.CrossRef.stacksTagDBStacks 1024 (Lean.ParserDescr.symbol "stacks")
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.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Wikidata attribute #
traceCrossRefs db verbose prints the cross-references of database db and
inlines the declaration types if verbose is true.
Equations
- One or more equations did not get rendered due to their size.
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.
Equations
- One or more equations did not get rendered due to their size.
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.
Equations
- One or more equations did not get rendered due to their size.
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.
Equations
- One or more equations did not get rendered due to their size.