Chapter 6 Vernacular commands
6.1 Displaying
6.1.1 Print qualid.
This command displays on the screen informations about the declared or
defined object referred by qualid.
Error messages: -
qualid not a defined object
Variants: -
Print Term qualid.
This is a synonym to Print qualid when qualid denotes a
global constant.
- About qualid.
This displays various informations about the object denoted by qualid:
its kind (module, constant, assumption, inductive,
constructor, abbreviation...), long name, type, implicit
arguments and argument scopes.
6.1.2 Print All.
This command displays informations about the current state of the
environment, including sections and modules.
Variants: -
Inspect num.
This command displays the num last objects of the current
environment, including sections and modules.
- Print Section ident.
should correspond to a currently open section, this command
displays the objects defined since the beginning of this section.
6.2 Requests to the environment
6.2.1 Check term.
This command displays the type of term. When called in proof mode,
the term is checked in the local context of the current subgoal.
6.2.2 Eval convtactic in term.
This command performs the specified reduction on term, and displays
the resulting term with its type. The term to be reduced may depend on
hypothesis introduced in the first subgoal (if a proof is in
progress).
See also: section 8.5.
6.2.3 Extraction term.
This command displays the extracted term from
term. The extraction is processed according to the distinction
between Set and Prop; that is to say, between logical and
computational content (see section 4.1.1). The extracted term is
displayed in Objective Caml syntax, where global identifiers are still
displayed as in Coq terms.
Variants: -
Recursive Extraction qualid1 ... qualidn.
Recursively extracts all the material needed for the extraction of
globals qualid1 ... qualidn.
See also: chapter 18.
6.2.4 Opaque qualid1 ...qualidn.
This command tells not to unfold the
the constants qualid1 ...qualidn in tactics using
delta-conversion. Unfolding a constant is replacing it by its
definition. Opaque can only apply on constants originally
defined as Transparent.
Constants defined by a proof ended by Qed are automatically
stamped as Opaque and can no longer be considered as Transparent. This is to keep with the usual mathematical practice of
proof irrelevance: what matters in a mathematical development is
the sequence of lemma statements, not their actual proofs. This
distinguishes lemmas from the usual defined constants, whose actual
values are of course relevant in general.
See also: sections 8.5, 8.11,
7.1.4
Error messages: -
The reference qualid was not found in the current
environment
There is no constant referred by qualid in the environment.
Nevertheless, if you asked Opaque foo bar
and if bar does not exist, foo is set opaque.
6.2.5 Transparent qualid1 ...qualidn.
This command is the converse of Opaque and can only apply on constants originally defined as Transparent to restore their initial behaviour after an Opaque command.
The constants automatically declared transparent are the ones defined by a proof ended by Defined, or by a Definition or Local with an explicit body.
Warning: Transparent and Opaque are not synchronous
with the reset mechanism. If a constant was transparent at point A, if
you set it opaque at point B and reset to point A, you return to state
of point A with the difference that the constant is still opaque. This
can cause changes in tactic scripts behaviour.
At section or module closing, a constant recovers the status it got at
the time of its definition.
Error messages: -
The reference qualid was not found in the current
environment
There is no constant referred by qualid in the environment.
See also: sections 8.5, 8.11,
7.1.4
6.2.6 Search qualid.
This command displays the name and type of all theorems of the current
context whose statement's conclusion has the form (qualid t1 ..
tn). This command is useful to remind the user of the name of
library lemmas.
Error messages: -
The reference qualid was not found in the current
environment
There is no constant in the environment named qualid.
Variants: -
Search qualid inside module1 ... modulen.
This restricts the search to constructions defined in modules
module1 ... modulen.
- Search qualid outside module1 ... modulen.
This restricts the search to constructions not defined in modules
module1 ... modulen.
Error messages: -
Module/section module not found
No module module has been required (see section 6.4.1).
6.2.7 SearchAbout qualid.
This command displays the name and type of all objects (theorems,
axioms, etc) of the current context whose statement contains qualid.
This command is useful to remind the user of the name of library
lemmas.
Error messages: -
The reference qualid was not found in the current
environment
There is no constant in the environment named qualid.
Variants: -
SearchAbout [ qualid-or-string ... qualid-or-string
].
where qualid-or-string is a qualid or
a string.
This extension of SearchAbout searches for all objects whose
statement mentions all of qualid of the list and whose name
contains all string of the list.
Example:
Coq < Require Import ZArith.
Coq < SearchAbout [ Zmult Zplus "distr" ].
weak_Zmult_plus_distr_r:
forall (p : positive) (n m : Z),
(Zpos p * (n + m))%Z = (Zpos p * n + Zpos p * m)%Z
Zmult_plus_distr_r:
forall n m p : Z, (n * (m + p))%Z = (n * m + n * p)%Z
Zmult_plus_distr_l:
forall n m p : Z, ((n + m) * p)%Z = (n * p + m * p)%Z
OmegaLemmas.fast_Zmult_plus_distr:
forall (n m p : Z) (P : Z -> Prop),
P (n * p + m * p)%Z -> P ((n + m) * p)%Z
SearchAbout term inside module1 ... modulen. |
SearchAbout [ qualid-or-string ... qualid-or-string ]
inside module1 ... modulen. |
This restricts the search to constructions defined in modules
module1 ... modulen.
SearchAbout term outside module1...modulen. |
SearchAbout [ qualid-or-string ... qualid-or-string ]
outside module1...modulen. |
This restricts the search to constructions not defined in modules
module1 ... modulen.
6.2.8 SearchPattern term.
This command displays the name and type of all theorems of the current
context whose statement's conclusion matches the expression term
where holes in the latter are denoted by ``_''.
Coq < Require Import Arith.
Coq < SearchPattern (_ + _ = _ + _).
plus_comm: forall n m : nat, n + m = m + n
plus_Snm_nSm: forall n m : nat, S n + m = n + S m
plus_assoc: forall n m p : nat, n + (m + p) = n + m + p
plus_permute: forall n m p : nat, n + (m + p) = m + (n + p)
plus_assoc_reverse: forall n m p : nat, n + m + p = n + (m + p)
plus_permute_2_in_4:
forall n m p q : nat, n + m + (p + q) = n + p + (m + q)
Patterns need not be linear: you can express that the same expression
must occur in two places by using pattern variables `?ident''.
Coq < Require Import Arith.
Coq < SearchPattern (?X1 + _ = _ + ?X1).
plus_comm: forall n m : nat, n + m = m + n
Variants: -
SearchPattern term inside
module1 ... modulen.
This restricts the search to constructions defined in modules
module1 ... modulen.
- SearchPattern term outside module1 ... modulen.
This restricts the search to constructions not defined in modules
module1 ... modulen.
6.2.9 SearchRewrite term.
This command displays the name and type of all theorems of the current
context whose statement's conclusion is an equality of which one side matches
the expression term=. Holes in term are denoted by ``_''.
Coq < Require Import Arith.
Coq < SearchRewrite (_ + _ + _).
plus_assoc: forall n m p : nat, n + (m + p) = n + m + p
plus_assoc_reverse: forall n m p : nat, n + m + p = n + (m + p)
plus_permute_2_in_4:
forall n m p q : nat, n + m + (p + q) = n + p + (m + q)
Variants: -
SearchRewrite term inside
module1 ... modulen.
This restricts the search to constructions defined in modules
module1 ... modulen.
- SearchRewrite term outside module1 ... modulen.
This restricts the search to constructions not defined in modules
module1 ... modulen.
6.2.10 Locate qualid.
This command displays the full name of the qualified identifier qualid
and consequently the Coq module in which it is defined.
Coq < Locate nat.
Inductive Coq.Init.Datatypes.nat
Coq < Locate Datatypes.O.
Constructor Coq.Init.Datatypes.O (visible as O)
Coq < Locate Init.Datatypes.O.
Constructor Coq.Init.Datatypes.O (visible as O)
Coq < Locate Coq.Init.Datatypes.O.
Constructor Coq.Init.Datatypes.O (visible as O)
Coq < Locate I.Dont.Exist.
No object of suffix I.Dont.Exist
See also: Section 11.1.10
6.3 Loading files
Coq offers the possibility of loading different
parts of a whole development stored in separate files. Their contents
will be loaded as if they were entered from the keyboard. This means
that the loaded files are ASCII files containing sequences of commands
for Coq's toplevel. This kind of file is called a script for
Coq. The standard (and default) extension of
Coq's script files is .v.
6.3.1 Load ident.
This command loads the file named ident.v, searching
successively in each of the directories specified in the loadpath. (see section 6.5)
Variants: -
Load string.
Loads the file denoted by the string string, where string is any
complete filename. Then the ~
and ..
abbreviations are allowed as well as shell variables. If no
extension is specified, Coq will use the default extension .v
- Load Verbose ident.,
Load Verbose string
Display, while loading, the answers of Coq to each command
(including tactics) contained in the loaded file
See also: section 6.8.1
Error messages: -
Can't find file ident on loadpath
6.4 Compiled files
This feature allows to build files for a quick loading. When loaded,
the commands contained in a compiled file will not be replayed.
In particular, proofs will not be replayed. This avoids a useless
waste of time.
Remark: A module containing an opened section cannot be compiled.
6.4.1 Require dirpath.
This command looks in the loadpath for a file containing module
dirpath, then loads and opens (imports) its contents.
More precisely, if dirpath splits into a library dirpath dirpath' and a module name ident, then the file ident.vo is searched in a physical path mapped to the logical path dirpath'.
TODO: effect on the name table.
If the module required has already been loaded, Coq
simply opens it (as Import dirpath would do it).
If a module A contains a command Require B then the
command Require A loads the module B but does not
open it (See the Require Export variant below).
Variants: -
Require Export qualid.
This command acts as Require qualid. But if a module A contains a command Require Export B, then the
command Require A opens the module B as if the
user would have typed RequireB.
- Require qualid string.
Specifies the file to load as being string but containing module
qualid which is then opened.
These different variants can be combined.
Error messages: - Cannot load ident: no physical path bound to dirpath
- Can't find module toto on loadpath
The command did not find the file toto.vo. Either toto.v exists but is not compiled or toto.vo is in a directory
which is not in your LoadPath (see section 6.5).
- Bad magic number
The file ident.vo was found but either it is not a Coq
compiled module, or it was compiled with an older and incompatible
version of Coq.
See also: chapter 12
6.4.2 Print Modules.
This command shows the currently loaded and currently opened
(imported) modules.
6.4.3 Declare ML Module string1 .. stringn.
This commands loads the Objective Caml compiled files string1 ...stringn (dynamic link). It is mainly used to load tactics
dynamically.
The files are
searched into the current Objective Caml loadpath (see the command Add ML Path in the section 6.5). Loading of Objective Caml
files is only possible under the bytecode version of coqtop
(i.e. coqtop called with options -byte, see chapter
12).
Error messages: -
File not found on loadpath : string
- Loading of ML object file forbidden in a native Coq
6.4.4 Print ML Modules.
This print the name of all Objective Caml modules loaded with Declare
ML Module. To know from where these module were loaded, the user
should use the command Locate File (see page ??)
6.5 Loadpath
There are currently two loadpaths in Coq. A loadpath where seeking
Coq files (extensions .v or .vo or .vi) and one where
seeking Objective Caml files. The default loadpath contains the
directory ``.'' denoting the current directory and mapped to the empty logical path (see section 2.5.2).
This command displays the current working directory.
6.5.2 Cd string.
This command changes the current directory according to string
which can be any valid path.
Variants: -
Cd.
Is equivalent to Pwd.
6.5.3 Add LoadPath string as dirpath.
This command adds the path string to the current Coq loadpath and
maps it to the logical directory dirpath, which means that every
file M.v physically lying in directory string becomes accessible
through logical name ``dirpath.M''.
Remark: Add LoadPath also adds string to the current ML loadpath.
Variants: -
Add LoadPath string.
Performs as Add LoadPath string as dirpath but for the empty directory path.
6.5.4 Add Rec LoadPath string as dirpath.
This command adds the directory string and all its subdirectories
to the current Coq loadpath. The top directory string is mapped to the logical directory dirpath while any subdirectory pdir is mapped to logical directory dirpath.pdir and so on.
Remark: Add Rec LoadPath also recursively adds string to the current ML loadpath.
Variants: -
Add Rec LoadPath string.
Works as Add Rec LoadPath string as dirpath but for the empty logical directory path.
6.5.5 Remove LoadPath string.
This command removes the path string from the current Coq loadpath.
6.5.6 Print LoadPath.
This command displays the current Coq loadpath.
6.5.7 Add ML Path string.
This command adds the path string to the current Objective Caml loadpath (see
the command Declare ML Module in the section 6.4).
Remark: This command is implied by Add LoadPath string as dirpath.
6.5.8 Add Rec ML Path string.
This command adds the directory string and all its subdirectories
to the current Objective Caml loadpath (see
the command Declare ML Module in the section 6.4).
Remark: This command is implied by Add Rec LoadPath string as dirpath.
6.5.9 Print ML Path string.
This command displays the current Objective Caml loadpath.
This command makes sense only under the bytecode version of coqtop, i.e. using option -byte (see the
command Declare ML Module in the section
6.4).
6.5.10 Locate File string.
This command displays the location of file string in the current loadpath.
Typically, string is a .cmo or .vo or .v file.
6.5.11 Locate Library dirpath.
This command gives the status of the Coq module dirpath. It tells if the
module is loaded and if not searches in the load path for a module
of logical name dirpath.
6.6 States and Reset
6.6.1 Reset ident.
This command removes all the objects in the environment since ident
was introduced, including ident. ident may be the name of a defined
or declared object as well as the name of a section. One cannot reset
over the name of a module or of an object inside a module.
Error messages: -
ident: no such entry
This commands undoes all the effects of the last vernacular
command. This does not include commands that only access to the
environment like those described in the previous sections of this
chapter (for instance Require and Load can be undone, but
not Check and Locate). Commands read from a vernacular
file are considered as a single command.
Variants: -
Back n
Undoes n vernacular commands.
Error messages: -
Reached begin of command history
Happens when there is vernacular command to undo.
6.6.3 Restore State string.
Restores the state contained in the file string.
Variants: -
Restore State ident
Equivalent to Restore State "ident.coq".
- Reset Initial.
Goes back to the initial state (like after the command coqtop,
when the interactive session began). This command is only available
interactively.
6.6.4 Write State string.
Writes the current state into a file string for
use in a further session. This file can be given as the inputstate argument of the commands coqtop and coqc.
Variants: -
Write State ident
Equivalent to Write State "ident.coq".
The state is saved in the current directory (see ??).
6.7 Quitting and debugging
This command permits to quit Coq.
This is used mostly as a debug facility by Coq's implementors
and does not concern the casual user.
This command permits to leave Coq temporarily and enter the
Objective Caml toplevel. The Objective Caml command:
add the right loadpaths and loads some toplevel printers for
all abstract types of Coq- section_path, identfifiers, terms, judgements,
.... You can also use the file base_include instead,
that loads only the pretty-printers for section_paths and
identifiers.
You can return back to Coq with the command:
Warnings: -
It only works with the bytecode version of Coq (i.e. coqtop called with option -byte, see page ??).
- You must have compiled Coq from the source package and set the
environment variable COQTOP to the root of your copy of the sources (see section 12.4).
6.7.3 Time command.
This command executes the vernac command command
and display the time needed to execute it.
6.8 Controlling display
6.8.1 Set Silent.
This command turns off the normal displaying.
6.8.2 Unset Silent.
This command turns the normal display on.
6.8.3 Set Printing Width integer.
This command sets which left-aligned part of the width of the screen
is used for display.
6.8.4 Unset Printing Width.
This command resets the width of the screen used for display to its
default value (which is 78 at the time of writing this documentation).
6.8.5 Test Printing Width.
This command displays the current screen width used for display.
6.8.6 Set Printing Depth integer.
This command sets the nesting depth of the formatter used for
pretty-printing. Beyond this depth, display of subterms is replaced by
dots.
6.8.7 Unset Printing Depth.
This command resets the nesting depth of the formatter used for
pretty-printing to its default value (at the
time of writing this documentation, the default value is 50).
6.8.8 Test Printing Depth.
This command displays the current nesting depth used for display.