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:

  1. qualid not a defined object


Variants:

  1. Print Term qualid.
    This is a synonym to Print qualid when qualid denotes a global constant.
  2. 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. It does not print the body of definitions or proofs.

6.1.2  Print All.

This command displays informations about the current state of the environment, including sections and modules.


Variants:

  1. Inspect num.
    This command displays the num last objects of the current environment, including sections and modules.
  2. Print Section ident.
    should correspond to a currently open section, this command displays the objects defined since the beginning of this section.

6.2  Options and Flags

6.2.1  Set option value.

This command sets option to value. The original value of option is restored when the current module ends.


Variants:

  1. Set flag.
    This command switches flag on. The original state of flag is restored when the current module ends.
  2. Local Set option value. This command sets option to value. The original value of option is restored when the current section ends.
  3. Local Set flag.
    This command switches flag on. The original state of flag is restored when the current section ends.
  4. Global Set option value. This command sets option to value. The original value of option is not restored at the end of the module. Additionally, if set in a file, option is set to value when the file is Require-d.
  5. Global Set flag.
    This command switches flag on. The original state of flag is not restored at the end of the module. Additionally, if set in a file, flag is switched on when the file is Require-d.

6.2.2  Unset flag.

This command switches flag off. The original state of flag is restored when the current module ends.


Variants:

  1. Local Unset flag.
    This command switches flag off. The original state of flag is restored when the current section ends.
  2. Global Unset flag.
    This command switches flag off. The original state of flag is not restored at the end of the module. Additionally, if set in a file, flag is switched on when the file is Require-d.

6.2.3  Test option.

This command prints the current value of option.


Variants:

  1. Test flag.
    This command prints whether flag is on or off.

6.3  Requests to the environment

6.3.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.3.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.3.3  Compute term.

This command performs a call-by-value evaluation of term by using the bytecode-based virtual machine. It is a shortcut for Eval vm_compute in term.


See also: Section 8.5.

6.3.4  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:

  1. Recursive Extraction qualid1qualidn.
    Recursively extracts all the material needed for the extraction of globals qualid1qualidn.


See also: Chapter 21.

6.3.5  Print Assumptions qualid.

This commands display all the assumptions (axioms, parameters and variables) a theorem or definition depends on. Especially, it informs on the assumptions with respect to which the validity of a theorem relies.


Variants:

  1. Print Opaque Dependencies qualid.
    Displays the set of opaque constants qualid relies on in addition to the assumptions.

6.3.6  Search term.

This command displays the name and type of all theorems of the current context whose statement’s conclusion has the form (term t1 .. tn). This command is useful to remind the user of the name of library lemmas.

Coq < Search le.
le_S: forall n m : nat, n <= m -> n <= S m
le_n: forall n : nat, n <= n

Coq < Search (@eq bool).
andb_true_intro:
  forall b1 b2 : bool, b1 = true /\ b2 = true -> (b1 && b2)%bool = true


Variants:

  1. Search term inside module1modulen.

    This restricts the search to constructions defined in modules module1modulen.

  2. Search term outside module1modulen.

    This restricts the search to constructions not defined in modules module1modulen.


    Error messages:

    1. Module/section module not found No module module has been required (see Section 6.5.1).

6.3.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:

  1. The reference qualid was not found in the current environment
    There is no constant in the environment named qualid.


