Development questions
The sequence of all declarations (logical ones such as Definition
, but also non logical ones such as say Notation
) is registered in a tree-like structure called the lib_stk
. Each entry has a tag describing what kind of declaration it is, e.g. "CONSTANT"
for Theorem
/Definition
/Axiom
/Parameter
/..., "VARIABLE"
for Variable
/Hypothesis
/Let
, "INDUCTIVE"
for Inductive
/CoInductive
/Record
/Variant
, "NOTATION"
for interpretation of notations, etc.
Independently, each kind of declaration generally comes with its own data structures or tables storing relevant information about this entry.
Back to the library stack, each entry there has a kernel name which is an identifier for fetching the information related to this entry in the appropriate table. For instance, with the kernel name of a "CONSTANT"
you can get its body, type and other related informations by looking up the table of constants (function
Global.lookup_constant
). You can see examples of walking through the environment in the code for "Search" (Search.iter_declarations
which itself relies on an iterator over module contents called
Declaremods.iter_all_segments
), or in the code for Print All
(Printer.print_full_pure_context
).
To the extent possible under law, the contributors of “Cocorico!, the Coq wiki” have waived all copyright and related or neighboring rights to their contributions.
By contributing to Cocorico!, the Coq wiki, you agree that you hold the copyright and you agree to license your contribution under the CC0 license or you agree that you have permission to distribute your contribution under the CC0 license.