2.6 Qualified names
Modules contain constructions (axioms, parameters,
definitions, lemmas, theorems, remarks or facts). The (full) name of a
construction starts with the logical name of the module in which it is defined
followed by the (short) name of the construction.
Typically, Coq.Init.Logic.eq denotes Leibniz' equality
defined in the module Logic in the sublibrary Init of the
standard library of Coq.
Absolute and short names
The full name of a library, module, section, definition, theorem,
... is called absolute name.
The final identifier (in the example
above, it is eq) is called short name (or sometimes base name). Coq maintains a names table mapping short names
to absolute names. This greatly simplifies the notations. Coq
cannot accept two constructions (definition, theorem, ...) with the
same absolute name.
The special case of remarks and facts
In contrast with definitions, lemmas, theorems, axioms and parameters,
the absolute name of remarks includes the segment of sections in which
it is defined. Concretely, if a remark R is defined in
subsection S2 of section S1 in module M, then its
absolute name is M.S1.S2.R. The same for facts, except that the
name of the innermost section is dropped from the full name. Then, if
a fact F is defined in subsection S2 of section S1
in module M, then its absolute name is M.S1.F.
Visibility and qualified names
An absolute name is called visible when its base name suffices
to denote it. This means the base name is mapped to the absolute name
in Coq name table.
All the base names of definitions and
theorems are automatically put in the Coq name table. But
sometimes, the short name of a construction defined in a module may
hide the short name of another construction defined in another module.
Instead of just distinguishing the clashing names by using the
absolute names, it is enough to prefix the base name just by the name
of the module in which the definition, theorem, ... is defined.
Such a name built from single identifiers separated by dots is called
a partially qualified name (or shortly a qualified name,
written qualid). Especially, both absolute names and short names
are qualified names. To ensure that a construction always remains
accessible, absolute names can never be hidden.
Examples:
Coq < Check O.
O
: nat
Coq < Definition nat := bool.
nat is defined
Coq < Check O.
O
: Datatypes.nat
Coq < Check Datatypes.nat.
Datatypes.nat
: Set
Remark: There is also a names table for sublibraries, modules and sections.
Requiring a file
A module compiled in a ``.vo'' file comes with a logical names (e.g.
physical file theories/Init/Datatypes.vo
in Coq installation directory contains logical module Coq.Init.Datatypes).
When requiring the file, the mapping between physical directories and logical library should be consistent with the mapping used to compile the file (for modules of the standard library, this is automatic -- check it by typing Print LoadPath).
The command Add Rec LoadPath is also available from coqtop
and coqc by using option -R
.