Variants:

  1. SearchAbout string.

    If string is a valid identifier, this command displays the name and type of all objects (theorems, axioms, etc) of the current context whose name contains string. If string is a notation’s string denoting some reference qualid (referred to by its main symbol as in "+" or by its notation’s string as in "_ + _" or "_ 'U' _", see Section 12.1), the command works like SearchAbout qualid.

  2. SearchAbout string%key.

    The string string must be a notation or the main symbol of a notation which is then interpreted in the scope bound to the delimiting key key (see Section 12.2.2).

  3. SearchAbout term_pattern.

    This searches for all statements or types of definition that contains a subterm that matches the pattern term_pattern (holes of the pattern are either denoted by “_” or by “?ident” when non linear patterns are expected).

  4. SearchAbout [ [-]term_pattern-string    [-]term_pattern-string ].
    where term_pattern-string is a term_pattern or a string, or a string followed by a scope delimiting key %key.

    This generalization of SearchAbout searches for all objects whose statement or type contains a subterm matching term_pattern (or qualid if string is the notation for a reference qualid) and whose name contains all string of the request that correspond to valid identifiers. If a term_pattern or a string is prefixed by “-”, the search excludes the objects that mention that term_pattern or that string.

  5. SearchAbout term_pattern-string inside module1modulen.
    SearchAbout [ term_pattern-string    term_pattern-string ] inside module1modulen.

    This restricts the search to constructions defined in modules module1modulen.

  6. SearchAbout term_pattern-string outside module1...modulen.
    SearchAbout [ term_pattern-string    term_pattern-string ] outside module1...modulen.

    This restricts the search to constructions not defined in modules module1modulen.


Examples:

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
fast_Zmult_plus_distr_l:
  forall (n m p : Z) (P : Z -> Prop),
  P (n * p + m * p)%Z -> P ((n + m) * p)%Z

Coq < SearchAbout [ "+"%Z "*"%Z "distr" -positive -Prop].
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

Coq < SearchAbout (?x * _ + ?x * _)%Z outside OmegaLemmas.
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

6.3.8  SearchPattern term.

This command displays the name and type of all theorems of the current context whose statement’s conclusion or last hypothesis and conclusion matches the expression term where holes in the latter are denoted by “_”. It is a variant of SearchAbout term_pattern that does not look for subterms but searches for statements whose conclusion has exactly the expected form, or whose statement finishes by the given series of hypothesis/conclusion.

Coq < Require Import Arith.

Coq < SearchPattern (_ + _ = _ + _).
plus_permute_2_in_4:
  forall n m p q : nat, n + m + (p + q) = n + p + (m + q)
plus_permute: forall n m p : nat, n + (m + p) = m + (n + p)
plus_comm: forall n m : nat, n + m = m + n
plus_assoc_reverse: forall n m p : nat, n + m + p = n + (m + p)
plus_assoc: forall n m p : nat, n + (m + p) = n + m + p
plus_Snm_nSm: forall n m : nat, S n + m = n + S m

Coq < SearchPattern (nat -> bool).
Ndigits.xorf: (nat -> bool) -> (nat -> bool) -> nat -> bool
Ndigits.Pbit: positive -> nat -> bool
Ndigits.Nbit: N -> nat -> bool
beq_nat: nat -> nat -> bool
leb: nat -> nat -> bool

Coq < SearchPattern (forall l : list _, _ l l).
List.lel_refl: forall (A : Type) (l : list A), List.lel l l
List.incl_refl: forall (A : Type) (l : list A), List.incl l l

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:

  1. SearchPattern term inside module1modulen.

    This restricts the search to constructions defined in modules module1modulen.

  2. SearchPattern term outside module1modulen.

    This restricts the search to constructions not defined in modules module1modulen.

6.3.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_permute_2_in_4:
  forall n m p q : nat, n + m + (p + q) = n + p + (m + q)
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)
plus_assoc: forall n m p : nat, n + (m + p) = n + m + p


Variants:

  1. SearchRewrite term inside module1modulen.

    This restricts the search to constructions defined in modules module1modulen.

  2. SearchRewrite term outside module1modulen.

    This restricts the search to constructions not defined in modules module1modulen.

6.3.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
  (shorter name to refer to it in current context is O)

Coq < Locate Init.Datatypes.O.
Constructor Coq.Init.Datatypes.O
  (shorter name to refer to it in current context is O)

Coq < Locate Coq.Init.Datatypes.O.
Constructor Coq.Init.Datatypes.O
  (shorter name to refer to it in current context is O)

Coq < Locate I.Dont.Exist.
No object of suffix I.Dont.Exist


See also: Section 12.1.10

6.3.11  The Whelp searching tool

Whelp is an experimental searching and browsing tool for the whole Coq library and the whole set of Coq user contributions. Whelp requires a browser to work. Whelp has been developed at the University of Bologna as part of the HELM1 and MoWGLI2 projects. It can be invoked directly from the Coq toplevel or from CoqIDE, assuming a graphical environment is also running. The browser to use can be selected by setting the environment variable COQREMOTEBROWSER. If not explicitly set, it defaults to firefox -remote \"OpenURL(%s,new-tab)\" || firefox %s &" or C:\\PROGRA~1\\INTERN~1\\IEXPLORE %s, depending on the underlying operating system (in the command, the string %s serves as metavariable for the url to open). The Whelp tool relies on a dedicated Whelp server and on another server called Getter that retrieves formal documents. The default Whelp server name can be obtained using the command Test Whelp Server and the default Getter can be obtained using the command: Test Whelp Getter . The Whelp server name can be changed using the command:


Set Whelp Server string.
where string is a URL (e.g. http://mowgli.cs.unibo.it:58080).

The Getter can be changed using the command:

Set Whelp Getter string.
where string is a URL (e.g. http://mowgli.cs.unibo.it:58081).



The Whelp commands are:

Whelp Locate "reg_expr".

This command opens a browser window and displays the result of seeking for all names that match the regular expression reg_expr in the Coq library and user contributions. The regular expression can contain the special operators are * and ? that respectively stand for an arbitrary substring and for exactly one character.


Variant: Whelp Locate ident.
This is equivalent to Whelp Locate "ident".

Whelp Match pattern.

This command opens a browser window and displays the result of seeking for all statements that match the pattern pattern. Holes in the pattern are represented by the wildcard character “_”.

Whelp Instance pattern.

This command opens a browser window and displays the result of seeking for all statements that are instances of the pattern pattern. The pattern is here assumed to be an universally quantified expression.

Whelp Elim qualid.

This command opens a browser window and displays the result of seeking for all statements that have the “form” of an elimination scheme over the type denoted by qualid.

Whelp Hint term.

This command opens a browser window and displays the result of seeking for all statements that can be instantiated so that to prove the statement term.


Variant: Whelp Hint.
This is equivalent to Whelp Hint goal where goal is the current goal to prove. Notice that Coq does not send the local environment of definitions to the Whelp tool so that it only works on requests strictly based on, only, definitions of the standard library and user contributions.

6.4  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.4.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.6)


Variants:

  1. 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
  2. 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.9.1


Error messages:

  1. Can’t find file ident on loadpath

6.5  Compiled files

This section describes the commands used to load compiled files (see Chapter 13 for documentation on how to compile a file). A compiled file is a particular case of module called library file.

6.5.1  Require qualid.

This command looks in the loadpath for a file containing module qualid and adds the corresponding module to the environment of Coq. As library files have dependencies in other library files, the command Require qualid recursively requires all library files the module qualid depends on and adds the corresponding modules to the environment of Coq too. Coq assumes that the compiled files have been produced by a valid Coq compiler and their contents are then not replayed nor rechecked.

To locate the file in the file system, qualid is decomposed under the form dirpath.ident and the file ident.vo is searched in the physical directory of the file system that is mapped in Coq loadpath to the logical path dirpath (see Section 6.6). The mapping between physical directories and logical names at the time of requiring the file must be consistent with the mapping used to compile the file.


Variants:

  1. Require Import qualid.

    This loads and declares the module qualid and its dependencies then imports the contents of qualid as described in Section 2.5.8.

    It does not import the modules on which qualid depends unless these modules were itself required in module qualid using Require Export, as described below, or recursively required through a sequence of Require Export.

    If the module required has already been loaded, Require Import qualid simply imports it, as Import qualid would.

  2. Require Export qualid.

    This command acts as Require Import qualid, but if a further module, say A, contains a command Require Export B, then the command Require Import A also imports the module B.

  3. Require [Import | Export] qualid1qualidn.

    This loads the modules qualid1, …, qualidn and their recursive dependencies. If Import or Export is given, it also imports qualid1, …, qualidn and all the recursive dependencies that were marked or transitively marked as Export.

  4. Require [Import | Export] string.

    This shortcuts the resolution of the qualified name into a library file name by directly requiring the module to be found in file string.vo.


Error messages:

  1. Cannot load qualid: no physical path bound to dirpath
  2. Cannot find library foo in loadpath

    The command did not find the file foo.vo. Either foo.v exists but is not compiled or foo.vo is in a directory which is not in your LoadPath (see Section 6.6).

  3. Compiled library ident.vo makes inconsistent assumptions over library qualid

    The command tried to load library file ident.vo that depends on some specific version of library qualid which is not the one already loaded in the current Coq session. Probably ident.v was not properly recompiled with the last version of the file containing module qualid.

  4. 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.

  5. The file ident.vo contains library dirpath and not library dirpath

    The library file dirpath’ is indirectly required by the Require command but it is bound in the current loadpath to the file ident.vo which was bound to a different library name dirpath at the time it was compiled.


See also: Chapter 13

6.5.2  Print Libraries.

This command displays the list of library files loaded in the current Coq session. For each of these libraries, it also tells if it is imported.

6.5.3  Declare ML Module string1 .. stringn.

This commands loads the Objective Caml compiled files string1stringn (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.6). Loading of Objective Caml files is only possible under the bytecode version of coqtop (i.e. coqtop called with options -byte, see chapter 13), or when Coq has been compiled with a version of Objective Caml that supports native Dynlink (≥ 3.11).


Error messages:

  1. File not found on loadpath : string
  2. Loading of ML object file forbidden in a native Coq

6.5.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 Section 6.6.10)

6.6  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.6.2).

6.6.1  Pwd.

This command displays the current working directory.

6.6.2  Cd string.

This command changes the current directory according to string which can be any valid path.


Variants:

  1. Cd.
    Is equivalent to Pwd.

6.6.3  Add LoadPath string as dirpath.

This command adds the physical directory string to the current Coq loadpath and maps it to the logical directory dirpath, which means that every file dirname/basename.v physically lying in subdirectory string/dirname becomes accessible in Coq through absolute logical name dirpath.dirname.basename.


Remark: Add LoadPath also adds string to the current ML loadpath.


Variants:

  1. Add LoadPath string.
    Performs as Add LoadPath string as dirpath but for the empty directory path.

6.6.4  Add Rec LoadPath string as dirpath.

This command adds the physical directory string and all its subdirectories to the current Coq loadpath. The top directory string is mapped to the logical directory dirpath and any subdirectory pdir of it is mapped to logical name dirpath.pdir and recursively. Subdirectories corresponding to invalid Coq identifiers are skipped, and, by convention, subdirectories named CVS or _darcs are skipped too.

Otherwise, said, Add Rec LoadPath string as dirpath behaves as Add LoadPath string as dirpath excepts that files lying in validly named subdirectories of string need not be qualified to be found.

In case of files with identical base name, files lying in most recently declared dirpath are found first and explicit qualification is required to refer to the other files of same base name.

If several files with identical base name are present in different subdirectories of a recursive loadpath declared via a single instance of Add Rec LoadPath, which of these files is found first is system-dependent and explicit qualification is recommended.


Remark: Add Rec LoadPath also recursively adds string to the current ML loadpath.


Variants:

  1. Add Rec LoadPath string.
    Works as Add Rec LoadPath string as dirpath but for the empty logical directory path.

6.6.5  Remove LoadPath string.

This command removes the path string from the current Coq loadpath.

6.6.6  Print LoadPath.

This command displays the current Coq loadpath.


Variants:

  1. Print LoadPath dirpath.
    Works as Print LoadPath but displays only the paths that extend the dirpath prefix.

6.6.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.5).


Remark: This command is implied by Add LoadPath string as dirpath.

6.6.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.5).


Remark: This command is implied by Add Rec LoadPath string as dirpath.

6.6.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.5).

6.6.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.6.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.7  States and Reset

6.7.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:

  1. ident: no such entry

6.7.2  Back.

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:

  1. Back n
    Undoes n vernacular commands.


Error messages:

  1. Reached begin of command history
    Happens when there is vernacular command to undo.

6.7.3  Backtrack num1 num2 num3.

This command is dedicated for the use in graphical interfaces. It allows to backtrack to a particular global state, i.e. typically a state corresponding to a previous line in a script. A global state includes declaration environment but also proof environment (see Chapter 7). The three numbers num1, num2 and num3 represent the following:

How to get state numbers?

Notice that when in -emacs mode, Coq displays the current proof and environment state numbers in the prompt. More precisely the prompt in -emacs mode is the following:

<prompt> idi < num1 | id1|id2||idn | num2 < </prompt>

Where:

It is then possible to compute the Backtrack command to unbury the state corresponding to a particular prompt. For example, suppose the current prompt is:

< goal4 < 35 |goal1|goal4|goal3|goal2| |8 < </prompt>

and we want to backtrack to a state labeled by:

< goal2 < 32 |goal1|goal2 |12 < </prompt>

We have to perform Backtrack 32 12 2 , i.e. perform 2 Aborts (to cancel goal4 and goal3), then rewind proof until state 12 and finally go back to environment state 32. Notice that this supposes that proofs are nested in a regular way (no Resume or Suspend commands).


Variants:

  1. BackTo n.
    Is a more basic form of Backtrack where only the first argument (global environment number) is given, no abort and no Undo is performed.

6.7.4  Restore State string.

Restores the state contained in the file string.


Variants:

  1. Restore State ident
    Equivalent to Restore State "ident.coq".
  2. 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.7.5  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:

  1. Write State ident
    Equivalent to Write State "ident.coq". The state is saved in the current directory (see Section 6.6.1).

6.8  Quitting and debugging

6.8.1  Quit.

This command permits to quit Coq.

6.8.2  Drop.

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:

#use "include";;

add the right loadpaths and loads some toplevel printers for all abstract types of Coq- section_path, identifiers, terms, judgments, …. 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:

go();;


Warnings:

  1. It only works with the bytecode version of Coq (i.e. coqtop called with option -byte, see the contents of Section 13.1).
  2. 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 13.4).

6.8.3  Time command.

This command executes the vernacular command command and display the time needed to execute it.

6.8.4  Timeout int command.

This command executes the vernacular command command. If the command has not terminated after the time specified by the integer (time expressed in seconds), then it is interrupted and an error message is displayed.

6.8.5  Set Default Timeout int.

After using this command, all subsequent commands behave as if they were passed to a Timeout command. Commands already starting by a Timeout are unaffected.

6.8.6  Unset Default Timeout.

This command turns off the use of a defaut timeout.

6.8.7  Test Default Timeout.

This command displays whether some default timeout has be set or not.

6.9  Controlling display

6.9.1  Set Silent.

This command turns off the normal displaying.

6.9.2  Unset Silent.

This command turns the normal display on.

6.9.3  Set Printing Width integer.

This command sets which left-aligned part of the width of the screen is used for display.

6.9.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.9.5  Test Printing Width.

This command displays the current screen width used for display.

6.9.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.9.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.9.8  Test Printing Depth.

This command displays the current nesting depth used for display.

6.10  Controlling the reduction strategies and the conversion algorithm

Coq provides reduction strategies that the tactics can invoke and two different algorithms to check the convertibility of types. The first conversion algorithm lazily compares applicative terms while the other is a brute-force but efficient algorithm that first normalizes the terms before comparing them. The second algorithm is based on a bytecode representation of terms similar to the bytecode representation used in the ZINC virtual machine [91]. It is specially useful for intensive computation of algebraic values, such as numbers, and for reflexion-based tactics. The commands to fine-tune the reduction strategies and the lazy conversion algorithm are described first.

6.10.1  Opaque qualid1 qualidn.

This command has an effect on unfoldable constants, i.e. on constants defined by Definition or Let (with an explicit body), or by a command assimilated to a definition such as Fixpoint, Program Definition, etc, or by a proof ended by Defined. The command tells not to unfold the constants qualid1qualidn in tactics using δ-conversion (unfolding a constant is replacing it by its definition).

Opaque has also on effect on the conversion algorithm of Coq, telling to delay the unfolding of a constant as later as possible in case Coq has to check the conversion (see Section 4.3) of two distinct applied constants.

The scope of Opaque is limited to the current section, or current file, unless the variant Global Opaque qualid1 qualidn is used.


See also: sections 8.5, 8.12, 7.1


Error messages:

  1. 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.10.2  Transparent qualid1 qualidn.

This command is the converse of Opaque and it applies on unfoldable constants to restore their unfoldability after an Opaque command.

Note in particular that constants defined by a proof ended by Qed are not unfoldable and Transparent has no effect on them. 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.

The scope of Transparent is limited to the current section, or current file, unless the variant Global Transparent qualid1qualidn is used.


Error messages:

  1. 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.12, 7.1

6.10.3  Strategy level [ qualid1 qualidn ].

This command generalizes the behavior of Opaque and Transparent commands. It is used to fine-tune the strategy for unfolding constants, both at the tactic level and at the kernel level. This command associates a level to qualid1qualidn. Whenever two expressions with two distinct head constants are compared (for instance, this comparison can be triggered by a type cast), the one with lower level is expanded first. In case of a tie, the second one (appearing in the cast type) is expanded.

Levels can be one of the following (higher to lower):

opaque
: level of opaque constants. They cannot be expanded by tactics (behaves like +∞, see next item).
num
: levels indexed by an integer. Level 0 corresponds to the default behavior, which corresponds to transparent constants. This level can also be referred to as transparent. Negative levels correspond to constants to be expanded before normal transparent constants, while positive levels correspond to constants to be expanded after normal transparent constants.
expand
: level of constants that should be expanded first (behaves like −∞)

These directives survive section and module closure, unless the command is prefixed by Local. In the latter case, the behavior regarding sections and modules is the same as for the Transparent and Opaque commands.

6.10.4  Declare Reduction ident := convtactic.

This command allows to give a short name to a reduction expression, for instance lazy beta delta [foo bar]. This short name can then be used in Eval ident in ... or eval directives. This command accepts the Local modifier, for discarding this reduction name at the end of the file or module. For the moment the name cannot be qualified. In particular declaring the same name in several modules or in several functor applications will be refused if these declarations are not local. The name ident cannot be used directly as an Ltac tactic, but nothing prevent the user to also perform a Ltac ident := convtactic.


See also: sections 8.5

6.10.5  Set Virtual Machine

This activates the bytecode-based conversion algorithm.

6.10.6  Unset Virtual Machine

This deactivates the bytecode-based conversion algorithm.

6.10.7  Test Virtual Machine

This tells if the bytecode-based conversion algorithm is activated. The default behavior is to have the bytecode-based conversion algorithm deactivated.


See also: sections 8.5.1 and 13.5.

6.11  Controlling the locality of commands

6.11.1  Local, Global

Some commands support a Local or Global prefix modifier to control the scope of their effect. There are four kinds of commands:


1
Hypertextual Electronic Library of Mathematics
2
Mathematics on the Web, Get it by Logics and Interfaces