summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2012-06-04 12:07:52 +0200
committerGravatar Stephane Glondu <steph@glondu.net>2012-06-04 12:07:52 +0200
commit61dc740ed1c3780cccaec00d059a28f0d31d0052 (patch)
treed88d05baf35b9b09a034233300f35a694f9fa6c2 /doc
parent97fefe1fcca363a1317e066e7f4b99b9c1e9987b (diff)
Imported Upstream version 8.4~gamma0+really8.4beta2upstream/8.4_gamma0+really8.4beta2
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/common/macros.tex1
-rw-r--r--doc/common/styles/html/coqremote/cover.html9
-rw-r--r--doc/common/styles/html/coqremote/footer.html45
-rw-r--r--doc/common/styles/html/coqremote/header.html49
-rw-r--r--doc/common/styles/html/simple/cover.html10
-rw-r--r--doc/common/styles/html/simple/footer.html (renamed from doc/stdlib/index-trailer.html)0
-rw-r--r--doc/common/styles/html/simple/header.html13
-rwxr-xr-xdoc/common/title.tex2
-rw-r--r--doc/faq/FAQ.tex6
-rw-r--r--doc/refman/Cases.tex2
-rw-r--r--doc/refman/RefMan-cic.tex77
-rw-r--r--doc/refman/RefMan-coi.tex4
-rw-r--r--doc/refman/RefMan-com.tex176
-rw-r--r--doc/refman/RefMan-ext.tex41
-rw-r--r--doc/refman/RefMan-gal.tex4
-rw-r--r--doc/refman/RefMan-ltac.tex3
-rw-r--r--doc/refman/RefMan-oth.tex138
-rw-r--r--doc/refman/RefMan-pro.tex79
-rw-r--r--doc/refman/RefMan-sch.tex418
-rw-r--r--doc/refman/RefMan-syn.tex2
-rw-r--r--doc/refman/RefMan-tac.tex5242
-rw-r--r--doc/refman/RefMan-tacex.tex584
-rw-r--r--doc/refman/RefMan-uti.tex52
-rw-r--r--doc/refman/Reference-Manual.tex7
-rw-r--r--doc/refman/coqdoc.tex12
-rw-r--r--doc/stdlib/hidden-files0
-rw-r--r--doc/stdlib/index-list.html.template36
-rwxr-xr-xdoc/stdlib/make-library-index34
28 files changed, 3563 insertions, 3483 deletions
diff --git a/doc/common/macros.tex b/doc/common/macros.tex
index f0fb0883..ce998a9b 100755
--- a/doc/common/macros.tex
+++ b/doc/common/macros.tex
@@ -206,6 +206,7 @@
%END LATEX
%HEVEA \renewcommand{\proof}{\nterm{proof}}
\newcommand{\record}{\nterm{record}}
+\newcommand{\recordkw}{\nterm{record\_keyword}}
\newcommand{\rewrule}{\nterm{rewriting\_rule}}
\newcommand{\sentence}{\nterm{sentence}}
\newcommand{\simplepattern}{\nterm{simple\_pattern}}
diff --git a/doc/common/styles/html/coqremote/cover.html b/doc/common/styles/html/coqremote/cover.html
index f4809a48..62ee00ac 100644
--- a/doc/common/styles/html/coqremote/cover.html
+++ b/doc/common/styles/html/coqremote/cover.html
@@ -27,7 +27,6 @@
<ul class="links-menu">
<li><a href="http://coq.inria.fr/" class="active">Home</a></li>
-
<li><a href="http://coq.inria.fr/about-coq" title="More about coq">About Coq</a></li>
<li><a href="http://coq.inria.fr/download">Get Coq</a></li>
<li><a href="http://coq.inria.fr/documentation">Documentation</a></li>
@@ -64,9 +63,11 @@
<div style="text-align: left; font-size: 80%; text-indent: 0pt">
<ul style="list-style: none; margin-left: 0pt">
<li>V7.x © INRIA 1999-2004</li>
- <li>V8.0 © INRIA 2004-2006</li>
- <li>V8.1 © INRIA 2006-2008</li>
- <li>V8.2 © INRIA 2008-2009</li>
+ <li>V8.0 © INRIA 2004-2008</li>
+ <li>V8.1 © INRIA 2006-2011</li>
+ <li>V8.2 © INRIA 2008-2011</li>
+ <li>V8.3 © INRIA 2010-2011</li>
+ <li>V8.4 © INRIA 2012</li>
</ul>
<p style="text-indent: 0pt">This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at <a href="http://www.opencontent.org/openpub">http://www.opencontent.org/openpub</a>). Options A and B are not elected.</p>
diff --git a/doc/common/styles/html/coqremote/footer.html b/doc/common/styles/html/coqremote/footer.html
new file mode 100644
index 00000000..138c3025
--- /dev/null
+++ b/doc/common/styles/html/coqremote/footer.html
@@ -0,0 +1,45 @@
+<div id="sidebarWrapper">
+<div id="sidebar">
+
+<div class="block">
+<h2 class="title">Navigation</h2>
+<div class="content">
+
+<ul class="menu">
+
+<li class="leaf">Standard Library
+ <ul class="menu">
+ <li><a href="index.html">Table of contents</a></li>
+ <li><a href="genindex.html">Index</a></li>
+ </ul>
+</li>
+
+</ul>
+
+</div>
+</div>
+
+</div>
+</div>
+
+
+</div>
+
+</div>
+
+<div id="footer">
+<div id="nav-footer">
+ <ul class="links-menu-footer">
+ <li><a href="mailto:webmaster_@_www.lix.polytechnique.fr">webmaster</a></li>
+ <li><a href="http://validator.w3.org/check?uri=referer">xhtml valid</a></li>
+ <li><a href="http://jigsaw.w3.org/css-validator/check/referer">CSS valid</a></li>
+ </ul>
+
+</div>
+</div>
+
+</div>
+
+</body>
+</html>
+
diff --git a/doc/common/styles/html/coqremote/header.html b/doc/common/styles/html/coqremote/header.html
new file mode 100644
index 00000000..afcdbe73
--- /dev/null
+++ b/doc/common/styles/html/coqremote/header.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Standard Library | The Coq Proof Assistant</title>
+
+<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+<style type="text/css" media="all">@import "http://www.lix.polytechnique.fr/coq/modules/node/node.css";</style>
+
+<style type="text/css" media="all">@import "http://www.lix.polytechnique.fr/coq/modules/system/defaults.css";</style>
+<style type="text/css" media="all">@import "http://www.lix.polytechnique.fr/coq/modules/system/system.css";</style>
+<style type="text/css" media="all">@import "http://www.lix.polytechnique.fr/coq/modules/user/user.css";</style>
+
+<style type="text/css" media="all">@import "http://www.lix.polytechnique.fr/coq/sites/all/themes/coq/style.css";</style>
+<style type="text/css" media="all">@import "http://www.lix.polytechnique.fr/coq/sites/all/themes/coq/coqdoc.css";</style>
+
+</head>
+
+<body>
+
+<div id="container">
+<div id="headertop">
+<div id="nav">
+ <ul class="links-menu">
+ <li><a href="http://www.lix.polytechnique.fr/coq/" class="active">Home</a></li>
+
+ <li><a href="http://www.lix.polytechnique.fr/coq/about-coq" title="More about coq">About Coq</a></li>
+ <li><a href="http://www.lix.polytechnique.fr/coq/download">Get Coq</a></li>
+ <li><a href="http://www.lix.polytechnique.fr/coq/documentation">Documentation</a></li>
+ <li><a href="http://www.lix.polytechnique.fr/coq/community">Community</a></li>
+ </ul>
+</div>
+</div>
+
+<div id="header">
+
+<div id="logoWrapper">
+
+<div id="logo"><a href="http://www.lix.polytechnique.fr/coq/" title="Home"><img src="http://www.lix.polytechnique.fr/coq/files/barron_logo.png" alt="Home" /></a>
+</div>
+<div id="siteName"><a href="http://www.lix.polytechnique.fr/coq/" title="Home">The Coq Proof Assistant</a>
+</div>
+
+</div>
+</div>
+
+<div id="content">
+
diff --git a/doc/common/styles/html/simple/cover.html b/doc/common/styles/html/simple/cover.html
index 75b938f9..39dfd4ab 100644
--- a/doc/common/styles/html/simple/cover.html
+++ b/doc/common/styles/html/simple/cover.html
@@ -25,7 +25,7 @@
<h1 style="font-weight:bold; font-size: 300%; line-height: 2ex">Reference Manual</h1>
<h2 style="font-size: 120%">
- Version 8.2<a name="text1"></a><a href="#note1"><sup><span style="font-size: 80%">1</span></sup></a></h2>
+ Version 8.4<a name="text1"></a><a href="#note1"><sup><span style="font-size: 80%">1</span></sup></a></h2>
<br/><br/><br/><br/><br/><br/>
<p><span style="text-align: center; font-size: 120%; ">The Coq Development Team</span></p>
@@ -35,9 +35,11 @@
<div style="text-align: left; font-size: 80%; text-indent: 0pt">
<ul style="list-style: none; margin-left: 0pt">
<li>V7.x © INRIA 1999-2004</li>
- <li>V8.0 © INRIA 2004-2006</li>
- <li>V8.1 © INRIA 2006-2008</li>
- <li>V8.2 © INRIA 2008-2009</li>
+ <li>V8.0 © INRIA 2004-2008</li>
+ <li>V8.1 © INRIA 2006-2011</li>
+ <li>V8.2 © INRIA 2008-2011</li>
+ <li>V8.3 © INRIA 2010-2011</li>
+ <li>V8.4 © INRIA 2012</li>
</ul>
<p style="text-indent: 0pt">This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at <a href="http://www.opencontent.org/openpub">http://www.opencontent.org/openpub</a>). Options A and B are not elected.</p>
diff --git a/doc/stdlib/index-trailer.html b/doc/common/styles/html/simple/footer.html
index 308b1d01..308b1d01 100644
--- a/doc/stdlib/index-trailer.html
+++ b/doc/common/styles/html/simple/footer.html
diff --git a/doc/common/styles/html/simple/header.html b/doc/common/styles/html/simple/header.html
new file mode 100644
index 00000000..14d2f988
--- /dev/null
+++ b/doc/common/styles/html/simple/header.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
+<link rel="stylesheet" href="coqdoc.css" type="text/css"/>
+<title>The Coq Standard Library</title>
+</head>
+
+<body>
+
diff --git a/doc/common/title.tex b/doc/common/title.tex
index 1dc52432..809b1046 100755
--- a/doc/common/title.tex
+++ b/doc/common/title.tex
@@ -45,7 +45,7 @@ V\coqversion, \today
%END LATEX
\copyright INRIA 1999-2004 ({\Coq} versions 7.x)
-\copyright INRIA 2004-2009 ({\Coq} versions 8.x)
+\copyright INRIA 2004-2012 ({\Coq} versions 8.x)
#3
\end{flushleft}
diff --git a/doc/faq/FAQ.tex b/doc/faq/FAQ.tex
index c0f8c087..0bd84992 100644
--- a/doc/faq/FAQ.tex
+++ b/doc/faq/FAQ.tex
@@ -379,15 +379,15 @@ This FAQ is unfinished (in the sense that there are some obvious
sections that are missing). Please send contributions to Coq-Club.
\Question{Is there any mailing list about {\Coq}?}
-The main {\Coq} mailing list is \url{coq-club@pauillac.inria.fr}, which
+The main {\Coq} mailing list is \url{coq-club@inria.fr}, which
broadcasts questions and suggestions about the implementation, the
logical formalism or proof developments. See
-\ahref{http://coq.inria.fr/mailman/listinfo/coq-club}{\url{http://pauillac.inria.fr/mailman/listinfo/coq-club}} for
+\ahref{http://coq.inria.fr/mailman/listinfo/coq-club}{\url{http://sympa-roc.inria.fr/wws/info/coq-club}} for
subscription. For bugs reports see question \ref{coqbug}.
\Question{Where can I find an archive of the list?}
The archives of the {\Coq} mailing list are available at
-\ahref{http://pauillac.inria.fr/pipermail/coq-club}{\url{http://coq.inria.fr/pipermail/coq-club}}.
+\ahref{http://pauillac.inria.fr/pipermail/coq-club}{\url{http://sympa-roc.inria.fr/wws/arc/coq-club}}.
\Question{How can I be kept informed of new releases of {\Coq}?}
diff --git a/doc/refman/Cases.tex b/doc/refman/Cases.tex
index 6f58269f..3ff4e25d 100644
--- a/doc/refman/Cases.tex
+++ b/doc/refman/Cases.tex
@@ -14,7 +14,7 @@ This section describes the full form of pattern-matching in {\Coq} terms.
match} is presented in Figures~\ref{term-syntax}
and~\ref{term-syntax-aux}. Identifiers in patterns are either
constructor names or variables. Any identifier that is not the
-constructor of an inductive or coinductive type is considered to be a
+constructor of an inductive or co-inductive type is considered to be a
variable. A variable name cannot occur more than once in a given
pattern. It is recommended to start variable names by a lowercase
letter.
diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex
index 9660a04b..6a132eba 100644
--- a/doc/refman/RefMan-cic.tex
+++ b/doc/refman/RefMan-cic.tex
@@ -41,7 +41,7 @@ The beginner can skip them.
The reader seeking a background on the Calculus of Inductive
Constructions may read several papers. Giménez and Castéran~\cite{GimCas05}
provide
-an introduction to inductive and coinductive definitions in Coq. In
+an introduction to inductive and co-inductive definitions in Coq. In
their book~\cite{CoqArt}, Bertot and Castéran give a precise
description of the \CIC{} based on numerous practical examples.
Barras~\cite{Bar99}, Werner~\cite{Wer94} and
@@ -80,35 +80,48 @@ type $(P~n)$ and consequently represent proofs of the formula
\subsection[Sorts]{Sorts\label{Sorts}
\index{Sorts}}
-Types are seen as terms of the language and then should belong to
-another type. The type of a type is always a constant of the language
-called a {\em sort}.
-
-The two basic sorts in the language of \CIC\ are \Set\ and \Prop.
-
-The sort \Prop\ intends to be the type of logical propositions. If
-$M$ is a logical proposition then it denotes a class, namely the class
-of terms representing proofs of $M$. An object $m$ belonging to $M$
-witnesses the fact that $M$ is true. An object of type \Prop\ is
-called a {\em proposition}.
-
-The sort \Set\ intends to be the type of specifications. This includes
-programs and the usual sets such as booleans, naturals, lists
-etc.
-
-These sorts themselves can be manipulated as ordinary terms.
-Consequently sorts also should be given a type. Because assuming
-simply that \Set\ has type \Set\ leads to an inconsistent theory, we
-have infinitely many sorts in the language of \CIC. These are, in
-addition to \Set\ and \Prop\, a hierarchy of universes \Type$(i)$
-for any integer $i$. We call \Sort\ the set of sorts
-which is defined by:
+When manipulated as terms, types have themselves a type which is called a sort.
+
+There is an infinite well-founded typing hierarchy of sorts whose base
+sorts are {\Prop} and {\Set}.
+
+The sort {\Prop} intends to be the type of logical propositions. If
+$M$ is a logical proposition then it denotes the class of terms
+representing proofs of $M$. An object $m$ belonging to $M$ witnesses
+the fact that $M$ is provable. An object of type {\Prop} is called a
+proposition.
+
+The sort {\Set} intends to be the type of small sets. This includes data
+types such as booleans and naturals, but also products, subsets, and
+function types over these data types.
+
+{\Prop} and {\Set} themselves can be manipulated as ordinary
+terms. Consequently they also have a type. Because assuming simply
+that {\Set} has type {\Set} leads to an inconsistent theory, the
+language of {\CIC} has infinitely many sorts. There are, in addition
+to {\Set} and {\Prop} a hierarchy of universes {\Type$(i)$} for any
+integer $i$.
+
+Like {\Set}, all of the sorts {\Type$(i)$} contain small sets such as
+booleans, natural numbers, as well as products, subsets and function
+types over small sets. But, unlike {\Set}, they also contain large
+sets, namely the sorts {\Set} and {\Type$(j)$} for $j<i$, and all
+products, subsets and function types over these sorts.
+
+Formally, we call {\Sort} the set of sorts which is defined by:
\[\Sort \equiv \{\Prop,\Set,\Type(i)| i \in \NN\} \]
\index{Type@{\Type}}
\index{Prop@{\Prop}}
\index{Set@{\Set}}
-The sorts enjoy the following properties: {\Prop:\Type(0)}, {\Set:\Type(0)} and
- {\Type$(i)$:\Type$(i+1)$}.
+
+The sorts enjoy the following properties\footnote{In the Reference
+ Manual of versions of Coq prior to 8.4, the level of {\Type} typing
+ {\Prop} and {\Set} was numbered $0$. From Coq 8.4, it started to be
+ numbered $1$ so as to be able to leave room for re-interpreting
+ {\Set} in the hierarchy as {\Type$(0)$}. This change also put the
+ reference manual in accordance with the internal conventions adopted
+ in the implementation.}: {\Prop:\Type$(1)$}, {\Set:\Type$(1)$} and
+{\Type$(i)$:\Type$(i+1)$}.
The user will never mention explicitly the index $i$ when referring to
the universe \Type$(i)$. One only writes \Type. The
@@ -420,9 +433,9 @@ convertibility into an order inductively defined by:
\begin{enumerate}
\item if $\WTEGCONV{t}{u}$ then $\WTEGLECONV{t}{u}$,
\item if $i \leq j$ then $\WTEGLECONV{\Type(i)}{\Type(j)}$,
-\item for any $i$, $\WTEGLECONV{\Prop}{\Type(i)}$,
\item for any $i$, $\WTEGLECONV{\Set}{\Type(i)}$,
-\item $\WTEGLECONV{\Prop}{\Set}$,
+\item $\WTEGLECONV{\Prop}{\Set}$, hence, by transitivity,
+ $\WTEGLECONV{\Prop}{\Type(i)}$, for any $i$
\item if $\WTEGCONV{T}{U}$ and $\WTELECONV{\Gamma::(x:T)}{T'}{U'}$ then $\WTEGLECONV{\forall~x:T,T'}{\forall~x:U,U'}$.
\end{enumerate}
@@ -1650,12 +1663,12 @@ Abort.
The principles of mutual induction can be automatically generated
using the {\tt Scheme} command described in Section~\ref{Scheme}.
-\section{Coinductive types}
-The implementation contains also coinductive definitions, which are
+\section{Co-inductive types}
+The implementation contains also co-inductive definitions, which are
types inhabited by infinite objects.
-More information on coinductive definitions can be found
+More information on co-inductive definitions can be found
in~\cite{Gimenez95b,Gim98,GimCas05}.
-%They are described in Chapter~\ref{Coinductives}.
+%They are described in Chapter~\ref{Co-inductives}.
\section[\iCIC : the Calculus of Inductive Construction with
impredicative \Set]{\iCIC : the Calculus of Inductive Construction with
diff --git a/doc/refman/RefMan-coi.tex b/doc/refman/RefMan-coi.tex
index 619a8ee1..e609fce8 100644
--- a/doc/refman/RefMan-coi.tex
+++ b/doc/refman/RefMan-coi.tex
@@ -5,7 +5,7 @@
%\begin{document}
%\coverpage{Co-inductive types in Coq}{Eduardo Gim\'enez}
-\chapter[Co-inductive types in Coq]{Co-inductive types in Coq\label{Coinductives}}
+\chapter[Co-inductive types in Coq]{Co-inductive types in Coq\label{Co-inductives}}
%\begin{abstract}
{\it Co-inductive} types are types whose elements may not be well-founded.
@@ -59,7 +59,7 @@ CoInductive Stream (A:Set) : Set :=
The syntax of this command is the same as the
command \verb!Inductive! (cf. section
\ref{gal_Inductive_Definitions}).
-Definition of mutually coinductive types are possible.
+Definition of mutually co-inductive types are possible.
As was already said, there are not principles of
induction for co-inductive sets, the only way of eliminating these
diff --git a/doc/refman/RefMan-com.tex b/doc/refman/RefMan-com.tex
index a40c210e..bcc68c78 100644
--- a/doc/refman/RefMan-com.tex
+++ b/doc/refman/RefMan-com.tex
@@ -49,8 +49,9 @@ Notice that the \verb!-byte! and \verb!-opt! options are still
available with \verb!coqc! and allow you to select the byte-code or
native-code versions of the system.
+\section[Customization]{Customization at launch time}
-\section[Resource file]{Resource file\index{Resource file}}
+\subsection{By resource file\index{Resource file}}
When \Coq\ is launched, with either {\tt coqtop} or {\tt coqc}, the
resource file \verb:$XDG_CONFIG_HOME/coq/coqrc.xxx: is loaded, where
@@ -59,8 +60,7 @@ default its home directory \verb!/.config! and \verb:xxx: is the version
number (e.g. 8.3). If this file is not found, then the file
\verb:$XDG_CONFIG_HOME/coqrc: is searched. You can also specify an
arbitrary name for the resource file (see option \verb:-init-file:
-below), or the name of another user to load the resource file of someone
-else (see option \verb:-user:).
+below).
This file may contain, for instance, \verb:Add LoadPath: commands to add
@@ -68,27 +68,19 @@ directories to the load path of \Coq.
It is possible to skip the loading of the resource file with the
option \verb:-q:.
-\section[Environment variables]{Environment variables\label{EnvVariables}
-\index{Environment variables}}
-
-There are four environment variables used by the \Coq\ system.
-\verb:$COQBIN: for the directory where the binaries are,
-\verb:$COQLIB: for the directory where the standard library is,
-\verb:$COQPATH: for a list of directories seperated by \verb|:|
-(\verb|;| on windows) to add to the load path, and
-\verb:$COQTOP: for the directory of the sources. The latter is useful
-only for developers that are writing their own tactics and are using
-\texttt{coq\_makefile} (see \ref{Makefile}). If \verb:$COQBIN: or
-\verb:$COQLIB: are not defined, \Coq\ will use the default values
-(defined at installation time). So these variables are useful only if
-you move the \Coq\ binaries and library after installation.
-
-Coq will also honor \verb:$XDG_DATA_HOME: and \verb:$XDG_DATA_DIRS: (see
+\section{By environment variables\label{EnvVariables}
+\index{Environment variables}\label{envars}}
+
+Load path can be specified to the \Coq\ system by setting up
+\verb:$COQPATH: environment variable. It is a list of directories separated by \verb|:|
+(\verb|;| on windows).
+
+\Coq will also honour \verb:$XDG_DATA_HOME: and \verb:$XDG_DATA_DIRS: (see
\url{http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html}).
-Coq adds \verb:${XDG_DATA_HOME}/coq: and \verb:${XDG_DATA_DIRS}/coq: to its
+\Coq adds \verb:${XDG_DATA_HOME}/coq: and \verb:${XDG_DATA_DIRS}/coq: to its
search path.
-\section[Options]{Options\index{Options of the command line}
+\subsection{By command line options\index{Options of the command line}
\label{vmoption}
\label{coqoptions}}
@@ -96,86 +88,52 @@ The following command-line options are recognized by the commands {\tt
coqc} and {\tt coqtop}, unless stated otherwise:
\begin{description}
-\item[{\tt -byte}]\
-
- Run the byte-code version of \Coq{}.
-
-\item[{\tt -opt}]\
-
- Run the native-code version of \Coq{}.
-
-\item[{\tt -I} {\em directory}, {\tt -include} {\em directory}]\
-
- Add physical path {\em directory} to the list of directories where to
- look for a file and bind it to the empty logical directory. The
- subdirectory structure of {\em directory} is recursively available
- from {\Coq} using absolute names (see Section~\ref{LongNames}).
-
-\item[{\tt -I} {\em directory} {\tt -as} {\em dirpath}]\
+\item[{\tt -I} {\em directory}, {\tt -include} {\em directory}[ {\tt -as} {\em dirpath}]]\
- Add physical path {\em directory} to the list of directories where to
- look for a file and bind it to the logical directory {\dirpath}. The
- subdirectory structure of {\em directory} is recursively available
- from {\Coq} using absolute names extending the {\dirpath} prefix.
+Add physical path {\em directory} to the list of directories where to look for a
+file and bind it to the empty logical directory/the logical directory {\em
+ dirpath}. The sub-directory structure of {\em directory} is recursively available
+from {\Coq} using absolute names (extending the {\dirpath} prefix) (see
+Section~\ref{LongNames}).
\SeeAlso {\tt Add LoadPath} in Section~\ref{AddLoadPath} and logical
paths in Section~\ref{Libraries}.
-\item[{\tt -R} {\em directory} {\dirpath}, {\tt -R} {\em directory} {\tt -as} {\dirpath}]\
+\item[{\tt -R} {\em directory} {\dirpath}, {\tt -R} {\em directory} [{\tt -as} {\dirpath}]]\
Do as {\tt -I} {\em directory} {\tt -as} {\dirpath} but make the
- subdirectory structure of {\em directory} recursively visible so
+ sub-directory structure of {\em directory} recursively visible so
that the recursive contents of physical {\em directory} is available
from {\Coq} using short or partially qualified names.
\SeeAlso {\tt Add Rec LoadPath} in Section~\ref{AddRecLoadPath} and logical
paths in Section~\ref{Libraries}.
-\item[{\tt -top} {\dirpath}]\
+\item[{\tt -top} {\dirpath}, {\tt -notop}]\
- This sets the toplevel module name to {\dirpath} instead of {\tt
- Top}. Not valid for {\tt coqc}.
-
-\item[{\tt -notop} {\dirpath}]\
-
- This sets the toplevel module name to the empty logical dirpath. Not
- valid for {\tt coqc}.
+ This sets the toplevel module name to {\dirpath}/the empty logical path instead
+ of {\tt Top}. Not valid for {\tt coqc}.
\item[{\tt -exclude-dir} {\em subdirectory}]\
- This tells to exclude any subdirectory named {\em subdirectory}
+ This tells to exclude any sub-directory named {\em subdirectory}
while processing option {\tt -R}. Without this option only the
- conventional version control management subdirectories named {\tt
+ conventional version control management sub-directories named {\tt
CVS} and {\tt \_darcs} are excluded.
-\item[{\tt -is} {\em file}, {\tt -inputstate} {\em file}]\
+\item[{\tt -is} {\em file}, {\tt -inputstate} {\em file}, {\tt -outputstate} {\em file}]\
- Cause \Coq~to use the state put in the file {\em file} as its input
- state. The default state is {\em initial.coq}.
- Mainly useful to build the standard input state.
+ Load at the beginning/Dump at the end a \Coq{} state from the file {\em file}.
-\item[{\tt -outputstate} {\em file}]\
-
- Cause \Coq~to dump its state to file {\em file}.coq just after finishing
- parsing and evaluating all the arguments from the command line.
+ Incompatible with some not purely functional aspect of the code
\item[{\tt -nois}]\
- Cause \Coq~to begin with an empty state. Mainly useful to build the
- standard input state.
-
-%Obsolete?
-%
-%\item[{\tt -notactics}]\
-%
-% Forbid the dynamic loading of tactics in the bytecode version of {\Coq}.
-
-\item[{\tt -init-file} {\em file}]\
+ Cause \Coq~to begin with an empty state.
- Take {\em file} as the resource file.
-
-\item[{\tt -q}]\
+\item[{\tt -init-file} {\em file}, {\tt -q}]\
+ Take {\em file} as the resource file. /
Cause \Coq~not to load the resource file.
\item[{\tt -load-ml-source} {\em file}]\
@@ -186,51 +144,34 @@ The following command-line options are recognized by the commands {\tt
Load the Caml object file {\em file}.
-\item[{\tt -l} {\em file}, {\tt -load-vernac-source} {\em file}]\
-
- Load \Coq~file {\em file}{\tt .v}
+\item[{\tt -l[v]} {\em file}, {\tt -load-vernac-source[-verbose]} {\em file}]\
-\item[{\tt -lv} {\em file}, {\tt -load-vernac-source-verbose} {\em file}]\
-
- Load \Coq~file {\em file}{\tt .v} with
- a copy of the contents of the file on standard input.
+ Load \Coq~file {\em file}{\tt .v} optionally with copy it contents on the
+ standard input.
\item[{\tt -load-vernac-object} {\em file}]\
Load \Coq~compiled file {\em file}{\tt .vo}
-%\item[{\tt -preload} {\em file}]\ \\
-%Add {\em file}{\tt .vo} to the files to be loaded and opened
-%before making the initial state.
-%
\item[{\tt -require} {\em file}]\
Load \Coq~compiled file {\em file}{\tt .vo} and import it ({\tt
Require} {\em file}).
-\item[{\tt -compile} {\em file}]\
+\item[{\tt -compile} {\em file},{\tt -compile-verbose} {\em file}, {\tt -batch}]\
- This compiles file {\em file}{\tt .v} into {\em file}{\tt .vo}.
- This option implies options {\tt -batch} and {\tt -silent}. It is
- only available for {\tt coqtop}.
+ {\tt coqtop} options only used internally by {\tt coqc}.
-\item[{\tt -compile-verbose} {\em file}]\
-
- This compiles file {\em file}{\tt .v} into {\em file}{\tt .vo} with
- a copy of the contents of the file on standard input.
- This option implies options {\tt -batch} and {\tt -silent}. It is
- only available for {\tt coqtop}.
+ This compiles file {\em file}{\tt .v} into {\em file}{\tt .vo} without/with a
+ copy of the contents of the file on standard input. This option implies options
+ {\tt -batch} (exit just after arguments parsing). It is only
+ available for {\tt coqtop}.
\item[{\tt -verbose}]\
This option is only for {\tt coqc}. It tells to compile the file with
a copy of its contents on standard input.
-\item[{\tt -batch}]\
-
- Batch mode : exit just after arguments parsing. This option is only
- used by {\tt coqc}.
-
%Mostly unused in the code
%\item[{\tt -debug}]\
%
@@ -241,13 +182,23 @@ The following command-line options are recognized by the commands {\tt
This option is for use with {\tt coqc}. It tells \Coq\ to export on
the standard output the content of the compiled file into XML format.
+\item[{\tt -with-geoproof} (yes|no)]\
+
+ Activate or not special functions for Geoproof within Coqide (default is yes).
+
+\item[{\tt -beautify}]\
+
+ While compiling {\em file}, pretty prints each command just after having parsing
+ it in {\em file}{\tt .beautified} in order to get old-fashion
+ syntax/definitions/notations.
+
\item[{\tt -quality}]
Improve the legibility of the proof terms produced by some tactics.
-\item[{\tt -emacs}]\
+\item[{\tt -emacs}, {\tt -ide-slave}]\
- Tells \Coq\ it is executed under Emacs.
+ Start a special main loop to communicate with ide.
\item[{\tt -impredicative-set}]\
@@ -256,11 +207,16 @@ The following command-line options are recognized by the commands {\tt
some standard axioms of classical mathematics such as the functional
axiom of choice or the principle of description
-\item[{\tt -dump-glob} {\em file}]\
+\item[{\tt -compat} {\em version}] \null
+
+ Attempt to maintain some of the incompatible changes in their {\em version}
+ behavior.
+
+\item[{\tt -dump-glob} {\em file}]\
This dumps references for global names in file {\em file}
(to be used by coqdoc, see~\ref{coqdoc})
-
+
\item[{\tt -dont-load-proofs}]\
Warning: this is an unsafe mode.
@@ -283,6 +239,8 @@ The following command-line options are recognized by the commands {\tt
Proofs of opaque theorems are loaded in memory as soon as the
corresponding {\tt Require} is done. This used to be Coq's default behavior.
+\item[{\tt -no-hash-consing}] \null
+
\item[{\tt -vm}]\
This activates the use of the bytecode-based conversion algorithm
@@ -290,18 +248,20 @@ The following command-line options are recognized by the commands {\tt
\item[{\tt -image} {\em file}]\
- This option sets the binary image to be used to be {\em file}
+ This option sets the binary image to be used by {\tt coqc} to be {\em file}
instead of the standard one. Not of general use.
\item[{\tt -bindir} {\em directory}]\
Set for {\tt coqc} the directory containing \Coq\ binaries.
It is equivalent to do \texttt{export COQBIN=}{\em directory}
- before lauching {\tt coqc}.
+ before launching {\tt coqc}.
-\item[{\tt -where}]\
+\item[{\tt -where}, {\tt -config}, {\tt -filteropts}]\
- Print the \Coq's standard library location and exit.
+ Print the \Coq's standard library location or \Coq's binaries, dependencies,
+ libraries locations or the list of command line arguments that {\tt coqtop} has
+ recognize as options and exit.
\item[{\tt -v}]\
diff --git a/doc/refman/RefMan-ext.tex b/doc/refman/RefMan-ext.tex
index 2da5bec1..2c4985c1 100644
--- a/doc/refman/RefMan-ext.tex
+++ b/doc/refman/RefMan-ext.tex
@@ -5,6 +5,8 @@ the Gallina's syntax.
\section{Record types
\comindex{Record}
+\comindex{Inductive}
+\comindex{CoInductive}
\label{Record}}
The \verb+Record+ construction is a macro allowing the definition of
@@ -20,10 +22,13 @@ construction allows to define ``signatures''.
{\sentence} & ++= & {\record}\\
& & \\
{\record} & ::= &
- {\tt Record} {\ident} \zeroone{\binders} \zeroone{{\tt :} {\sort}} \verb.:=. \\
+ {\recordkw} {\ident} \zeroone{\binders} \zeroone{{\tt :} {\sort}} \verb.:=. \\
&& ~~~~\zeroone{\ident}
\verb!{! \zeroone{\nelist{\field}{;}} \verb!}! \verb:.:\\
& & \\
+{\recordkw} & ::= &
+ {\tt Record} $|$ {\tt Inductive} $|$ {\tt CoInductive}\\
+ & & \\
{\field} & ::= & {\name} \zeroone{\binders} : {\type} [ {\tt where} {\it notation} ] \\
& $|$ & {\name} \zeroone{\binders} {\typecstr} := {\term}
\end{tabular}
@@ -149,6 +154,13 @@ Eval compute in half.(Rat_bottom_cond).
Reset Initial.
\end{coq_eval}
+Records defined with the {\tt Record} keyword are not allowed to be
+recursive (references to the record's name in the type of its field
+raises an error). To define recursive records, one can use the {\tt
+ Inductive} and {\tt CoInductive} keywords, resulting in an inductive
+or co-inductive record. A \emph{caveat}, however, is that records
+cannot appear in mutually inductive (or co-inductive) definitions.
+
\begin{Warnings}
\item {\tt Warning: {\ident$_i$} cannot be defined.}
@@ -167,10 +179,16 @@ Reset Initial.
\begin{ErrMsgs}
-\item \errindex{A record cannot be recursive}
+\item \errindex{Records declared with the keyword Record or Structure cannot be recursive.}
- The record name {\ident} appears in the type of its fields.
-
+ The record name {\ident} appears in the type of its fields, but uses
+ the keyword {\tt Record}. Use the keyword {\tt Inductive} or {\tt
+ CoInductive} instead.
+\item \errindex{Cannot handle mutually (co)inductive records.}
+
+ Records cannot be defined as part of mutually inductive (or
+ co-inductive) definitions, whether with records only or mixed with
+ standard definitions.
\item During the definition of the one-constructor inductive
definition, all the errors of inductive definitions, as described in
Section~\ref{gal_Inductive_Definitions}, may also occur.
@@ -1557,8 +1575,23 @@ but succeeds in
Check Prop = nat.
\end{coq_example*}
+\subsection{Deactivation of implicit arguments for parsing}
+\comindex{Set Parsing Explicit}
+\comindex{Unset Parsing Explicit}
+Use of implicit arguments can be deactivated by issuing the command:
+\begin{quote}
+{\tt Set Parsing Explicit.}
+\end{quote}
+In this case, all arguments of constants, inductive types,
+constructors, etc, including the arguments declared as implicit, have
+to be given as if none arguments were implicit. By symmetry, this also
+affects printing. To restore parsing and normal printing of implicit
+arguments, use:
+\begin{quote}
+{\tt Set Parsing Explicit.}
+\end{quote}
\subsection{Canonical structures
\comindex{Canonical Structure}}
diff --git a/doc/refman/RefMan-gal.tex b/doc/refman/RefMan-gal.tex
index 204fa90d..7e4be79d 100644
--- a/doc/refman/RefMan-gal.tex
+++ b/doc/refman/RefMan-gal.tex
@@ -1589,11 +1589,11 @@ These commands are synonyms of \texttt{Theorem {\ident} \zeroone{\binders} : {\t
This command is useful for theorems that are proved by simultaneous
induction over a mutually inductive assumption, or that assert mutually
-dependent statements in some mutual coinductive type. It is equivalent
+dependent statements in some mutual co-inductive type. It is equivalent
to {\tt Fixpoint} or {\tt CoFixpoint}
(see Section~\ref{CoFixpoint}) but using tactics to build the proof of
the statements (or the body of the specification, depending on the
-point of view). The inductive or coinductive types on which the
+point of view). The inductive or co-inductive types on which the
induction or coinduction has to be done is assumed to be non ambiguous
and is guessed by the system.
diff --git a/doc/refman/RefMan-ltac.tex b/doc/refman/RefMan-ltac.tex
index 38ad9aa8..d7f00584 100644
--- a/doc/refman/RefMan-ltac.tex
+++ b/doc/refman/RefMan-ltac.tex
@@ -946,7 +946,8 @@ simple newline: & go to the next step\\
h: & get help\\
x: & exit current evaluation\\
s: & continue current evaluation without stopping\\
-r$n$: & advance $n$ steps further\\
+r $n$: & advance $n$ steps further\\
+r {\qstring}: & advance up to the next call to ``{\tt idtac} {\qstring}''\\
\end{tabular}
\endinput
diff --git a/doc/refman/RefMan-oth.tex b/doc/refman/RefMan-oth.tex
index 5b1ad198..f8181143 100644
--- a/doc/refman/RefMan-oth.tex
+++ b/doc/refman/RefMan-oth.tex
@@ -743,45 +743,70 @@ 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}.
-\section{States and Reset}
+\section{Backtracking}
+
+The backtracking commands described in this section can only be used
+interactively, they cannot be part of a vernacular file loaded via
+{\tt Load} or compiled by {\tt coqc}.
\subsection[\tt Reset \ident.]{\tt Reset \ident.\comindex{Reset}}
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
+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.
\begin{ErrMsgs}
\item \ident: \errindex{no such entry}
\end{ErrMsgs}
+\begin{Variants}
+ \item {\tt Reset Initial.}\comindex{Reset Initial}\\
+ Goes back to the initial state, just after the start of the
+ interactive session.
+\end{Variants}
+
\subsection[\tt Back.]{\tt Back.\comindex{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 {\tt Require} and {\tt Load} can be undone, but
-not {\tt Check} and {\tt Locate}). Commands read from a vernacular
-file are considered as a single command.
+command. Commands read from a vernacular file via a {\tt Load} are
+considered as a single command. Proof managment commands
+are also handled by this command (see Chapter~\ref{Proof-handling}).
+For that, {\tt Back} may have to undo more than one command in order
+to reach a state where the proof managment information is available.
+For instance, when the last command is a {\tt Qed}, the managment
+information about the closed proof has been discarded. In this case,
+{\tt Back} will then undo all the proof steps up to the statement of
+this proof.
\begin{Variants}
\item {\tt Back $n$} \\
- Undoes $n$ vernacular commands.
+ Undoes $n$ vernacular commands. As for {\tt Back}, some extra
+ commands may be undone in order to reach an adequate state.
+ For instance {\tt Back n} will not re-enter a closed proof,
+ but rather go just before that proof.
\end{Variants}
\begin{ErrMsgs}
-\item \errindex{Reached begin of command history} \\
- Happens when there is vernacular command to undo.
+\item \errindex{Invalid backtrack} \\
+ The user wants to undo more commands than available in the history.
\end{ErrMsgs}
-\subsection[\tt Backtrack $\num_1$ $\num_2$ $\num_3$.]{\tt Backtrack $\num_1$ $\num_2$ $\num_3$.\comindex{Backtrack}}
+\subsection[\tt BackTo $\num$.]{\tt BackTo $\num$.\comindex{BackTo}}
+\label{sec:statenums}
+
+This command brings back the system to the state labelled $\num$,
+forgetting the effect of all commands executed after this state.
+The state label is an integer which grows after each successful command.
+It is displayed in the prompt when in \texttt{-emacs} mode.
+Just as {\tt Back} (see above), the {\tt BackTo} command now handles
+proof states. For that, it may have to undo some
+extra commands and end on a state $\num' \leq \num$ if necessary.
-This command is dedicated for the use in graphical interfaces. It
-allows to backtrack to a particular \emph{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~\ref{Proof-handling}). The three numbers
-$\num_1$, $\num_2$ and $\num_3$ represent the following:
+\begin{Variants}
+\item {\tt Backtrack $\num_1$ $\num_2$ $\num_3$}.\comindex{Backtrack}\\
+ {\tt Backtrack} is a \emph{deprecated} form of {\tt BackTo} which
+ allows to explicitely manipulate the proof environment. The three
+ numbers $\num_1$, $\num_2$ and $\num_3$ represent the following:
\begin{itemize}
\item $\num_3$: Number of \texttt{Abort} to perform, i.e. the number
of currently opened nested proofs that must be canceled (see
@@ -789,75 +814,16 @@ $\num_1$, $\num_2$ and $\num_3$ represent the following:
\item $\num_2$: \emph{Proof state number} to unbury once aborts have
been done. Coq will compute the number of \texttt{Undo} to perform
(see Chapter~\ref{Proof-handling}).
-\item $\num_1$: Environment state number to unbury, Coq will compute
- the number of \texttt{Back} to perform.
-\end{itemize}
-
-
-\subsubsection{How to get state numbers?}
-\label{sec:statenums}
-
-
-Notice that when in \texttt{-emacs} mode, \Coq\ displays the current
-proof and environment state numbers in the prompt. More precisely the
-prompt in \texttt{-emacs} mode is the following:
-
-\verb!<prompt>! \emph{$id_i$} \verb!<! $\num_1$
-\verb!|! $id_1$\verb!|!$id_2$\verb!|!\dots\verb!|!$id_n$
-\verb!|! $\num_2$ \verb!< </prompt>!
-
-Where:
-
-\begin{itemize}
-\item \emph{$id_i$} is the name of the current proof (if there is
- one, otherwise \texttt{Coq} is displayed, see
-Chapter~\ref{Proof-handling}).
-\item $\num_1$ is the environment state number after the last
- command.
-\item $\num_2$ is the proof state number after the last
- command.
-\item $id_1$ $id_2$ {\dots} $id_n$ are the currently opened proof names
- (order not significant).
+\item $\num_1$: State label to reach, as for {\tt BackTo}.
\end{itemize}
-
-It is then possible to compute the \texttt{Backtrack} command to
-unbury the state corresponding to a particular prompt. For example,
-suppose the current prompt is:
-
-\verb!<! goal4 \verb!<! 35
-\verb!|!goal1\verb!|!goal4\verb!|!goal3\verb!|!goal2\verb!|!
-\verb!|!8 \verb!< </prompt>!
-
-and we want to backtrack to a state labeled by:
-
-\verb!<! goal2 \verb!<! 32
-\verb!|!goal1\verb!|!goal2
-\verb!|!12 \verb!< </prompt>!
-
-We have to perform \verb!Backtrack 32 12 2! , i.e. perform 2
-\texttt{Abort}s (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 \texttt{Resume} or
-\texttt{Suspend} commands).
-
-\begin{Variants}
-\item {\tt BackTo n}. \comindex{BackTo}\\
- Is a more basic form of \texttt{Backtrack} where only the first
- argument (global environment number) is given, no \texttt{abort} and
- no \texttt{Undo} is performed.
\end{Variants}
-\subsection[\tt Restore State \str.]{\tt Restore State \str.\comindex{Restore State}}
- Restores the state contained in the file \str.
+\begin{ErrMsgs}
+\item \errindex{Invalid backtrack} \\
+ The destination state label is unknown.
+\end{ErrMsgs}
-\begin{Variants}
-\item {\tt Restore State \ident}\\
- Equivalent to {\tt Restore State "}{\ident}{\tt .coq"}.
-\item {\tt Reset Initial.}\comindex{Reset Initial}\\
- Goes back to the initial state (like after the command {\tt coqtop},
- when the interactive session began). This command is only available
- interactively.
-\end{Variants}
+\section{State files}
\subsection[\tt Write State \str.]{\tt Write State \str.\comindex{Write State}}
Writes the current state into a file \str{} for
@@ -870,6 +836,14 @@ use in a further session. This file can be given as the {\tt
The state is saved in the current directory (see Section~\ref{Pwd}).
\end{Variants}
+\subsection[\tt Restore State \str.]{\tt Restore State \str.\comindex{Restore State}}
+ Restores the state contained in the file \str.
+
+\begin{Variants}
+\item {\tt Restore State \ident}\\
+ Equivalent to {\tt Restore State "}{\ident}{\tt .coq"}.
+\end{Variants}
+
\section{Quitting and debugging}
\subsection[\tt Quit.]{\tt Quit.\comindex{Quit}}
diff --git a/doc/refman/RefMan-pro.tex b/doc/refman/RefMan-pro.tex
index e5dc669d..ca3a9cc9 100644
--- a/doc/refman/RefMan-pro.tex
+++ b/doc/refman/RefMan-pro.tex
@@ -34,9 +34,6 @@ isomorphism} \cite{How80,Bar91,Gir89,Hue89}, \Coq~ stores proofs as
terms of {\sc Cic}. Those terms are called {\em proof
terms}\index{Proof term}.
-It is possible to edit several proofs in parallel: see Section
-\ref{Resume}.
-
\ErrMsg When one attempts to use a proof editing command out of the
proof editing mode, \Coq~ raises the error message : \errindex{No focused
proof}.
@@ -174,35 +171,6 @@ proof was edited.
\end{Variants}
%%%%
-\subsection[\tt Suspend.]{\tt Suspend.\comindex{Suspend}}
-
-This command applies in proof editing mode. It switches back to the
-\Coq\ toplevel, but without canceling the current proofs.
-
-%%%%
-\subsection[\tt Resume.]{\tt Resume.\comindex{Resume}\label{Resume}}
-
-This commands switches back to the editing of the last edited proof.
-
-\begin{ErrMsgs}
-\item \errindex{No proof-editing in progress}
-\end{ErrMsgs}
-
-\begin{Variants}
-
-\item {\tt Resume {\ident}.}
-
- Restarts the editing of the proof named {\ident}. This can be used
- to navigate between currently edited proofs.
-
-\end{Variants}
-
-\begin{ErrMsgs}
-\item \errindex{No such proof}
-\end{ErrMsgs}
-
-
-%%%%
\subsection[\tt Existential {\num} := {\term}.]{\tt Existential {\num} := {\term}.\comindex{Existential}
\label{Existential}}
@@ -216,7 +184,14 @@ existential variables remain. To instantiate existential variables
during proof edition, you should use the tactic {\tt instantiate}.
\SeeAlso {\tt instantiate (\num:= \term).} in Section~\ref{instantiate}.
+\SeeAlso {\tt Grab Existential Variables.} below.
+
+\subsection[\tt Grab Existential Variables.]{\tt Grab Existential Variables.\comindex{Grab Existential Variables}
+\label{GrabEvars}}
+This command can be run when a proof has no more goal to be solved but has remaining
+uninstantiated existential variables. It takes every uninstantiated existential variable
+and turns it into a goal.
%%%%%%%%
\section{Navigation in the proof tree}
@@ -259,7 +234,45 @@ This focuses the attention on the $\num^{th}$ subgoal to prove.
\end{Variant}
\subsection[\tt Unfocus.]{\tt Unfocus.\comindex{Unfocus}}
-Turns off the focus mode.
+This command restores to focus the goal that were suspended by the
+last {\tt Focus} command.
+
+\subsection[\tt Unfocused.]{\tt Unfocused.\comindex{Unfocused}}
+Succeeds in the proof is fully unfocused, fails is there are some
+goals out of focus.
+
+\subsection[\tt \{ \textrm{and} \}]{\tt \{ \textrm{and} \}\comindex{\{}\comindex{\}}}
+The command {\tt \{} (without a terminating period) focuses on the
+first goal, much like {\tt Focus.} does, however, the subproof can
+only be unfocused when it has been fully solved (\emph{i.e.} when
+there is no focused goal left). Unfocusing is then handled by {\tt \}}
+(again, without a terminating period). See also example in next section.
+
+\subsection[Bullets]{Bullets\comindex{+ (command)}\comindex{- (command)}\comindex{* (command)}\index{Bullets}}
+Alternatively to {\tt \{} and {\tt \}}, proofs can be structured with
+bullets. The use of a bullet for the first time focuses on the first
+goal, the same bullet cannot be used again until the subproof in
+completed, then it focuses on the next goal. Different bullets can be
+used to nest levels. The scope of bullet does not go beyond enclosing
+{\tt \{} and {\tt \}}, so bullets can be reused as further nesting
+level provided they are delimited by these. Available bullets are
+{\tt -}, {\tt +} and {\tt *} (without a terminating period).
+
+The following example script illustrates all these features:
+\begin{coq_example*}
+Goal (((True/\True)/\True)/\True)/\True.
+Proof.
+ split.
+ - split.
+ + split.
+ * { split.
+ - trivial.
+ - trivial.
+ }
+ * trivial.
+ + trivial.
+ - trivial.
+\end{coq_example*}
\section{Requesting information}
diff --git a/doc/refman/RefMan-sch.tex b/doc/refman/RefMan-sch.tex
new file mode 100644
index 00000000..707ee824
--- /dev/null
+++ b/doc/refman/RefMan-sch.tex
@@ -0,0 +1,418 @@
+\chapter{Proof schemes}
+
+\section{Generation of induction principles with {\tt Scheme}}
+\label{Scheme}
+\index{Schemes}
+\comindex{Scheme}
+
+The {\tt Scheme} command is a high-level tool for generating
+automatically (possibly mutual) induction principles for given types
+and sorts. Its syntax follows the schema:
+\begin{quote}
+{\tt Scheme {\ident$_1$} := Induction for \ident'$_1$ Sort {\sort$_1$} \\
+ with\\
+ \mbox{}\hspace{0.1cm} \dots\\
+ with {\ident$_m$} := Induction for {\ident'$_m$} Sort
+ {\sort$_m$}}
+\end{quote}
+where \ident'$_1$ \dots\ \ident'$_m$ are different inductive type
+identifiers belonging to the same package of mutual inductive
+definitions. This command generates {\ident$_1$}\dots{} {\ident$_m$}
+to be mutually recursive definitions. Each term {\ident$_i$} proves a
+general principle of mutual induction for objects in type {\term$_i$}.
+
+\begin{Variants}
+\item {\tt Scheme {\ident$_1$} := Minimality for \ident'$_1$ Sort {\sort$_1$} \\
+ with\\
+ \mbox{}\hspace{0.1cm} \dots\ \\
+ with {\ident$_m$} := Minimality for {\ident'$_m$} Sort
+ {\sort$_m$}}
+
+ Same as before but defines a non-dependent elimination principle more
+ natural in case of inductively defined relations.
+
+\item {\tt Scheme Equality for \ident$_1$\comindex{Scheme Equality}}
+
+ Tries to generate a boolean equality and a proof of the
+ decidability of the usual equality. If \ident$_i$ involves
+ some other inductive types, their equality has to be defined first.
+
+\item {\tt Scheme Induction for \ident$_1$ Sort {\sort$_1$} \\
+ with\\
+ \mbox{}\hspace{0.1cm} \dots\\
+ with Induction for {\ident$_m$} Sort
+ {\sort$_m$}}
+
+ If you do not provide the name of the schemes, they will be automatically
+ computed from the sorts involved (works also with Minimality).
+
+\end{Variants}
+\label{Scheme-examples}
+
+\firstexample
+\example{Induction scheme for \texttt{tree} and \texttt{forest}}
+
+The definition of principle of mutual induction for {\tt tree} and
+{\tt forest} over the sort {\tt Set} is defined by the command:
+
+\begin{coq_eval}
+Reset Initial.
+Variables A B : Set.
+\end{coq_eval}
+
+\begin{coq_example*}
+Inductive tree : Set :=
+ node : A -> forest -> tree
+with forest : Set :=
+ | leaf : B -> forest
+ | cons : tree -> forest -> forest.
+
+Scheme tree_forest_rec := Induction for tree Sort Set
+ with forest_tree_rec := Induction for forest Sort Set.
+\end{coq_example*}
+
+You may now look at the type of {\tt tree\_forest\_rec}:
+
+\begin{coq_example}
+Check tree_forest_rec.
+\end{coq_example}
+
+This principle involves two different predicates for {\tt trees} and
+{\tt forests}; it also has three premises each one corresponding to a
+constructor of one of the inductive definitions.
+
+The principle {\tt forest\_tree\_rec} shares exactly the same
+premises, only the conclusion now refers to the property of forests.
+
+\begin{coq_example}
+Check forest_tree_rec.
+\end{coq_example}
+
+\example{Predicates {\tt odd} and {\tt even} on naturals}
+
+Let {\tt odd} and {\tt even} be inductively defined as:
+
+% Reset Initial.
+\begin{coq_eval}
+Open Scope nat_scope.
+\end{coq_eval}
+
+\begin{coq_example*}
+Inductive odd : nat -> Prop :=
+ oddS : forall n:nat, even n -> odd (S n)
+with even : nat -> Prop :=
+ | evenO : even 0
+ | evenS : forall n:nat, odd n -> even (S n).
+\end{coq_example*}
+
+The following command generates a powerful elimination
+principle:
+
+\begin{coq_example}
+Scheme odd_even := Minimality for odd Sort Prop
+ with even_odd := Minimality for even Sort Prop.
+\end{coq_example}
+
+The type of {\tt odd\_even} for instance will be:
+
+\begin{coq_example}
+Check odd_even.
+\end{coq_example}
+
+The type of {\tt even\_odd} shares the same premises but the
+conclusion is {\tt (n:nat)(even n)->(Q n)}.
+
+\subsection{Automatic declaration of schemes}
+\comindex{Set Equality Schemes}
+\comindex{Set Elimination Schemes}
+
+It is possible to deactivate the automatic declaration of the induction
+ principles when defining a new inductive type with the
+ {\tt Unset Elimination Schemes} command. It may be
+reactivated at any time with {\tt Set Elimination Schemes}.
+\\
+
+You can also activate the automatic declaration of those boolean equalities
+(see the second variant of {\tt Scheme}) with the {\tt Set Equality Schemes}
+ command. However you have to be careful with this option since
+\Coq~ may now reject well-defined inductive types because it cannot compute
+a boolean equality for them.
+
+\subsection{\tt Combined Scheme}
+\label{CombinedScheme}
+\comindex{Combined Scheme}
+
+The {\tt Combined Scheme} command is a tool for combining
+induction principles generated by the {\tt Scheme} command.
+Its syntax follows the schema :
+\begin{quote}
+{\tt Combined Scheme {\ident$_0$} from {\ident$_1$}, .., {\ident$_n$}}
+\end{quote}
+where
+\ident$_1$ \ldots \ident$_n$ are different inductive principles that must belong to
+the same package of mutual inductive principle definitions. This command
+generates {\ident$_0$} to be the conjunction of the principles: it is
+built from the common premises of the principles and concluded by the
+conjunction of their conclusions.
+
+\Example
+We can define the induction principles for trees and forests using:
+\begin{coq_example}
+Scheme tree_forest_ind := Induction for tree Sort Prop
+ with forest_tree_ind := Induction for forest Sort Prop.
+\end{coq_example}
+
+Then we can build the combined induction principle which gives the
+conjunction of the conclusions of each individual principle:
+\begin{coq_example}
+Combined Scheme tree_forest_mutind from tree_forest_ind, forest_tree_ind.
+\end{coq_example}
+
+The type of {\tt tree\_forest\_mutrec} will be:
+\begin{coq_example}
+Check tree_forest_mutind.
+\end{coq_example}
+
+\section{Generation of induction principles with {\tt Functional Scheme}}
+\label{FunScheme}
+\comindex{Functional Scheme}
+
+The {\tt Functional Scheme} command is a high-level experimental
+tool for generating automatically induction principles
+corresponding to (possibly mutually recursive) functions. Its
+syntax follows the schema:
+\begin{quote}
+{\tt Functional Scheme {\ident$_1$} := Induction for \ident'$_1$ Sort {\sort$_1$} \\
+ with\\
+ \mbox{}\hspace{0.1cm} \dots\ \\
+ with {\ident$_m$} := Induction for {\ident'$_m$} Sort
+ {\sort$_m$}}
+\end{quote}
+where \ident'$_1$ \dots\ \ident'$_m$ are different mutually defined function
+names (they must be in the same order as when they were defined).
+This command generates the induction principles
+\ident$_1$\dots\ident$_m$, following the recursive structure and case
+analyses of the functions \ident'$_1$ \dots\ \ident'$_m$.
+
+\Rem
+There is a difference between obtaining an induction scheme by using
+\texttt{Functional Scheme} on a function defined by \texttt{Function}
+or not. Indeed \texttt{Function} generally produces smaller
+principles, closer to the definition written by the user.
+
+\firstexample
+\example{Induction scheme for \texttt{div2}}
+\label{FunScheme-examples}
+
+We define the function \texttt{div2} as follows:
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+
+\begin{coq_example*}
+Require Import Arith.
+Fixpoint div2 (n:nat) : nat :=
+ match n with
+ | O => 0
+ | S O => 0
+ | S (S n') => S (div2 n')
+ end.
+\end{coq_example*}
+
+The definition of a principle of induction corresponding to the
+recursive structure of \texttt{div2} is defined by the command:
+
+\begin{coq_example}
+Functional Scheme div2_ind := Induction for div2 Sort Prop.
+\end{coq_example}
+
+You may now look at the type of {\tt div2\_ind}:
+
+\begin{coq_example}
+Check div2_ind.
+\end{coq_example}
+
+We can now prove the following lemma using this principle:
+
+\begin{coq_example*}
+Lemma div2_le' : forall n:nat, div2 n <= n.
+intro n.
+ pattern n , (div2 n).
+\end{coq_example*}
+
+\begin{coq_example}
+apply div2_ind; intros.
+\end{coq_example}
+
+\begin{coq_example*}
+auto with arith.
+auto with arith.
+simpl; auto with arith.
+Qed.
+\end{coq_example*}
+
+We can use directly the \texttt{functional induction}
+(\ref{FunInduction}) tactic instead of the pattern/apply trick:
+\tacindex{functional induction}
+
+\begin{coq_example*}
+Reset div2_le'.
+Lemma div2_le : forall n:nat, div2 n <= n.
+intro n.
+\end{coq_example*}
+
+\begin{coq_example}
+functional induction (div2 n).
+\end{coq_example}
+
+\begin{coq_example*}
+auto with arith.
+auto with arith.
+auto with arith.
+Qed.
+\end{coq_example*}
+
+\Rem There is a difference between obtaining an induction scheme for a
+function by using \texttt{Function} (see Section~\ref{Function}) and by
+using \texttt{Functional Scheme} after a normal definition using
+\texttt{Fixpoint} or \texttt{Definition}. See \ref{Function} for
+details.
+
+
+\example{Induction scheme for \texttt{tree\_size}}
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+
+We define trees by the following mutual inductive type:
+
+\begin{coq_example*}
+Variable A : Set.
+Inductive tree : Set :=
+ node : A -> forest -> tree
+with forest : Set :=
+ | empty : forest
+ | cons : tree -> forest -> forest.
+\end{coq_example*}
+
+We define the function \texttt{tree\_size} that computes the size
+of a tree or a forest. Note that we use \texttt{Function} which
+generally produces better principles.
+
+\begin{coq_example*}
+Function tree_size (t:tree) : nat :=
+ match t with
+ | node A f => S (forest_size f)
+ end
+ with forest_size (f:forest) : nat :=
+ match f with
+ | empty => 0
+ | cons t f' => (tree_size t + forest_size f')
+ end.
+\end{coq_example*}
+
+\Rem \texttt{Function} generates itself non mutual induction
+principles {\tt tree\_size\_ind} and {\tt forest\_size\_ind}:
+
+\begin{coq_example}
+Check tree_size_ind.
+\end{coq_example}
+
+The definition of mutual induction principles following the recursive
+structure of \texttt{tree\_size} and \texttt{forest\_size} is defined
+by the command:
+
+\begin{coq_example*}
+Functional Scheme tree_size_ind2 := Induction for tree_size Sort Prop
+with forest_size_ind2 := Induction for forest_size Sort Prop.
+\end{coq_example*}
+
+You may now look at the type of {\tt tree\_size\_ind2}:
+
+\begin{coq_example}
+Check tree_size_ind2.
+\end{coq_example}
+
+\section{Generation of inversion principles with \tt Derive Inversion}
+\label{Derive-Inversion}
+\comindex{Derive Inversion}
+
+The syntax of {\tt Derive Inversion} follows the schema:
+\begin{quote}
+{\tt Derive Inversion {\ident} with forall
+ $(\vec{x} : \vec{T})$, $I~\vec{t}$ Sort \sort}
+\end{quote}
+
+This command generates an inversion principle for the
+\texttt{inversion \dots\ using} tactic.
+\tacindex{inversion \dots\ using}
+Let $I$ be an inductive predicate and $\vec{x}$ the variables
+occurring in $\vec{t}$. This command generates and stocks the
+inversion lemma for the sort \sort~ corresponding to the instance
+$\forall (\vec{x}:\vec{T}), I~\vec{t}$ with the name {\ident} in the {\bf
+global} environment. When applied, it is equivalent to having inverted
+the instance with the tactic {\tt inversion}.
+
+\begin{Variants}
+\item \texttt{Derive Inversion\_clear {\ident} with forall
+ $(\vec{x}:\vec{T})$, $I~\vec{t}$ Sort \sort}\\
+ \comindex{Derive Inversion\_clear}
+ When applied, it is equivalent to having
+ inverted the instance with the tactic \texttt{inversion}
+ replaced by the tactic \texttt{inversion\_clear}.
+\item \texttt{Derive Dependent Inversion {\ident} with forall
+ $(\vec{x}:\vec{T})$, $I~\vec{t}$ Sort \sort}\\
+ \comindex{Derive Dependent Inversion}
+ When applied, it is equivalent to having
+ inverted the instance with the tactic \texttt{dependent inversion}.
+\item \texttt{Derive Dependent Inversion\_clear {\ident} with forall
+ $(\vec{x}:\vec{T})$, $I~\vec{t}$ Sort \sort}\\
+ \comindex{Derive Dependent Inversion\_clear}
+ When applied, it is equivalent to having
+ inverted the instance with the tactic \texttt{dependent inversion\_clear}.
+\end{Variants}
+
+\Example
+
+Let us consider the relation \texttt{Le} over natural numbers and the
+following variable:
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+
+\begin{coq_example*}
+Inductive Le : nat -> nat -> Set :=
+ | LeO : forall n:nat, Le 0 n
+ | LeS : forall n m:nat, Le n m -> Le (S n) (S m).
+Variable P : nat -> nat -> Prop.
+\end{coq_example*}
+
+To generate the inversion lemma for the instance
+\texttt{(Le (S n) m)} and the sort \texttt{Prop}, we do:
+
+\begin{coq_example*}
+Derive Inversion_clear leminv with (forall n m:nat, Le (S n) m) Sort Prop.
+\end{coq_example*}
+
+\begin{coq_example}
+Check leminv.
+\end{coq_example}
+
+Then we can use the proven inversion lemma:
+
+\begin{coq_eval}
+Lemma ex : forall n m:nat, Le (S n) m -> P n m.
+intros.
+\end{coq_eval}
+
+\begin{coq_example}
+Show.
+\end{coq_example}
+
+\begin{coq_example}
+inversion H using leminv.
+\end{coq_example}
+
diff --git a/doc/refman/RefMan-syn.tex b/doc/refman/RefMan-syn.tex
index ea3d55f2..fd608f06 100644
--- a/doc/refman/RefMan-syn.tex
+++ b/doc/refman/RefMan-syn.tex
@@ -369,7 +369,7 @@ reserved. Hence their precedence and associativity cannot be changed.
\comindex{CoFixpoint {\ldots} where {\ldots}}
\comindex{Inductive {\ldots} where {\ldots}}}
-Thanks to reserved notations, the inductive, coinductive, recursive
+Thanks to reserved notations, the inductive, co-inductive, recursive
and corecursive definitions can benefit of customized notations. To do
this, insert a {\tt where} notation clause after the definition of the
(co)inductive type or (co)recursive term (or after the definition of
diff --git a/doc/refman/RefMan-tac.tex b/doc/refman/RefMan-tac.tex
index 198f8f30..b630772b 100644
--- a/doc/refman/RefMan-tac.tex
+++ b/doc/refman/RefMan-tac.tex
@@ -6,15 +6,15 @@
A deduction rule is a link between some (unique) formula, that we call
the {\em conclusion} and (several) formulas that we call the {\em
-premises}. Indeed, a deduction rule can be read in two ways. The first
-one has the shape: {\it ``if I know this and this then I can deduce
+premises}. A deduction rule can be read in two ways. The first
+one says: {\it ``if I know this and this then I can deduce
this''}. For instance, if I have a proof of $A$ and a proof of $B$
then I have a proof of $A \land B$. This is forward reasoning from
premises to conclusion. The other way says: {\it ``to prove this I
have to prove this and this''}. For instance, to prove $A \land B$, I
have to prove $A$ and I have to prove $B$. This is backward reasoning
-which proceeds from conclusion to premises. We say that the conclusion
-is {\em the goal}\index{goal} to prove and premises are {\em the
+from conclusion to premises. We say that the conclusion
+is the {\em goal}\index{goal} to prove and premises are the {\em
subgoals}\index{subgoal}. The tactics implement {\em backward
reasoning}. When applied to a goal, a tactic replaces this goal with
the subgoals it generates. We say that a tactic reduces a goal to its
@@ -25,29 +25,23 @@ Each (sub)goal is denoted with a number. The current goal is numbered
address a particular goal in the list by writing {\sl n:\tac} which
means {\it ``apply tactic {\tac} to goal number {\sl n}''}.
We can show the list of subgoals by typing {\tt Show} (see
-Section~\ref{Show}).
+Section~\ref{Show}).
Since not every rule applies to a given statement, every tactic cannot be
used to reduce any goal. In other words, before applying a tactic to a
given goal, the system checks that some {\em preconditions} are
satisfied. If it is not the case, the tactic raises an error message.
-Tactics are build from atomic tactics and tactic expressions (which
+Tactics are built from atomic tactics and tactic expressions (which
extends the folklore notion of tactical) to combine those atomic
tactics. This chapter is devoted to atomic tactics. The tactic
language will be described in Chapter~\ref{TacticLanguage}.
-There are, at least, three levels of atomic tactics. The simplest one
-implements basic rules of the logical framework. The second level is
-the one of {\em derived rules} which are built by combination of other
-tactics. The third one implements heuristics or decision procedures to
-build a complete proof of a goal.
-
\section{Invocation of tactics
\label{tactic-syntax}
\index{tactic@{\tac}}}
-A tactic is applied as an ordinary command. If the tactic does not
+A tactic is applied as an ordinary command. If the tactic is not meant to
address the first subgoal, the command may be preceded by the wished
subgoal number as shown below:
@@ -56,11 +50,107 @@ subgoal number as shown below:
& $|$ & {\tac} {\tt .}
\end{tabular}
-\section{Explicit proof as a term}
+\subsection{Bindings list
+\index{Binding list}
+\label{Binding-list}}
+
+Tactics that take a term as argument may also support a bindings list, so
+as to instantiate some parameters of the term by name or position.
+The general form of a term equipped with a bindings list is {\tt
+{\term} with {\bindinglist}} where {\bindinglist} may be of two
+different forms:
+
+\begin{itemize}
+\item In a bindings list of the form {\tt (\vref$_1$ := \term$_1$)
+ \dots\ (\vref$_n$ := \term$_n$)}, {\vref} is either an {\ident} or a
+ {\num}. The references are determined according to the type of
+ {\term}. If \vref$_i$ is an identifier, this identifier has to be
+ bound in the type of {\term} and the binding provides the tactic
+ with an instance for the parameter of this name. If \vref$_i$ is
+ some number $n$, this number denotes the $n$-th non dependent
+ premise of the {\term}, as determined by the type of {\term}.
+
+ \ErrMsg \errindex{No such binder}
+
+\item A bindings list can also be a simple list of terms {\tt
+ \term$_1$ \dots\ \term$_n$}. In that case the references to
+ which these terms correspond are determined by the tactic. In case
+ of {\tt induction}, {\tt destruct}, {\tt elim} and {\tt case} (see
+ Section~\ref{elim}) the terms have to provide instances for all the
+ dependent products in the type of \term\ while in the case of {\tt
+ apply}, or of {\tt constructor} and its variants, only instances for
+ the dependent products that are not bound in the conclusion of the
+ type are required.
+
+ \ErrMsg \errindex{Not the right number of missing arguments}
+\end{itemize}
+
+\subsection{Occurrences sets and occurrences clauses}
+\label{Occurrences clauses}
+\index{Occurrences clauses}
+
+An occurrences clause is a modifier to some tactics that obeys the
+following syntax:
+
+\begin{tabular}{lcl}
+{\occclause} & ::= & {\tt in} {\occgoalset} \\
+{\occgoalset} & ::= &
+ \zeroone{{\ident$_1$} \zeroone{\atoccurrences} {\tt ,} \\
+& & {\dots} {\tt ,}\\
+& & {\ident$_m$} \zeroone{\atoccurrences}}\\
+& & \zeroone{{\tt |-} \zeroone{{\tt *} \zeroone{\atoccurrences}}}\\
+& | &
+ {\tt *} {\tt |-} \zeroone{{\tt *} \zeroone{\atoccurrences}}\\
+& | &
+ {\tt *}\\
+{\atoccurrences} & ::= & {\tt at} {\occlist}\\
+{\occlist} & ::= & \zeroone{{\tt -}} {\num$_1$} \dots\ {\num$_n$}
+\end{tabular}
+
+The role of an occurrence clause is to select a set of occurrences of
+a {\term} in a goal. In the first case, the {{\ident$_i$}
+\zeroone{{\tt at} {\num$_1^i$} \dots\ {\num$_{n_i}^i$}}} parts
+indicate that occurrences have to be selected in the hypotheses named
+{\ident$_i$}. If no numbers are given for hypothesis {\ident$_i$},
+then all the occurrences of {\term} in the hypothesis are selected. If
+numbers are given, they refer to occurrences of {\term} when the term
+is printed using option {\tt Set Printing All} (see
+Section~\ref{SetPrintingAll}), counting from left to right. In
+particular, occurrences of {\term} in implicit arguments (see
+Section~\ref{Implicit Arguments}) or coercions (see
+Section~\ref{Coercions}) are counted.
+
+If a minus sign is given between {\tt at} and the list of occurrences,
+it negates the condition so that the clause denotes all the occurrences except
+the ones explicitly mentioned after the minus sign.
+
+As an exception to the left-to-right order, the occurrences in the
+{\tt return} subexpression of a {\tt match} are considered {\em
+before} the occurrences in the matched term.
+
+In the second case, the {\tt *} on the left of {\tt |-} means that
+all occurrences of {\term} are selected in every hypothesis.
+
+In the first and second case, if {\tt *} is mentioned on the right of
+{\tt |-}, the occurrences of the conclusion of the goal have to be
+selected. If some numbers are given, then only the occurrences denoted
+by these numbers are selected. In no numbers are given, all
+occurrences of {\term} in the goal are selected.
+
+Finally, the last notation is an abbreviation for {\tt * |- *}. Note
+also that {\tt |-} is optional in the first case when no {\tt *} is
+given.
+
+Here are some tactics that understand occurrences clauses:
+{\tt set}, {\tt remember}, {\tt induction}, {\tt destruct}.
+
+\SeeAlso~Sections~\ref{tactic:set}, \ref{Tac-induction}, \ref{SetPrintingAll}.
+
+\section{Applying theorems}
-\subsection{\tt exact \term
+\subsection{\tt exact \term}
\tacindex{exact}
-\label{exact}}
+\label{exact}
This tactic applies to any goal. It gives directly the exact proof
term of the goal. Let {\T} be our goal, let {\tt p} be a term of type
@@ -72,192 +162,497 @@ convertible (see Section~\ref{conv-rules}).
\end{ErrMsgs}
\begin{Variants}
- \item \texttt{eexact \term}\tacindex{eexact}
-
- This tactic behaves like \texttt{exact} but is able to handle terms with meta-variables.
+ \item \texttt{eexact \term}\tacindex{eexact}
+
+ This tactic behaves like \texttt{exact} but is able to handle terms
+ and goals with meta-variables.
\end{Variants}
+\subsection{\tt assumption}
+\tacindex{assumption}
+
+This tactic looks in the local context for an
+hypothesis which type is equal to the goal. If it is the case, the
+subgoal is proved. Otherwise, it fails.
+
+\begin{ErrMsgs}
+\item \errindex{No such assumption}
+\end{ErrMsgs}
+
+\begin{Variants}
+\tacindex{eassumption}
+ \item \texttt{eassumption}
+
+ This tactic behaves like \texttt{assumption} but is able to handle
+ goals with meta-variables.
-\subsection{\tt refine \term
+\end{Variants}
+
+\subsection{\tt refine \term}
\tacindex{refine}
\label{refine}
-\index{?@{\texttt{?}}}}
+\label{refine-example}
+\index{?@{\texttt{?}}}
-This tactic allows to give an exact proof but still with some
-holes. The holes are noted ``\texttt{\_}''.
+This tactic applies to any goal. It behaves like {\tt exact} with a big
+difference: the user can leave some holes (denoted by \texttt{\_} or
+{\tt (\_:\type)}) in the term. {\tt refine} will generate as
+many subgoals as there are holes in the term. The type of holes must be
+either synthesized by the system or declared by an
+explicit cast like \verb|(_:nat->Prop)|. This low-level
+tactic can be useful to advanced users.
+
+\Example
+
+\begin{coq_example*}
+Inductive Option : Set :=
+ | Fail : Option
+ | Ok : bool -> Option.
+\end{coq_example}
+\begin{coq_example}
+Definition get : forall x:Option, x <> Fail -> bool.
+refine
+ (fun x:Option =>
+ match x return x <> Fail -> bool with
+ | Fail => _
+ | Ok b => fun _ => b
+ end).
+intros; absurd (Fail = Fail); trivial.
+\end{coq_example}
+\begin{coq_example*}
+Defined.
+\end{coq_example*}
\begin{ErrMsgs}
-\item \errindex{invalid argument}:
- the tactic \texttt{refine} doesn't know what to do
+\item \errindex{invalid argument}:
+ the tactic \texttt{refine} does not know what to do
with the term you gave.
\item \texttt{Refine passed ill-formed term}: the term you gave is not
a valid proof (not easy to debug in general).
- This message may also occur in higher-level tactics, which call
+ This message may also occur in higher-level tactics that call
\texttt{refine} internally.
-\item \errindex{Cannot infer a term for this placeholder}
+\item \errindex{Cannot infer a term for this placeholder}:
there is a hole in the term you gave
which type cannot be inferred. Put a cast around it.
\end{ErrMsgs}
-An example of use is given in Section~\ref{refine-example}.
+\subsection{\tt apply \term}
+\tacindex{apply}
+\label{apply}
-\section{Basics
-\index{Typing rules}}
+This tactic applies to any goal. The argument {\term} is a term
+well-formed in the local context. The tactic {\tt apply} tries to
+match the current goal against the conclusion of the type of {\term}.
+If it succeeds, then the tactic returns as many subgoals as the number
+of non-dependent premises of the type of {\term}. If the conclusion of
+the type of {\term} does not match the goal {\em and} the conclusion
+is an inductive type isomorphic to a tuple type, then each component
+of the tuple is recursively matched to the goal in the left-to-right
+order.
-Tactics presented in this section implement the basic typing rules of
-{\CIC} given in Chapter~\ref{Cic}.
+The tactic {\tt apply} relies on first-order unification with
+dependent types unless the conclusion of the type of {\term} is of the
+form {\tt ($P$ $t_1$ \dots\ $t_n$)} with $P$ to be instantiated. In
+the latter case, the behavior depends on the form of the goal. If the
+goal is of the form {\tt (fun $x$ => $Q$)~$u_1$~\ldots~$u_n$} and the
+$t_i$ and $u_i$ unifies, then $P$ is taken to be {\tt (fun $x$ => $Q$)}.
+Otherwise, {\tt apply} tries to define $P$ by abstracting over
+$t_1$~\ldots ~$t_n$ in the goal. See {\tt pattern} in
+Section~\ref{pattern} to transform the goal so that it gets the form
+{\tt (fun $x$ => $Q$)~$u_1$~\ldots~$u_n$}.
-\subsection{{\tt assumption}
-\tacindex{assumption}}
+\begin{ErrMsgs}
+\item \errindex{Impossible to unify \dots\ with \dots}
-This tactic applies to any goal. It implements the
-``Var''\index{Typing rules!Var} rule given in
-Section~\ref{Typed-terms}. It looks in the local context for an
-hypothesis which type is equal to the goal. If it is the case, the
-subgoal is proved. Otherwise, it fails.
+ The {\tt apply}
+ tactic failed to match the conclusion of {\term} and the current goal.
+ You can help the {\tt apply} tactic by transforming your
+ goal with the {\tt change} or {\tt pattern} tactics (see
+ sections~\ref{pattern},~\ref{change}).
+
+\item \errindex{Unable to find an instance for the variables
+{\ident} \dots\ {\ident}}
+
+ This occurs when some instantiations of the premises of {\term} are not
+ deducible from the unification. This is the case, for instance, when
+ you want to apply a transitivity property. In this case, you have to
+ use one of the variants below:
-\begin{ErrMsgs}
-\item \errindex{No such assumption}
\end{ErrMsgs}
\begin{Variants}
-\tacindex{eassumption}
- \item \texttt{eassumption}
- This tactic behaves like \texttt{assumption} but is able to handle
- goals with meta-variables.
+\item{\tt apply {\term} with {\term$_1$} \dots\ {\term$_n$}}
+ \tacindex{apply \dots\ with}
-\end{Variants}
+ Provides {\tt apply} with explicit instantiations for all dependent
+ premises of the type of {\term} which do not occur in the conclusion
+ and consequently cannot be found by unification. Notice that
+ {\term$_1$} \dots\ {\term$_n$} must be given according to the order
+ of these dependent premises of the type of {\term}.
+ \ErrMsg \errindex{Not the right number of missing arguments}
-\subsection{\tt clear {\ident}
-\tacindex{clear}
-\label{clear}}
+\item{\tt apply {\term} with ({\vref$_1$} := {\term$_1$}) \dots\ ({\vref$_n$}
+ := {\term$_n$})}
-This tactic erases the hypothesis named {\ident} in the local context
-of the current goal. Then {\ident} is no more displayed and no more
-usable in the proof development.
+ This also provides {\tt apply} with values for instantiating
+ premises. Here, variables are referred by names and non-dependent
+ products by increasing numbers (see syntax in Section~\ref{Binding-list}).
-\begin{Variants}
+\item {\tt apply} {\term$_1$} {\tt ,} \ldots {\tt ,} {\term$_n$}
-\item {\tt clear {\ident$_1$} {\ldots} {\ident$_n$}}
-
- This is equivalent to {\tt clear {\ident$_1$}. {\ldots} clear
- {\ident$_n$}.}
-
-\item {\tt clearbody {\ident}}\tacindex{clearbody}
+ This is a shortcut for {\tt apply} {\term$_1$} {\tt ; [ ..~|}
+ \ldots~{\tt ; [ ..~| {\tt apply} {\term$_n$} ]} \ldots~{\tt ]}, i.e. for the
+ successive applications of {\term$_{i+1}$} on the last subgoal
+ generated by {\tt apply} {\term$_i$}, starting from the application
+ of {\term$_1$}.
- This tactic expects {\ident} to be a local definition then clears
- its body. Otherwise said, this tactic turns a definition into an
- assumption.
+\item {\tt eapply \term}\tacindex{eapply}\label{eapply}
-\item \texttt{clear - {\ident$_1$} {\ldots} {\ident$_n$}}
+ The tactic {\tt eapply} behaves like {\tt apply} but it does not fail
+ when no instantiations are deducible for some variables in the
+ premises. Rather, it turns these variables into so-called
+ existential variables which are variables still to instantiate. An
+ existential variable is identified by a name of the form {\tt ?$n$}
+ where $n$ is a number. The instantiation is intended to be found
+ later in the proof.
- This tactic clears all hypotheses except the ones depending in
- the hypotheses named {\ident$_1$} {\ldots} {\ident$_n$} and in the
- goal.
+\item {\tt simple apply {\term}} \tacindex{simple apply}
-\item \texttt{clear}
+ This behaves like {\tt apply} but it reasons modulo conversion only
+ on subterms that contain no variables to instantiate. For instance,
+ the following example does not succeed because it would require the
+ conversion of {\tt id ?1234} and {\tt O}.
- This tactic clears all hypotheses except the ones depending in
- goal.
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+\begin{coq_example*}
+Definition id (x : nat) := x.
+Hypothesis H : forall y, id y = y.
+Goal O = O.
+\end{coq_example*}
+\begin{coq_example}
+simple apply H.
+\end{coq_example}
-\item {\tt clear dependent \ident \tacindex{clear dependent}}
+ Because it reasons modulo a limited amount of conversion, {\tt
+ simple apply} fails quicker than {\tt apply} and it is then
+ well-suited for uses in used-defined tactics that backtrack often.
+ Moreover, it does not traverse tuples as {\tt apply} does.
- This clears the hypothesis \ident\ and all hypotheses
- which depend on it.
+\item \zeroone{{\tt simple}} {\tt apply} {\term$_1$} \zeroone{{\tt with}
+ {\bindinglist$_1$}} {\tt ,} \ldots {\tt ,} {\term$_n$} \zeroone{{\tt with}
+ {\bindinglist$_n$}}\\
+ \zeroone{{\tt simple}} {\tt eapply} {\term$_1$} \zeroone{{\tt with}
+ {\bindinglist$_1$}} {\tt ,} \ldots {\tt ,} {\term$_n$} \zeroone{{\tt with}
+ {\bindinglist$_n$}}
+
+ This summarizes the different syntaxes for {\tt apply} and {\tt eapply}.
+
+\item {\tt lapply {\term}} \tacindex{lapply}
+
+ This tactic applies to any goal, say {\tt G}. The argument {\term}
+ has to be well-formed in the current context, its type being
+ reducible to a non-dependent product {\tt A -> B} with {\tt B}
+ possibly containing products. Then it generates two subgoals {\tt
+ B->G} and {\tt A}. Applying {\tt lapply H} (where {\tt H} has type
+ {\tt A->B} and {\tt B} does not start with a product) does the same
+ as giving the sequence {\tt cut B. 2:apply H.} where {\tt cut} is
+ described below.
+
+ \Warning When {\term} contains more than one non
+ dependent product the tactic {\tt lapply} only takes into account the
+ first product.
\end{Variants}
+\Example
+Assume we have a transitive relation {\tt R} on {\tt nat}:
+\label{eapply-example}
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+\begin{coq_example*}
+Variable R : nat -> nat -> Prop.
+Hypothesis Rtrans : forall x y z:nat, R x y -> R y z -> R x z.
+Variables n m p : nat.
+Hypothesis Rnm : R n m.
+Hypothesis Rmp : R m p.
+\end{coq_example*}
+
+Consider the goal {\tt (R n p)} provable using the transitivity of
+{\tt R}:
+
+\begin{coq_example*}
+Goal R n p.
+\end{coq_example*}
+
+The direct application of {\tt Rtrans} with {\tt apply} fails because
+no value for {\tt y} in {\tt Rtrans} is found by {\tt apply}:
+
+%\begin{coq_eval}
+%Set Printing Depth 50.
+%(********** The following is not correct and should produce **********)
+%(**** Error: generated subgoal (R n ?17) has metavariables in it *****)
+%\end{coq_eval}
+\begin{coq_example}
+apply Rtrans.
+\end{coq_example}
+
+A solution is to apply {\tt (Rtrans n m p)} or {\tt (Rtrans n m)}.
+
+\begin{coq_example}
+apply (Rtrans n m p).
+\end{coq_example}
+
+\begin{coq_eval}
+Undo.
+\end{coq_eval}
+
+Note that {\tt n} can be inferred from the goal, so the following would
+work too.
+
+\begin{coq_example*}
+apply (Rtrans _ m).
+\end{coq_example*}
+\begin{coq_eval}
+Undo.
+\end{coq_eval}
+
+More elegantly, {\tt apply Rtrans with (y:=m)} allows to only mention
+the unknown {\tt m}:
+
+\begin{coq_example*}
+apply Rtrans with (y := m).
+\end{coq_example*}
+\begin{coq_eval}
+Undo.
+\end{coq_eval}
+
+Another solution is to mention the proof of {\tt (R x y)} in {\tt
+Rtrans} \ldots
+
+\begin{coq_example}
+apply Rtrans with (1 := Rnm).
+\end{coq_example}
+\begin{coq_eval}
+Undo.
+\end{coq_eval}
+
+\ldots or the proof of {\tt (R y z)}.
+
+\begin{coq_example}
+apply Rtrans with (2 := Rmp).
+\end{coq_example}
+\begin{coq_eval}
+Undo.
+\end{coq_eval}
+
+On the opposite, one can use {\tt eapply} which postpone the problem
+of finding {\tt m}. Then one can apply the hypotheses {\tt Rnm} and {\tt
+Rmp}. This instantiates the existential variable and completes the proof.
+
+\begin{coq_example}
+eapply Rtrans.
+apply Rnm.
+apply Rmp.
+\end{coq_example}
+
+\begin{coq_eval}
+Reset R.
+\end{coq_eval}
+
+\subsection{\tt apply {\term} in {\ident}}
+\tacindex{apply \dots\ in}
+
+This tactic applies to any goal. The argument {\term} is a term
+well-formed in the local context and the argument {\ident} is an
+hypothesis of the context. The tactic {\tt apply {\term} in {\ident}}
+tries to match the conclusion of the type of {\ident} against a
+non-dependent premise of the type of {\term}, trying them from right to
+left. If it succeeds, the statement of hypothesis {\ident} is
+replaced by the conclusion of the type of {\term}. The tactic also
+returns as many subgoals as the number of other non-dependent premises
+in the type of {\term} and of the non-dependent premises of the type
+of {\ident}. If the conclusion of the type of {\term} does not match
+the goal {\em and} the conclusion is an inductive type isomorphic to a
+tuple type, then the tuple is (recursively) decomposed and the first
+component of the tuple of which a non-dependent premise matches the
+conclusion of the type of {\ident}. Tuples are decomposed in a
+width-first left-to-right order (for instance if the type of {\tt H1}
+is a \verb=A <-> B= statement, and the type of {\tt H2} is \verb=A=
+then {\tt apply H1 in H2} transforms the type of {\tt H2} into {\tt
+ B}). The tactic {\tt apply} relies on first-order pattern-matching
+with dependent types.
+
\begin{ErrMsgs}
-\item \errindex{{\ident} not found}
-\item \errindexbis{{\ident} is used in the conclusion}{is used in the
- conclusion}
-\item \errindexbis{{\ident} is used in the hypothesis {\ident'}}{is
- used in the hypothesis}
+\item \errindex{Statement without assumptions}
+
+This happens if the type of {\term} has no non dependent premise.
+
+\item \errindex{Unable to apply}
+
+This happens if the conclusion of {\ident} does not match any of the
+non dependent premises of the type of {\term}.
\end{ErrMsgs}
-\subsection{\tt move {\ident$_1$} after {\ident$_2$}
-\tacindex{move}
-\label{move}}
+\begin{Variants}
+\item {\tt apply \nelist{\term}{,} in {\ident}}
-This moves the hypothesis named {\ident$_1$} in the local context
-after the hypothesis named {\ident$_2$}.
+This applies each of {\term} in sequence in {\ident}.
-If {\ident$_1$} comes before {\ident$_2$} in the order of dependences,
-then all hypotheses between {\ident$_1$} and {\ident$_2$} which
-(possibly indirectly) depend on {\ident$_1$} are moved also.
+\item {\tt apply \nelist{{\term} with {\bindinglist}}{,} in {\ident}}
-If {\ident$_1$} comes after {\ident$_2$} in the order of dependences,
-then all hypotheses between {\ident$_1$} and {\ident$_2$} which
-(possibly indirectly) occur in {\ident$_1$} are moved also.
+This does the same but uses the bindings in each {\bindinglist} to
+instantiate the parameters of the corresponding type of {\term}
+(see syntax of bindings in Section~\ref{Binding-list}).
-\begin{Variants}
+\item {\tt eapply \nelist{{\term} with {\bindinglist}}{,} in {\ident}}
+\tacindex{eapply \dots\ in}
-\item {\tt move {\ident$_1$} before {\ident$_2$}}
+This works as {\tt apply \nelist{{\term} with {\bindinglist}}{,} in
+{\ident}} but turns unresolved bindings into existential variables, if
+any, instead of failing.
-This moves {\ident$_1$} towards and just before the hypothesis named {\ident$_2$}.
+\item {\tt apply \nelist{{\term}{,} with {\bindinglist}}{,} in {\ident} as {\disjconjintropattern}}
-\item {\tt move {\ident} at top}
+This works as {\tt apply \nelist{{\term}{,} with {\bindinglist}}{,} in
+{\ident}} then destructs the hypothesis {\ident} along
+{\disjconjintropattern} as {\tt destruct {\ident} as
+{\disjconjintropattern}} would.
-This moves {\ident} at the top of the local context (at the beginning of the context).
+\item {\tt eapply \nelist{{\term}{,} with {\bindinglist}}{,} in {\ident} as {\disjconjintropattern}}
-\item {\tt move {\ident} at bottom}
+This works as {\tt apply \nelist{{\term}{,} with {\bindinglist}}{,} in {\ident} as {\disjconjintropattern}} but using {\tt eapply}.
-This moves {\ident} at the bottom of the local context (at the end of the context).
+\item {\tt simple apply {\term} in {\ident}}
+\tacindex{simple apply \dots\ in}
+\tacindex{simple eapply \dots\ in}
+
+This behaves like {\tt apply {\term} in {\ident}} but it reasons
+modulo conversion only on subterms that contain no variables to
+instantiate. For instance, if {\tt id := fun x:nat => x} and {\tt H :
+ forall y, id y = y -> True} and {\tt H0 :\ O = O} then {\tt simple
+ apply H in H0} does not succeed because it would require the
+conversion of {\tt id ?1234} and {\tt O} where {\tt ?1234} is a variable to
+instantiate. Tactic {\tt simple apply {\term} in {\ident}} does not
+either traverse tuples as {\tt apply {\term} in {\ident}} does.
+
+\item {\tt \zeroone{simple} apply \nelist{{\term} \zeroone{with {\bindinglist}}}{,} in {\ident} \zeroone{as {\disjconjintropattern}}}\\
+{\tt \zeroone{simple} eapply \nelist{{\term} \zeroone{with {\bindinglist}}}{,} in {\ident} \zeroone{as {\disjconjintropattern}}}
+This summarizes the different syntactic variants of {\tt apply {\term}
+ in {\ident}} and {\tt eapply {\term} in {\ident}}.
\end{Variants}
+\subsection{\tt constructor \num}
+\label{constructor}
+\tacindex{constructor}
+
+This tactic applies to a goal such that its conclusion is
+an inductive type (say {\tt I}). The argument {\num} must be less
+or equal to the numbers of constructor(s) of {\tt I}. Let {\tt ci} be
+the {\tt i}-th constructor of {\tt I}, then {\tt constructor i} is
+equivalent to {\tt intros; apply ci}.
+
\begin{ErrMsgs}
+\item \errindex{Not an inductive product}
+\item \errindex{Not enough constructors}
+\end{ErrMsgs}
-\item \errindex{{\ident$_i$} not found}
+\begin{Variants}
+\item \texttt{constructor}
-\item \errindex{Cannot move {\ident$_1$} after {\ident$_2$}:
- it occurs in {\ident$_2$}}
+ This tries \texttt{constructor 1} then \texttt{constructor 2},
+ \dots\ , then \texttt{constructor} \textit{n} where \textit{n} is
+ the number of constructors of the head of the goal.
-\item \errindex{Cannot move {\ident$_1$} after {\ident$_2$}:
- it depends on {\ident$_2$}}
+\item {\tt constructor \num~with} {\bindinglist}
-\end{ErrMsgs}
+ Let {\tt ci} be the {\tt i}-th constructor of {\tt I}, then {\tt
+ constructor i with \bindinglist} is equivalent to {\tt intros;
+ apply ci with \bindinglist}.
-\subsection{\tt rename {\ident$_1$} into {\ident$_2$}
-\tacindex{rename}}
+ \Warning the terms in the \bindinglist\ are checked
+ in the context where {\tt constructor} is executed and not in the
+ context where {\tt apply} is executed (the introductions are not
+ taken into account).
-This renames hypothesis {\ident$_1$} into {\ident$_2$} in the current
-context\footnote{but it does not rename the hypothesis in the
- proof-term...}
+% To document?
+% \item {\tt constructor {\tactic}}
-\begin{Variants}
+\item {\tt split}\tacindex{split}
-\item {\tt rename {\ident$_1$} into {\ident$_2$}, \ldots,
- {\ident$_{2k-1}$} into {\ident$_{2k}$}}
+ This applies only if {\tt I} has a single constructor. It is then
+ equivalent to {\tt constructor 1}. It is typically used in the case
+ of a conjunction $A\land B$.
- Is equivalent to the sequence of the corresponding atomic {\tt rename}.
+ \ErrMsg \errindex{Not an inductive goal with 1 constructor}
-\end{Variants}
+\item {\tt exists {\bindinglist}}\tacindex{exists}
-\begin{ErrMsgs}
+ This applies only if {\tt I} has a single constructor. It is then
+ equivalent to {\tt intros; constructor 1 with \bindinglist}. It is
+ typically used in the case of an existential quantification $\exists
+ x, P(x)$.
-\item \errindex{{\ident$_1$} not found}
+ \ErrMsg \errindex{Not an inductive goal with 1 constructor}
-\item \errindexbis{{\ident$_2$} is already used}{is already used}
+\item {\tt exists \nelist{\bindinglist}{,}}
-\end{ErrMsgs}
+ This iteratively applies {\tt exists {\bindinglist}}.
+
+\item {\tt left}\tacindex{left}\\
+ {\tt right}\tacindex{right}
+
+ These tactics apply only if {\tt I} has two constructors, for instance
+ in the case of a
+ disjunction $A\lor B$. Then, they are respectively equivalent to {\tt
+ constructor 1} and {\tt constructor 2}.
+
+ \ErrMsg \errindex{Not an inductive goal with 2 constructors}
+
+\item {\tt left with \bindinglist}\\
+ {\tt right with \bindinglist}\\
+ {\tt split with \bindinglist}
+
+ As soon as the inductive type has the right number of constructors,
+ these expressions are equivalent to calling {\tt
+ constructor $i$ with \bindinglist} for the appropriate $i$.
+
+\item \texttt{econstructor}\tacindex{econstructor}\\
+ \texttt{eexists}\tacindex{eexists}\\
+ \texttt{esplit}\tacindex{esplit}\\
+ \texttt{eleft}\tacindex{eleft}\\
+ \texttt{eright}\tacindex{eright}
-\subsection{\tt intro
+ These tactics and their variants behave like \texttt{constructor},
+ \texttt{exists}, \texttt{split}, \texttt{left}, \texttt{right} and
+ their variants but they introduce existential variables instead of
+ failing when the instantiation of a variable cannot be found (cf
+ \texttt{eapply} and Section~\ref{eapply-example}).
+
+\end{Variants}
+
+\section{Managing the local context}
+
+\subsection{\tt intro}
\tacindex{intro}
-\label{intro}}
+\label{intro}
-This tactic applies to a goal which is either a product or starts with
+This tactic applies to a goal that is either a product or starts with
a let binder. If the goal is a product, the tactic implements the
``Lam''\index{Typing rules!Lam} rule given in
Section~\ref{Typed-terms}\footnote{Actually, only the second subgoal will be
generated since the other one can be automatically checked.}. If the
-goal starts with a let binder then the tactic implements a mix of the
+goal starts with a let binder, then the tactic implements a mix of the
``Let''\index{Typing rules!Let} and ``Conv''\index{Typing rules!Conv}.
-If the current goal is a dependent product {\tt forall $x$:$T$, $U$} (resp {\tt
+If the current goal is a dependent product $\forall x:T,~U$ (resp {\tt
let $x$:=$t$ in $U$}) then {\tt intro} puts {\tt $x$:$T$} (resp {\tt $x$:=$t$})
in the local context.
% Obsolete (quantified names already avoid hypotheses names):
@@ -265,15 +660,15 @@ let $x$:=$t$ in $U$}) then {\tt intro} puts {\tt $x$:$T$} (resp {\tt $x$:=$t$})
% {\tt x}{\it n}{\tt :T} where {\it n} is such that {\tt x}{\it n} is a
%fresh name.
The new subgoal is $U$.
-% If the {\tt x} has been renamed {\tt x}{\it n} then it is replaced
-% by {\tt x}{\it n} in {\tt U}.
+% If the {\tt x} has been renamed {\tt x}{\it n} then it is replaced
+% by {\tt x}{\it n} in {\tt U}.
-If the goal is a non dependent product {\tt $T$ -> $U$}, then it puts
+If the goal is a non-dependent product $T \to U$, then it puts
in the local context either {\tt H}{\it n}{\tt :$T$} (if $T$ is of
type {\tt Set} or {\tt Prop}) or {\tt X}{\it n}{\tt :$T$} (if the type
of $T$ is {\tt Type}). The optional index {\it n} is such that {\tt
H}{\it n} or {\tt X}{\it n} is a fresh identifier.
-In both cases the new subgoal is $U$.
+In both cases, the new subgoal is $U$.
If the goal is neither a product nor starting with a let definition,
the tactic {\tt intro} applies the tactic {\tt red} until the tactic
@@ -288,12 +683,12 @@ the tactic {\tt intro} applies the tactic {\tt red} until the tactic
\item {\tt intros}\tacindex{intros}
- Repeats {\tt intro} until it meets the head-constant. It never reduces
+ This repeats {\tt intro} until it meets the head-constant. It never reduces
head-constants and it never fails.
\item {\tt intro {\ident}}
- Applies {\tt intro} but forces {\ident} to be the name of the
+ This applies {\tt intro} but forces {\ident} to be the name of the
introduced hypothesis.
\ErrMsg \errindex{name {\ident} is already used}
@@ -302,28 +697,28 @@ the tactic {\tt intro} applies the tactic {\tt red} until the tactic
constant then the latter can still be referred to by a qualified name
(see \ref{LongNames}).
-\item {\tt intros \ident$_1$ \dots\ \ident$_n$}
-
- Is equivalent to the composed tactic {\tt intro \ident$_1$; \dots\ ;
+\item {\tt intros \ident$_1$ \dots\ \ident$_n$}
+
+ This is equivalent to the composed tactic {\tt intro \ident$_1$; \dots\ ;
intro \ident$_n$}.
More generally, the \texttt{intros} tactic takes a pattern as
argument in order to introduce names for components of an inductive
- definition or to clear introduced hypotheses; This is explained
+ definition or to clear introduced hypotheses. This is explained
in~\ref{intros-pattern}.
\item {\tt intros until {\ident}} \tacindex{intros until}
-
- Repeats {\tt intro} until it meets a premise of the goal having form
+
+ This repeats {\tt intro} until it meets a premise of the goal having form
{\tt (} {\ident}~{\tt :}~{\term} {\tt )} and discharges the variable
named {\ident} of the current goal.
\ErrMsg \errindex{No such hypothesis in current goal}
-
+
\item {\tt intros until {\num}} \tacindex{intros until}
-
- Repeats {\tt intro} until the {\num}-th non-dependent product. For
- instance, on the subgoal %
+
+ This repeats {\tt intro} until the {\num}-th non-dependent product. For
+ instance, on the subgoal %
\verb+forall x y:nat, x=y -> y=x+ the tactic \texttt{intros until 1}
is equivalent to \texttt{intros x y H}, as \verb+x=y -> y=x+ is the
first non-dependent product. And on the subgoal %
@@ -335,7 +730,7 @@ the tactic {\tt intro} applies the tactic {\tt red} until the tactic
\ErrMsg \errindex{No such hypothesis in current goal}
- Happens when {\num} is 0 or is greater than the number of non-dependent
+ This happens when {\num} is 0 or is greater than the number of non-dependent
products of the goal.
\item {\tt intro after \ident} \tacindex{intro after}\\
@@ -343,7 +738,7 @@ the tactic {\tt intro} applies the tactic {\tt red} until the tactic
{\tt intro at top} \tacindex{intro at top}\\
{\tt intro at bottom} \tacindex{intro at bottom}
- Applies {\tt intro} and moves the freshly introduced hypothesis
+ These tactics apply {\tt intro} and move the freshly introduced hypothesis
respectively after the hypothesis \ident{}, before the hypothesis
\ident{}, at the top of the local context, or at the bottom of the
local context. All hypotheses on which the new hypothesis depends
@@ -351,307 +746,380 @@ the tactic {\tt intro} applies the tactic {\tt red} until the tactic
hypotheses. Note that {\tt intro at bottom} is a synonym for {\tt
intro} with no argument.
-\begin{ErrMsgs}
-\item \errindex{No product even after head-reduction}
-\item \errindex{No such hypothesis} : {\ident}
-\end{ErrMsgs}
+ \ErrMsg \errindex{No such hypothesis} : {\ident}
\item {\tt intro \ident$_1$ after \ident$_2$}\\
{\tt intro \ident$_1$ before \ident$_2$}\\
{\tt intro \ident$_1$ at top}\\
{\tt intro \ident$_1$ at bottom}
-
- Behaves as previously but naming the introduced hypothesis
+
+ These tactics behave as previously but naming the introduced hypothesis
\ident$_1$. It is equivalent to {\tt intro \ident$_1$} followed by
the appropriate call to {\tt move}~(see Section~\ref{move}).
-\begin{ErrMsgs}
-\item \errindex{No product even after head-reduction}
-\item \errindex{No such hypothesis} : {\ident}
-\end{ErrMsgs}
-
\end{Variants}
-\subsection{\tt apply \term
-\tacindex{apply}
-\label{apply}}
+\subsection{\tt intros {\intropattern} {\ldots} {\intropattern}}
+\label{intros-pattern}
+\tacindex{intros \intropattern}
+\index{Introduction patterns}
+\index{Naming introduction patterns}
+\index{Disjunctive/conjunctive introduction patterns}
-This tactic applies to any goal. The argument {\term} is a term
-well-formed in the local context. The tactic {\tt apply} tries to
-match the current goal against the conclusion of the type of {\term}.
-If it succeeds, then the tactic returns as many subgoals as the number
-of non dependent premises of the type of {\term}. If the conclusion of
-the type of {\term} does not match the goal {\em and} the conclusion
-is an inductive type isomorphic to a tuple type, then each component
-of the tuple is recursively matched to the goal in the left-to-right
-order.
+This extension of the tactic {\tt intros} combines introduction of
+variables or hypotheses and case analysis. An {\em introduction pattern} is
+either:
+\begin{itemize}
+\item a {\em naming introduction pattern}, i.e. either one of:
+ \begin{itemize}
+ \item the pattern \texttt{?}
+ \item the pattern \texttt{?\ident}
+ \item an identifier
+ \end{itemize}
+\item a {\em disjunctive/conjunctive introduction pattern}, i.e. either one of:
+ \begin{itemize}
+ \item a disjunction of lists of patterns:
+ {\tt [$p_{11}$ \dots\ $p_{1m_1}$ | \dots\ | $p_{11}$ \dots\ $p_{nm_n}$]}
+ \item a conjunction of patterns: {\tt ($p_1$ , \dots\ , $p_n$)}
+ \item a list of patterns {\tt ($p_1$ \&\ \dots\ \&\ $p_n$)}
+ for sequence of right-associative binary constructs
+ \end{itemize}
+\item the wildcard: {\tt \_}
+\item the rewriting orientations: {\tt ->} or {\tt <-}
+\end{itemize}
-The tactic {\tt apply} relies on first-order unification with
-dependent types unless the conclusion of the type of {\term} is of the
-form {\tt ($P$~ $t_1$~\ldots ~$t_n$)} with $P$ to be instantiated. In
-the latter case, the behavior depends on the form of the goal. If the
-goal is of the form {\tt (fun $x$ => $Q$)~$u_1$~\ldots~$u_n$} and the
-$t_i$ and $u_i$ unifies, then $P$ is taken to be (fun $x$ => $Q$).
-Otherwise, {\tt apply} tries to define $P$ by abstracting over
-$t_1$~\ldots ~$t_n$ in the goal. See {\tt pattern} in
-Section~\ref{pattern} to transform the goal so that it gets the form
-{\tt (fun $x$ => $Q$)~$u_1$~\ldots~$u_n$}.
+Assuming a goal of type $Q \to P$ (non-dependent product), or
+of type $\forall x:T,~P$ (dependent product), the behavior of
+{\tt intros $p$} is defined inductively over the structure of the
+introduction pattern~$p$:
+\begin{itemize}
+\item introduction on \texttt{?} performs the introduction, and lets {\Coq}
+ choose a fresh name for the variable;
+\item introduction on \texttt{?\ident} performs the introduction, and
+ lets {\Coq} choose a fresh name for the variable based on {\ident};
+\item introduction on \texttt{\ident} behaves as described in
+ Section~\ref{intro};
+\item introduction over a disjunction of list of patterns {\tt
+ [$p_{11}$ \dots\ $p_{1m_1}$ | \dots\ | $p_{11}$ \dots\ $p_{nm_n}$]}
+ expects the product to be over an inductive type
+ whose number of constructors is $n$ (or more generally over a type
+ of conclusion an inductive type built from $n$ constructors,
+ e.g. {\tt C -> A\textbackslash/B if $n=2$}): it destructs the introduced
+ hypothesis as {\tt destruct} (see Section~\ref{destruct}) would and
+ applies on each generated subgoal the corresponding tactic;
+ \texttt{intros}~$p_{i1}$ {\ldots} $p_{im_i}$; if the disjunctive
+ pattern is part of a sequence of patterns and is not the last
+ pattern of the sequence, then {\Coq} completes the pattern so that all
+ the argument of the constructors of the inductive type are
+ introduced (for instance, the list of patterns {\tt [$\;$|$\;$] H}
+ applied on goal {\tt forall x:nat, x=0 -> 0=x} behaves the same as
+ the list of patterns {\tt [$\,$|$\,$?$\,$] H});
+\item introduction over a conjunction of patterns {\tt ($p_1$, \ldots,
+ $p_n$)} expects the goal to be a product over an inductive type $I$ with a
+ single constructor that itself has at least $n$ arguments: it
+ performs a case analysis over the hypothesis, as {\tt destruct}
+ would, and applies the patterns $p_1$~\ldots~$p_n$ to the arguments
+ of the constructor of $I$ (observe that {\tt ($p_1$, {\ldots},
+ $p_n$)} is an alternative notation for {\tt [$p_1$ {\ldots}
+ $p_n$]});
+\item introduction via {\tt ($p_1$ \& \dots\ \& $p_n$)}
+ is a shortcut for introduction via
+ {\tt ($p_1$,(\ldots,(\dots,$p_n$)\ldots))}; it expects the
+ hypothesis to be a sequence of right-associative binary inductive
+ constructors such as {\tt conj} or {\tt ex\_intro}; for instance, an
+ hypothesis with type {\tt A\verb|/\|exists x, B\verb|/\|C\verb|/\|D} can be
+ introduced via pattern {\tt (a \& x \& b \& c \& d)};
+\item introduction on the wildcard depends on whether the product is
+ dependent or not: in the non-dependent case, it erases the
+ corresponding hypothesis (i.e. it behaves as an {\tt intro} followed
+ by a {\tt clear}, cf Section~\ref{clear}) while in the dependent
+ case, it succeeds and erases the variable only if the wildcard is
+ part of a more complex list of introduction patterns that also
+ erases the hypotheses depending on this variable;
+\item introduction over {\tt ->} (respectively {\tt <-}) expects the
+ hypothesis to be an equality and the right-hand-side (respectively
+ the left-hand-side) is replaced by the left-hand-side (respectively
+ the right-hand-side) in both the conclusion and the context of the goal;
+ if moreover the term to substitute is a variable, the hypothesis is
+ removed.
+\end{itemize}
-\begin{ErrMsgs}
-\item \errindex{Impossible to unify \dots\ with \dots}
+\Example
- The {\tt apply}
- tactic failed to match the conclusion of {\term} and the current goal.
- You can help the {\tt apply} tactic by transforming your
- goal with the {\tt change} or {\tt pattern} tactics (see
- sections~\ref{pattern},~\ref{change}).
+\begin{coq_example}
+Goal forall A B C:Prop, A \/ B /\ C -> (A -> C) -> C.
+intros A B C [a| [_ c]] f.
+apply (f a).
+exact c.
+Qed.
+\end{coq_example}
-\item \errindex{Unable to find an instance for the variables
-{\ident} \ldots {\ident}}
+\Rem {\tt intros $p_1~\ldots~p_n$} is not equivalent to \texttt{intros
+ $p_1$;\ldots; intros $p_n$} for the following reasons:
+\begin{itemize}
+\item A wildcard pattern never succeeds when applied isolated on a
+ dependent product, while it succeeds as part of a list of
+ introduction patterns if the hypotheses that depends on it are
+ erased too.
+\item A disjunctive or conjunctive pattern followed by an introduction
+ pattern forces the introduction in the context of all arguments of
+ the constructors before applying the next pattern while a terminal
+ disjunctive or conjunctive pattern does not. Here is an example
- This occurs when some instantiations of the premises of {\term} are not
- deducible from the unification. This is the case, for instance, when
- you want to apply a transitivity property. In this case, you have to
- use one of the variants below:
+\begin{coq_example}
+Goal forall n:nat, n = 0 -> n = 0.
+intros [ | ] H.
+Show 2.
+Undo.
+intros [ | ]; intros H.
+Show 2.
+\end{coq_example}
+
+\end{itemize}
+
+\subsection{\tt clear \ident}
+\tacindex{clear}
+\label{clear}
+
+This tactic erases the hypothesis named {\ident} in the local context
+of the current goal. As a consequence, {\ident} is no more displayed and no more
+usable in the proof development.
+\begin{ErrMsgs}
+\item \errindex{No such hypothesis}
+\item \errindexbis{{\ident} is used in the conclusion}{is used in the
+ conclusion}
+\item \errindexbis{{\ident} is used in the hypothesis {\ident'}}{is
+ used in the hypothesis}
\end{ErrMsgs}
\begin{Variants}
-\item{\tt apply {\term} with {\term$_1$} \dots\ {\term$_n$}}
- \tacindex{apply \dots\ with}
-
- Provides {\tt apply} with explicit instantiations for all dependent
- premises of the type of {\term} which do not occur in the conclusion
- and consequently cannot be found by unification. Notice that
- {\term$_1$} \dots\ {\term$_n$} must be given according to the order
- of these dependent premises of the type of {\term}.
+\item {\tt clear {\ident$_1$} \dots\ {\ident$_n$}}
- \ErrMsg \errindex{Not the right number of missing arguments}
+ This is equivalent to {\tt clear {\ident$_1$}. {\ldots} clear
+ {\ident$_n$}.}
-\item{\tt apply {\term} with ({\vref$_1$} := {\term$_1$}) \dots\ ({\vref$_n$}
- := {\term$_n$})}
-
- This also provides {\tt apply} with values for instantiating
- premises. Here, variables are referred by names and non-dependent
- products by increasing numbers (see syntax in Section~\ref{Binding-list}).
+\item {\tt clearbody {\ident}}\tacindex{clearbody}
-\item {\tt apply} {\term$_1$} {\tt ,} \ldots {\tt ,} {\term$_n$}
+ This tactic expects {\ident} to be a local definition then clears
+ its body. Otherwise said, this tactic turns a definition into an
+ assumption.
- This is a shortcut for {\tt apply} {\term$_1$} {\tt ; [ ..~|}
- \ldots~{\tt ; [ ..~| {\tt apply} {\term$_n$} ]} \ldots~{\tt ]}, i.e. for the
- successive applications of {\term$_{i+1}$} on the last subgoal
- generated by {\tt apply} {\term$_i$}, starting from the application
- of {\term$_1$}.
+ \ErrMsg \errindexbis{{\ident} is not a local definition}{is not a local definition}
-\item {\tt eapply \term}\tacindex{eapply}\label{eapply}
-
- The tactic {\tt eapply} behaves as {\tt apply} but does not fail
- when no instantiation are deducible for some variables in the
- premises. Rather, it turns these variables into so-called
- existential variables which are variables still to instantiate. An
- existential variable is identified by a name of the form {\tt ?$n$}
- where $n$ is a number. The instantiation is intended to be found
- later in the proof.
+\item \texttt{clear - {\ident$_1$} \dots\ {\ident$_n$}}
- An example of use of {\tt eapply} is given in
- Section~\ref{eapply-example}.
+ This tactic clears all the hypotheses except the ones depending in
+ the hypotheses named {\ident$_1$} {\ldots} {\ident$_n$} and in the
+ goal.
-\item {\tt simple apply {\term}} \tacindex{simple apply}
+\item \texttt{clear}
- This behaves like {\tt apply} but it reasons modulo conversion only
- on subterms that contain no variables to instantiate. For instance,
- if {\tt id := fun x:nat => x} and {\tt H : forall y, id y = y} then
- {\tt simple apply H} on goal {\tt O = O} does not succeed because it
- would require the conversion of {\tt f ?y} and {\tt O} where {\tt
- ?y} is a variable to instantiate. Tactic {\tt simple apply} does not
- either traverse tuples as {\tt apply} does.
+ This tactic clears all the hypotheses except the ones the goal depends on.
- Because it reasons modulo a limited amount of conversion, {\tt
- simple apply} fails quicker than {\tt apply} and it is then
- well-suited for uses in used-defined tactics that backtrack often.
+\item {\tt clear dependent \ident \tacindex{clear dependent}}
-\item \zeroone{{\tt simple}} {\tt apply} {\term$_1$} \zeroone{{\tt with}
- {\bindinglist$_1$}} {\tt ,} \ldots {\tt ,} {\term$_n$} \zeroone{{\tt with}
- {\bindinglist$_n$}}\\
- \zeroone{{\tt simple}} {\tt eapply} {\term$_1$} \zeroone{{\tt with}
- {\bindinglist$_1$}} {\tt ,} \ldots {\tt ,} {\term$_n$} \zeroone{{\tt with}
- {\bindinglist$_n$}}
+ This clears the hypothesis \ident\ and all the hypotheses
+ that depend on it.
- This summarizes the different syntaxes for {\tt apply} and {\tt eapply}.
+\end{Variants}
-\item {\tt lapply {\term}} \tacindex{lapply}
+\subsection{\tt revert \ident$_1$ \dots\ \ident$_n$}
+\tacindex{revert}
+\label{revert}
- This tactic applies to any goal, say {\tt G}. The argument {\term}
- has to be well-formed in the current context, its type being
- reducible to a non-dependent product {\tt A -> B} with {\tt B}
- possibly containing products. Then it generates two subgoals {\tt
- B->G} and {\tt A}. Applying {\tt lapply H} (where {\tt H} has type
- {\tt A->B} and {\tt B} does not start with a product) does the same
- as giving the sequence {\tt cut B. 2:apply H.} where {\tt cut} is
- described below.
+This applies to any goal with variables \ident$_1$ \dots\ \ident$_n$.
+It moves the hypotheses (possibly defined) to the goal, if this respects
+dependencies. This tactic is the inverse of {\tt intro}.
- \Warning When {\term} contains more than one non
- dependent product the tactic {\tt lapply} only takes into account the
- first product.
+\begin{ErrMsgs}
+\item \errindex{No such hypothesis}
+\item \errindexbis{{\ident} is used in the hypothesis {\ident'}}{is
+ used in the hypothesis}
+\end{ErrMsgs}
-\end{Variants}
+\begin{Variants}
+\item {\tt revert dependent \ident \tacindex{revert dependent}}
-\subsection{{\tt apply {\term} in {\ident}}
-\tacindex{apply \ldots\ in}}
+ This moves to the goal the hypothesis \ident\ and all hypotheses
+ which depend on it.
-This tactic applies to any goal. The argument {\term} is a term
-well-formed in the local context and the argument {\ident} is an
-hypothesis of the context. The tactic {\tt apply {\term} in {\ident}}
-tries to match the conclusion of the type of {\ident} against a non
-dependent premise of the type of {\term}, trying them from right to
-left. If it succeeds, the statement of hypothesis {\ident} is
-replaced by the conclusion of the type of {\term}. The tactic also
-returns as many subgoals as the number of other non dependent premises
-in the type of {\term} and of the non dependent premises of the type
-of {\ident}. If the conclusion of the type of {\term} does not match
-the goal {\em and} the conclusion is an inductive type isomorphic to a
-tuple type, then the tuple is (recursively) decomposed and the first
-component of the tuple of which a non dependent premise matches the
-conclusion of the type of {\ident}. Tuples are decomposed in a
-width-first left-to-right order (for instance if the type of {\tt H1}
-is a \verb=A <-> B= statement, and the type of {\tt H2} is \verb=A=
-then {\tt apply H1 in H2} transforms the type of {\tt H2} into {\tt
- B}). The tactic {\tt apply} relies on first-order pattern-matching
-with dependent types.
+\end{Variants}
-\begin{ErrMsgs}
-\item \errindex{Statement without assumptions}
+\subsection{\tt move {\ident$_1$} after {\ident$_2$}}
+\tacindex{move}
+\label{move}
-This happens if the type of {\term} has no non dependent premise.
+This moves the hypothesis named {\ident$_1$} in the local context
+after the hypothesis named {\ident$_2$}. The proof term is not changed.
-\item \errindex{Unable to apply}
+If {\ident$_1$} comes before {\ident$_2$} in the order of dependences,
+then all hypotheses between {\ident$_1$} and {\ident$_2$} that
+(possibly indirectly) depend on {\ident$_1$} are moved also.
-This happens if the conclusion of {\ident} does not match any of the
-non dependent premises of the type of {\term}.
-\end{ErrMsgs}
+If {\ident$_1$} comes after {\ident$_2$} in the order of dependences,
+then all hypotheses between {\ident$_1$} and {\ident$_2$} that
+(possibly indirectly) occur in {\ident$_1$} are moved also.
\begin{Variants}
-\item {\tt apply \nelist{\term}{,} in {\ident}}
-This applies each of {\term} in sequence in {\ident}.
+\item {\tt move {\ident$_1$} before {\ident$_2$}}
-\item {\tt apply \nelist{{\term} with {\bindinglist}}{,} in {\ident}}
+This moves {\ident$_1$} towards and just before the hypothesis named {\ident$_2$}.
-This does the same but uses the bindings in each {\bindinglist} to
-instantiate the parameters of the corresponding type of {\term}
-(see syntax of bindings in Section~\ref{Binding-list}).
+\item {\tt move {\ident} at top}
-\item {\tt eapply \nelist{{\term} with {\bindinglist}}{,} in {\ident}}
-\tacindex{eapply {\ldots} in}
+This moves {\ident} at the top of the local context (at the beginning of the context).
-This works as {\tt apply \nelist{{\term} with {\bindinglist}}{,} in
-{\ident}} but turns unresolved bindings into existential variables, if
-any, instead of failing.
+\item {\tt move {\ident} at bottom}
-\item {\tt apply \nelist{{\term}{,} with {\bindinglist}}{,} in {\ident} as {\disjconjintropattern}}
+This moves {\ident} at the bottom of the local context (at the end of the context).
-This works as {\tt apply \nelist{{\term}{,} with {\bindinglist}}{,} in
-{\ident}} then destructs the hypothesis {\ident} along
-{\disjconjintropattern} as {\tt destruct {\ident} as
-{\disjconjintropattern}} would.
+\end{Variants}
-\item {\tt eapply \nelist{{\term}{,} with {\bindinglist}}{,} in {\ident} as {\disjconjintropattern}}
+\begin{ErrMsgs}
-This works as {\tt apply \nelist{{\term}{,} with {\bindinglist}}{,} in {\ident} as {\disjconjintropattern}} but using {\tt eapply}.
+\item \errindex{No such hypothesis}
-\item {\tt simple apply {\term} in {\ident}}
-\tacindex{simple apply {\ldots} in}
-\tacindex{simple eapply {\ldots} in}
+\item \errindex{Cannot move {\ident$_1$} after {\ident$_2$}:
+ it occurs in {\ident$_2$}}
-This behaves like {\tt apply {\term} in {\ident}} but it reasons
-modulo conversion only on subterms that contain no variables to
-instantiate. For instance, if {\tt id := fun x:nat => x} and {\tt H :
- forall y, id y = y -> True} and {\tt H0 : O = O} then {\tt simple
- apply H in H0} does not succeed because it would require the
-conversion of {\tt f ?y} and {\tt O} where {\tt ?y} is a variable to
-instantiate. Tactic {\tt simple apply {\term} in {\ident}} does not
-either traverse tuples as {\tt apply {\term} in {\ident}} does.
+\item \errindex{Cannot move {\ident$_1$} after {\ident$_2$}:
+ it depends on {\ident$_2$}}
-\item {\tt \zeroone{simple} apply \nelist{{\term} \zeroone{with {\bindinglist}}}{,} in {\ident} \zeroone{as {\disjconjintropattern}}}\\
-{\tt \zeroone{simple} eapply \nelist{{\term} \zeroone{with {\bindinglist}}}{,} in {\ident} \zeroone{as {\disjconjintropattern}}}
+\end{ErrMsgs}
+
+\subsection{\tt rename {\ident$_1$} into {\ident$_2$}}
+\tacindex{rename}
+
+This renames hypothesis {\ident$_1$} into {\ident$_2$} in the current
+context. The name of the hypothesis in the proof-term, however, is left
+unchanged.
+
+\begin{Variants}
+
+\item {\tt rename {\ident$_1$} into {\ident$_2$}, \ldots,
+ {\ident$_{2k-1}$} into {\ident$_{2k}$}}
+
+This is equivalent to the sequence of the corresponding atomic {\tt rename}.
-This summarizes the different syntactic variants of {\tt apply {\term}
- in {\ident}} and {\tt eapply {\term} in {\ident}}.
\end{Variants}
-\subsection{{\tt set ( {\ident} {\tt :=} {\term} \tt )}
+\begin{ErrMsgs}
+\item \errindex{No such hypothesis}
+\item \errindexbis{{\ident$_2$} is already used}{is already used}
+\end{ErrMsgs}
+
+\subsection{\tt set ( {\ident} := {\term} )}
\label{tactic:set}
\tacindex{set}
-\tacindex{pose}
-\tacindex{remember}}
-This replaces {\term} by {\ident} in the conclusion or in the
-hypotheses of the current goal and adds the new definition {\ident
-{\tt :=} \term} to the local context. The default is to make this
-replacement only in the conclusion.
+This replaces {\term} by {\ident} in the conclusion of the current goal
+and adds the new definition {\tt {\ident} := \term} to the local context.
If {\term} has holes (i.e. subexpressions of the form ``\_''), the
tactic first checks that all subterms matching the pattern are
compatible before doing the replacement using the leftmost subterm
matching the pattern.
+\begin{ErrMsgs}
+\item \errindex{The variable {\ident} is already defined}
+\end{ErrMsgs}
+
\begin{Variants}
-\item {\tt set (} {\ident} {\tt :=} {\term} {\tt ) in {\occgoalset}}
+\item {\tt set ( {\ident} := {\term} ) in {\occgoalset}}
This notation allows to specify which occurrences of {\term} have to
be substituted in the context. The {\tt in {\occgoalset}} clause is an
-occurrence clause whose syntax and behavior is described in
+occurrence clause whose syntax and behavior are described in
Section~\ref{Occurrences clauses}.
-\item {\tt set (} {\ident} \nelist{\binder}{} {\tt :=} {\term} {\tt )}
+\item {\tt set ( {\ident} \nelist{\binder}{} := {\term} )}
- This is equivalent to {\tt set (} {\ident} {\tt :=} {\tt fun}
- \nelist{\binder}{} {\tt =>} {\term} {\tt )}.
+ This is equivalent to {\tt set ( {\ident} := fun
+ \nelist{\binder}{} => {\term} )}.
-\item {\tt set } {\term}
+\item {\tt set \term}
This behaves as {\tt set (} {\ident} := {\term} {\tt )} but {\ident}
is generated by {\Coq}. This variant also supports an occurrence clause.
-\item {\tt set (} {\ident$_0$} \nelist{\binder}{} {\tt :=} {\term}
- {\tt ) in {\occgoalset}}\\
+\item {\tt set ( {\ident$_0$} \nelist{\binder}{} := {\term} ) in {\occgoalset}}\\
{\tt set {\term} in {\occgoalset}}
These are the general forms which combine the previous possibilities.
-\item {\tt remember {\term} {\tt as} {\ident}}
+\item {\tt remember {\term} as {\ident}}\tacindex{remember}
- This behaves as {\tt set (} {\ident} := {\term} {\tt ) in *} and using a
+ This behaves as {\tt set ( {\ident} := {\term} ) in *} and using a
logical (Leibniz's) equality instead of a local definition.
-\item {\tt remember {\term} {\tt as} {\ident} in {\occgoalset}}
+\item {\tt remember {\term} as {\ident} in {\occgoalset}}
This is a more general form of {\tt remember} that remembers the
occurrences of {\term} specified by an occurrences set.
-\item {\tt pose ( {\ident} := {\term} )}
-
+\item {\tt pose ( {\ident} := {\term} )}\tacindex{pose}
+
This adds the local definition {\ident} := {\term} to the current
context without performing any replacement in the goal or in the
hypotheses. It is equivalent to {\tt set ( {\ident} {\tt :=}
{\term} {\tt ) in |-}}.
-\item {\tt pose (} {\ident} \nelist{\binder}{} {\tt :=} {\term} {\tt )}
+\item {\tt pose ( {\ident} \nelist{\binder}{} := {\term} )}
This is equivalent to {\tt pose (} {\ident} {\tt :=} {\tt fun}
\nelist{\binder}{} {\tt =>} {\term} {\tt )}.
\item{\tt pose {\term}}
- This behaves as {\tt pose (} {\ident} := {\term} {\tt )} but
+ This behaves as {\tt pose ( {\ident} := {\term} )} but
{\ident} is generated by {\Coq}.
\end{Variants}
-\subsection{{\tt assert ( {\ident} : {\form} \tt )}
-\tacindex{assert}}
+\subsection{\tt decompose [ {\qualid$_1$} \dots\ {\qualid$_n$} ] \term}
+\label{decompose}
+\tacindex{decompose}
+
+This tactic allows to recursively decompose a
+complex proposition in order to obtain atomic ones.
+
+\Example
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+\begin{coq_example}
+Goal forall A B C:Prop, A /\ B /\ C \/ B /\ C \/ C /\ A -> C.
+intros A B C H; decompose [and or] H; assumption.
+\end{coq_example}
+\begin{coq_example*}
+Qed.
+\end{coq_example*}
+
+{\tt decompose} does not work on right-hand sides of implications or products.
+
+\begin{Variants}
+
+\item {\tt decompose sum \term}\tacindex{decompose sum}
+
+ This decomposes sum types (like \texttt{or}).
+
+\item {\tt decompose record \term}\tacindex{decompose record}
+
+ This decomposes record types (inductive types with one constructor,
+ like \texttt{and} and \texttt{exists} and those defined with the
+ \texttt{Record} macro, see Section~\ref{Record}).
+
+\end{Variants}
+
+\section{Controlling the proof flow}
+
+\subsection{\tt assert ( {\ident} :\ {\form} )}
+\tacindex{assert}
This tactic applies to any goal. {\tt assert (H : U)} adds a new
hypothesis of name \texttt{H} asserting \texttt{U} to the current goal
@@ -661,7 +1129,7 @@ in the list of subgoals remaining to prove.
\begin{ErrMsgs}
\item \errindex{Not a proposition or a type}
-
+
Arises when the argument {\form} is neither of type {\tt Prop}, {\tt
Set} nor {\tt Type}.
@@ -670,18 +1138,20 @@ in the list of subgoals remaining to prove.
\begin{Variants}
\item{\tt assert {\form}}
-
- This behaves as {\tt assert (} {\ident} : {\form} {\tt )} but
+
+ This behaves as {\tt assert ( {\ident} :\ {\form} )} but
{\ident} is generated by {\Coq}.
-\item{\tt assert (} {\ident} := {\term} {\tt )}
-
- This behaves as {\tt assert ({\ident} : {\type});[exact
+\item{\tt assert ( {\ident} := {\term} )}
+
+ This behaves as {\tt assert ({\ident} :\ {\type});[exact
{\term}|idtac]} where {\type} is the type of {\term}.
-\item {\tt cut {\form}}\tacindex{cut}
-
- This tactic applies to any goal. It implements the non dependent
+ \ErrMsg \errindex{Variable {\ident} is already declared}
+
+\item {\tt cut {\form}}\tacindex{cut}
+
+ This tactic applies to any goal. It implements the non-dependent
case of the ``App''\index{Typing rules!App} rule given in
Section~\ref{Typed-terms}. (This is Modus Ponens inference rule.)
{\tt cut U} transforms the current goal \texttt{T} into the two
@@ -689,16 +1159,18 @@ in the list of subgoals remaining to prove.
-> T} comes first in the list of remaining subgoal to prove.
\item \texttt{assert {\form} by {\tac}}\tacindex{assert by}
-
+
This tactic behaves like \texttt{assert} but applies {\tac}
to solve the subgoals generated by \texttt{assert}.
+ \ErrMsg \errindex{Proof is not complete}
+
\item \texttt{assert {\form} as {\intropattern}\tacindex{assert as}}
If {\intropattern} is a naming introduction pattern (see
Section~\ref{intros-pattern}), the hypothesis is named after this
introduction pattern (in particular, if {\intropattern} is {\ident},
- the tactic behaves like \texttt{assert ({\ident} : {\form})}).
+ the tactic behaves like \texttt{assert ({\ident} :\ {\form})}).
If {\intropattern} is a disjunctive/conjunctive introduction
pattern, the tactic behaves like \texttt{assert {\form}} then destructing the
@@ -714,12 +1186,11 @@ in the list of subgoals remaining to prove.
exact {\term}} where \texttt{T} is the type of {\term}.
In particular, \texttt{pose proof {\term} as {\ident}} behaves as
- \texttt{assert ({\ident}:T) by exact {\term}} (where \texttt{T} is
- the type of {\term}) and \texttt{pose proof {\term} as
+ \texttt{assert ({\ident} := {\term})} and \texttt{pose proof {\term} as
{\disjconjintropattern}\tacindex{pose proof}} behaves
like \texttt{destruct {\term} as {\disjconjintropattern}}.
-\item {\tt specialize ({\ident} \term$_1$ {\ldots} \term$_n$)\tacindex{specialize}} \\
+\item {\tt specialize ({\ident} \term$_1$ \dots\ \term$_n$)\tacindex{specialize}} \\
{\tt specialize {\ident} with \bindinglist}
The tactic {\tt specialize} works on local hypothesis \ident.
@@ -730,30 +1201,37 @@ in the list of subgoals remaining to prove.
Section~\ref{Binding-list} for more about bindings lists). In the
second form, all instantiation elements must be given, whereas
in the first form the application to \term$_1$ {\ldots}
- \term$_n$ can be partial. The first form is equivalent to
- {\tt assert (\ident':=\ident \term$_1$ {\ldots} \term$_n$);
- clear \ident; rename \ident' into \ident}.
+ \term$_n$ can be partial. The first form is equivalent to
+ {\tt assert (\ident' := {\ident} {\term$_1$} \dots\ \term$_n$);
+ clear \ident; rename \ident' into \ident}.
The name {\ident} can also refer to a global lemma or
hypothesis. In this case, for compatibility reasons, the
behavior of {\tt specialize} is close to that of {\tt
- generalize}: the instantiated statement becomes an additional
- premise of the goal.
+ generalize}: the instantiated statement becomes an additional
+ premise of the goal.
-%% Moreover, the old syntax allows the use of a number after {\tt specialize}
-%% for controlling the number of premises to instantiate. Giving this
+ \begin{ErrMsgs}
+ \item \errindexbis{{\ident} is used in hypothesis \ident'}{is used in hypothesis}
+ \item \errindexbis{{\ident} is used in conclusion}{is used in conclusion}
+ \end{ErrMsgs}
+
+%% Moreover, the old syntax allows the use of a number after {\tt specialize}
+%% for controlling the number of premises to instantiate. Giving this
%% number should not be mandatory anymore (automatic detection of how
-%% many premises can be eaten without leaving meta-variables). Hence
+%% many premises can be eaten without leaving meta-variables). Hence
%% no documentation for this integer optional argument of specialize
\end{Variants}
-\subsection{\tt generalize \term
+\subsection{\tt generalize \term}
\tacindex{generalize}
-\label{generalize}}
+\label{generalize}
-This tactic applies to any goal. It generalizes the conclusion w.r.t.
-one subterm of it. For example:
+This tactic applies to any goal. It generalizes the conclusion with
+respect to one of its subterms.
+
+\Example
\begin{coq_eval}
Goal forall x y:nat, (0 <= x + y + y).
@@ -775,185 +1253,49 @@ where $G'$ is obtained from $G$ by replacing all occurrences of $t$ by
\begin{Variants}
\item {\tt generalize {\term$_1$ , \dots\ , \term$_n$}}
-
- Is equivalent to {\tt generalize \term$_n$; \dots\ ; generalize
+
+ This is equivalent to {\tt generalize \term$_n$; \dots\ ; generalize
\term$_1$}. Note that the sequence of \term$_i$'s are processed
from $n$ to $1$.
\item {\tt generalize {\term} at {\num$_1$ \dots\ \num$_i$}}
-
- Is equivalent to {\tt generalize \term} but generalizing only over
+
+ This is equivalent to {\tt generalize \term} but it generalizes only over
the specified occurrences of {\term} (counting from left to right on the
expression printed using option {\tt Set Printing All}).
\item {\tt generalize {\term} as {\ident}}
-
- Is equivalent to {\tt generalize \term} but use {\ident} to name the
+
+ This is equivalent to {\tt generalize \term} but it uses {\ident} to name the
generalized hypothesis.
-\item {\tt generalize {\term$_1$} at {\num$_{11}$ \dots\ \num$_{1i_1}$}
+\item {\tt generalize {\term$_1$} at {\num$_{11}$ \dots\ \num$_{1i_1}$}
as {\ident$_1$}
, {\ldots} ,
{\term$_n$} at {\num$_{n1}$ \dots\ \num$_{ni_n}$}
as {\ident$_2$}}
-
+
This is the most general form of {\tt generalize} that combines the
previous behaviors.
-
-\item {\tt generalize dependent \term} \tacindex{generalize dependent}
-
- This generalizes {\term} but also {\em all} hypotheses which depend
- on {\term}. It clears the generalized hypotheses.
-
-\end{Variants}
-
-
-\subsection{\tt revert \ident$_1$ \dots\ \ident$_n$
-\tacindex{revert}
-\label{revert}}
-
-This applies to any goal with variables \ident$_1$ \dots\ \ident$_n$.
-It moves the hypotheses (possibly defined) to the goal, if this respects
-dependencies. This tactic is the inverse of {\tt intro}.
-
-\begin{ErrMsgs}
-\item \errindexbis{{\ident} is used in the hypothesis {\ident'}}{is
- used in the hypothesis}
-\end{ErrMsgs}
-
-\begin{Variants}
-\item {\tt revert dependent \ident \tacindex{revert dependent}}
-
- This moves to the goal the hypothesis \ident\ and all hypotheses
- which depend on it.
-
-\end{Variants}
-
-\subsection{\tt change \term
-\tacindex{change}
-\label{change}}
-
-This tactic applies to any goal. It implements the rule
-``Conv''\index{Typing rules!Conv} given in Section~\ref{Conv}. {\tt
- change U} replaces the current goal \T\ with \U\ providing that
-\U\ is well-formed and that \T\ and \U\ are convertible.
-
-\begin{ErrMsgs}
-\item \errindex{Not convertible}
-\end{ErrMsgs}
-
-\tacindex{change \dots\ in}
-\begin{Variants}
-\item {\tt change \term$_1$ with \term$_2$}
-
- This replaces the occurrences of \term$_1$ by \term$_2$ in the
- current goal. The terms \term$_1$ and \term$_2$ must be
- convertible.
-
-\item {\tt change \term$_1$ at \num$_1$ \dots\ \num$_i$ with \term$_2$}
-
- This replaces the occurrences numbered \num$_1$ \dots\ \num$_i$ of
- \term$_1$ by \term$_2$ in the current goal.
- The terms \term$_1$ and \term$_2$ must be convertible.
-
- \ErrMsg {\tt Too few occurrences}
-
-\item {\tt change {\term} in {\ident}}
-
-\item {\tt change \term$_1$ with \term$_2$ in {\ident}}
-
-\item {\tt change \term$_1$ at \num$_1$ \dots\ \num$_i$ with \term$_2$ in
- {\ident}}
-
- This applies the {\tt change} tactic not to the goal but to the
- hypothesis {\ident}.
-
-\end{Variants}
-
-\SeeAlso \ref{Conversion-tactics}
-
-\subsection{\tt fix {\ident} {\num}
-\tacindex{fix}
-\label{tactic:fix}}
-
-This tactic is a primitive tactic to start a proof by induction. In
-general, it is easier to rely on higher-level induction tactics such
-as the ones described in Section~\ref{Tac-induction}.
-
-In the syntax of the tactic, the identifier {\ident} is the name given
-to the induction hypothesis. The natural number {\num} tells on which
-premise of the current goal the induction acts, starting
-from 1 and counting both dependent and non dependent
-products. Especially, the current lemma must be composed of at least
-{\num} products.
-
-Like in a {\tt fix} expression, the induction
-hypotheses have to be used on structurally smaller arguments.
-The verification that inductive proof arguments are correct is done
-only at the time of registering the lemma in the environment. To know
-if the use of induction hypotheses is correct at some
-time of the interactive development of a proof, use the command {\tt
- Guarded} (see Section~\ref{Guarded}).
-
-\begin{Variants}
- \item {\tt fix} {\ident}$_1$ {\num} {\tt with (} {\ident}$_2$
- \nelist{{\binder}$_{2}$}{} \zeroone{{\tt \{ struct {\ident$'_2$}
- \}}} {\tt :} {\type}$_2$ {\tt )} {\ldots} {\tt (} {\ident}$_1$
- \nelist{{\binder}$_n$}{} \zeroone{{\tt \{ struct {\ident$'_n$} \}}}
- {\tt :} {\type}$_n$ {\tt )}
-
-This starts a proof by mutual induction. The statements to be
-simultaneously proved are respectively {\tt forall}
- \nelist{{\binder}$_2$}{}{\tt ,} {\type}$_2$, {\ldots}, {\tt forall}
- \nelist{{\binder}$_n$}{}{\tt ,} {\type}$_n$. The identifiers
-{\ident}$_1$ {\ldots} {\ident}$_n$ are the names of the induction
-hypotheses. The identifiers {\ident}$'_2$ {\ldots} {\ident}$'_n$ are the
-respective names of the premises on which the induction is performed
-in the statements to be simultaneously proved (if not given, the
-system tries to guess itself what they are).
-
-\end{Variants}
-\subsection{\tt cofix {\ident}
-\tacindex{cofix}
-\label{tactic:cofix}}
-
-This tactic starts a proof by coinduction. The identifier {\ident} is
-the name given to the coinduction hypothesis. Like in a {\tt cofix}
-expression, the use of induction hypotheses have to guarded by a
-constructor. The verification that the use of coinductive hypotheses
-is correct is done only at the time of registering the lemma in the
-environment. To know if the use of coinduction hypotheses is correct
-at some time of the interactive development of a proof, use the
-command {\tt Guarded} (see Section~\ref{Guarded}).
-
-
-\begin{Variants}
- \item {\tt cofix} {\ident}$_1$ {\tt with (} {\ident}$_2$
- \nelist{{\binder}$_2$}{} {\tt :} {\type}$_2$ {\tt )} {\ldots} {\tt
- (} {\ident}$_1$ \nelist{{\binder}$_1$}{} {\tt :} {\type}$_n$
- {\tt )}
+\item {\tt generalize dependent \term} \tacindex{generalize dependent}
-This starts a proof by mutual coinduction. The statements to be
-simultaneously proved are respectively {\tt forall}
-\nelist{{\binder}$_2$}{}{\tt ,} {\type}$_2$, {\ldots}, {\tt forall}
- \nelist{{\binder}$_n$}{}{\tt ,} {\type}$_n$. The identifiers
- {\ident}$_1$ {\ldots} {\ident}$_n$ are the names of the
- coinduction hypotheses.
+ This generalizes {\term} but also {\em all} hypotheses that depend
+ on {\term}. It clears the generalized hypotheses.
\end{Variants}
-\subsection{\tt evar (\ident:\term)
+\subsection{\tt evar ( {\ident} :\ {\term} )}
\tacindex{evar}
-\label{evar}}
+\label{evar}
The {\tt evar} tactic creates a new local definition named \ident\ with
type \term\ in the context. The body of this binding is a fresh
existential variable.
-\subsection{\tt instantiate (\num:= \term)
+\subsection{\tt instantiate ( {\num} := {\term} )}
\tacindex{instantiate}
-\label{instantiate}}
+\label{instantiate}
The {\tt instantiate} tactic allows to refine (see Section~\ref{refine})
an existential variable
@@ -963,14 +1305,14 @@ the number of the existential variable since this number is different
in every session.
\begin{Variants}
- \item {\tt instantiate (\num:=\term) in \ident}
-
- \item {\tt instantiate (\num:=\term) in (Value of \ident)}
-
- \item {\tt instantiate (\num:=\term) in (Type of \ident)}
+ \item {\tt instantiate ( {\num} := {\term} ) in \ident}
-These allow to refer respectively to existential variables occurring in
-a hypothesis or in the body or the type of a local definition.
+ \item {\tt instantiate ( {\num} := {\term} ) in ( Value of {\ident} )}
+
+ \item {\tt instantiate ( {\num} := {\term} ) in ( Type of {\ident} )}
+
+These allow to refer respectively to existential variables occurring in
+a hypothesis or in the body or the type of a local definition.
\item {\tt instantiate}
@@ -983,9 +1325,9 @@ a hypothesis or in the body or the type of a local definition.
\end{Variants}
-\subsection{\tt admit
+\subsection{\tt admit}
\tacindex{admit}
-\label{admit}}
+\label{admit}
The {\tt admit} tactic ``solves'' the current subgoal by an
axiom. This typically allows to temporarily skip a subgoal so as to
@@ -995,147 +1337,9 @@ Assumptions} (see Section~\ref{PrintAssumptions}). Admitted subgoals
have names of the form {\ident}\texttt{\_admitted} possibly followed
by a number.
-\subsection{\tt constr\_eq \term$_1$ \term$_2$
-\tacindex{constr\_eq}
-\label{constreq}}
-
-This tactic applies to any goal. It checks whether its arguments are
-equal modulo alpha conversion and casts.
-
-\ErrMsg \errindex{Not equal}
-
-\subsection{\tt is\_evar \term
-\tacindex{is\_evar}
-\label{isevar}}
-
-This tactic applies to any goal. It checks whether its argument is an
-existential variable. Existential variables are uninstantiated
-variables generated by e.g. {\tt eapply} (see Section~\ref{apply}).
-
-\ErrMsg \errindex{Not an evar}
-
-\subsection{\tt has\_evar \term
-\tacindex{has\_evar}
-\label{hasevar}}
-
-This tactic applies to any goal. It checks whether its argument has an
-existential variable as a subterm. Unlike {\tt context} patterns
-combined with {\tt is\_evar}, this tactic scans all subterms,
-including those under binders.
-
-\ErrMsg \errindex{No evars}
-
-\subsection{\tt is\_var \term
-\tacindex{is\_var}
-\label{isvar}}
-
-This tactic applies to any goal. It checks whether its argument is a
-variable or hypothesis in the current goal context or in the opened sections.
-
-\ErrMsg \errindex{Not a variable or hypothesis}
-
-\subsection{Bindings list
-\index{Binding list}
-\label{Binding-list}}
-
-Tactics that take a term as argument may also support a bindings list, so
-as to instantiate some parameters of the term by name or position.
-The general form of a term equipped with a bindings list is {\tt
-{\term} with {\bindinglist}} where {\bindinglist} may be of two
-different forms:
-
-\begin{itemize}
-\item In a bindings list of the form {\tt (\vref$_1$ := \term$_1$)
- \dots\ (\vref$_n$ := \term$_n$)}, {\vref} is either an {\ident} or a
- {\num}. The references are determined according to the type of
- {\term}. If \vref$_i$ is an identifier, this identifier has to be
- bound in the type of {\term} and the binding provides the tactic
- with an instance for the parameter of this name. If \vref$_i$ is
- some number $n$, this number denotes the $n$-th non dependent
- premise of the {\term}, as determined by the type of {\term}.
-
- \ErrMsg \errindex{No such binder}
-
-\item A bindings list can also be a simple list of terms {\tt
- \term$_1$ \dots\term$_n$}. In that case the references to
- which these terms correspond are determined by the tactic. In case
- of {\tt induction}, {\tt destruct}, {\tt elim} and {\tt case} (see
- Section~\ref{elim}) the terms have to provide instances for all the
- dependent products in the type of \term\ while in the case of {\tt
- apply}, or of {\tt constructor} and its variants, only instances for
- the dependent products which are not bound in the conclusion of the
- type are required.
-
- \ErrMsg \errindex{Not the right number of missing arguments}
-\end{itemize}
-
-\subsection{Occurrences sets and occurrences clauses}
-\label{Occurrences clauses}
-\index{Occurrences clauses}
-
-An occurrences clause is a modifier to some tactics that obeys the
-following syntax:
-
-$\!\!\!$\begin{tabular}{lcl}
-{\occclause} & ::= & {\tt in} {\occgoalset} \\
-{\occgoalset} & ::= &
- \zeroone{{\ident$_1$} \zeroone{\atoccurrences} {\tt ,} \\
-& & {\dots} {\tt ,}\\
-& & {\ident$_m$} \zeroone{\atoccurrences}}\\
-& & \zeroone{{\tt |-} \zeroone{{\tt *} \zeroone{\atoccurrences}}}\\
-& | &
- {\tt *} {\tt |-} \zeroone{{\tt *} \zeroone{\atoccurrences}}\\
-& | &
- {\tt *}\\
-{\atoccurrences} & ::= & {\tt at} {\occlist}\\
-{\occlist} & ::= & \zeroone{{\tt -}} {\num$_1$} \dots\ {\num$_n$}
-\end{tabular}
-
-The role of an occurrence clause is to select a set of occurrences of
-a {\term} in a goal. In the first case, the {{\ident$_i$}
-\zeroone{{\tt at} {\num$_1^i$} \dots\ {\num$_{n_i}^i$}}} parts
-indicate that occurrences have to be selected in the hypotheses named
-{\ident$_i$}. If no numbers are given for hypothesis {\ident$_i$},
-then all occurrences of {\term} in the hypothesis are selected. If
-numbers are given, they refer to occurrences of {\term} when the term
-is printed using option {\tt Set Printing All} (see
-Section~\ref{SetPrintingAll}), counting from left to right. In
-particular, occurrences of {\term} in implicit arguments (see
-Section~\ref{Implicit Arguments}) or coercions (see
-Section~\ref{Coercions}) are counted.
-
-If a minus sign is given between {\tt at} and the list of occurrences,
-it negates the condition so that the clause denotes all the occurrences except
-the ones explicitly mentioned after the minus sign.
-
-As an exception to the left-to-right order, the occurrences in the
-{\tt return} subexpression of a {\tt match} are considered {\em
-before} the occurrences in the matched term.
-
-In the second case, the {\tt *} on the left of {\tt |-} means that
-all occurrences of {\term} are selected in every hypothesis.
-
-In the first and second case, if {\tt *} is mentioned on the right of
-{\tt |-}, the occurrences of the conclusion of the goal have to be
-selected. If some numbers are given, then only the occurrences denoted
-by these numbers are selected. In no numbers are given, all
-occurrences of {\term} in the goal are selected.
-
-Finally, the last notation is an abbreviation for {\tt * |- *}. Note
-also that {\tt |-} is optional in the first case when no {\tt *} is
-given.
-
-Here are some tactics that understand occurrences clauses:
-{\tt set}, {\tt remember}, {\tt induction}, {\tt destruct}.
-
-\SeeAlso~Sections~\ref{tactic:set}, \ref{Tac-induction}, \ref{SetPrintingAll}.
-
-
-\section{Negation and contradiction}
-
-\subsection{\tt absurd \term
+\subsection{\tt absurd \term}
\tacindex{absurd}
-\label{absurd}}
+\label{absurd}
This tactic applies to any goal. The argument {\term} is any
proposition {\tt P} of type {\tt Prop}. This tactic applies {\tt
@@ -1145,15 +1349,15 @@ very useful in proofs by cases, where some cases are impossible. In
most cases, \texttt{P} or $\sim$\texttt{P} is one of the hypotheses of
the local context.
-\subsection{\tt contradiction
+\subsection{\tt contradiction}
\label{contradiction}
-\tacindex{contradiction}}
+\tacindex{contradiction}
This tactic applies to any goal. The {\tt contradiction} tactic
attempts to find in the current context (after all {\tt intros}) one
-hypothesis which is equivalent to {\tt False}. It permits to prune
-irrelevant cases. This tactic is a macro for the tactics sequence
-{\tt intros; elimtype False; assumption}.
+hypothesis that is equivalent to {\tt False}. It permits to prune
+irrelevant cases. This tactic is a macro for the tactics sequence
+{\tt intros; elimtype False; assumption}.
\begin{ErrMsgs}
\item \errindex{No such assumption}
@@ -1165,14 +1369,14 @@ irrelevant cases. This tactic is a macro for the tactics sequence
The proof of {\tt False} is searched in the hypothesis named \ident.
\end{Variants}
-\subsection {\tt contradict \ident}
+\subsection{\tt contradict \ident}
\label{contradict}
\tacindex{contradict}
This tactic allows to manipulate negated hypothesis and goals. The
-name \ident\ should correspond to a hypothesis. With
+name \ident\ should correspond to a hypothesis. With
{\tt contradict H}, the current goal and context is transformed in
-the following way:
+the following way:
\begin{itemize}
\item {\tt H:$\neg$A $\vd$ B} \ becomes \ {\tt $\vd$ A}
\item {\tt H:$\neg$A $\vd$ $\neg$B} \ becomes \ {\tt H: B $\vd$ A }
@@ -1189,497 +1393,169 @@ an elimination of {\tt False} is performed on the current goal, and the
user is then required to prove that {\tt False} is indeed provable in
the current context. This tactic is a macro for {\tt elimtype False}.
-\section{Conversion tactics
-\index{Conversion tactics}
-\label{Conversion-tactics}}
-
-This set of tactics implements different specialized usages of the
-tactic \texttt{change}.
-
-All conversion tactics (including \texttt{change}) can be
-parameterized by the parts of the goal where the conversion can
-occur. This is done using \emph{goal clauses} which consists in a list
-of hypotheses and, optionally, of a reference to the conclusion of the
-goal. For defined hypothesis it is possible to specify if the
-conversion should occur on the type part, the body part or both
-(default).
-
-\index{Clauses}
-\index{Goal clauses}
-Goal clauses are written after a conversion tactic (tactics
-\texttt{set}~\ref{tactic:set}, \texttt{rewrite}~\ref{rewrite},
-\texttt{replace}~\ref{tactic:replace} and
-\texttt{autorewrite}~\ref{tactic:autorewrite} also use goal clauses) and
-are introduced by the keyword \texttt{in}. If no goal clause is provided,
-the default is to perform the conversion only in the conclusion.
-
-The syntax and description of the various goal clauses is the following:
-\begin{description}
-\item[]\texttt{in {\ident}$_1$ $\ldots$ {\ident}$_n$ |- } only in hypotheses {\ident}$_1$
- \ldots {\ident}$_n$
-\item[]\texttt{in {\ident}$_1$ $\ldots$ {\ident}$_n$ |- *} in hypotheses {\ident}$_1$ \ldots
- {\ident}$_n$ and in the conclusion
-\item[]\texttt{in * |-} in every hypothesis
-\item[]\texttt{in *} (equivalent to \texttt{in * |- *}) everywhere
-\item[]\texttt{in (type of {\ident}$_1$) (value of {\ident}$_2$) $\ldots$ |-} in
- type part of {\ident}$_1$, in the value part of {\ident}$_2$, etc.
-\end{description}
-
-For backward compatibility, the notation \texttt{in}~{\ident}$_1$\ldots {\ident}$_n$
-performs the conversion in hypotheses {\ident}$_1$\ldots {\ident}$_n$.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%voir reduction__conv_x : histoires d'univers.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\subsection[{\tt cbv \flag$_1$ \dots\ \flag$_n$}, {\tt lazy \flag$_1$
-\dots\ \flag$_n$} and {\tt compute}]
-{{\tt cbv \flag$_1$ \dots\ \flag$_n$}, {\tt lazy \flag$_1$
-\dots\ \flag$_n$} and {\tt compute}
-\tacindex{cbv}
-\tacindex{lazy}
-\tacindex{compute}
-\tacindex{vm\_compute}\label{vmcompute}}
-
-These parameterized reduction tactics apply to any goal and perform
-the normalization of the goal according to the specified flags. In
-correspondence with the kinds of reduction considered in \Coq\, namely
-$\beta$ (reduction of functional application), $\delta$ (unfolding of
-transparent constants, see \ref{Transparent}), $\iota$ (reduction of
-pattern-matching over a constructed term, and unfolding of {\tt fix}
-and {\tt cofix} expressions) and $\zeta$ (contraction of local
-definitions), the flag are either {\tt beta}, {\tt delta}, {\tt iota}
-or {\tt zeta}. The {\tt delta} flag itself can be refined into {\tt
-delta [\qualid$_1$\ldots\qualid$_k$]} or {\tt delta
--[\qualid$_1$\ldots\qualid$_k$]}, restricting in the first case the
-constants to unfold to the constants listed, and restricting in the
-second case the constant to unfold to all but the ones explicitly
-mentioned. Notice that the {\tt delta} flag does not apply to
-variables bound by a let-in construction inside the term itself (use
-here the {\tt zeta} flag). In any cases, opaque constants are not
-unfolded (see Section~\ref{Opaque}).
-
-The goal may be normalized with two strategies: {\em lazy} ({\tt lazy}
-tactic), or {\em call-by-value} ({\tt cbv} tactic). The lazy strategy
-is a call-by-need strategy, with sharing of reductions: the arguments of a
-function call are partially evaluated only when necessary, and if an
-argument is used several times then it is computed only once. This
-reduction is efficient for reducing expressions with dead code. For
-instance, the proofs of a proposition {\tt exists~$x$. $P(x)$} reduce to a
-pair of a witness $t$, and a proof that $t$ satisfies the predicate
-$P$. Most of the time, $t$ may be computed without computing the proof
-of $P(t)$, thanks to the lazy strategy.
-
-The call-by-value strategy is the one used in ML languages: the
-arguments of a function call are evaluated first, using a weak
-reduction (no reduction under the $\lambda$-abstractions). Despite the
-lazy strategy always performs fewer reductions than the call-by-value
-strategy, the latter is generally more efficient for evaluating purely
-computational expressions (i.e. with few dead code).
+\section{Case analysis and induction}
-\begin{Variants}
-\item {\tt compute} \tacindex{compute}\\
- {\tt cbv}
-
- These are synonyms for {\tt cbv beta delta iota zeta}.
-
-\item {\tt lazy}
-
- This is a synonym for {\tt lazy beta delta iota zeta}.
-
-\item {\tt compute [\qualid$_1$\ldots\qualid$_k$]}\\
- {\tt cbv [\qualid$_1$\ldots\qualid$_k$]}
-
- These are synonyms of {\tt cbv beta delta
- [\qualid$_1$\ldots\qualid$_k$] iota zeta}.
-
-\item {\tt compute -[\qualid$_1$\ldots\qualid$_k$]}\\
- {\tt cbv -[\qualid$_1$\ldots\qualid$_k$]}
-
- These are synonyms of {\tt cbv beta delta
- -[\qualid$_1$\ldots\qualid$_k$] iota zeta}.
-
-\item {\tt lazy [\qualid$_1$\ldots\qualid$_k$]}\\
- {\tt lazy -[\qualid$_1$\ldots\qualid$_k$]}
-
- These are respectively synonyms of {\tt lazy beta delta
- [\qualid$_1$\ldots\qualid$_k$] iota zeta} and {\tt lazy beta delta
- -[\qualid$_1$\ldots\qualid$_k$] iota zeta}.
-
-\item {\tt vm\_compute} \tacindex{vm\_compute}
-
- This tactic evaluates the goal using the optimized call-by-value
- evaluation bytecode-based virtual machine. This algorithm is
- dramatically more efficient than the algorithm used for the {\tt
- cbv} tactic, but it cannot be fine-tuned. It is specially
- interesting for full evaluation of algebraic objects. This includes
- the case of reflexion-based tactics.
-
-\end{Variants}
-
-% Obsolete? Anyway not very important message
-%\begin{ErrMsgs}
-%\item \errindex{Delta must be specified before}
-%
-% A list of constants appeared before the {\tt delta} flag.
-%\end{ErrMsgs}
-
-
-\subsection{{\tt red}
-\tacindex{red}}
-
-This tactic applies to a goal which has the form {\tt
- forall (x:T1)\dots(xk:Tk), c t1 \dots\ tn} where {\tt c} is a constant. If
-{\tt c} is transparent then it replaces {\tt c} with its definition
-(say {\tt t}) and then reduces {\tt (t t1 \dots\ tn)} according to
-$\beta\iota\zeta$-reduction rules.
-
-\begin{ErrMsgs}
-\item \errindex{Not reducible}
-\end{ErrMsgs}
-
-\subsection{{\tt hnf}
-\tacindex{hnf}}
-
-This tactic applies to any goal. It replaces the current goal with its
-head normal form according to the $\beta\delta\iota\zeta$-reduction
-rules, i.e. it reduces the head of the goal until it becomes a
-product or an irreducible term.
+The tactics presented in this section implement induction or case
+analysis on inductive or co-inductive objects (see
+Section~\ref{Cic-inductive-definitions}).
-\Example
-The term \verb+forall n:nat, (plus (S n) (S n))+ is not reduced by {\tt hnf}.
+\subsection{\tt destruct \term}
+\tacindex{destruct}
+\label{destruct}
-\Rem The $\delta$ rule only applies to transparent constants
-(see Section~\ref{Opaque} on transparency and opacity).
+This tactic applies to any goal. The argument {\term} must be of
+inductive or co-inductive type and the tactic generates subgoals, one
+for each possible form of {\term}, i.e. one for each constructor of
+the inductive or co-inductive type. Unlike {\tt induction}, no
+induction hypothesis is generated by {\tt destruct}.
-\subsection{\tt simpl
-\tacindex{simpl}}
+If the argument is dependent in either the conclusion or some
+hypotheses of the goal, the argument is replaced by the appropriate
+constructor form in each of the resulting subgoals, thus performing
+case analysis. If non-dependent, the tactic simply exposes the
+inductive or co-inductive structure of the argument.
-This tactic applies to any goal. The tactic {\tt simpl} first applies
-$\beta\iota$-reduction rule. Then it expands transparent constants
-and tries to reduce {\tt T'} according, once more, to $\beta\iota$
-rules. But when the $\iota$ rule is not applicable then possible
-$\delta$-reductions are not applied. For instance trying to use {\tt
-simpl} on {\tt (plus n O)=n} changes nothing. Notice that only
-transparent constants whose name can be reused as such in the
-recursive calls are possibly unfolded. For instance a constant defined
-by {\tt plus' := plus} is possibly unfolded and reused in the
-recursive calls, but a constant such as {\tt succ := plus (S O)} is
-never unfolded.
+There are special cases:
-The behaviour of {\tt simpl} can be tuned using the {\tt Arguments} vernacular
-command as follows:
\begin{itemize}
-\item
-A constant can be marked to be never unfolded by {\tt simpl}:
-\begin{coq_example*}
-Arguments minus x y : simpl never
-\end{coq_example*}
-After that command an expression like {\tt (minus (S x) y)} is left untouched by
-the {\tt simpl} tactic.
-\item
-A constant can be marked to be unfolded only if applied to enough arguments.
-The number of arguments required can be specified using
-the {\tt /} symbol in the arguments list of the {\tt Arguments} vernacular
-command.
-\begin{coq_example*}
-Definition fcomp A B C f (g : A -> B) (x : A) : C := f (g x).
-Notation "f \o g" := (fcomp f g) (at level 50).
-Arguments fcomp {A B C} f g x /.
-\end{coq_example*}
-After that command the expression {\tt (f \verb+\+o g)} is left untouched by
-{\tt simpl} while {\tt ((f \verb+\+o g) t)} is reduced to {\tt (f (g t))}.
-The same mechanism can be used to make a constant volatile, i.e. always
-unfolded by {\tt simpl}.
-\begin{coq_example*}
-Definition volatile := fun x : nat => x.
-Arguments volatile / x.
-\end{coq_example*}
-\item
-A constant can be marked to be unfolded only if an entire set of arguments
-evaluates to a constructor. The {\tt !} symbol can be used to mark such
-arguments.
-\begin{coq_example*}
-Arguments minus !x !y.
-\end{coq_example*}
-After that command, the expression {\tt (minus (S x) y)} is left untouched by
-{\tt simpl}, while {\tt (minus (S x) (S y))} is reduced to {\tt (minus x y)}.
-\item
-A special heuristic to determine if a constant has to be unfolded can be
-activated with the following command:
-\begin{coq_example*}
-Arguments minus x y : simpl nomatch
-\end{coq_example*}
-The heuristic avoids to perform a simplification step that would
-expose a {\tt match} construct in head position. For example the
-expression {\tt (minus (S (S x)) (S y))} is simplified to
-{\tt (minus (S x) y)} even if an extra simplification is possible.
-\end{itemize}
-
-\tacindex{simpl \dots\ in}
-\begin{Variants}
-\item {\tt simpl {\term}}
-
- This applies {\tt simpl} only to the occurrences of {\term} in the
- current goal.
-
-\item {\tt simpl {\term} at \num$_1$ \dots\ \num$_i$}
-
- This applies {\tt simpl} only to the \num$_1$, \dots, \num$_i$
- occurrences of {\term} in the current goal.
-
- \ErrMsg {\tt Too few occurrences}
-
-\item {\tt simpl {\ident}}
-
- This applies {\tt simpl} only to the applicative subterms whose head
- occurrence is {\ident}.
-
-\item {\tt simpl {\ident} at \num$_1$ \dots\ \num$_i$}
-
- This applies {\tt simpl} only to the \num$_1$, \dots, \num$_i$
-applicative subterms whose head occurrence is {\ident}.
-
-\end{Variants}
-
-\subsection{\tt unfold \qualid
-\tacindex{unfold}
-\label{unfold}}
-
-This tactic applies to any goal. The argument {\qualid} must denote a
-defined transparent constant or local definition (see Sections~\ref{Basic-definitions} and~\ref{Transparent}). The tactic {\tt
- unfold} applies the $\delta$ rule to each occurrence of the constant
-to which {\qualid} refers in the current goal and then replaces it
-with its $\beta\iota$-normal form.
-
-\begin{ErrMsgs}
-\item {\qualid} \errindex{does not denote an evaluable constant}
-
-\end{ErrMsgs}
-
-\begin{Variants}
-\item {\tt unfold {\qualid}$_1$, \dots, \qualid$_n$}
- \tacindex{unfold \dots\ in}
-
- Replaces {\em simultaneously} {\qualid}$_1$, \dots, {\qualid}$_n$
- with their definitions and replaces the current goal with its
- $\beta\iota$ normal form.
-
-\item {\tt unfold {\qualid}$_1$ at \num$_1^1$, \dots, \num$_i^1$,
-\dots,\ \qualid$_n$ at \num$_1^n$ \dots\ \num$_j^n$}
-
- The lists \num$_1^1$, \dots, \num$_i^1$ and \num$_1^n$, \dots,
- \num$_j^n$ specify the occurrences of {\qualid}$_1$, \dots,
- \qualid$_n$ to be unfolded. Occurrences are located from left to
- right.
-
- \ErrMsg {\tt bad occurrence number of {\qualid}$_i$}
-
- \ErrMsg {\qualid}$_i$ {\tt does not occur}
-
-\item {\tt unfold {\qstring}}
- If {\qstring} denotes the discriminating symbol of a notation (e.g. {\tt
- "+"}) or an expression defining a notation (e.g. \verb!"_ + _"!), and
- this notation refers to an unfoldable constant, then the tactic
- unfolds it.
-
-\item {\tt unfold {\qstring}\%{\delimkey}}
-
- This is variant of {\tt unfold {\qstring}} where {\qstring} gets its
- interpretation from the scope bound to the delimiting key
- {\delimkey} instead of its default interpretation (see
- Section~\ref{scopechange}).
-
-\item {\tt unfold \qualidorstring$_1$ at \num$_1^1$, \dots, \num$_i^1$,
-\dots,\ \qualidorstring$_n$ at \num$_1^n$ \dots\ \num$_j^n$}
-
- This is the most general form, where {\qualidorstring} is either a
- {\qualid} or a {\qstring} referring to a notation.
-
-\end{Variants}
-
-\subsection{{\tt fold} \term
-\tacindex{fold}}
-
-This tactic applies to any goal. The term \term\ is reduced using the {\tt red}
-tactic. Every occurrence of the resulting term in the goal is then
-replaced by \term.
-
-\begin{Variants}
-\item {\tt fold} \term$_1$ \dots\ \term$_n$
-
- Equivalent to {\tt fold} \term$_1${\tt;}\ldots{\tt; fold} \term$_n$.
-\end{Variants}
+\item If {\term} is an identifier {\ident} denoting a quantified
+variable of the conclusion of the goal, then {\tt destruct {\ident}}
+behaves as {\tt intros until {\ident}; destruct {\ident}}.
-\subsection{{\tt pattern {\term}}
-\tacindex{pattern}
-\label{pattern}}
+\item If {\term} is a {\num}, then {\tt destruct {\num}} behaves as
+{\tt intros until {\num}} followed by {\tt destruct} applied to the
+last introduced hypothesis. Remark: For destruction of a numeral, use
+syntax {\tt destruct ({\num})} (not very interesting anyway).
-This command applies to any goal. The argument {\term} must be a free
-subterm of the current goal. The command {\tt pattern} performs
-$\beta$-expansion (the inverse of $\bt$-reduction) of the current goal
-(say \T) by
-\begin{enumerate}
-\item replacing all occurrences of {\term} in {\T} with a fresh variable
-\item abstracting this variable
-\item applying the abstracted goal to {\term}
-\end{enumerate}
+\item The argument {\term} can also be a pattern of which holes are
+ denoted by ``\_''. In this case, the tactic checks that all subterms
+ matching the pattern in the conclusion and the hypotheses are
+ compatible and performs case analysis using this subterm.
-For instance, if the current goal $T$ is expressible has $\phi(t)$
-where the notation captures all the instances of $t$ in $\phi(t)$,
-then {\tt pattern $t$} transforms it into {\tt (fun x:$A$ => $\phi(${\tt
-x}$)$) $t$}. This command can be used, for instance, when the tactic
-{\tt apply} fails on matching.
+\end{itemize}
\begin{Variants}
-\item {\tt pattern {\term} at {\num$_1$} \dots\ {\num$_n$}}
-
- Only the occurrences {\num$_1$} \dots\ {\num$_n$} of {\term} are
- considered for $\beta$-expansion. Occurrences are located from left
- to right.
+\item{\tt destruct {\term} as {\disjconjintropattern}}
-\item {\tt pattern {\term} at - {\num$_1$} \dots\ {\num$_n$}}
-
- All occurrences except the occurrences of indexes {\num$_1$} \dots\
- {\num$_n$} of {\term} are considered for
- $\beta$-expansion. Occurrences are located from left to right.
+ This behaves as {\tt destruct {\term}} but uses the names in
+ {\intropattern} to name the variables introduced in the context.
+ The {\intropattern} must have the form {\tt [} $p_{11}$ \ldots
+ $p_{1n_1}$ {\tt |} {\ldots} {\tt |} $p_{m1}$ \ldots $p_{mn_m}$ {\tt
+ ]} with $m$ being the number of constructors of the type of
+ {\term}. Each variable introduced by {\tt destruct} in the context
+ of the $i^{th}$ goal gets its name from the list $p_{i1}$ \ldots
+ $p_{in_i}$ in order. If there are not enough names, {\tt destruct}
+ invents names for the remaining variables to introduce. More
+ generally, the $p_{ij}$ can be any disjunctive/conjunctive
+ introduction pattern (see Section~\ref{intros-pattern}). This
+ provides a concise notation for nested destruction.
-\item {\tt pattern {\term$_1$}, \dots, {\term$_m$}}
-
- Starting from a goal $\phi(t_1 \dots\ t_m)$, the tactic
- {\tt pattern $t_1$, \dots,\ $t_m$} generates the equivalent goal {\tt
- (fun (x$_1$:$A_1$) \dots\ (x$_m$:$A_m$) => $\phi(${\tt x$_1$\dots\
- x$_m$}$)$) $t_1$ \dots\ $t_m$}.\\ If $t_i$ occurs in one of the
- generated types $A_j$ these occurrences will also be considered and
- possibly abstracted.
+% It is recommended to use this variant of {\tt destruct} for
+% robust proof scripts.
-\item {\tt pattern {\term$_1$} at {\num$_1^1$} \dots\ {\num$_{n_1}^1$}, \dots,
- {\term$_m$} at {\num$_1^m$} \dots\ {\num$_{n_m}^m$}}
-
- This behaves as above but processing only the occurrences \num$_1^1$,
- \dots, \num$_i^1$ of \term$_1$, \dots, \num$_1^m$, \dots, \num$_j^m$
- of \term$_m$ starting from \term$_m$.
+\item{\tt destruct {\term} as {\disjconjintropattern} \_eqn}
-\item {\tt pattern} {\term$_1$} \zeroone{{\tt at \zeroone{-}} {\num$_1^1$} \dots\ {\num$_{n_1}^1$}} {\tt ,} \dots {\tt ,}
- {\term$_m$} \zeroone{{\tt at \zeroone{-}} {\num$_1^m$} \dots\ {\num$_{n_m}^m$}}
-
- This is the most general syntax that combines the different variants.
+ This behaves as {\tt destruct {\term}} but adds an equation between
+ {\term} and the value that {\term} takes in each of the possible
+ cases. The name of the equation is chosen by Coq. If
+ {\disjconjintropattern} is simply {\tt []}, it is automatically considered
+ as a disjunctive pattern of the appropriate size.
-\end{Variants}
+\item{\tt destruct {\term} as {\disjconjintropattern} \_eqn:~{\namingintropattern}}
-\subsection{Conversion tactics applied to hypotheses}
+ This behaves as {\tt destruct {\term} as
+ {\disjconjintropattern} \_eqn} but use {\namingintropattern} to
+ name the equation (see Section~\ref{intros-pattern}). Note that spaces
+ can generally be removed around {\tt \_eqn}.
-{\convtactic} {\tt in} \ident$_1$ \dots\ \ident$_n$
+\item{\tt destruct {\term} with \bindinglist}
-Applies the conversion tactic {\convtactic} to the
-hypotheses \ident$_1$, \ldots, \ident$_n$. The tactic {\convtactic} is
-any of the conversion tactics listed in this section.
+ This behaves like \texttt{destruct {\term}} providing explicit
+ instances for the dependent premises of the type of {\term} (see
+ syntax of bindings in Section~\ref{Binding-list}).
-If \ident$_i$ is a local definition, then \ident$_i$ can be replaced
-by (Type of \ident$_i$) to address not the body but the type of the
-local definition. Example: {\tt unfold not in (Type of H1) (Type of H3).}
+\item{\tt edestruct {\term}\tacindex{edestruct}}
-\begin{ErrMsgs}
-\item \errindex{No such hypothesis} : {\ident}.
-\end{ErrMsgs}
+ This tactic behaves like \texttt{destruct {\term}} except that it
+ does not fail if the instance of a dependent premises of the type of
+ {\term} is not inferable. Instead, the unresolved instances are left
+ as existential variables to be inferred later, in the same way as
+ {\tt eapply} does (see Section~\ref{eapply-example}).
+\item{\tt destruct {\term$_1$} using {\term$_2$}}\\
+ {\tt destruct {\term$_1$} using {\term$_2$} with {\bindinglist}}
-\section{Introductions}
+ These are synonyms of {\tt induction {\term$_1$} using {\term$_2$}} and
+ {\tt induction {\term$_1$} using {\term$_2$} with {\bindinglist}}.
-Introduction tactics address goals which are inductive constants.
-They are used when one guesses that the goal can be obtained with one
-of its constructors' type.
+\item \texttt{destruct {\term} in {\occgoalset}}
-\subsection{\tt constructor \num
-\label{constructor}
-\tacindex{constructor}}
+ This syntax is used for selecting which occurrences of {\term} the
+ case analysis has to be done on. The {\tt in {\occgoalset}} clause is an
+ occurrence clause whose syntax and behavior is described in
+ Section~\ref{Occurrences clauses}.
-This tactic applies to a goal such that the head of its conclusion is
-an inductive constant (say {\tt I}). The argument {\num} must be less
-or equal to the numbers of constructor(s) of {\tt I}. Let {\tt ci} be
-the {\tt i}-th constructor of {\tt I}, then {\tt constructor i} is
-equivalent to {\tt intros; apply ci}.
+% When an occurrence clause is given, an equation between {\term} and
+% the value it gets in each case of the analysis is added to the
+% context of the subgoals corresponding to the cases (even
+% if no clause {\tt as {\namingintropattern}} is given).
-\begin{ErrMsgs}
-\item \errindex{Not an inductive product}
-\item \errindex{Not enough constructors}
-\end{ErrMsgs}
+\item{\tt destruct {\term$_1$} with {\bindinglist$_1$} as {\disjconjintropattern} \_eqn:~{\namingintropattern} using {\term$_2$} with {\bindinglist$_2$} in {\occgoalset}}\\
+ {\tt edestruct {\term$_1$} with {\bindinglist$_1$} as {\disjconjintropattern} \_eqn:~{\namingintropattern} using {\term$_2$} with {\bindinglist$_2$} in {\occgoalset}}
-\begin{Variants}
-\item \texttt{constructor}
-
- This tries \texttt{constructor 1} then \texttt{constructor 2},
- \dots\ , then \texttt{constructor} \textit{n} where \textit{n} if
- the number of constructors of the head of the goal.
+ These are the general forms of {\tt destruct} and {\tt edestruct}.
+ They combine the effects of the {\tt with}, {\tt as}, {\tt using},
+ and {\tt in} clauses.
-\item {\tt constructor \num~with} {\bindinglist}
-
- Let {\tt ci} be the {\tt i}-th constructor of {\tt I}, then {\tt
- constructor i with \bindinglist} is equivalent to {\tt intros;
- apply ci with \bindinglist}.
+\item{\tt case \term}\label{case}\tacindex{case}
- \Warning the terms in the \bindinglist\ are checked
- in the context where {\tt constructor} is executed and not in the
- context where {\tt apply} is executed (the introductions are not
- taken into account).
+ The tactic {\tt case} is a more basic tactic to perform case
+ analysis without recursion. It behaves as {\tt elim \term} but using
+ a case-analysis elimination principle and not a recursive one.
-% To document?
-% \item {\tt constructor {\tactic}}
+\item {\tt case {\term} with {\bindinglist}}
-\item {\tt split}\tacindex{split}
+ Analogous to {\tt elim {\term} with {\bindinglist}} above.
- Applies if {\tt I} has only one constructor, typically in the case
- of conjunction $A\land B$. Then, it is equivalent to {\tt constructor 1}.
+\item{\tt ecase {\term}\tacindex{ecase}}\\
+ {\tt ecase {\term} with {\bindinglist}}
-\item {\tt exists {\bindinglist}}\tacindex{exists}
+ In case the type of {\term} has dependent premises, or dependent
+ premises whose values are not inferable from the {\tt with
+ {\bindinglist}} clause, {\tt ecase} turns them into existential
+ variables to be resolved later on.
- Applies if {\tt I} has only one constructor, for instance in the
- case of existential quantification $\exists x\cdot P(x)$.
- Then, it is equivalent to {\tt intros; constructor 1 with \bindinglist}.
+\item {\tt simple destruct \ident}\tacindex{simple destruct}
-\item {\tt exists \nelist{\bindinglist}{,}}
+ This tactic behaves as {\tt intros until
+ {\ident}; case {\tt {\ident}}} when {\ident} is a quantified
+ variable of the goal.
- This iteratively applies {\tt exists {\bindinglist}}.
+\item {\tt simple destruct {\num}}
-\item {\tt left}\tacindex{left}\\
- {\tt right}\tacindex{right}
+ This tactic behaves as {\tt intros until
+ {\num}; case {\tt {\ident}}} where {\ident} is the name given by
+ {\tt intros until {\num}} to the {\num}-th non-dependent premise of
+ the goal.
- Apply if {\tt I} has two constructors, for instance in the case of
- disjunction $A\lor B$. Then, they are respectively equivalent to {\tt
- constructor 1} and {\tt constructor 2}.
-
-\item {\tt left with \bindinglist}\\
- {\tt right with \bindinglist}\\
- {\tt split with \bindinglist}
-
- As soon as the inductive type has the right number of constructors,
- these expressions are equivalent to calling {\tt
- constructor $i$ with \bindinglist} for the appropriate $i$.
+\item{\tt case\_eq \term}\label{case_eq}\tacindex{case\_eq}
-\item \texttt{econstructor}\tacindex{econstructor}\\
- \texttt{eexists}\tacindex{eexists}\\
- \texttt{esplit}\tacindex{esplit}\\
- \texttt{eleft}\tacindex{eleft}\\
- \texttt{eright}\tacindex{eright}\\
+ The tactic {\tt case\_eq} is a variant of the {\tt case} tactic that
+ allow to perform case analysis on a term without completely
+ forgetting its original form. This is done by generating equalities
+ between the original form of the term and the outcomes of the case
+ analysis.
- These tactics and their variants behave like \texttt{constructor},
- \texttt{exists}, \texttt{split}, \texttt{left}, \texttt{right} and
- their variants but they introduce existential variables instead of
- failing when the instantiation of a variable cannot be found (cf
- \texttt{eapply} and Section~\ref{eapply-example}).
+% The effect of this tactic is similar to the effect of {\tt
+% destruct {\term} in |- *} with the exception that no new hypotheses
+% are introduced in the context.
\end{Variants}
-\section[Induction and Case Analysis]{Induction and Case Analysis
-\label{Tac-induction}}
-
-The tactics presented in this section implement induction or case
-analysis on inductive or coinductive objects (see
-Section~\ref{Cic-inductive-definitions}).
-
-\subsection{\tt induction \term
-\tacindex{induction}}
+\subsection{\tt induction \term}
+\tacindex{induction}
+\label{Tac-induction}
This tactic applies to any goal. The argument {\term} must be of
inductive type and the tactic {\tt induction} generates subgoals,
@@ -1724,14 +1600,14 @@ induction n.
\item \errindex{Not an inductive product}
\item \errindex{Unable to find an instance for the variables
{\ident} \ldots {\ident}}
-
- Use in this case
+
+ Use in this case
the variant {\tt elim \dots\ with \dots} below.
\end{ErrMsgs}
\begin{Variants}
\item{\tt induction {\term} as {\disjconjintropattern}}
-
+
This behaves as {\tt induction {\term}} but uses the names in
{\disjconjintropattern} to name the variables introduced in the context.
The {\disjconjintropattern} must typically be of the form
@@ -1748,17 +1624,17 @@ induction n.
{\tt ($p_{1}$,\ldots,$p_{n}$)} can be used instead of
{\tt [} $p_{1}$ \ldots $p_{n}$ {\tt ]}.
-\item{\tt induction {\term} as {\namingintropattern}}
+%\item{\tt induction {\term} as {\namingintropattern}}
- This behaves as {\tt induction {\term}} but adds an equation between
- {\term} and the value that {\term} takes in each of the induction
- case. The name of the equation is built according to
- {\namingintropattern} which can be an identifier, a ``?'', etc, as
- indicated in Section~\ref{intros-pattern}.
+% This behaves as {\tt induction {\term}} but adds an equation between
+% {\term} and the value that {\term} takes in each of the induction
+% case. The name of the equation is built according to
+% {\namingintropattern} which can be an identifier, a ``?'', etc, as
+% indicated in Section~\ref{intros-pattern}.
-\item{\tt induction {\term} as {\namingintropattern} {\disjconjintropattern}}
+%\item{\tt induction {\term} as {\namingintropattern} {\disjconjintropattern}}
- This combines the two previous forms.
+% This combines the two previous forms.
\item{\tt induction {\term} with \bindinglist}
@@ -1794,14 +1670,14 @@ induction n.
\item \texttt{induction {\term} in {\occgoalset}}
This syntax is used for selecting which occurrences of {\term} the
- induction has to be carried on. The {\tt in {\atoccurrences}} clause is an
+ induction has to be carried on. The {\tt in \occgoalset} clause is an
occurrence clause whose syntax and behavior is described in
Section~\ref{Occurrences clauses}.
- When an occurrence clause is given, an equation between {\term} and
- the value it gets in each case of the induction is added to the
- context of the subgoals corresponding to the induction cases (even
- if no clause {\tt as {\namingintropattern}} is given).
+% When an occurrence clause is given, an equation between {\term} and
+% the value it gets in each case of the induction is added to the
+% context of the subgoals corresponding to the induction cases (even
+% if no clause {\tt as {\namingintropattern}} is given).
\item {\tt induction {\term$_1$} with {\bindinglist$_1$} as {\namingintropattern} {\disjconjintropattern} using {\term$_2$} with {\bindinglist$_2$} in {\occgoalset}}\\
{\tt einduction {\term$_1$} with {\bindinglist$_1$} as {\namingintropattern} {\disjconjintropattern} using {\term$_2$} with {\bindinglist$_2$} in {\occgoalset}}
@@ -1811,7 +1687,7 @@ induction n.
{\tt using}, and {\tt in} clauses.
\item {\tt elim \term}\label{elim}
-
+
This is a more basic induction tactic. Again, the type of the
argument {\term} must be an inductive type. Then, according to
the type of the goal, the tactic {\tt elim} chooses the appropriate
@@ -1832,7 +1708,7 @@ induction n.
otherwise.
\item {\tt elim {\term} with {\bindinglist}}
-
+
Allows to give explicit instances to the premises of the type
of {\term} (see Section~\ref{Binding-list}).
@@ -1857,7 +1733,7 @@ instantiate premises of the type of {\term$_2$}.
of the {\tt with} clause.
\item {\tt elimtype \form}\tacindex{elimtype}
-
+
The argument {\form} must be inductively defined. {\tt elimtype I}
is equivalent to {\tt cut I. intro H{\rm\sl n}; elim H{\rm\sl n};
clear H{\rm\sl n}}. Therefore the hypothesis {\tt H{\rm\sl n}} will
@@ -1867,20 +1743,20 @@ instantiate premises of the type of {\term$_2$}.
exact t.}
\item {\tt simple induction \ident}\tacindex{simple induction}
-
+
This tactic behaves as {\tt intros until
{\ident}; elim {\tt {\ident}}} when {\ident} is a quantified
variable of the goal.
\item {\tt simple induction {\num}}
-
+
This tactic behaves as {\tt intros until
{\num}; elim {\tt {\ident}}} where {\ident} is the name given by
{\tt intros until {\num}} to the {\num}-th non-dependent premise of
the goal.
%% \item {\tt simple induction {\term}}\tacindex{simple induction}
-
+
%% If {\term} is an {\ident} corresponding to a quantified variable of
%% the goal then the tactic behaves as {\tt intros until {\ident}; elim
%% {\tt {\ident}}}. If {\term} is a {\num} then the tactic behaves as
@@ -1892,280 +1768,12 @@ instantiate premises of the type of {\term$_2$}.
\end{Variants}
-\subsection{\tt destruct \term
-\tacindex{destruct}}
-\label{destruct}
-
-This tactic applies to any goal. The argument {\term} must be of
-inductive or coinductive type and the tactic generates subgoals, one
-for each possible form of {\term}, i.e. one for each constructor of
-the inductive or coinductive type. Unlike {\tt induction}, no
-induction hypothesis is generated by {\tt destruct}.
-
-If the argument is dependent in either the conclusion or some
-hypotheses of the goal, the argument is replaced by the appropriate
-constructor form in each of the resulting subgoals, thus performing
-case analysis. If non dependent, the tactic simply exposes the
-inductive or coinductive structure of the argument.
-
-There are special cases:
-
-\begin{itemize}
-
-\item If {\term} is an identifier {\ident} denoting a quantified
-variable of the conclusion of the goal, then {\tt destruct {\ident}}
-behaves as {\tt intros until {\ident}; destruct {\ident}}.
-
-\item If {\term} is a {\num}, then {\tt destruct {\num}} behaves as
-{\tt intros until {\num}} followed by {\tt destruct} applied to the
-last introduced hypothesis. Remark: For destruction of a numeral, use
-syntax {\tt destruct ({\num})} (not very interesting anyway).
-
-\item The argument {\term} can also be a pattern of which holes are
- denoted by ``\_''. In this case, the tactic checks that all subterms
- matching the pattern in the conclusion and the hypotheses are
- compatible and performs case analysis using this subterm.
-
-\end{itemize}
-
-\begin{Variants}
-\item{\tt destruct {\term} as {\disjconjintropattern}}
-
- This behaves as {\tt destruct {\term}} but uses the names in
- {\intropattern} to name the variables introduced in the context.
- The {\intropattern} must have the form {\tt [} $p_{11}$ \ldots
- $p_{1n_1}$ {\tt |} {\ldots} {\tt |} $p_{m1}$ \ldots $p_{mn_m}$ {\tt
- ]} with $m$ being the number of constructors of the type of
- {\term}. Each variable introduced by {\tt destruct} in the context
- of the $i^{th}$ goal gets its name from the list $p_{i1}$ \ldots
- $p_{in_i}$ in order. If there are not enough names, {\tt destruct}
- invents names for the remaining variables to introduce. More
- generally, the $p_{ij}$ can be any disjunctive/conjunctive
- introduction pattern (see Section~\ref{intros-pattern}). This
- provides a concise notation for nested destruction.
-
-% It is recommended to use this variant of {\tt destruct} for
-% robust proof scripts.
-
-\item{\tt destruct {\term} as {\disjconjintropattern} \_eqn}
-
- This behaves as {\tt destruct {\term}} but adds an equation between
- {\term} and the value that {\term} takes in each of the possible
- cases. The name of the equation is chosen by Coq. If
- {\disjconjintropattern} is simply {\tt []}, it is automatically considered
- as a disjunctive pattern of the appropriate size.
-
-\item{\tt destruct {\term} as {\disjconjintropattern} \_eqn: {\namingintropattern}}
-
- This behaves as {\tt destruct {\term} as
- {\disjconjintropattern} \_eqn} but use {\namingintropattern} to
- name the equation (see Section~\ref{intros-pattern}). Note that spaces
- can generally be removed around {\tt \_eqn}.
-
-\item{\tt destruct {\term} with \bindinglist}
-
- This behaves like \texttt{destruct {\term}} providing explicit
- instances for the dependent premises of the type of {\term} (see
- syntax of bindings in Section~\ref{Binding-list}).
-
-\item{\tt edestruct {\term}\tacindex{edestruct}}
-
- This tactic behaves like \texttt{destruct {\term}} excepts that it
- does not fail if the instance of a dependent premises of the type of
- {\term} is not inferable. Instead, the unresolved instances are left
- as existential variables to be inferred later, in the same way as
- {\tt eapply} does (see Section~\ref{eapply-example}).
-
-\item{\tt destruct {\term$_1$} using {\term$_2$}}\\
- {\tt destruct {\term$_1$} using {\term$_2$} with {\bindinglist}}
-
- These are synonyms of {\tt induction {\term$_1$} using {\term$_2$}} and
- {\tt induction {\term$_1$} using {\term$_2$} with {\bindinglist}}.
-
-\item \texttt{destruct {\term} in {\occgoalset}}
-
- This syntax is used for selecting which occurrences of {\term} the
- case analysis has to be done on. The {\tt in {\occgoalset}} clause is an
- occurrence clause whose syntax and behavior is described in
- Section~\ref{Occurrences clauses}.
-
- When an occurrence clause is given, an equation between {\term} and
- the value it gets in each case of the analysis is added to the
- context of the subgoals corresponding to the cases (even
- if no clause {\tt as {\namingintropattern}} is given).
-
-\item{\tt destruct {\term$_1$} with {\bindinglist$_1$} as {\disjconjintropattern} \_eqn: {\namingintropattern} using {\term$_2$} with {\bindinglist$_2$} in {\occgoalset}}\\
- {\tt edestruct {\term$_1$} with {\bindinglist$_1$} as {\disjconjintropattern} \_eqn: {\namingintropattern} using {\term$_2$} with {\bindinglist$_2$} in {\occgoalset}}
-
- These are the general forms of {\tt destruct} and {\tt edestruct}.
- They combine the effects of the {\tt with}, {\tt as}, {\tt using},
- and {\tt in} clauses.
-
-\item{\tt case \term}\label{case}\tacindex{case}
-
- The tactic {\tt case} is a more basic tactic to perform case
- analysis without recursion. It behaves as {\tt elim \term} but using
- a case-analysis elimination principle and not a recursive one.
-
-\item{\tt case\_eq \term}\label{case_eq}\tacindex{case\_eq}
-
- The tactic {\tt case\_eq} is a variant of the {\tt case} tactic that
- allow to perform case analysis on a term without completely
- forgetting its original form. This is done by generating equalities
- between the original form of the term and the outcomes of the case
- analysis. The effect of this tactic is similar to the effect of {\tt
- destruct {\term} in |- *} with the exception that no new hypotheses
- are introduced in the context.
-
-\item {\tt case {\term} with {\bindinglist}}
-
- Analogous to {\tt elim {\term} with {\bindinglist}} above.
-
-\item{\tt ecase {\term}\tacindex{ecase}}\\
- {\tt ecase {\term} with {\bindinglist}}
-
- In case the type of {\term} has dependent premises, or dependent
- premises whose values are not inferable from the {\tt with
- {\bindinglist}} clause, {\tt ecase} turns them into existential
- variables to be resolved later on.
-
-\item {\tt simple destruct \ident}\tacindex{simple destruct}
-
- This tactic behaves as {\tt intros until
- {\ident}; case {\tt {\ident}}} when {\ident} is a quantified
- variable of the goal.
-
-\item {\tt simple destruct {\num}}
-
- This tactic behaves as {\tt intros until
- {\num}; case {\tt {\ident}}} where {\ident} is the name given by
- {\tt intros until {\num}} to the {\num}-th non-dependent premise of
- the goal.
-
-
-\end{Variants}
-
-\subsection{\tt intros {\intropattern} {\ldots} {\intropattern}
-\label{intros-pattern}
-\tacindex{intros \intropattern}}
-\index{Introduction patterns}
-\index{Naming introduction patterns}
-\index{Disjunctive/conjunctive introduction patterns}
-
-This extension of the tactic {\tt intros} combines introduction of
-variables or hypotheses and case analysis. An {\em introduction pattern} is
-either:
-\begin{itemize}
-\item A {\em naming introduction pattern}, i.e. either one of:
- \begin{itemize}
- \item the pattern \texttt{?}
- \item the pattern \texttt{?\ident}
- \item an identifier
- \end{itemize}
-\item A {\em disjunctive/conjunctive introduction pattern}, i.e. either one of:
- \begin{itemize}
- \item a disjunction of lists of patterns:
- {\tt [$p_{11}$ {\ldots} $p_{1m_1}$ | {\ldots} | $p_{11}$ {\ldots} $p_{nm_n}$]}
- \item a conjunction of patterns: {\tt (} $p_1$ {\tt ,} {\ldots} {\tt ,} $p_n$ {\tt )}
- \item a list of patterns {\tt (} $p_1$\ {\tt \&}\ {\ldots}\ {\tt \&}\ $p_n$ {\tt )}
- for sequence of right-associative binary constructs
- \end{itemize}
-\item the wildcard: {\tt \_}
-\item the rewriting orientations: {\tt ->} or {\tt <-}
-\end{itemize}
-
-Assuming a goal of type {\tt $Q$ -> $P$} (non dependent product), or
-of type {\tt forall $x$:$T$, $P$} (dependent product), the behavior of
-{\tt intros $p$} is defined inductively over the structure of the
-introduction pattern $p$:
-\begin{itemize}
-\item introduction on \texttt{?} performs the introduction, and lets {\Coq}
- choose a fresh name for the variable;
-\item introduction on \texttt{?\ident} performs the introduction, and
- lets {\Coq} choose a fresh name for the variable based on {\ident};
-\item introduction on \texttt{\ident} behaves as described in
- Section~\ref{intro};
-\item introduction over a disjunction of list of patterns {\tt
- [$p_{11}$ {\ldots} $p_{1m_1}$ | {\ldots} | $p_{11}$ {\ldots}
- $p_{nm_n}$]} expects the product to be over an inductive type
- whose number of constructors is $n$ (or more generally over a type
- of conclusion an inductive type built from $n$ constructors,
- e.g. {\tt C -> A$\backslash$/B if $n=2$}): it destructs the introduced
- hypothesis as {\tt destruct} (see Section~\ref{destruct}) would and
- applies on each generated subgoal the corresponding tactic;
- \texttt{intros}~$p_{i1}$ {\ldots} $p_{im_i}$; if the disjunctive
- pattern is part of a sequence of patterns and is not the last
- pattern of the sequence, then {\Coq} completes the pattern so as all
- the argument of the constructors of the inductive type are
- introduced (for instance, the list of patterns {\tt [$\;$|$\;$] H}
- applied on goal {\tt forall x:nat, x=0 -> 0=x} behaves the same as
- the list of patterns {\tt [$\,$|$\,$?$\,$] H});
-\item introduction over a conjunction of patterns {\tt ($p_1$, \ldots,
- $p_n$)} expects the goal to be a product over an inductive type $I$ with a
- single constructor that itself has at least $n$ arguments: it
- performs a case analysis over the hypothesis, as {\tt destruct}
- would, and applies the patterns $p_1$~\ldots~$p_n$ to the arguments
- of the constructor of $I$ (observe that {\tt ($p_1$, {\ldots},
- $p_n$)} is an alternative notation for {\tt [$p_1$ {\ldots}
- $p_n$]});
-\item introduction via {\tt ( $p_1$ \& \ldots \& $p_n$ )}
- is a shortcut for introduction via
- {\tt ($p_1$,(\ldots,(\dots,$p_n$)\ldots))}; it expects the
- hypothesis to be a sequence of right-associative binary inductive
- constructors such as {\tt conj} or {\tt ex\_intro}; for instance, an
- hypothesis with type {\tt A\verb|/\|exists x, B\verb|/\|C\verb|/\|D} can be
- introduced via pattern {\tt (a \& x \& b \& c \& d)};
-\item introduction on the wildcard depends on whether the product is
- dependent or not: in the non dependent case, it erases the
- corresponding hypothesis (i.e. it behaves as an {\tt intro} followed
- by a {\tt clear}, cf Section~\ref{clear}) while in the dependent
- case, it succeeds and erases the variable only if the wildcard is
- part of a more complex list of introduction patterns that also
- erases the hypotheses depending on this variable;
-\item introduction over {\tt ->} (respectively {\tt <-}) expects the
- hypothesis to be an equality and the right-hand-side (respectively
- the left-hand-side) is replaced by the left-hand-side (respectively
- the right-hand-side) in both the conclusion and the context of the goal;
- if moreover the term to substitute is a variable, the hypothesis is
- removed.
-\end{itemize}
-
-\Rem {\tt intros $p_1~\ldots~p_n$} is not equivalent to \texttt{intros
- $p_1$;\ldots; intros $p_n$} for the following reasons:
-\begin{itemize}
-\item A wildcard pattern never succeeds when applied isolated on a
- dependent product, while it succeeds as part of a list of
- introduction patterns if the hypotheses that depends on it are
- erased too.
-\item A disjunctive or conjunctive pattern followed by an introduction
- pattern forces the introduction in the context of all arguments of
- the constructors before applying the next pattern while a terminal
- disjunctive or conjunctive pattern does not. Here is an example
-
-\begin{coq_example}
-Goal forall n:nat, n = 0 -> n = 0.
-intros [ | ] H.
-Show 2.
-Undo.
-intros [ | ]; intros H.
-Show 2.
-\end{coq_example}
-
-\end{itemize}
-
-\begin{coq_example}
-Lemma intros_test : forall A B C:Prop, A \/ B /\ C -> (A -> C) -> C.
-intros A B C [a| [_ c]] f.
-apply (f a).
-exact c.
-Qed.
-\end{coq_example}
-
%\subsection[\tt FixPoint \dots]{\tt FixPoint \dots\tacindex{Fixpoint}}
%Not yet documented.
\subsection{\tt double induction \ident$_1$ \ident$_2$}
-%\tacindex{double induction}}
+\tacindex{double induction}
+
This tactic is deprecated and should be replaced by {\tt induction \ident$_1$; induction \ident$_2$} (or {\tt induction \ident$_1$; destruct \ident$_2$} depending on the exact needs).
%% This tactic applies to any goal. If the variables {\ident$_1$} and
@@ -2175,7 +1783,7 @@ This tactic is deprecated and should be replaced by {\tt induction \ident$_1$; i
%% m} yields the four cases with their respective inductive hypotheses.
%% In particular, for proving \verb+(P (S n) (S m))+, the generated induction
-%% hypotheses are \verb+(P (S n) m)+ and \verb+(m:nat)(P n m)+ (of the latter,
+%% hypotheses are \verb+(P (S n) m)+ and \verb+(m:nat)(P n m)+ (of the latter,
%% \verb+(P n m)+ and \verb+(P n (S m))+ are derivable).
%% \Rem When the induction hypothesis \verb+(P (S n) m)+ is not
@@ -2198,9 +1806,9 @@ This tactic is deprecated and should be replaced by {\tt induction
\end{Variant}
-\subsection{\tt dependent induction \ident
- \tacindex{dependent induction}
- \label{DepInduction}}
+\subsection{\tt dependent induction \ident}
+\tacindex{dependent induction}
+\label{DepInduction}
The \emph{experimental} tactic \texttt{dependent induction} performs
induction-inversion on an instantiated inductive predicate.
@@ -2208,12 +1816,13 @@ One needs to first require the {\tt Coq.Program.Equality} module to use
this tactic. The tactic is based on the BasicElim tactic by Conor
McBride \cite{DBLP:conf/types/McBride00} and the work of Cristina Cornes
around inversion \cite{DBLP:conf/types/CornesT95}. From an instantiated
-inductive predicate and a goal it generates an equivalent goal where the
+inductive predicate and a goal, it generates an equivalent goal where the
hypothesis has been generalized over its indexes which are then
constrained by equalities to be the right instances. This permits to
state lemmas without resorting to manually adding these equalities and
-still get enough information in the proofs.
-A simple example is the following:
+still get enough information in the proofs.
+
+\Example
\begin{coq_eval}
Reset Initial.
@@ -2223,8 +1832,8 @@ Lemma le_minus : forall n:nat, n < 1 -> n = 0.
intros n H ; induction H.
\end{coq_example}
-Here we didn't get any information on the indexes to help fulfill this
-proof. The problem is that when we use the \texttt{induction} tactic
+Here we did not get any information on the indexes to help fulfill this
+proof. The problem is that, when we use the \texttt{induction} tactic,
we lose information on the hypothesis instance, notably that the second
argument is \texttt{1} here. Dependent induction solves this problem by
adding the corresponding equality to the context.
@@ -2240,7 +1849,7 @@ intros n H ; dependent induction H.
The subgoal is cleaned up as the tactic tries to automatically
simplify the subgoals with respect to the generated equalities.
-In this enriched context it becomes possible to solve this subgoal.
+In this enriched context, it becomes possible to solve this subgoal.
\begin{coq_example}
reflexivity.
\end{coq_example}
@@ -2254,65 +1863,32 @@ This technique works with any inductive predicate.
In fact, the \texttt{dependent induction} tactic is just a wrapper around
the \texttt{induction} tactic. One can make its own variant by just
writing a new tactic based on the definition found in
-\texttt{Coq.Program.Equality}. Common useful variants are the following,
-defined in the same file:
+\texttt{Coq.Program.Equality}.
\begin{Variants}
\item {\tt dependent induction {\ident} generalizing {\ident$_1$} \dots
{\ident$_n$}}\tacindex{dependent induction \dots\ generalizing}
-
- Does dependent induction on the hypothesis {\ident} but first
+
+ This performs dependent induction on the hypothesis {\ident} but first
generalizes the goal by the given variables so that they are
universally quantified in the goal. This is generally what one wants
to do with the variables that are inside some constructors in the
induction hypothesis. The other ones need not be further generalized.
\item {\tt dependent destruction {\ident}}\tacindex{dependent destruction}
-
- Does the generalization of the instance {\ident} but uses {\tt destruct}
+
+ This performs the generalization of the instance {\ident} but uses {\tt destruct}
instead of {\tt induction} on the generalized hypothesis. This gives
results equivalent to {\tt inversion} or {\tt dependent inversion} if
the hypothesis is dependent.
\end{Variants}
-A larger example of dependent induction and an explanation of the
-underlying technique are developed in section~\ref{dependent-induction-example}.
-
-\subsection{\tt decompose [ {\qualid$_1$} \dots\ {\qualid$_n$} ] \term
-\label{decompose}
-\tacindex{decompose}}
-
-This tactic allows to recursively decompose a
-complex proposition in order to obtain atomic ones.
-Example:
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
-\begin{coq_example}
-Lemma ex1 : forall A B C:Prop, A /\ B /\ C \/ B /\ C \/ C /\ A -> C.
-intros A B C H; decompose [and or] H; assumption.
-\end{coq_example}
-\begin{coq_example*}
-Qed.
-\end{coq_example*}
-
-{\tt decompose} does not work on right-hand sides of implications or products.
-
-\begin{Variants}
-
-\item {\tt decompose sum \term}\tacindex{decompose sum}
- This decomposes sum types (like \texttt{or}).
-\item {\tt decompose record \term}\tacindex{decompose record}
- This decomposes record types (inductive types with one constructor,
- like \texttt{and} and \texttt{exists} and those defined with the
- \texttt{Record} macro, see Section~\ref{Record}).
-\end{Variants}
-
+\SeeAlso \ref{dependent-induction-example} for a larger example of
+dependent induction and an explanation of the underlying technique.
-\subsection{\tt functional induction (\qualid\ \term$_1$ \dots\ \term$_n$).
+\subsection{\tt functional induction (\qualid\ \term$_1$ \dots\ \term$_n$)}
\tacindex{functional induction}
-\label{FunInduction}}
+\label{FunInduction}
The \emph{experimental} tactic \texttt{functional induction} performs
case analysis and induction following the definition of a function. It
@@ -2325,9 +1901,8 @@ Reset Initial.
\end{coq_eval}
\begin{coq_example}
Functional Scheme minus_ind := Induction for minus Sort Prop.
-
-Lemma le_minus : forall n m:nat, (n - m <= n).
-intros n m.
+Check minus_ind.
+Lemma le_minus (n m:nat) : n - m <= n.
functional induction (minus n m); simpl; auto.
\end{coq_example}
\begin{coq_example*}
@@ -2339,15 +1914,15 @@ full application of \qualid. In particular, the rules for implicit
arguments are the same as usual. For example use \texttt{@\qualid} if
you want to write implicit arguments explicitly.
-\Rem Parenthesis over \qualid \dots \term$_n$ are mandatory.
+\Rem Parentheses over \qualid \dots \term$_n$ are mandatory.
\Rem \texttt{functional induction (f x1 x2 x3)} is actually a wrapper
for \texttt{induction x1 x2 x3 (f x1 x2 x3) using \qualid} followed by
-a cleaning phase, where $\qualid$ is the induction principle
+a cleaning phase, where {\qualid} is the induction principle
registered for $f$ (by the \texttt{Function} (see Section~\ref{Function})
or \texttt{Functional Scheme} (see Section~\ref{FunScheme}) command)
corresponding to the sort of the goal. Therefore \texttt{functional
- induction} may fail if the induction scheme (\texttt{\qualid}) is
+ induction} may fail if the induction scheme {\qualid} is
not defined. See also Section~\ref{Function} for the function terms
accepted by \texttt{Function}.
@@ -2362,38 +1937,548 @@ details.
\begin{ErrMsgs}
\item \errindex{Cannot find induction information on \qualid}
-
- ~
-
\item \errindex{Not the right number of induction arguments}
\end{ErrMsgs}
\begin{Variants}
\item {\tt functional induction (\qualid\ \term$_1$ \dots\ \term$_n$)
- using \term$_{m+1}$ with {\term$_{n+1}$} \dots {\term$_m$}}
+ as {\disjconjintropattern} using \term$_{m+1}$ with \bindinglist}
- Similar to \texttt{Induction} and \texttt{elim}
- (see Section~\ref{Tac-induction}), allows to give explicitly the
- induction principle and the values of dependent premises of the
+ Similarly to \texttt{Induction} and \texttt{elim}
+ (see Section~\ref{Tac-induction}), this allows to give explicitly the
+ name of the introduced variables, the
+ induction principle, and the values of dependent premises of the
elimination scheme, including \emph{predicates} for mutual induction
when {\qualid} is part of a mutually recursive definition.
-\item {\tt functional induction (\qualid\ \term$_1$ \dots\ \term$_n$)
- using \term$_{m+1}$ with {\vref$_1$} := {\term$_{n+1}$} \dots\
- {\vref$_m$} := {\term$_n$}}
+\end{Variants}
+
+\subsection{\tt discriminate \term}
+\label{discriminate}
+\tacindex{discriminate}
- Similar to \texttt{induction} and \texttt{elim}
- (see Section~\ref{Tac-induction}).
-\item All previous variants can be extended by the usual \texttt{as
- \intropattern} construction, similar for example to
- \texttt{induction} and \texttt{elim} (see Section~\ref{Tac-induction}).
-
+This tactic proves any goal from an assumption stating that two
+structurally different terms of an inductive set are equal. For
+example, from {\tt (S (S O))=(S O)} we can derive by absurdity any
+proposition.
+
+The argument {\term} is assumed to be a proof of a statement
+of conclusion {\tt{\term$_1$} = {\term$_2$}} with {\term$_1$} and
+{\term$_2$} being elements of an inductive set. To build the proof,
+the tactic traverses the normal forms\footnote{Reminder: opaque
+ constants will not be expanded by $\delta$ reductions.} of
+{\term$_1$} and {\term$_2$} looking for a couple of subterms {\tt u}
+and {\tt w} ({\tt u} subterm of the normal form of {\term$_1$} and
+{\tt w} subterm of the normal form of {\term$_2$}), placed at the same
+positions and whose head symbols are two different constructors. If
+such a couple of subterms exists, then the proof of the current goal
+is completed, otherwise the tactic fails.
+
+\Rem The syntax {\tt discriminate {\ident}} can be used to refer to a
+hypothesis quantified in the goal. In this case, the quantified
+hypothesis whose name is {\ident} is first introduced in the local
+context using \texttt{intros until \ident}.
+
+\begin{ErrMsgs}
+\item \errindex{No primitive equality found}
+\item \errindex{Not a discriminable equality}
+\end{ErrMsgs}
+
+\begin{Variants}
+\item \texttt{discriminate \num}
+
+ This does the same thing as \texttt{intros until \num} followed by
+ \texttt{discriminate \ident} where {\ident} is the identifier for
+ the last introduced hypothesis.
+
+\item \texttt{discriminate {\term} with \bindinglist}
+
+ This does the same thing as \texttt{discriminate {\term}} but using
+the given bindings to instantiate parameters or hypotheses of {\term}.
+
+\item \texttt{ediscriminate \num}\tacindex{ediscriminate}\\
+ \texttt{ediscriminate {\term} \zeroone{with \bindinglist}}
+
+ This works the same as {\tt discriminate} but if the type of {\term},
+ or the type of the hypothesis referred to by {\num}, has uninstantiated
+ parameters, these parameters are left as existential variables.
+
+\item \texttt{discriminate}
+
+ This behaves like {\tt discriminate {\ident}} if {\ident} is the
+ name of an hypothesis to which {\tt discriminate} is applicable; if
+ the current goal is of the form {\term$_1$} {\tt <>} {\term$_2$},
+ this behaves as {\tt intro {\ident}; injection {\ident}}.
+
+ \ErrMsg \errindex{No discriminable equalities}
\end{Variants}
+\subsection{\tt injection \term}
+\label{injection}
+\tacindex{injection}
+The {\tt injection} tactic is based on the fact that constructors of
+inductive sets are injections. That means that if $c$ is a constructor
+of an inductive set, and if $(c~\vec{t_1})$ and $(c~\vec{t_2})$ are two
+terms that are equal then $~\vec{t_1}$ and $~\vec{t_2}$ are equal
+too.
+
+If {\term} is a proof of a statement of conclusion
+ {\tt {\term$_1$} = {\term$_2$}},
+then {\tt injection} applies injectivity as deep as possible to
+derive the equality of all the subterms of {\term$_1$} and {\term$_2$}
+placed in the same positions. For example, from {\tt (S
+ (S n))=(S (S (S m)))} we may derive {\tt n=(S m)}. To use this
+tactic {\term$_1$} and {\term$_2$} should be elements of an inductive
+set and they should be neither explicitly equal, nor structurally
+different. We mean by this that, if {\tt n$_1$} and {\tt n$_2$} are
+their respective normal forms, then:
+\begin{itemize}
+\item {\tt n$_1$} and {\tt n$_2$} should not be syntactically equal,
+\item there must not exist any pair of subterms {\tt u} and {\tt w},
+ {\tt u} subterm of {\tt n$_1$} and {\tt w} subterm of {\tt n$_2$} ,
+ placed in the same positions and having different constructors as
+ head symbols.
+\end{itemize}
+If these conditions are satisfied, then, the tactic derives the
+equality of all the subterms of {\term$_1$} and {\term$_2$} placed in
+the same positions and puts them as antecedents of the current goal.
+
+\Example Consider the following goal:
+
+\begin{coq_example*}
+Inductive list : Set :=
+ | nil : list
+ | cons : nat -> list -> list.
+Variable P : list -> Prop.
+\end{coq_example*}
+\begin{coq_eval}
+Lemma ex :
+ forall (l:list) (n:nat), P nil -> cons n l = cons 0 nil -> P l.
+intros l n H H0.
+\end{coq_eval}
+\begin{coq_example}
+Show.
+injection H0.
+\end{coq_example}
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
+Beware that \texttt{injection} yields always an equality in a sigma type
+whenever the injected object has a dependent type.
+
+\Rem There is a special case for dependent pairs. If we have a decidable
+equality over the type of the first argument, then it is safe to do
+the projection on the second one, and so {\tt injection} will work fine.
+To define such an equality, you have to use the {\tt Scheme} command
+(see \ref{Scheme}).
+
+\Rem If some quantified hypothesis of the goal is named {\ident}, then
+{\tt injection {\ident}} first introduces the hypothesis in the local
+context using \texttt{intros until \ident}.
+
+\begin{ErrMsgs}
+\item \errindex{Not a projectable equality but a discriminable one}
+\item \errindex{Nothing to do, it is an equality between convertible terms}
+\item \errindex{Not a primitive equality}
+\end{ErrMsgs}
+
+\begin{Variants}
+\item \texttt{injection \num}
+
+ This does the same thing as \texttt{intros until \num} followed by
+\texttt{injection \ident} where {\ident} is the identifier for the last
+introduced hypothesis.
+
+\item \texttt{injection {\term} with \bindinglist}
+
+ This does the same as \texttt{injection {\term}} but using
+ the given bindings to instantiate parameters or hypotheses of {\term}.
+
+\item \texttt{einjection \num}\tacindex{einjection}\\
+ \texttt{einjection {\term} \zeroone{with \bindinglist}}
+
+ This works the same as {\tt injection} but if the type of {\term},
+ or the type of the hypothesis referred to by {\num}, has uninstantiated
+ parameters, these parameters are left as existential variables.
+
+\item{\tt injection}
+
+ If the current goal is of the form {\term$_1$} {\tt <>} {\term$_2$},
+ this behaves as {\tt intro {\ident}; injection {\ident}}.
+
+ \ErrMsg \errindex{goal does not satisfy the expected preconditions}
+
+\item \texttt{injection {\term} \zeroone{with \bindinglist} as \nelist{\intropattern}{}}\\
+\texttt{injection {\num} as {\intropattern} \dots\ \intropattern}\\
+\texttt{injection as {\intropattern} \dots\ \intropattern}\\
+\texttt{einjection {\term} \zeroone{with \bindinglist} as \nelist{\intropattern}{}}\\
+\texttt{einjection {\num} as {\intropattern} \dots\ \intropattern}\\
+\texttt{einjection as {\intropattern} \dots\ \intropattern}
+\tacindex{injection \dots\ as}
+
+These variants apply \texttt{intros} \nelist{\intropattern}{} after
+the call to \texttt{injection} or \texttt{einjection}.
+
+\end{Variants}
+
+\subsection{\tt inversion \ident}
+\tacindex{inversion}
+
+Let the type of {\ident} in the local context be $(I~\vec{t})$,
+where $I$ is a (co)inductive predicate. Then,
+\texttt{inversion} applied to \ident~ derives for each possible
+constructor $c_i$ of $(I~\vec{t})$, {\bf all} the necessary
+conditions that should hold for the instance $(I~\vec{t})$ to be
+proved by $c_i$.
+
+\Rem If {\ident} does not denote a hypothesis in the local context
+but refers to a hypothesis quantified in the goal, then the
+latter is first introduced in the local context using
+\texttt{intros until \ident}.
+
+\Rem As inversion proofs may be large in size, we recommend the user to
+stock the lemmas whenever the same instance needs to be inverted
+several times. See Section~\ref{Derive-Inversion}.
+
+\begin{Variants}
+\item \texttt{inversion \num}
+
+ This does the same thing as \texttt{intros until \num} then
+ \texttt{inversion \ident} where {\ident} is the identifier for the
+ last introduced hypothesis.
+
+\item \tacindex{inversion\_clear} \texttt{inversion\_clear \ident}
+
+ This behaves as \texttt{inversion} and then erases \ident~ from the
+ context.
+
+\item \tacindex{inversion \dots\ as} \texttt{inversion {\ident} as \intropattern}
+
+ This behaves as \texttt{inversion} but using names in
+ {\intropattern} for naming hypotheses. The {\intropattern} must have
+ the form {\tt [} $p_{11}$ \ldots $p_{1n_1}$ {\tt |} {\ldots} {\tt |}
+ $p_{m1}$ \ldots $p_{mn_m}$ {\tt ]} with $m$ being the number of
+ constructors of the type of {\ident}. Be careful that the list must
+ be of length $m$ even if {\tt inversion} discards some cases (which
+ is precisely one of its roles): for the discarded cases, just use an
+ empty list (i.e. $n_i=0$).
+
+ The arguments of the $i^{th}$ constructor and the
+ equalities that {\tt inversion} introduces in the context of the
+ goal corresponding to the $i^{th}$ constructor, if it exists, get
+ their names from the list $p_{i1}$ \ldots $p_{in_i}$ in order. If
+ there are not enough names, {\tt induction} invents names for the
+ remaining variables to introduce. In case an equation splits into
+ several equations (because {\tt inversion} applies {\tt injection}
+ on the equalities it generates), the corresponding name $p_{ij}$ in
+ the list must be replaced by a sublist of the form {\tt [$p_{ij1}$
+ \ldots $p_{ijq}$]} (or, equivalently, {\tt ($p_{ij1}$,
+ \ldots, $p_{ijq}$)}) where $q$ is the number of subequalities
+ obtained from splitting the original equation. Here is an example.
+
+\begin{coq_eval}
+Require Import List.
+\end{coq_eval}
+
+\begin{coq_example}
+Inductive contains0 : list nat -> Prop :=
+ | in_hd : forall l, contains0 (0 :: l)
+ | in_tl : forall l b, contains0 l -> contains0 (b :: l).
+Goal forall l:list nat, contains0 (1 :: l) -> contains0 l.
+intros l H; inversion H as [ | l' p Hl' [Heqp Heql'] ].
+\end{coq_example}
+
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
+\item \texttt{inversion {\num} as \intropattern}
+
+ This allows to name the hypotheses introduced by
+ \texttt{inversion \num} in the context.
+
+\item \tacindex{inversion\_clear \dots\ as} \texttt{inversion\_clear
+ {\ident} as \intropattern}
+
+ This allows to name the hypotheses introduced by
+ \texttt{inversion\_clear} in the context.
+
+\item \tacindex{inversion \dots\ in} \texttt{inversion {\ident}
+ in \ident$_1$ \dots\ \ident$_n$}
+
+ Let \ident$_1$ \dots\ \ident$_n$, be identifiers in the local context. This
+ tactic behaves as generalizing \ident$_1$ \dots\ \ident$_n$, and
+ then performing \texttt{inversion}.
+
+\item \tacindex{inversion \dots\ as \dots\ in} \texttt{inversion
+ {\ident} as {\intropattern} in \ident$_1$ \dots\
+ \ident$_n$}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{inversion {\ident} in \ident$_1$ \dots\ \ident$_n$}.
+
+\item \tacindex{inversion\_clear \dots\ in} \texttt{inversion\_clear
+ {\ident} in \ident$_1$ \dots\ \ident$_n$}
+
+ Let \ident$_1$ \dots\ \ident$_n$, be identifiers in the local context. This
+ tactic behaves as generalizing \ident$_1$ \dots\ \ident$_n$, and
+ then performing {\tt inversion\_clear}.
+
+\item \tacindex{inversion\_clear \dots\ as \dots\ in}
+ \texttt{inversion\_clear {\ident} as {\intropattern}
+ in \ident$_1$ \dots\ \ident$_n$}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{inversion\_clear {\ident} in \ident$_1$ \dots\ \ident$_n$}.
+
+\item \tacindex{dependent inversion} \texttt{dependent inversion \ident}
+
+ That must be used when \ident\ appears in the current goal. It acts
+ like \texttt{inversion} and then substitutes \ident\ for the
+ corresponding term in the goal.
+
+\item \tacindex{dependent inversion \dots\ as } \texttt{dependent
+ inversion {\ident} as \intropattern}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{dependent inversion} {\ident}.
+
+\item \tacindex{dependent inversion\_clear} \texttt{dependent
+ inversion\_clear \ident}
+
+ Like \texttt{dependent inversion}, except that {\ident} is cleared
+ from the local context.
+
+\item \tacindex{dependent inversion\_clear \dots\ as}
+ \texttt{dependent inversion\_clear {\ident} as \intropattern}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{dependent inversion\_clear} {\ident}.
+
+\item \tacindex{dependent inversion \dots\ with} \texttt{dependent
+ inversion {\ident} with \term}
+
+ This variant allows you to specify the generalization of the goal. It
+ is useful when the system fails to generalize the goal automatically. If
+ {\ident} has type $(I~\vec{t})$ and $I$ has type
+ $\forall (\vec{x}:\vec{T}), s$, then \term~ must be of type
+ $I:\forall (\vec{x}:\vec{T}), I~\vec{x}\to s'$ where $s'$ is the
+ type of the goal.
+
+\item \tacindex{dependent inversion \dots\ as \dots\ with}
+ \texttt{dependent inversion {\ident} as {\intropattern}
+ with \term}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{dependent inversion {\ident} with \term}.
+
+\item \tacindex{dependent inversion\_clear \dots\ with}
+ \texttt{dependent inversion\_clear {\ident} with \term}
+
+ Like \texttt{dependent inversion \dots\ with} but clears {\ident} from
+ the local context.
+
+\item \tacindex{dependent inversion\_clear \dots\ as \dots\ with}
+ \texttt{dependent inversion\_clear {\ident} as
+ {\intropattern} with \term}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{dependent inversion\_clear {\ident} with \term}.
+
+\item \tacindex{simple inversion} \texttt{simple inversion \ident}
+
+ It is a very primitive inversion tactic that derives all the necessary
+ equalities but it does not simplify the constraints as
+ \texttt{inversion} does.
+
+\item \tacindex{simple inversion \dots\ as} \texttt{simple inversion
+ {\ident} as \intropattern}
+
+ This allows to name the hypotheses introduced in the context by
+ \texttt{simple inversion}.
+
+\item \tacindex{inversion \dots\ using} \texttt{inversion {\ident}
+ using \ident$'$}
+
+ Let {\ident} have type $(I~\vec{t})$ ($I$ an inductive
+ predicate) in the local context, and \ident$'$ be a (dependent) inversion
+ lemma. Then, this tactic refines the current goal with the specified
+ lemma.
+
+\item \tacindex{inversion \dots\ using \dots\ in} \texttt{inversion
+ {\ident} using \ident$'$ in \ident$_1$\dots\ \ident$_n$}
+
+ This tactic behaves as generalizing \ident$_1$\dots\ \ident$_n$,
+ then doing \texttt{inversion {\ident} using \ident$'$}.
+
+\end{Variants}
+
+\firstexample
+\example{Non-dependent inversion}
+\label{inversion-examples}
+
+Let us consider the relation \texttt{Le} over natural numbers and the
+following variables:
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+
+\begin{coq_example*}
+Inductive Le : nat -> nat -> Set :=
+ | LeO : forall n:nat, Le 0 n
+ | LeS : forall n m:nat, Le n m -> Le (S n) (S m).
+Variable P : nat -> nat -> Prop.
+Variable Q : forall n m:nat, Le n m -> Prop.
+\end{coq_example*}
+
+Let us consider the following goal:
+
+\begin{coq_eval}
+Lemma ex : forall n m:nat, Le (S n) m -> P n m.
+intros.
+\end{coq_eval}
+
+\begin{coq_example}
+Show.
+\end{coq_example}
+
+To prove the goal, we may need to reason by cases on \texttt{H} and to
+derive that \texttt{m} is necessarily of
+the form $(S~m_0)$ for certain $m_0$ and that $(Le~n~m_0)$.
+Deriving these conditions corresponds to prove that the
+only possible constructor of \texttt{(Le (S n) m)} is
+\texttt{LeS} and that we can invert the
+\texttt{->} in the type of \texttt{LeS}.
+This inversion is possible because \texttt{Le} is the smallest set closed by
+the constructors \texttt{LeO} and \texttt{LeS}.
+
+\begin{coq_example}
+inversion_clear H.
+\end{coq_example}
+
+Note that \texttt{m} has been substituted in the goal for \texttt{(S m0)}
+and that the hypothesis \texttt{(Le n m0)} has been added to the
+context.
+
+Sometimes it is
+interesting to have the equality \texttt{m=(S m0)} in the
+context to use it after. In that case we can use \texttt{inversion} that
+does not clear the equalities:
+
+\begin{coq_eval}
+Undo.
+\end{coq_eval}
+
+\begin{coq_example}
+inversion H.
+\end{coq_example}
+
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
+\example{Dependent inversion}
+
+Let us consider the following goal:
+
+\begin{coq_eval}
+Lemma ex_dep : forall (n m:nat) (H:Le (S n) m), Q (S n) m H.
+intros.
+\end{coq_eval}
+
+\begin{coq_example}
+Show.
+\end{coq_example}
+
+As \texttt{H} occurs in the goal, we may want to reason by cases on its
+structure and so, we would like inversion tactics to
+substitute \texttt{H} by the corresponding term in constructor form.
+Neither \texttt{Inversion} nor {\tt Inversion\_clear} make such a
+substitution.
+To have such a behavior we use the dependent inversion tactics:
+
+\begin{coq_example}
+dependent inversion_clear H.
+\end{coq_example}
+
+Note that \texttt{H} has been substituted by \texttt{(LeS n m0 l)} and
+\texttt{m} by \texttt{(S m0)}.
+
+\subsection{\tt fix {\ident} {\num}}
+\tacindex{fix}
+\label{tactic:fix}
+
+This tactic is a primitive tactic to start a proof by induction. In
+general, it is easier to rely on higher-level induction tactics such
+as the ones described in Section~\ref{Tac-induction}.
+
+In the syntax of the tactic, the identifier {\ident} is the name given
+to the induction hypothesis. The natural number {\num} tells on which
+premise of the current goal the induction acts, starting
+from 1 and counting both dependent and non dependent
+products. Especially, the current lemma must be composed of at least
+{\num} products.
+
+Like in a {\tt fix} expression, the induction
+hypotheses have to be used on structurally smaller arguments.
+The verification that inductive proof arguments are correct is done
+only at the time of registering the lemma in the environment. To know
+if the use of induction hypotheses is correct at some
+time of the interactive development of a proof, use the command {\tt
+ Guarded} (see Section~\ref{Guarded}).
+
+\begin{Variants}
+ \item {\tt fix \ident$_1$ {\num} with ( \ident$_2$
+ \nelist{\binder$_2$}{} \zeroone{\{ struct \ident$'_2$
+ \}} :~\type$_2$ ) \dots\ ( \ident$_n$
+ \nelist{\binder$_n$}{} \zeroone{\{ struct \ident$'_n$ \}} :~\type$_n$ )}
+
+This starts a proof by mutual induction. The statements to be
+simultaneously proved are respectively {\tt forall}
+ \nelist{{\binder}$_2$}{}{\tt ,} {\type}$_2$, {\ldots}, {\tt forall}
+ \nelist{{\binder}$_n$}{}{\tt ,} {\type}$_n$. The identifiers
+{\ident}$_1$ {\ldots} {\ident}$_n$ are the names of the induction
+hypotheses. The identifiers {\ident}$'_2$ {\ldots} {\ident}$'_n$ are the
+respective names of the premises on which the induction is performed
+in the statements to be simultaneously proved (if not given, the
+system tries to guess itself what they are).
+
+\end{Variants}
+
+\subsection{\tt cofix \ident}
+\tacindex{cofix}
+\label{tactic:cofix}
+
+This tactic starts a proof by coinduction. The identifier {\ident} is
+the name given to the coinduction hypothesis. Like in a {\tt cofix}
+expression, the use of induction hypotheses have to guarded by a
+constructor. The verification that the use of co-inductive hypotheses
+is correct is done only at the time of registering the lemma in the
+environment. To know if the use of coinduction hypotheses is correct
+at some time of the interactive development of a proof, use the
+command {\tt Guarded} (see Section~\ref{Guarded}).
+
+
+\begin{Variants}
+ \item {\tt cofix \ident$_1$ with ( \ident$_2$
+ \nelist{\binder$_2$}{} :~\type$_2$ ) \dots\ (
+ \ident$_n$ \nelist{\binder$_n$}{} :~\type$_n$ )}
+
+This starts a proof by mutual coinduction. The statements to be
+simultaneously proved are respectively {\tt forall}
+\nelist{{\binder}$_2$}{}{\tt ,} {\type}$_2$, {\ldots}, {\tt forall}
+ \nelist{{\binder}$_n$}{}{\tt ,} {\type}$_n$. The identifiers
+ {\ident}$_1$ {\ldots} {\ident}$_n$ are the names of the
+ coinduction hypotheses.
+
+\end{Variants}
+
+\section{Rewriting expressions}
-\section{Equality}
These tactics use the equality {\tt eq:forall A:Type, A->A->Prop}
defined in file {\tt Logic.v} (see Section~\ref{Equality}). The
@@ -2407,7 +2492,7 @@ implicit type of $t$ and $u$.
This tactic applies to any goal. The type of {\term}
must have the form
-\texttt{forall (x$_1$:A$_1$) \dots\ (x$_n$:A$_n$)}\texttt{eq} \term$_1$ \term$_2$.
+\texttt{forall (x$_1$:A$_1$) \dots\ (x$_n$:A$_n$)}\texttt{eq} \term$_1$ \term$_2$.
\noindent where \texttt{eq} is the Leibniz equality or a registered
setoid equality.
@@ -2419,7 +2504,7 @@ Hence, some of the variables x$_i$ are
solved by unification, and some of the types \texttt{A}$_1$, \dots,
\texttt{A}$_n$ become new subgoals.
-% \Rem In case the type of
+% \Rem In case the type of
% \term$_1$ contains occurrences of variables bound in the
% type of \term, the tactic tries first to find a subterm of the goal
% which matches this term in order to find a closed instance \term$'_1$
@@ -2449,13 +2534,13 @@ This happens if \term$_1$ does not occur in the goal.
\texttt{H1} instead of the current goal.
\item \texttt{rewrite H in H1 at 1, H2 at - 2 |- *} means \texttt{rewrite H; rewrite H in H1 at 1;
rewrite H in H2 at - 2}. In particular a failure will happen if any of
- these three simpler tactics fails.
+ these three simpler tactics fails.
\item \texttt{rewrite H in * |- } will do \texttt{rewrite H in
H$_i$} for all hypothesis \texttt{H$_i$ <> H}. A success will happen
as soon as at least one of these simpler tactics succeeds.
- \item \texttt{rewrite H in *} is a combination of \texttt{rewrite H}
+ \item \texttt{rewrite H in *} is a combination of \texttt{rewrite H}
and \texttt{rewrite H in * |-} that succeeds if at
- least one of these two tactics succeeds.
+ least one of these two tactics succeeds.
\end{itemize}
Orientation {\tt ->} or {\tt <-} can be
inserted before the term to rewrite.
@@ -2466,7 +2551,7 @@ This happens if \term$_1$ does not occur in the goal.
Rewrite only the given occurrences of \term$_1'$. Occurrences are
specified from left to right as for \texttt{pattern} (\S
\ref{pattern}). The rewrite is always performed using setoid
- rewriting, even for Leibniz's equality, so one has to
+ rewriting, even for Leibniz's equality, so one has to
\texttt{Import Setoid} to use this variant.
\item {\tt rewrite {\term} by {\tac}}
@@ -2481,7 +2566,7 @@ This happens if \term$_1$ does not occur in the goal.
generated by the previous one.
Orientation {\tt ->} or {\tt <-} can be
inserted before each term to rewrite. One unique \textit{clause}
- can be added at the end after the keyword {\tt in}; it will
+ can be added at the end after the keyword {\tt in}; it will
then affect all rewrite operations.
\item In all forms of {\tt rewrite} described above, a term to rewrite
@@ -2489,13 +2574,13 @@ This happens if \term$_1$ does not occur in the goal.
\begin{itemize}
\item {\tt ?} : the tactic {\tt rewrite ?$\term$} performs the
rewrite of $\term$ as many times as possible (perhaps zero time).
- This form never fails.
- \item {\tt $n$?} : works similarly, except that it will do at most
- $n$ rewrites.
- \item {\tt !} : works as {\tt ?}, except that at least one rewrite
- should succeed, otherwise the tactic fails.
- \item {\tt $n$!} (or simply {\tt $n$}) : precisely $n$ rewrites
- of $\term$ will be done, leading to failure if these $n$ rewrites are not possible.
+ This form never fails.
+ \item {\tt $n$?} : works similarly, except that it will do at most
+ $n$ rewrites.
+ \item {\tt !} : works as {\tt ?}, except that at least one rewrite
+ should succeed, otherwise the tactic fails.
+ \item {\tt $n$!} (or simply {\tt $n$}) : precisely $n$ rewrites
+ of $\term$ will be done, leading to failure if these $n$ rewrites are not possible.
\end{itemize}
\item {\tt erewrite {\term}\tacindex{erewrite}}
@@ -2542,10 +2627,10 @@ n}| assumption || symmetry; try assumption]}.
\item {\tt replace <- {\term}}\\ Replace {\term} with {\term'} using the
first assumption whose type has the form {\tt \term'=\term}
\item {\tt replace {\term$_1$} with {\term$_2$} \textit{clause} }\\
- {\tt replace {\term$_1$} with {\term$_2$} \textit{clause} by \tac }\\
- {\tt replace {\term} \textit{clause}}\\
- {\tt replace -> {\term} \textit{clause}}\\
- {\tt replace <- {\term} \textit{clause}}\\
+ {\tt replace {\term$_1$} with {\term$_2$} \textit{clause} by \tac }\\
+ {\tt replace {\term} \textit{clause}}\\
+ {\tt replace -> {\term} \textit{clause}}\\
+ {\tt replace <- {\term} \textit{clause}}\\
Act as before but the replacements take place in
\textit{clause}~(see Section~\ref{Conversion-tactics}) and not only
in the conclusion of the goal.\\
@@ -2578,7 +2663,7 @@ the tactic changes it to {\tt u=t}.
\subsection{\tt transitivity \term
\tacindex{transitivity}}
This tactic applies to a goal which has the form {\tt t=u}
-and transforms it into the two subgoals
+and transforms it into the two subgoals
{\tt t={\term}} and {\tt {\term}=u}.
\subsection{\tt subst {\ident}
@@ -2586,13 +2671,13 @@ and transforms it into the two subgoals
This tactic applies to a goal which has \ident\ in its context and
(at least) one hypothesis, say {\tt H}, of type {\tt
- \ident=t} or {\tt t=\ident}. Then it replaces
-\ident\ by {\tt t} everywhere in the goal (in the hypotheses
+ \ident=t} or {\tt t=\ident}. Then it replaces
+\ident\ by {\tt t} everywhere in the goal (in the hypotheses
and in the conclusion) and clears \ident\ and {\tt H} from the context.
-\Rem
+\Rem
When several hypotheses have the form {\tt \ident=t} or {\tt
- t=\ident}, the first one is used.
+ t=\ident}, the first one is used.
\begin{Variants}
\item {\tt subst \ident$_1$ \dots \ident$_n$} \\
@@ -2612,7 +2697,7 @@ is typically a setoid equality. The application of {\tt stepl {\term}}
then replaces the goal by ``$R$ {\term} {\term}$_2$'' and adds a new
goal stating ``$eq$ {\term} {\term}$_1$''.
-Lemmas are added to the database using the command
+Lemmas are added to the database using the command
\comindex{Declare Left Step}
\begin{quote}
{\tt Declare Left Step {\term}.}
@@ -2640,586 +2725,448 @@ and are registered using the command
\end{quote}
\end{Variants}
+\subsection{\tt change \term
+\tacindex{change}
+\label{change}}
-\subsection{\tt f\_equal
-\label{f-equal}
-\tacindex{f\_equal}}
-
-This tactic applies to a goal of the form $f\ a_1\ \ldots\ a_n = f'\
-a'_1\ \ldots\ a'_n$. Using {\tt f\_equal} on such a goal leads to
-subgoals $f=f'$ and $a_1=a'_1$ and so on up to $a_n=a'_n$. Amongst
-these subgoals, the simple ones (e.g. provable by
-reflexivity or congruence) are automatically solved by {\tt f\_equal}.
-
-
-\section{Equality and inductive sets}
+This tactic applies to any goal. It implements the rule
+``Conv''\index{Typing rules!Conv} given in Section~\ref{Conv}. {\tt
+ change U} replaces the current goal \T\ with \U\ providing that
+\U\ is well-formed and that \T\ and \U\ are convertible.
-We describe in this section some special purpose tactics dealing with
-equality and inductive sets or types. These tactics use the equality
-{\tt eq:forall (A:Type), A->A->Prop}, simply written with the
-infix symbol {\tt =}.
+\begin{ErrMsgs}
+\item \errindex{Not convertible}
+\end{ErrMsgs}
-\subsection{\tt decide equality
-\label{decideequality}
-\tacindex{decide equality}}
+\tacindex{change \dots\ in}
+\begin{Variants}
+\item {\tt change \term$_1$ with \term$_2$}
-This tactic solves a goal of the form
-{\tt forall $x$ $y$:$R$, \{$x$=$y$\}+\{\verb|~|$x$=$y$\}}, where $R$
-is an inductive type such that its constructors do not take proofs or
-functions as arguments, nor objects in dependent types.
-It solves goals of the form {\tt \{$x$=$y$\}+\{\verb|~|$x$=$y$\}} as well.
+ This replaces the occurrences of \term$_1$ by \term$_2$ in the
+ current goal. The terms \term$_1$ and \term$_2$ must be
+ convertible.
-\subsection{\tt compare \term$_1$ \term$_2$
-\tacindex{compare}}
+\item {\tt change \term$_1$ at \num$_1$ \dots\ \num$_i$ with \term$_2$}
-This tactic compares two given objects \term$_1$ and \term$_2$
-of an inductive datatype. If $G$ is the current goal, it leaves the sub-goals
-\term$_1${\tt =}\term$_2$ {\tt ->} $G$ and \verb|~|\term$_1${\tt =}\term$_2$
-{\tt ->} $G$. The type
-of \term$_1$ and \term$_2$ must satisfy the same restrictions as in the tactic
-\texttt{decide equality}.
+ This replaces the occurrences numbered \num$_1$ \dots\ \num$_i$ of
+ \term$_1$ by \term$_2$ in the current goal.
+ The terms \term$_1$ and \term$_2$ must be convertible.
-\subsection{\tt discriminate {\term}
-\label{discriminate}
-\tacindex{discriminate}
-\tacindex{ediscriminate}}
+ \ErrMsg {\tt Too few occurrences}
-This tactic proves any goal from an assumption stating that two
-structurally different terms of an inductive set are equal. For
-example, from {\tt (S (S O))=(S O)} we can derive by absurdity any
-proposition.
+\item {\tt change {\term} in {\ident}}
-The argument {\term} is assumed to be a proof of a statement
-of conclusion {\tt{\term$_1$} = {\term$_2$}} with {\term$_1$} and
-{\term$_2$} being elements of an inductive set. To build the proof,
-the tactic traverses the normal forms\footnote{Reminder: opaque
- constants will not be expanded by $\delta$ reductions} of
-{\term$_1$} and {\term$_2$} looking for a couple of subterms {\tt u}
-and {\tt w} ({\tt u} subterm of the normal form of {\term$_1$} and
-{\tt w} subterm of the normal form of {\term$_2$}), placed at the same
-positions and whose head symbols are two different constructors. If
-such a couple of subterms exists, then the proof of the current goal
-is completed, otherwise the tactic fails.
+\item {\tt change \term$_1$ with \term$_2$ in {\ident}}
-\Rem The syntax {\tt discriminate {\ident}} can be used to refer to a
-hypothesis quantified in the goal. In this case, the quantified
-hypothesis whose name is {\ident} is first introduced in the local
-context using \texttt{intros until \ident}.
+\item {\tt change \term$_1$ at \num$_1$ \dots\ \num$_i$ with \term$_2$ in
+ {\ident}}
-\begin{ErrMsgs}
-\item \errindex{No primitive equality found}
-\item \errindex{Not a discriminable equality}
-\end{ErrMsgs}
+ This applies the {\tt change} tactic not to the goal but to the
+ hypothesis {\ident}.
-\begin{Variants}
-\item \texttt{discriminate} \num
+\end{Variants}
- This does the same thing as \texttt{intros until \num} followed by
- \texttt{discriminate \ident} where {\ident} is the identifier for
- the last introduced hypothesis.
+\SeeAlso \ref{Conversion-tactics}
-\item \texttt{discriminate} {\term} {\tt with} {\bindinglist}
- This does the same thing as \texttt{discriminate {\term}} but using
-the given bindings to instantiate parameters or hypotheses of {\term}.
+\section{Performing computations
+\index{Conversion tactics}
+\label{Conversion-tactics}}
-\item \texttt{ediscriminate} \num\\
- \texttt{ediscriminate} {\term} \zeroone{{\tt with} {\bindinglist}}
+This set of tactics implements different specialized usages of the
+tactic \texttt{change}.
- This works the same as {\tt discriminate} but if the type of {\term},
- or the type of the hypothesis referred to by {\num}, has uninstantiated
- parameters, these parameters are left as existential variables.
+All conversion tactics (including \texttt{change}) can be
+parameterized by the parts of the goal where the conversion can
+occur. This is done using \emph{goal clauses} which consists in a list
+of hypotheses and, optionally, of a reference to the conclusion of the
+goal. For defined hypothesis it is possible to specify if the
+conversion should occur on the type part, the body part or both
+(default).
-\item \texttt{discriminate}
+\index{Clauses}
+\index{Goal clauses}
+Goal clauses are written after a conversion tactic (tactics
+\texttt{set}~\ref{tactic:set}, \texttt{rewrite}~\ref{rewrite},
+\texttt{replace}~\ref{tactic:replace} and
+\texttt{autorewrite}~\ref{tactic:autorewrite} also use goal clauses) and
+are introduced by the keyword \texttt{in}. If no goal clause is provided,
+the default is to perform the conversion only in the conclusion.
- This behaves like {\tt discriminate {\ident}} if {\ident} is the
- name of an hypothesis to which {\tt discriminate} is applicable; if
- the current goal is of the form {\term$_1$} {\tt <>} {\term$_2$},
- this behaves as {\tt intro {\ident}; injection {\ident}}.
+The syntax and description of the various goal clauses is the following:
+\begin{description}
+\item[]\texttt{in {\ident}$_1$ $\ldots$ {\ident}$_n$ |- } only in hypotheses {\ident}$_1$
+ \ldots {\ident}$_n$
+\item[]\texttt{in {\ident}$_1$ $\ldots$ {\ident}$_n$ |- *} in hypotheses {\ident}$_1$ \ldots
+ {\ident}$_n$ and in the conclusion
+\item[]\texttt{in * |-} in every hypothesis
+\item[]\texttt{in *} (equivalent to \texttt{in * |- *}) everywhere
+\item[]\texttt{in (type of {\ident}$_1$) (value of {\ident}$_2$) $\ldots$ |-} in
+ type part of {\ident}$_1$, in the value part of {\ident}$_2$, etc.
+\end{description}
- \begin{ErrMsgs}
- \item \errindex{No discriminable equalities} \\
- occurs when the goal does not verify the expected preconditions.
- \end{ErrMsgs}
-\end{Variants}
+For backward compatibility, the notation \texttt{in}~{\ident}$_1$\ldots {\ident}$_n$
+performs the conversion in hypotheses {\ident}$_1$\ldots {\ident}$_n$.
-\subsection{\tt injection {\term}
-\label{injection}
-\tacindex{injection}
-\tacindex{einjection}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%voir reduction__conv_x : histoires d'univers.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-The {\tt injection} tactic is based on the fact that constructors of
-inductive sets are injections. That means that if $c$ is a constructor
-of an inductive set, and if $(c~\vec{t_1})$ and $(c~\vec{t_2})$ are two
-terms that are equal then $~\vec{t_1}$ and $~\vec{t_2}$ are equal
-too.
+\subsection[{\tt cbv \flag$_1$ \dots\ \flag$_n$}, {\tt lazy \flag$_1$
+\dots\ \flag$_n$} and {\tt compute}]
+{{\tt cbv \flag$_1$ \dots\ \flag$_n$}, {\tt lazy \flag$_1$
+\dots\ \flag$_n$} and {\tt compute}
+\tacindex{cbv}
+\tacindex{lazy}
+\tacindex{compute}
+\tacindex{vm\_compute}\label{vmcompute}}
-If {\term} is a proof of a statement of conclusion
- {\tt {\term$_1$} = {\term$_2$}},
-then {\tt injection} applies injectivity as deep as possible to
-derive the equality of all the subterms of {\term$_1$} and {\term$_2$}
-placed in the same positions. For example, from {\tt (S
- (S n))=(S (S (S m)))} we may derive {\tt n=(S m)}. To use this
-tactic {\term$_1$} and {\term$_2$} should be elements of an inductive
-set and they should be neither explicitly equal, nor structurally
-different. We mean by this that, if {\tt n$_1$} and {\tt n$_2$} are
-their respective normal forms, then:
-\begin{itemize}
-\item {\tt n$_1$} and {\tt n$_2$} should not be syntactically equal,
-\item there must not exist any pair of subterms {\tt u} and {\tt w},
- {\tt u} subterm of {\tt n$_1$} and {\tt w} subterm of {\tt n$_2$} ,
- placed in the same positions and having different constructors as
- head symbols.
-\end{itemize}
-If these conditions are satisfied, then, the tactic derives the
-equality of all the subterms of {\term$_1$} and {\term$_2$} placed in
-the same positions and puts them as antecedents of the current goal.
+These parameterized reduction tactics apply to any goal and perform
+the normalization of the goal according to the specified flags. In
+correspondence with the kinds of reduction considered in \Coq\, namely
+$\beta$ (reduction of functional application), $\delta$ (unfolding of
+transparent constants, see \ref{Transparent}), $\iota$ (reduction of
+pattern-matching over a constructed term, and unfolding of {\tt fix}
+and {\tt cofix} expressions) and $\zeta$ (contraction of local
+definitions), the flag are either {\tt beta}, {\tt delta}, {\tt iota}
+or {\tt zeta}. The {\tt delta} flag itself can be refined into {\tt
+delta [\qualid$_1$\ldots\qualid$_k$]} or {\tt delta
+-[\qualid$_1$\ldots\qualid$_k$]}, restricting in the first case the
+constants to unfold to the constants listed, and restricting in the
+second case the constant to unfold to all but the ones explicitly
+mentioned. Notice that the {\tt delta} flag does not apply to
+variables bound by a let-in construction inside the term itself (use
+here the {\tt zeta} flag). In any cases, opaque constants are not
+unfolded (see Section~\ref{Opaque}).
-\Example Consider the following goal:
+The goal may be normalized with two strategies: {\em lazy} ({\tt lazy}
+tactic), or {\em call-by-value} ({\tt cbv} tactic). The lazy strategy
+is a call-by-need strategy, with sharing of reductions: the arguments of a
+function call are partially evaluated only when necessary, and if an
+argument is used several times then it is computed only once. This
+reduction is efficient for reducing expressions with dead code. For
+instance, the proofs of a proposition {\tt exists~$x$. $P(x)$} reduce to a
+pair of a witness $t$, and a proof that $t$ satisfies the predicate
+$P$. Most of the time, $t$ may be computed without computing the proof
+of $P(t)$, thanks to the lazy strategy.
-\begin{coq_example*}
-Inductive list : Set :=
- | nil : list
- | cons : nat -> list -> list.
-Variable P : list -> Prop.
-\end{coq_example*}
-\begin{coq_eval}
-Lemma ex :
- forall (l:list) (n:nat), P nil -> cons n l = cons 0 nil -> P l.
-intros l n H H0.
-\end{coq_eval}
-\begin{coq_example}
-Show.
-injection H0.
-\end{coq_example}
-\begin{coq_eval}
-Abort.
-\end{coq_eval}
+The call-by-value strategy is the one used in ML languages: the
+arguments of a function call are evaluated first, using a weak
+reduction (no reduction under the $\lambda$-abstractions). Despite the
+lazy strategy always performs fewer reductions than the call-by-value
+strategy, the latter is generally more efficient for evaluating purely
+computational expressions (i.e. with few dead code).
-Beware that \texttt{injection} yields always an equality in a sigma type
-whenever the injected object has a dependent type.
+\begin{Variants}
+\item {\tt compute} \tacindex{compute}\\
+ {\tt cbv}
-\Rem There is a special case for dependent pairs. If we have a decidable
-equality over the type of the first argument, then it is safe to do
-the projection on the second one, and so {\tt injection} will work fine.
-To define such an equality, you have to use the {\tt Scheme} command
-(see \ref{Scheme}).
+ These are synonyms for {\tt cbv beta delta iota zeta}.
-\Rem If some quantified hypothesis of the goal is named {\ident}, then
-{\tt injection {\ident}} first introduces the hypothesis in the local
-context using \texttt{intros until \ident}.
+\item {\tt lazy}
-\begin{ErrMsgs}
-\item \errindex{Not a projectable equality but a discriminable one}
-\item \errindex{Nothing to do, it is an equality between convertible terms}
-\item \errindex{Not a primitive equality}
-\end{ErrMsgs}
+ This is a synonym for {\tt lazy beta delta iota zeta}.
-\begin{Variants}
-\item \texttt{injection} \num{}
+\item {\tt compute [\qualid$_1$\ldots\qualid$_k$]}\\
+ {\tt cbv [\qualid$_1$\ldots\qualid$_k$]}
- This does the same thing as \texttt{intros until \num} followed by
-\texttt{injection \ident} where {\ident} is the identifier for the last
-introduced hypothesis.
+ These are synonyms of {\tt cbv beta delta
+ [\qualid$_1$\ldots\qualid$_k$] iota zeta}.
-\item \texttt{injection} \term{} {\tt with} {\bindinglist}
+\item {\tt compute -[\qualid$_1$\ldots\qualid$_k$]}\\
+ {\tt cbv -[\qualid$_1$\ldots\qualid$_k$]}
- This does the same as \texttt{injection {\term}} but using
- the given bindings to instantiate parameters or hypotheses of {\term}.
+ These are synonyms of {\tt cbv beta delta
+ -[\qualid$_1$\ldots\qualid$_k$] iota zeta}.
-\item \texttt{einjection} \num\\
- \texttt{einjection} \term{} \zeroone{{\tt with} {\bindinglist}}
+\item {\tt lazy [\qualid$_1$\ldots\qualid$_k$]}\\
+ {\tt lazy -[\qualid$_1$\ldots\qualid$_k$]}
- This works the same as {\tt injection} but if the type of {\term},
- or the type of the hypothesis referred to by {\num}, has uninstantiated
- parameters, these parameters are left as existential variables.
+ These are respectively synonyms of {\tt lazy beta delta
+ [\qualid$_1$\ldots\qualid$_k$] iota zeta} and {\tt lazy beta delta
+ -[\qualid$_1$\ldots\qualid$_k$] iota zeta}.
-\item{\tt injection}
-
- If the current goal is of the form {\term$_1$} {\tt <>} {\term$_2$},
- this behaves as {\tt intro {\ident}; injection {\ident}}.
-
- \ErrMsg \errindex{goal does not satisfy the expected preconditions}
+\item {\tt vm\_compute} \tacindex{vm\_compute}
-\item \texttt{injection} \term{} \zeroone{{\tt with} {\bindinglist}} \texttt{as} \nelist{\intropattern}{}\\
-\texttt{injection} \num{} \texttt{as} {\intropattern} {\ldots} {\intropattern}\\
-\texttt{injection} \texttt{as} {\intropattern} {\ldots} {\intropattern}\\
-\texttt{einjection} \term{} \zeroone{{\tt with} {\bindinglist}} \texttt{as} \nelist{\intropattern}{}\\
-\texttt{einjection} \num{} \texttt{as} {\intropattern} {\ldots} {\intropattern}\\
-\texttt{einjection} \texttt{as} {\intropattern} {\ldots} {\intropattern}\\
-\tacindex{injection \ldots{} as}
-
-These variants apply \texttt{intros} \nelist{\intropattern}{} after
-the call to \texttt{injection} or \texttt{einjection}.
+ This tactic evaluates the goal using the optimized call-by-value
+ evaluation bytecode-based virtual machine. This algorithm is
+ dramatically more efficient than the algorithm used for the {\tt
+ cbv} tactic, but it cannot be fine-tuned. It is specially
+ interesting for full evaluation of algebraic objects. This includes
+ the case of reflexion-based tactics.
\end{Variants}
-\subsection{\tt simplify\_eq {\term}
-\tacindex{simplify\_eq}
-\tacindex{esimplify\_eq}
-\label{simplify-eq}}
-
-Let {\term} be the proof of a statement of conclusion {\tt
- {\term$_1$}={\term$_2$}}. If {\term$_1$} and
-{\term$_2$} are structurally different (in the sense described for the
-tactic {\tt discriminate}), then the tactic {\tt simplify\_eq} behaves as {\tt
- discriminate {\term}}, otherwise it behaves as {\tt injection
- {\term}}.
+% Obsolete? Anyway not very important message
+%\begin{ErrMsgs}
+%\item \errindex{Delta must be specified before}
+%
+% A list of constants appeared before the {\tt delta} flag.
+%\end{ErrMsgs}
-\Rem If some quantified hypothesis of the goal is named {\ident}, then
-{\tt simplify\_eq {\ident}} first introduces the hypothesis in the local
-context using \texttt{intros until \ident}.
-\begin{Variants}
-\item \texttt{simplify\_eq} \num
+\subsection{{\tt red}
+\tacindex{red}}
- This does the same thing as \texttt{intros until \num} then
-\texttt{simplify\_eq \ident} where {\ident} is the identifier for the last
-introduced hypothesis.
+This tactic applies to a goal which has the form {\tt
+ forall (x:T1)\dots(xk:Tk), c t1 \dots\ tn} where {\tt c} is a constant. If
+{\tt c} is transparent then it replaces {\tt c} with its definition
+(say {\tt t}) and then reduces {\tt (t t1 \dots\ tn)} according to
+$\beta\iota\zeta$-reduction rules.
-\item \texttt{simplify\_eq} \term{} {\tt with} {\bindinglist}
+\begin{ErrMsgs}
+\item \errindex{Not reducible}
+\end{ErrMsgs}
- This does the same as \texttt{simplify\_eq {\term}} but using
- the given bindings to instantiate parameters or hypotheses of {\term}.
+\subsection{{\tt hnf}
+\tacindex{hnf}}
-\item \texttt{esimplify\_eq} \num\\
- \texttt{esimplify\_eq} \term{} \zeroone{{\tt with} {\bindinglist}}
+This tactic applies to any goal. It replaces the current goal with its
+head normal form according to the $\beta\delta\iota\zeta$-reduction
+rules, i.e. it reduces the head of the goal until it becomes a
+product or an irreducible term.
- This works the same as {\tt simplify\_eq} but if the type of {\term},
- or the type of the hypothesis referred to by {\num}, has uninstantiated
- parameters, these parameters are left as existential variables.
+\Example
+The term \verb+forall n:nat, (plus (S n) (S n))+ is not reduced by {\tt hnf}.
-\item{\tt simplify\_eq}
+\Rem The $\delta$ rule only applies to transparent constants
+(see Section~\ref{Opaque} on transparency and opacity).
-If the current goal has form $t_1\verb=<>=t_2$, it behaves as
-\texttt{intro {\ident}; simplify\_eq {\ident}}.
-\end{Variants}
+\subsection{\tt simpl
+\tacindex{simpl}}
-\subsection{\tt dependent rewrite -> {\ident}
-\tacindex{dependent rewrite ->}
-\label{dependent-rewrite}}
+This tactic applies to any goal. The tactic {\tt simpl} first applies
+$\beta\iota$-reduction rule. Then it expands transparent constants
+and tries to reduce {\tt T'} according, once more, to $\beta\iota$
+rules. But when the $\iota$ rule is not applicable then possible
+$\delta$-reductions are not applied. For instance trying to use {\tt
+simpl} on {\tt (plus n O)=n} changes nothing. Notice that only
+transparent constants whose name can be reused as such in the
+recursive calls are possibly unfolded. For instance a constant defined
+by {\tt plus' := plus} is possibly unfolded and reused in the
+recursive calls, but a constant such as {\tt succ := plus (S O)} is
+never unfolded.
-This tactic applies to any goal. If \ident\ has type
-\verb+(existT B a b)=(existT B a' b')+
-in the local context (i.e. each term of the
-equality has a sigma type $\{ a:A~ \&~(B~a)\}$) this tactic rewrites
-\verb+a+ into \verb+a'+ and \verb+b+ into \verb+b'+ in the current
-goal. This tactic works even if $B$ is also a sigma type. This kind
-of equalities between dependent pairs may be derived by the injection
-and inversion tactics.
+The behavior of {\tt simpl} can be tuned using the {\tt Arguments} vernacular
+command as follows:
+\comindex{Arguments}
+\begin{itemize}
+\item
+A constant can be marked to be never unfolded by {\tt simpl}:
+\begin{coq_example*}
+Arguments minus x y : simpl never
+\end{coq_example*}
+After that command an expression like {\tt (minus (S x) y)} is left untouched by
+the {\tt simpl} tactic.
+\item
+A constant can be marked to be unfolded only if applied to enough arguments.
+The number of arguments required can be specified using
+the {\tt /} symbol in the arguments list of the {\tt Arguments} vernacular
+command.
+\begin{coq_example*}
+Definition fcomp A B C f (g : A -> B) (x : A) : C := f (g x).
+Notation "f \o g" := (fcomp f g) (at level 50).
+Arguments fcomp {A B C} f g x /.
+\end{coq_example*}
+After that command the expression {\tt (f \verb+\+o g)} is left untouched by
+{\tt simpl} while {\tt ((f \verb+\+o g) t)} is reduced to {\tt (f (g t))}.
+The same mechanism can be used to make a constant volatile, i.e. always
+unfolded by {\tt simpl}.
+\begin{coq_example*}
+Definition volatile := fun x : nat => x.
+Arguments volatile / x.
+\end{coq_example*}
+\item
+A constant can be marked to be unfolded only if an entire set of arguments
+evaluates to a constructor. The {\tt !} symbol can be used to mark such
+arguments.
+\begin{coq_example*}
+Arguments minus !x !y.
+\end{coq_example*}
+After that command, the expression {\tt (minus (S x) y)} is left untouched by
+{\tt simpl}, while {\tt (minus (S x) (S y))} is reduced to {\tt (minus x y)}.
+\item
+A special heuristic to determine if a constant has to be unfolded can be
+activated with the following command:
+\begin{coq_example*}
+Arguments minus x y : simpl nomatch
+\end{coq_example*}
+The heuristic avoids to perform a simplification step that would
+expose a {\tt match} construct in head position. For example the
+expression {\tt (minus (S (S x)) (S y))} is simplified to
+{\tt (minus (S x) y)} even if an extra simplification is possible.
+\end{itemize}
+\tacindex{simpl \dots\ in}
\begin{Variants}
-\item{\tt dependent rewrite <- {\ident}}
-\tacindex{dependent rewrite <-} \\
-Analogous to {\tt dependent rewrite ->} but uses the equality from
-right to left.
-\end{Variants}
+\item {\tt simpl {\term}}
-\section{Inversion
-\label{inversion}}
+ This applies {\tt simpl} only to the occurrences of {\term} in the
+ current goal.
-\subsection{\tt inversion {\ident}
-\tacindex{inversion}}
+\item {\tt simpl {\term} at \num$_1$ \dots\ \num$_i$}
-Let the type of \ident~ in the local context be $(I~\vec{t})$,
-where $I$ is a (co)inductive predicate. Then,
-\texttt{inversion} applied to \ident~ derives for each possible
-constructor $c_i$ of $(I~\vec{t})$, {\bf all} the necessary
-conditions that should hold for the instance $(I~\vec{t})$ to be
-proved by $c_i$.
+ This applies {\tt simpl} only to the \num$_1$, \dots, \num$_i$
+ occurrences of {\term} in the current goal.
-\Rem If {\ident} does not denote a hypothesis in the local context
-but refers to a hypothesis quantified in the goal, then the
-latter is first introduced in the local context using
-\texttt{intros until \ident}.
+ \ErrMsg {\tt Too few occurrences}
-\begin{Variants}
-\item \texttt{inversion} \num
-
- This does the same thing as \texttt{intros until \num} then
- \texttt{inversion \ident} where {\ident} is the identifier for the
- last introduced hypothesis.
+\item {\tt simpl {\ident}}
-\item \tacindex{inversion\_clear} \texttt{inversion\_clear} \ident
+ This applies {\tt simpl} only to the applicative subterms whose head
+ occurrence is {\ident}.
- This behaves as \texttt{inversion} and then erases \ident~ from the
- context.
+\item {\tt simpl {\ident} at \num$_1$ \dots\ \num$_i$}
-\item \tacindex{inversion \dots\ as} \texttt{inversion} {\ident} \texttt{as} {\intropattern}
-
- This behaves as \texttt{inversion} but using names in
- {\intropattern} for naming hypotheses. The {\intropattern} must have
- the form {\tt [} $p_{11}$ \ldots $p_{1n_1}$ {\tt |} {\ldots} {\tt |}
- $p_{m1}$ \ldots $p_{mn_m}$ {\tt ]} with $m$ being the number of
- constructors of the type of {\ident}. Be careful that the list must
- be of length $m$ even if {\tt inversion} discards some cases (which
- is precisely one of its roles): for the discarded cases, just use an
- empty list (i.e. $n_i=0$).
+ This applies {\tt simpl} only to the \num$_1$, \dots, \num$_i$
+applicative subterms whose head occurrence is {\ident}.
- The arguments of the $i^{th}$ constructor and the
- equalities that {\tt inversion} introduces in the context of the
- goal corresponding to the $i^{th}$ constructor, if it exists, get
- their names from the list $p_{i1}$ \ldots $p_{in_i}$ in order. If
- there are not enough names, {\tt induction} invents names for the
- remaining variables to introduce. In case an equation splits into
- several equations (because {\tt inversion} applies {\tt injection}
- on the equalities it generates), the corresponding name $p_{ij}$ in
- the list must be replaced by a sublist of the form {\tt [$p_{ij1}$
- \ldots $p_{ijq}$]} (or, equivalently, {\tt ($p_{ij1}$,
- \ldots, $p_{ijq}$)}) where $q$ is the number of subequalities
- obtained from splitting the original equation. Here is an example.
+\end{Variants}
-\begin{coq_eval}
-Require Import List.
-\end{coq_eval}
+\subsection{\tt unfold \qualid
+\tacindex{unfold}
+\label{unfold}}
-\begin{coq_example}
-Inductive contains0 : list nat -> Prop :=
- | in_hd : forall l, contains0 (0 :: l)
- | in_tl : forall l b, contains0 l -> contains0 (b :: l).
-Goal forall l:list nat, contains0 (1 :: l) -> contains0 l.
-intros l H; inversion H as [ | l' p Hl' [Heqp Heql'] ].
-\end{coq_example}
+This tactic applies to any goal. The argument {\qualid} must denote a
+defined transparent constant or local definition (see Sections~\ref{Basic-definitions} and~\ref{Transparent}). The tactic {\tt
+ unfold} applies the $\delta$ rule to each occurrence of the constant
+to which {\qualid} refers in the current goal and then replaces it
+with its $\beta\iota$-normal form.
-\begin{coq_eval}
-Abort.
-\end{coq_eval}
+\begin{ErrMsgs}
+\item {\qualid} \errindex{does not denote an evaluable constant}
-\item \texttt{inversion} {\num} {\tt as} {\intropattern}
+\end{ErrMsgs}
- This allows to name the hypotheses introduced by
- \texttt{inversion} {\num} in the context.
+\begin{Variants}
+\item {\tt unfold {\qualid}$_1$, \dots, \qualid$_n$}
+ \tacindex{unfold \dots\ in}
-\item \tacindex{inversion\_cleardots\ as} \texttt{inversion\_clear}
- {\ident} {\tt as} {\intropattern}
+ Replaces {\em simultaneously} {\qualid}$_1$, \dots, {\qualid}$_n$
+ with their definitions and replaces the current goal with its
+ $\beta\iota$ normal form.
- This allows to name the hypotheses introduced by
- \texttt{inversion\_clear} in the context.
-
-\item \tacindex{inversion \dots\ in} \texttt{inversion } {\ident}
- \texttt{in} \ident$_1$ \dots\ \ident$_n$
+\item {\tt unfold {\qualid}$_1$ at \num$_1^1$, \dots, \num$_i^1$,
+\dots,\ \qualid$_n$ at \num$_1^n$ \dots\ \num$_j^n$}
- Let \ident$_1$ \dots\ \ident$_n$, be identifiers in the local context. This
- tactic behaves as generalizing \ident$_1$ \dots\ \ident$_n$, and
- then performing \texttt{inversion}.
-
-\item \tacindex{inversion \dots\ as \dots\ in} \texttt{inversion }
- {\ident} {\tt as} {\intropattern} \texttt{in} \ident$_1$ \dots\
- \ident$_n$
-
- This allows to name the hypotheses introduced in the context by
- \texttt{inversion} {\ident} \texttt{in} \ident$_1$ \dots\
- \ident$_n$.
-
-\item \tacindex{inversion\_clear \dots\ in} \texttt{inversion\_clear}
- {\ident} \texttt{in} \ident$_1$ \ldots \ident$_n$
-
- Let \ident$_1$ \dots\ \ident$_n$, be identifiers in the local context. This
- tactic behaves as generalizing \ident$_1$ \dots\ \ident$_n$, and
- then performing {\tt inversion\_clear}.
-
-\item \tacindex{inversion\_clear \dots\ as \dots\ in}
- \texttt{inversion\_clear} {\ident} \texttt{as} {\intropattern}
- \texttt{in} \ident$_1$ \ldots \ident$_n$
+ The lists \num$_1^1$, \dots, \num$_i^1$ and \num$_1^n$, \dots,
+ \num$_j^n$ specify the occurrences of {\qualid}$_1$, \dots,
+ \qualid$_n$ to be unfolded. Occurrences are located from left to
+ right.
- This allows to name the hypotheses introduced in the context by
- \texttt{inversion\_clear} {\ident} \texttt{in} \ident$_1$ \ldots
- \ident$_n$.
+ \ErrMsg {\tt bad occurrence number of {\qualid}$_i$}
-\item \tacindex{dependent inversion} \texttt{dependent inversion}
- {\ident}
-
- That must be used when \ident\ appears in the current goal. It acts
- like \texttt{inversion} and then substitutes \ident\ for the
- corresponding term in the goal.
-
-\item \tacindex{dependent inversion \dots\ as } \texttt{dependent
- inversion} {\ident} \texttt{as} {\intropattern}
-
- This allows to name the hypotheses introduced in the context by
- \texttt{dependent inversion} {\ident}.
+ \ErrMsg {\qualid}$_i$ {\tt does not occur}
-\item \tacindex{dependent inversion\_clear} \texttt{dependent
- inversion\_clear} {\ident}
-
- Like \texttt{dependent inversion}, except that {\ident} is cleared
- from the local context.
+\item {\tt unfold {\qstring}}
-\item \tacindex{dependent inversion\_clear \dots\ as}
- \texttt{dependent inversion\_clear} {\ident}\texttt{as} {\intropattern}
-
- This allows to name the hypotheses introduced in the context by
- \texttt{dependent inversion\_clear} {\ident}.
+ If {\qstring} denotes the discriminating symbol of a notation (e.g. {\tt
+ "+"}) or an expression defining a notation (e.g. \verb!"_ + _"!), and
+ this notation refers to an unfoldable constant, then the tactic
+ unfolds it.
-\item \tacindex{dependent inversion \dots\ with} \texttt{dependent
- inversion } {\ident} \texttt{ with } \term
-
- This variant allows you to specify the generalization of the goal. It
- is useful when the system fails to generalize the goal automatically. If
- {\ident} has type $(I~\vec{t})$ and $I$ has type
- $forall (\vec{x}:\vec{T}), s$, then \term~ must be of type
- $I:forall (\vec{x}:\vec{T}), I~\vec{x}\to s'$ where $s'$ is the
- type of the goal.
+\item {\tt unfold {\qstring}\%{\delimkey}}
-\item \tacindex{dependent inversion \dots\ as \dots\ with}
- \texttt{dependent inversion } {\ident} \texttt{as} {\intropattern}
- \texttt{ with } \term
-
- This allows to name the hypotheses introduced in the context by
- \texttt{dependent inversion } {\ident} \texttt{ with } \term.
+ This is variant of {\tt unfold {\qstring}} where {\qstring} gets its
+ interpretation from the scope bound to the delimiting key
+ {\delimkey} instead of its default interpretation (see
+ Section~\ref{scopechange}).
-\item \tacindex{dependent inversion\_clear \dots\ with}
- \texttt{dependent inversion\_clear } {\ident} \texttt{ with } \term
-
- Like \texttt{dependent inversion \dots\ with} but clears {\ident} from
- the local context.
+\item {\tt unfold \qualidorstring$_1$ at \num$_1^1$, \dots, \num$_i^1$,
+\dots,\ \qualidorstring$_n$ at \num$_1^n$ \dots\ \num$_j^n$}
-\item \tacindex{dependent inversion\_clear \dots\ as \dots\ with}
- \texttt{dependent inversion\_clear } {\ident} \texttt{as}
- {\intropattern} \texttt{ with } \term
-
- This allows to name the hypotheses introduced in the context by
- \texttt{dependent inversion\_clear } {\ident} \texttt{ with } \term.
+ This is the most general form, where {\qualidorstring} is either a
+ {\qualid} or a {\qstring} referring to a notation.
-\item \tacindex{simple inversion} \texttt{simple inversion} {\ident}
-
- It is a very primitive inversion tactic that derives all the necessary
- equalities but it does not simplify the constraints as
- \texttt{inversion} does.
+\end{Variants}
-\item \tacindex{simple inversion \dots\ as} \texttt{simple inversion}
- {\ident} \texttt{as} {\intropattern}
-
- This allows to name the hypotheses introduced in the context by
- \texttt{simple inversion}.
+\subsection{{\tt fold} \term
+\tacindex{fold}}
-\item \tacindex{inversion \dots\ using} \texttt{inversion} \ident
- \texttt{ using} \ident$'$
-
- Let {\ident} have type $(I~\vec{t})$ ($I$ an inductive
- predicate) in the local context, and \ident$'$ be a (dependent) inversion
- lemma. Then, this tactic refines the current goal with the specified
- lemma.
+This tactic applies to any goal. The term \term\ is reduced using the {\tt red}
+tactic. Every occurrence of the resulting term in the goal is then
+replaced by \term.
-\item \tacindex{inversion \dots\ using \dots\ in} \texttt{inversion}
- {\ident} \texttt{using} \ident$'$ \texttt{in} \ident$_1$\dots\ \ident$_n$
-
- This tactic behaves as generalizing \ident$_1$\dots\ \ident$_n$,
- then doing \texttt{inversion} {\ident} \texttt{using} \ident$'$.
+\begin{Variants}
+\item {\tt fold} \term$_1$ \dots\ \term$_n$
+ Equivalent to {\tt fold} \term$_1${\tt;}\ldots{\tt; fold} \term$_n$.
\end{Variants}
-\SeeAlso~\ref{inversion-examples} for detailed examples
+\subsection{{\tt pattern {\term}}
+\tacindex{pattern}
+\label{pattern}}
-\subsection{\tt Derive Inversion {\ident} with
- ${\tt forall (}\vec{x}{\tt :}\vec{T}{\tt),} I~\vec{t}$ Sort \sort
-\label{Derive-Inversion}
-\comindex{Derive Inversion}}
+This command applies to any goal. The argument {\term} must be a free
+subterm of the current goal. The command {\tt pattern} performs
+$\beta$-expansion (the inverse of $\bt$-reduction) of the current goal
+(say \T) by
+\begin{enumerate}
+\item replacing all occurrences of {\term} in {\T} with a fresh variable
+\item abstracting this variable
+\item applying the abstracted goal to {\term}
+\end{enumerate}
-This command generates an inversion principle for the
-\texttt{inversion \dots\ using} tactic.
-Let $I$ be an inductive predicate and $\vec{x}$ the variables
-occurring in $\vec{t}$. This command generates and stocks the
-inversion lemma for the sort \sort~ corresponding to the instance
-$forall (\vec{x}:\vec{T}), I~\vec{t}$ with the name {\ident} in the {\bf
-global} environment. When applied it is equivalent to have inverted
-the instance with the tactic {\tt inversion}.
+For instance, if the current goal $T$ is expressible has $\phi(t)$
+where the notation captures all the instances of $t$ in $\phi(t)$,
+then {\tt pattern $t$} transforms it into {\tt (fun x:$A$ => $\phi(${\tt
+x}$)$) $t$}. This command can be used, for instance, when the tactic
+{\tt apply} fails on matching.
\begin{Variants}
-\item \texttt{Derive Inversion\_clear} {\ident} \texttt{with}
- \comindex{Derive Inversion\_clear}
- $forall (\vec{x}:\vec{T}), I~\vec{t}$ \texttt{Sort} \sort~ \\
- \index{Derive Inversion\_clear \dots\ with}
- When applied it is equivalent to having
- inverted the instance with the tactic \texttt{inversion}
- replaced by the tactic \texttt{inversion\_clear}.
-\item \texttt{Derive Dependent Inversion} {\ident} \texttt{with}
- $forall (\vec{x}:\vec{T}), I~\vec{t}$ \texttt{Sort} \sort~\\
- \comindex{Derive Dependent Inversion}
- When applied it is equivalent to having
- inverted the instance with the tactic \texttt{dependent inversion}.
-\item \texttt{Derive Dependent Inversion\_clear} {\ident} \texttt{with}
- $forall (\vec{x}:\vec{T}), I~\vec{t}$ \texttt{Sort} \sort~\\
- \comindex{Derive Dependent Inversion\_clear}
- When applied it is equivalent to having
- inverted the instance with the tactic \texttt{dependent inversion\_clear}.
-\end{Variants}
+\item {\tt pattern {\term} at {\num$_1$} \dots\ {\num$_n$}}
-\SeeAlso \ref{inversion-examples} for examples
+ Only the occurrences {\num$_1$} \dots\ {\num$_n$} of {\term} are
+ considered for $\beta$-expansion. Occurrences are located from left
+ to right.
+\item {\tt pattern {\term} at - {\num$_1$} \dots\ {\num$_n$}}
+ All occurrences except the occurrences of indexes {\num$_1$} \dots\
+ {\num$_n$} of {\term} are considered for
+ $\beta$-expansion. Occurrences are located from left to right.
-\subsection[\tt functional inversion \ident]{\tt functional inversion \ident\label{sec:functional-inversion}}
+\item {\tt pattern {\term$_1$}, \dots, {\term$_m$}}
-\texttt{functional inversion} is a \emph{highly} experimental tactic
-which performs inversion on hypothesis \ident\ of the form
-\texttt{\qualid\ \term$_1$\dots\term$_n$\ = \term} or \texttt{\term\ =
- \qualid\ \term$_1$\dots\term$_n$} where \qualid\ must have been
-defined using \texttt{Function} (see Section~\ref{Function}).
+ Starting from a goal $\phi(t_1 \dots\ t_m)$, the tactic
+ {\tt pattern $t_1$, \dots,\ $t_m$} generates the equivalent goal {\tt
+ (fun (x$_1$:$A_1$) \dots\ (x$_m$:$A_m$) => $\phi(${\tt x$_1$\dots\
+ x$_m$}$)$) $t_1$ \dots\ $t_m$}.\\ If $t_i$ occurs in one of the
+ generated types $A_j$ these occurrences will also be considered and
+ possibly abstracted.
-\begin{ErrMsgs}
-\item \errindex{Hypothesis {\ident} must contain at least one Function}
-\item \errindex{Cannot find inversion information for hypothesis \ident}
- This error may be raised when some inversion lemma failed to be
- generated by Function.
-\end{ErrMsgs}
+\item {\tt pattern {\term$_1$} at {\num$_1^1$} \dots\ {\num$_{n_1}^1$}, \dots,
+ {\term$_m$} at {\num$_1^m$} \dots\ {\num$_{n_m}^m$}}
-\begin{Variants}
-\item {\tt functional inversion \num}
+ This behaves as above but processing only the occurrences \num$_1^1$,
+ \dots, \num$_i^1$ of \term$_1$, \dots, \num$_1^m$, \dots, \num$_j^m$
+ of \term$_m$ starting from \term$_m$.
- This does the same thing as \texttt{intros until \num} then
- \texttt{functional inversion \ident} where {\ident} is the
- identifier for the last introduced hypothesis.
-\item {\tt functional inversion \ident\ \qualid}\\
- {\tt functional inversion \num\ \qualid}
+\item {\tt pattern} {\term$_1$} \zeroone{{\tt at \zeroone{-}} {\num$_1^1$} \dots\ {\num$_{n_1}^1$}} {\tt ,} \dots {\tt ,}
+ {\term$_m$} \zeroone{{\tt at \zeroone{-}} {\num$_1^m$} \dots\ {\num$_{n_m}^m$}}
+
+ This is the most general syntax that combines the different variants.
- In case the hypothesis {\ident} (or {\num}) has a type of the form
- \texttt{\qualid$_1$\ \term$_1$\dots\term$_n$\ =\ \qualid$_2$\
- \term$_{n+1}$\dots\term$_{n+m}$} where \qualid$_1$ and \qualid$_2$
- are valid candidates to functional inversion, this variant allows to
- choose which must be inverted.
\end{Variants}
+\subsection{Conversion tactics applied to hypotheses}
+{\convtactic} {\tt in} \ident$_1$ \dots\ \ident$_n$
-\subsection{\tt quote \ident
-\tacindex{quote}
-\index{2-level approach}}
+Applies the conversion tactic {\convtactic} to the
+hypotheses \ident$_1$, \ldots, \ident$_n$. The tactic {\convtactic} is
+any of the conversion tactics listed in this section.
-This kind of inversion has nothing to do with the tactic
-\texttt{inversion} above. This tactic does \texttt{change (\ident\
- t)}, where \texttt{t} is a term built in order to ensure the
-convertibility. In other words, it does inversion of the function
-\ident. This function must be a fixpoint on a simple recursive
-datatype: see~\ref{quote-examples} for the full details.
+If \ident$_i$ is a local definition, then \ident$_i$ can be replaced
+by (Type of \ident$_i$) to address not the body but the type of the
+local definition. Example: {\tt unfold not in (Type of H1) (Type of H3).}
\begin{ErrMsgs}
-\item \errindex{quote: not a simple fixpoint}\\
- Happens when \texttt{quote} is not able to perform inversion properly.
+\item \errindex{No such hypothesis} : {\ident}.
\end{ErrMsgs}
-\begin{Variants}
-\item \texttt{quote {\ident} [ \ident$_1$ \dots \ident$_n$ ]}\\
- All terms that are built only with \ident$_1$ \dots \ident$_n$ will be
- considered by \texttt{quote} as constants rather than variables.
-\end{Variants}
-
-% En attente d'un moyen de valoriser les fichiers de demos
-% \SeeAlso file \texttt{theories/DEMOS/DemoQuote.v} in the distribution
-
-\section[Classical tactics]{Classical tactics\label{ClassicalTactics}}
-
-In order to ease the proving process, when the {\tt Classical} module is loaded. A few more tactics are available. Make sure to load the module using the \texttt{Require Import} command.
-
-\subsection{{\tt classical\_left, classical\_right} \tacindex{classical\_left} \tacindex{classical\_right}}
-
-The tactics \texttt{classical\_left} and \texttt{classical\_right} are the analog of the \texttt{left} and \texttt{right} but using classical logic. They can only be used for disjunctions.
-Use \texttt{classical\_left} to prove the left part of the disjunction with the assumption that the negation of right part holds.
-Use \texttt{classical\_right} to prove the right part of the disjunction with the assumption that the negation of left part holds.
-
-\section{Automatizing
-\label{Automatizing}}
+\section{Automation}
\subsection{\tt auto
\label{auto}
\tacindex{auto}}
@@ -3231,20 +3178,20 @@ current goal. It first tries to solve the goal using the {\tt
Then it looks at the list of tactics associated to the head symbol of
the goal and tries to apply one of them (starting from the tactics
with lower cost). This process is recursively applied to the generated
-subgoals.
+subgoals.
By default, \texttt{auto} only uses the hypotheses of the current goal and the
-hints of the database named {\tt core}.
+hints of the database named {\tt core}.
\begin{Variants}
\item {\tt auto \num}
Forces the search depth to be \num. The maximal search depth is 5 by
- default.
+ default.
\item {\tt auto with \ident$_1$ \dots\ \ident$_n$}
-
+
Uses the hint databases $\ident_1$ \dots\ $\ident_n$ in addition to
the database {\tt core}. See Section~\ref{Hints-databases} for the
list of pre-defined databases and the way to create or extend a
@@ -3268,7 +3215,7 @@ hints of the database named {\tt core}.
\item {\tt trivial}\tacindex{trivial}
- This tactic is a restriction of {\tt auto} that is not recursive and
+ This tactic is a restriction of {\tt auto} that is not recursive and
tries only hints which cost 0. Typically it solves trivial
equalities like $X=X$.
@@ -3287,7 +3234,7 @@ intact. \texttt{auto} and \texttt{trivial} never fail.
\tacindex{eauto}
\label{eauto}}
-This tactic generalizes {\tt auto}. In contrast with
+This tactic generalizes {\tt auto}. In contrast with
the latter, {\tt eauto} uses unification of the goal
against the hints rather than pattern-matching
(in other words, it uses {\tt eapply} instead of
@@ -3317,454 +3264,14 @@ This tactic unfolds constants that were declared through a {\tt Hint
\begin{Variants}
\item {\tt autounfold with \ident$_1$ \dots\ \ident$_n$ in \textit{clause}}
-
+
Perform the unfolding in the given clause.
\item {\tt autounfold with *}
-
- Uses the unfold hints declared in all the hint databases.
-\end{Variants}
-
-
-% EXISTE ENCORE ?
-%
-% \subsection{\tt Prolog [ \term$_1$ \dots\ \term$_n$ ] \num}
-% \tacindex{Prolog}\label{Prolog}
-% This tactic, implemented by Chet Murthy, is based upon the concept of
-% existential variables of Gilles Dowek, stating that resolution is a
-% kind of unification. It tries to solve the current goal using the {\tt
-% Assumption} tactic, the {\tt intro} tactic, and applying hypotheses
-% of the local context and terms of the given list {\tt [ \term$_1$
-% \dots\ \term$_n$\ ]}. It is more powerful than {\tt auto} since it
-% may apply to any theorem, even those of the form {\tt (x:A)(P x) -> Q}
-% where {\tt x} does not appear free in {\tt Q}. The maximal search
-% depth is {\tt \num}.
-
-% \begin{ErrMsgs}
-% \item \errindex{Prolog failed}\\
-% The Prolog tactic was not able to prove the subgoal.
-% \end{ErrMsgs}
-
-\subsection{\tt tauto
-\tacindex{tauto}
-\label{tauto}}
-
-This tactic implements a decision procedure for intuitionistic propositional
-calculus based on the contraction-free sequent calculi LJT* of Roy Dyckhoff
-\cite{Dyc92}. Note that {\tt tauto} succeeds on any instance of an
-intuitionistic tautological proposition. {\tt tauto} unfolds negations
-and logical equivalence but does not unfold any other definition.
-
-The following goal can be proved by {\tt tauto} whereas {\tt auto}
-would fail:
-
-\begin{coq_example}
-Goal forall (x:nat) (P:nat -> Prop), x = 0 \/ P x -> x <> 0 -> P x.
- intros.
- tauto.
-\end{coq_example}
-\begin{coq_eval}
-Abort.
-\end{coq_eval}
-
-Moreover, if it has nothing else to do, {\tt tauto} performs
-introductions. Therefore, the use of {\tt intros} in the previous
-proof is unnecessary. {\tt tauto} can for instance prove the
-following:
-\begin{coq_example}
-(* auto would fail *)
-Goal forall (A:Prop) (P:nat -> Prop),
- A \/ (forall x:nat, ~ A -> P x) -> forall x:nat, ~ A -> P x.
-
- tauto.
-\end{coq_example}
-\begin{coq_eval}
-Abort.
-\end{coq_eval}
-
-\Rem In contrast, {\tt tauto} cannot solve the following goal
-
-\begin{coq_example*}
-Goal forall (A:Prop) (P:nat -> Prop),
- A \/ (forall x:nat, ~ A -> P x) -> forall x:nat, ~ ~ (A \/ P x).
-\end{coq_example*}
-\begin{coq_eval}
-Abort.
-\end{coq_eval}
-
-because \verb=(forall x:nat, ~ A -> P x)= cannot be treated as atomic and an
-instantiation of \verb=x= is necessary.
-
-\subsection{\tt intuition {\tac}
-\tacindex{intuition}
-\label{intuition}}
-
-The tactic \texttt{intuition} takes advantage of the search-tree built
-by the decision procedure involved in the tactic {\tt tauto}. It uses
-this information to generate a set of subgoals equivalent to the
-original one (but simpler than it) and applies the tactic
-{\tac} to them \cite{Mun94}. If this tactic fails on some goals then
-{\tt intuition} fails. In fact, {\tt tauto} is simply {\tt intuition
- fail}.
-
-For instance, the tactic {\tt intuition auto} applied to the goal
-\begin{verbatim}
-(forall (x:nat), P x)/\B -> (forall (y:nat),P y)/\ P O \/B/\ P O
-\end{verbatim}
-internally replaces it by the equivalent one:
-\begin{verbatim}
-(forall (x:nat), P x), B |- P O
-\end{verbatim}
-and then uses {\tt auto} which completes the proof.
-
-Originally due to C{\'e}sar~Mu{\~n}oz, these tactics ({\tt tauto} and {\tt intuition})
-have been completely re-engineered by David~Delahaye using mainly the tactic
-language (see Chapter~\ref{TacticLanguage}). The code is now much shorter and
-a significant increase in performance has been noticed. The general behavior
-with respect to dependent types, unfolding and introductions has
-slightly changed to get clearer semantics. This may lead to some
-incompatibilities.
-
-\begin{Variants}
-\item {\tt intuition}\\
- Is equivalent to {\tt intuition auto with *}.
-\end{Variants}
-
-% En attente d'un moyen de valoriser les fichiers de demos
-%\SeeAlso file \texttt{contrib/Rocq/DEMOS/Demo\_tauto.v}
-
-
-\subsection{\tt rtauto
-\tacindex{rtauto}
-\label{rtauto}}
-
-The {\tt rtauto} tactic solves propositional tautologies similarly to what {\tt tauto} does. The main difference is that the proof term is built using a reflection scheme applied to a sequent calculus proof of the goal. The search procedure is also implemented using a different technique.
-
-Users should be aware that this difference may result in faster proof-search but slower proof-checking, and {\tt rtauto} might not solve goals that {\tt tauto} would be able to solve (e.g. goals involving universal quantifiers).
-
-\subsection{{\tt firstorder}
-\tacindex{firstorder}
-\label{firstorder}}
-
-The tactic \texttt{firstorder} is an {\it experimental} extension of
-\texttt{tauto} to
-first-order reasoning, written by Pierre Corbineau.
-It is not restricted to usual logical connectives but
-instead may reason about any first-order class inductive definition.
-
-\begin{Variants}
- \item {\tt firstorder {\tac}}
- \tacindex{firstorder {\tac}}
-
- Tries to solve the goal with {\tac} when no logical rule may apply.
-
- \item {\tt firstorder with \ident$_1$ \dots\ \ident$_n$ }
- \tacindex{firstorder with}
-
- Adds lemmas \ident$_1$ \dots\ \ident$_n$ to the proof-search
- environment.
-
- \item {\tt firstorder using {\qualid}$_1$ , \dots\ , {\qualid}$_n$ }
- \tacindex{firstorder using}
-
- Adds lemmas in {\tt auto} hints bases {\qualid}$_1$ \dots\ {\qualid}$_n$
- to the proof-search environment. If {\qualid}$_i$ refers to an inductive
- type, it is the collection of its constructors which is added as hints.
-
-\item \texttt{firstorder using {\qualid}$_1$ , \dots\ , {\qualid}$_n$ with \ident$_1$ \dots\ \ident$_n$}
-
- This combines the effects of the {\tt using} and {\tt with} options.
-
-\end{Variants}
-
-Proof-search is bounded by a depth parameter which can be set by typing the
-{\nobreak \tt Set Firstorder Depth $n$} \comindex{Set Firstorder Depth}
-vernacular command.
-
-%% \subsection{{\tt jp} {\em (Jprover)}
-%% \tacindex{jp}
-%% \label{jprover}}
-
-%% The tactic \texttt{jp}, due to Huang Guan-Shieng, is an experimental
-%% port of the {\em Jprover}\cite{SLKN01} semi-decision procedure for
-%% first-order intuitionistic logic implemented in {\em
-%% NuPRL}\cite{Kre02}.
-
-%% The tactic \texttt{jp}, due to Huang Guan-Shieng, is an {\it
-%% experimental} port of the {\em Jprover}\cite{SLKN01} semi-decision
-%% procedure for first-order intuitionistic logic implemented in {\em
-%% NuPRL}\cite{Kre02}.
-
-%% Search may optionnaly be bounded by a multiplicity parameter
-%% indicating how many (at most) copies of a formula may be used in
-%% the proof process, its absence may lead to non-termination of the tactic.
-
-%% %\begin{coq_eval}
-%% %Variable S:Set.
-%% %Variables P Q:S->Prop.
-%% %Variable f:S->S.
-%% %\end{coq_eval}
-
-%% %\begin{coq_example*}
-%% %Lemma example: (exists x |P x\/Q x)->(exists x |P x)\/(exists x |Q x).
-%% %jp.
-%% %Qed.
-
-%% %Lemma example2: (forall x ,P x->P (f x))->forall x,P x->P (f(f x)).
-%% %jp.
-%% %Qed.
-%% %\end{coq_example*}
-
-%% \begin{Variants}
-%% \item {\tt jp $n$}\\
-%% \tacindex{jp $n$}
-%% Tries the {\em Jprover} procedure with multiplicities up to $n$,
-%% starting from 1.
-%% \item {\tt jp}\\
-%% Tries the {\em Jprover} procedure without multiplicity bound,
-%% possibly running forever.
-%% \end{Variants}
-
-%% \begin{ErrMsgs}
-%% \item \errindex{multiplicity limit reached}\\
-%% The procedure tried all multiplicities below the limit and
-%% failed. Goal might be solved by increasing the multiplicity limit.
-%% \item \errindex{formula is not provable}\\
-%% The procedure determined that goal was not provable in
-%% intuitionistic first-order logic, no matter how big the
-%% multiplicity is.
-%% \end{ErrMsgs}
-
-
-% \subsection[\tt Linear]{\tt Linear\tacindex{Linear}\label{Linear}}
-% The tactic \texttt{Linear}, due to Jean-Christophe Filli{\^a}atre
-% \cite{Fil94}, implements a decision procedure for {\em Direct
-% Predicate Calculus}, that is first-order Gentzen's Sequent Calculus
-% without contraction rules \cite{KeWe84,BeKe92}. Intuitively, a
-% first-order goal is provable in Direct Predicate Calculus if it can be
-% proved using each hypothesis at most once.
-
-% Unlike the previous tactics, the \texttt{Linear} tactic does not belong
-% to the initial state of the system, and it must be loaded explicitly
-% with the command
-
-% \begin{coq_example*}
-% Require Linear.
-% \end{coq_example*}
-
-% For instance, assuming that \texttt{even} and \texttt{odd} are two
-% predicates on natural numbers, and \texttt{a} of type \texttt{nat}, the
-% tactic \texttt{Linear} solves the following goal
-
-% \begin{coq_eval}
-% Variables even,odd : nat -> Prop.
-% Variable a:nat.
-% \end{coq_eval}
-
-% \begin{coq_example*}
-% Lemma example : (even a)
-% -> ((x:nat)((even x)->(odd (S x))))
-% -> (EX y | (odd y)).
-% \end{coq_example*}
-
-% You can find examples of the use of \texttt{Linear} in
-% \texttt{theories/DEMOS/DemoLinear.v}.
-% \begin{coq_eval}
-% Abort.
-% \end{coq_eval}
-
-% \begin{Variants}
-% \item {\tt Linear with \ident$_1$ \dots\ \ident$_n$}\\
-% \tacindex{Linear with}
-% Is equivalent to apply first {\tt generalize \ident$_1$ \dots
-% \ident$_n$} (see Section~\ref{generalize}) then the \texttt{Linear}
-% tactic. So one can use axioms, lemmas or hypotheses of the local
-% context with \texttt{Linear} in this way.
-% \end{Variants}
-
-% \begin{ErrMsgs}
-% \item \errindex{Not provable in Direct Predicate Calculus}
-% \item \errindex{Found $n$ classical proof(s) but no intuitionistic one}\\
-% The decision procedure looks actually for classical proofs of the
-% goals, and then checks that they are intuitionistic. In that case,
-% classical proofs have been found, which do not correspond to
-% intuitionistic ones.
-% \end{ErrMsgs}
-
-\subsection{\tt congruence
-\tacindex{congruence}
-\label{congruence}}
-
-The tactic {\tt congruence}, by Pierre Corbineau, implements the standard Nelson and Oppen
-congruence closure algorithm, which is a decision procedure for ground
-equalities with uninterpreted symbols. It also include the constructor theory
-(see \ref{injection} and \ref{discriminate}).
-If the goal is a non-quantified equality, {\tt congruence} tries to
-prove it with non-quantified equalities in the context. Otherwise it
-tries to infer a discriminable equality from those in the context. Alternatively, congruence tries to prove that a hypothesis is equal to the goal or to the negation of another hypothesis.
-
-{\tt congruence} is also able to take advantage of hypotheses stating quantified equalities, you have to provide a bound for the number of extra equalities generated that way. Please note that one of the members of the equality must contain all the quantified variables in order for {\tt congruence} to match against it.
-
-\begin{coq_eval}
-Reset Initial.
-Variable A:Set.
-Variables a b:A.
-Variable f:A->A.
-Variable g:A->A->A.
-\end{coq_eval}
-
-\begin{coq_example}
-Theorem T:
- a=(f a) -> (g b (f a))=(f (f a)) -> (g a b)=(f (g b a)) -> (g a b)=a.
-intros.
-congruence.
-\end{coq_example}
-
-\begin{coq_eval}
-Reset Initial.
-Variable A:Set.
-Variables a c d:A.
-Variable f:A->A*A.
-\end{coq_eval}
-
-\begin{coq_example}
-Theorem inj : f = pair a -> Some (f c) = Some (f d) -> c=d.
-intros.
-congruence.
-\end{coq_example}
-
-\begin{Variants}
- \item {\tt congruence {\sl n}}\\
- Tries to add at most {\tt \sl n} instances of hypotheses stating quantified equalities to the problem in order to solve it. A bigger value of {\tt \sl n} does not make success slower, only failure. You might consider adding some lemmas as hypotheses using {\tt assert} in order for congruence to use them.
+ Uses the unfold hints declared in all the hint databases.
\end{Variants}
-\begin{Variants}
-\item {\tt congruence with \term$_1$ \dots\ \term$_n$}\\
- Adds {\tt \term$_1$ \dots\ \term$_n$} to the pool of terms used by
- {\tt congruence}. This helps in case you have partially applied
- constructors in your goal.
-\end{Variants}
-
-\begin{ErrMsgs}
- \item \errindex{I don't know how to handle dependent equality} \\
- The decision procedure managed to find a proof of the goal or of
- a discriminable equality but this proof couldn't be built in {\Coq}
- because of dependently-typed functions.
- \item \errindex{I couldn't solve goal} \\
- The decision procedure didn't find any way to solve the goal.
- \item \errindex{Goal is solvable by congruence but some arguments are missing. Try "congruence with \dots", replacing metavariables by arbitrary terms.} \\
- The decision procedure could solve the goal with the provision
- that additional arguments are supplied for some partially applied
- constructors. Any term of an appropriate type will allow the
- tactic to successfully solve the goal. Those additional arguments
- can be given to {\tt congruence} by filling in the holes in the
- terms given in the error message, using the {\tt with} variant
- described above.
-\end{ErrMsgs}
-
-\subsection{\tt omega
-\tacindex{omega}
-\label{omega}}
-
-The tactic \texttt{omega}, due to Pierre Cr{\'e}gut,
-is an automatic decision procedure for Presburger
-arithmetic. It solves quantifier-free
-formulas built with \verb|~|, \verb|\/|, \verb|/\|,
-\verb|->| on top of equalities, inequalities and disequalities on
-both the type \texttt{nat} of natural numbers and \texttt{Z} of binary
-integers. This tactic must be loaded by the command \texttt{Require Import
- Omega}. See the additional documentation about \texttt{omega}
-(see Chapter~\ref{OmegaChapter}).
-
-\subsection{{\tt ring} and {\tt ring\_simplify \term$_1$ \dots\ \term$_n$}
-\tacindex{ring}
-\tacindex{ring\_simplify}
-\comindex{Add Ring}}
-
-The {\tt ring} tactic solves equations upon polynomial expressions of
-a ring (or semi-ring) structure. It proceeds by normalizing both hand
-sides of the equation (w.r.t. associativity, commutativity and
-distributivity, constant propagation) and comparing syntactically the
-results.
-
-{\tt ring\_simplify} applies the normalization procedure described
-above to the terms given. The tactic then replaces all occurrences of
-the terms given in the conclusion of the goal by their normal
-forms. If no term is given, then the conclusion should be an equation
-and both hand sides are normalized.
-
-See Chapter~\ref{ring} for more information on the tactic and how to
-declare new ring structures.
-
-\subsection{{\tt field}, {\tt field\_simplify \term$_1$\dots\ \term$_n$}
- and {\tt field\_simplify\_eq}
-\tacindex{field}
-\tacindex{field\_simplify}
-\tacindex{field\_simplify\_eq}
-\comindex{Add Field}}
-
-The {\tt field} tactic is built on the same ideas as {\tt ring}: this
-is a reflexive tactic that solves or simplifies equations in a field
-structure. The main idea is to reduce a field expression (which is an
-extension of ring expressions with the inverse and division
-operations) to a fraction made of two polynomial expressions.
-
-Tactic {\tt field} is used to solve subgoals, whereas {\tt
- field\_simplify \term$_1$\dots\term$_n$} replaces the provided terms
-by their reduced fraction. {\tt field\_simplify\_eq} applies when the
-conclusion is an equation: it simplifies both hand sides and multiplies
-so as to cancel denominators. So it produces an equation without
-division nor inverse.
-
-All of these 3 tactics may generate a subgoal in order to prove that
-denominators are different from zero.
-
-See Chapter~\ref{ring} for more information on the tactic and how to
-declare new field structures.
-
-\Example
-\begin{coq_example*}
-Require Import Reals.
-Goal forall x y:R,
- (x * y > 0)%R ->
- (x * (1 / x + x / (x + y)))%R =
- ((- 1 / y) * y * (- x * (x / (x + y)) - 1))%R.
-\end{coq_example*}
-
-\begin{coq_example}
-intros; field.
-\end{coq_example}
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
-
-\SeeAlso file {\tt plugins/setoid\_ring/RealField.v} for an example of instantiation,\\
-\phantom{\SeeAlso}theory {\tt theories/Reals} for many examples of use of {\tt
-field}.
-
-\subsection{\tt fourier
-\tacindex{fourier}}
-
-This tactic written by Lo{\"\i}c Pottier solves linear inequalities on
-real numbers using Fourier's method~\cite{Fourier}. This tactic must
-be loaded by {\tt Require Import Fourier}.
-
-\Example
-\begin{coq_example*}
-Require Import Reals.
-Require Import Fourier.
-Goal forall x y:R, (x < y)%R -> (y + 1 >= x - 1)%R.
-\end{coq_example*}
-
-\begin{coq_example}
-intros; fourier.
-\end{coq_example}
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
\subsection{\tt autorewrite with \ident$_1$ \dots \ident$_n$.
\label{tactic:autorewrite}
@@ -3811,7 +3318,7 @@ Performs, in the same way, all the rewritings of the bases {\tt \ident$_1$ $...$
\SeeAlso Section~\ref{HintRewrite} for feeding the database of lemmas used by {\tt autorewrite}.
\SeeAlso Section~\ref{autorewrite-example} for examples showing the use of
-this tactic.
+this tactic.
% En attente d'un moyen de valoriser les fichiers de demos
%\SeeAlso file \texttt{contrib/Rocq/DEMOS/Demo\_AutoRewrite.v}
@@ -3827,17 +3334,17 @@ The hints for \texttt{auto} and \texttt{eauto} are stored in
databases. Each database maps head symbols to a list of hints. One can
use the command \texttt{Print Hint \ident} to display the hints
associated to the head symbol \ident{} (see \ref{PrintHint}). Each
-hint has a cost that is an nonnegative integer, and an optional pattern.
-The hints with lower cost are tried first. A hint is tried by
+hint has a cost that is an nonnegative integer, and an optional pattern.
+The hints with lower cost are tried first. A hint is tried by
\texttt{auto} when the conclusion of the current goal
-matches its pattern or when it has no pattern.
+matches its pattern or when it has no pattern.
\subsubsection*{Creating Hint databases
\label{CreateHintDb}\comindex{CreateHintDb}}
One can optionally declare a hint database using the command
\texttt{Create HintDb}. If a hint is added to an unknown database, it
-will be automatically created.
+will be automatically created.
\medskip
\texttt{Create HintDb} {\ident} [\texttt{discriminated}]
@@ -3856,13 +3363,13 @@ in case the DT is not used). The new implementation enabled by
the {\tt discriminated} option makes use of DTs in all cases and takes
transparency information into account. However, the order in which hints
are retrieved from the DT may differ from the order in which they were
-inserted, making this implementation observationaly different from the
-legacy one.
+inserted, making this implementation observationally different from the
+legacy one.
\begin{Variants}
\item\texttt{Local Hint} \textsl{hint\_definition} \texttt{:}
\ident$_1$ \ldots\ \ident$_n$
-
+
This is used to declare a hint database that must not be exported to the other
modules that require and import the current module. Inside a
section, the option {\tt Local} is useless since hints do not
@@ -3878,18 +3385,18 @@ command to add a hint to some database \ident$_1$, \dots, \ident$_n$ is:
where {\sl hint\_definition} is one of the following expressions:
\begin{itemize}
-\item \texttt{Resolve} {\term}
+\item \texttt{Resolve} {\term}
\comindex{Hint Resolve}
-
+
This command adds {\tt apply {\term}} to the hint list
with the head symbol of the type of \term. The cost of that hint is
the number of subgoals generated by {\tt apply {\term}}.
-
+
In case the inferred type of \term\ does not start with a product the
tactic added in the hint list is {\tt exact {\term}}. In case this
type can be reduced to a type starting with a product, the tactic {\tt
apply {\term}} is also stored in the hints list.
-
+
If the inferred type of \term\ contains a dependent
quantification on a predicate, it is added to the hint list of {\tt
eapply} instead of the hint list of {\tt apply}. In this case, a
@@ -3919,19 +3426,19 @@ where {\sl hint\_definition} is one of the following expressions:
\end{Variants}
-\item \texttt{Immediate {\term}}
+\item \texttt{Immediate {\term}}
\comindex{Hint Immediate}
-
+
This command adds {\tt apply {\term}; trivial} to the hint list
associated with the head symbol of the type of {\ident} in the given
database. This tactic will fail if all the subgoals generated by
{\tt apply {\term}} are not solved immediately by the {\tt trivial}
tactic (which only tries tactics with cost $0$).
-
+
This command is useful for theorems such as the symmetry of equality
or $n+1=m+1 \to n=m$ that we may like to introduce with a
limited use in order to avoid useless proof-search.
-
+
The cost of this tactic (which never generates subgoals) is always 1,
so that it is not used by {\tt trivial} itself.
@@ -3939,13 +3446,13 @@ where {\sl hint\_definition} is one of the following expressions:
\item \errindex{Bound head variable}
- \item \term\ \errindex{cannot be used as a hint}
+ \item \term\ \errindex{cannot be used as a hint}
\end{ErrMsgs}
\begin{Variants}
- \item \texttt{Immediate} {\term$_1$} \dots {\term$_m$}
+ \item \texttt{Immediate} {\term$_1$} \dots {\term$_m$}
Adds each \texttt{Immediate} {\term$_i$}.
@@ -3953,7 +3460,7 @@ where {\sl hint\_definition} is one of the following expressions:
\item \texttt{Constructors} {\ident}
\comindex{Hint Constructors}
-
+
If {\ident} is an inductive type, this command adds all its
constructors as hints of type \texttt{Resolve}. Then, when the
conclusion of current goal has the form \texttt{({\ident} \dots)},
@@ -3969,7 +3476,7 @@ where {\sl hint\_definition} is one of the following expressions:
\begin{Variants}
- \item \texttt{Constructors} {\ident$_1$} \dots {\ident$_m$}
+ \item \texttt{Constructors} {\ident$_1$} \dots {\ident$_m$}
Adds each \texttt{Constructors} {\ident$_i$}.
@@ -3977,14 +3484,14 @@ where {\sl hint\_definition} is one of the following expressions:
\item \texttt{Unfold} {\qualid}
\comindex{Hint Unfold}
-
+
This adds the tactic {\tt unfold {\qualid}} to the hint list that
will only be used when the head constant of the goal is \ident. Its
cost is 4.
\begin{Variants}
- \item \texttt{Unfold} {\ident$_1$} \dots {\ident$_m$}
+ \item \texttt{Unfold} {\ident$_1$} \dots {\ident$_m$}
Adds each \texttt{Unfold} {\ident$_i$}.
@@ -3994,19 +3501,19 @@ where {\sl hint\_definition} is one of the following expressions:
\label{HintTransparency}
\comindex{Hint Transparent}
\comindex{Hint Opaque}
-
+
This adds a transparency hint to the database, making {\tt {\qualid}}
- a transparent or opaque constant during resolution. This information
+ a transparent or opaque constant during resolution. This information
is used during unification of the goal with any lemma in the database
and inside the discrimination network to relax or constrain it in the
case of \texttt{discriminated} databases.
-
+
\begin{Variants}
- \item \texttt{Transparent}, \texttt{Opaque} {\ident$_1$} \dots {\ident$_m$}
+ \item \texttt{Transparent}, \texttt{Opaque} {\ident$_1$} \dots {\ident$_m$}
Declares each {\ident$_i$} as a transparent or opaque constant.
-
+
\end{Variants}
\item \texttt{Extern \num\ [\pattern]\ => }\textsl{tactic}
@@ -4025,7 +3532,7 @@ Hint Extern 4 (~(_ = _)) => discriminate.
Now, when the head of the goal is a disequality, \texttt{auto} will
try \texttt{discriminate} if it does not manage to solve the goal
with hints with a cost less than 4.
-
+
One can even use some sub-patterns of the pattern in the tactic
script. A sub-pattern is a question mark followed by an ident, like
\texttt{?X1} or \texttt{?X2}. Here is an example:
@@ -4037,7 +3544,7 @@ Require Import List.
\begin{coq_example}
Hint Extern 5 ({?X1 = ?X2} + {?X1 <> ?X2}) =>
generalize X1, X2; decide equality : eqdec.
-Goal
+Goal
forall a b:list (nat * nat), {a = b} + {a <> b}.
info auto with eqdec.
\end{coq_example}
@@ -4048,14 +3555,14 @@ Abort.
\end{itemize}
\Rem One can use an \texttt{Extern} hint with no pattern to do
-pattern-matching on hypotheses using \texttt{match goal with} inside
+pattern-matching on hypotheses using \texttt{match goal with} inside
the tactic.
\begin{Variants}
-\item \texttt{Hint} \textsl{hint\_definition}
-
- No database name is given: the hint is registered in the {\tt core}
- database.
+\item \texttt{Hint} \textsl{hint\_definition}
+
+ No database name is given: the hint is registered in the {\tt core}
+ database.
\item\texttt{Hint Local} \textsl{hint\_definition} \texttt{:}
\ident$_1$ \ldots\ \ident$_n$
@@ -4065,10 +3572,10 @@ the tactic.
section, the option {\tt Local} is useless since hints do not
survive anyway to the closure of sections.
-\item\texttt{Hint Local} \textsl{hint\_definition}
+\item\texttt{Hint Local} \textsl{hint\_definition}
Idem for the {\tt core} database.
-
+
\end{Variants}
% There are shortcuts that allow to define several goal at once:
@@ -4108,7 +3615,7 @@ databases are non empty and can be used.
\texttt{auto}, except when pseudo-database \texttt{nocore} is
given to \texttt{auto}. The \texttt{core} database contains
only basic lemmas about negation,
- conjunction, and so on from. Most of the hints in this database come
+ conjunction, and so on from. Most of the hints in this database come
from the \texttt{Init} and \texttt{Logic} directories.
\item[\tt arith] This database contains all lemmas about Peano's
@@ -4124,10 +3631,10 @@ databases are non empty and can be used.
\item[\tt bool] contains lemmas about booleans, mostly from directory
\texttt{theories/Bool}.
-\item[\tt datatypes] is for lemmas about lists, streams and so on that
+\item[\tt datatypes] is for lemmas about lists, streams and so on that
are mainly proved in the \texttt{Lists} subdirectory.
-\item[\tt sets] contains lemmas about sets and relations from the
+\item[\tt sets] contains lemmas about sets and relations from the
directories \texttt{Sets} and \texttt{Relations}.
\item[\tt typeclass\_instances] contains all the type class instances
@@ -4166,7 +3673,7 @@ every moment.
\item {\tt Print Hint *}
- This command displays all declared hints.
+ This command displays all declared hints.
\item {\tt Print HintDb {\ident} }
\label{PrintHintDb}
@@ -4205,7 +3712,7 @@ When the rewriting rules {\tt \term$_1$ \dots \term$_n$} in {\tt \ident} will
be used, the tactic {\tt \tac} will be applied to the generated subgoals, the
main subgoal excluded.
-%% \item
+%% \item
%% {\tt Hint Rewrite [ \term$_1$ \dots \term$_n$ ] in \ident}\\
%% {\tt Hint Rewrite [ \term$_1$ \dots \term$_n$ ] in {\ident} using {\tac}}\\
%% These are deprecated syntactic variants for
@@ -4241,10 +3748,10 @@ e.g. \texttt{Require Import A.}).
\begin{Variants}
\item {\tt Proof with {\tac} using {\ident$_1$ \dots {\ident$_n$}}}
- Combines in a single line {\tt Proof with} and {\tt Proof using},
+ Combines in a single line {\tt Proof with} and {\tt Proof using},
see~\ref{ProofUsing}
\item {\tt Proof using {\ident$_1$ \dots {\ident$_n$}} with {\tac}}
- Combines in a single line {\tt Proof with} and {\tt Proof using},
+ Combines in a single line {\tt Proof with} and {\tt Proof using},
see~\ref{ProofUsing}
\end{Variants}
@@ -4271,117 +3778,722 @@ exists (n // m).
The tactic {\tt exists (n // m)} did not fail. The hole was solved by
{\tt assumption} so that it behaved as {\tt exists (quo n m H)}.
-\section{Generation of induction principles with {\tt Scheme}
-\label{Scheme}
-\index{Schemes}
-\comindex{Scheme}}
+\section{Decision procedures}
-The {\tt Scheme} command is a high-level tool for generating
-automatically (possibly mutual) induction principles for given types
-and sorts. Its syntax follows the schema:
-\begin{quote}
-{\tt Scheme {\ident$_1$} := Induction for \ident'$_1$ Sort {\sort$_1$} \\
- with\\
- \mbox{}\hspace{0.1cm} \dots\\
- with {\ident$_m$} := Induction for {\ident'$_m$} Sort
- {\sort$_m$}}
-\end{quote}
-where \ident'$_1$ \dots\ \ident'$_m$ are different inductive type
-identifiers belonging to the same package of mutual inductive
-definitions. This command generates {\ident$_1$}\dots{} {\ident$_m$}
-to be mutually recursive definitions. Each term {\ident$_i$} proves a
-general principle of mutual induction for objects in type {\term$_i$}.
+\subsection{\tt tauto
+\tacindex{tauto}
+\label{tauto}}
+
+This tactic implements a decision procedure for intuitionistic propositional
+calculus based on the contraction-free sequent calculi LJT* of Roy Dyckhoff
+\cite{Dyc92}. Note that {\tt tauto} succeeds on any instance of an
+intuitionistic tautological proposition. {\tt tauto} unfolds negations
+and logical equivalence but does not unfold any other definition.
+
+The following goal can be proved by {\tt tauto} whereas {\tt auto}
+would fail:
+
+\begin{coq_example}
+Goal forall (x:nat) (P:nat -> Prop), x = 0 \/ P x -> x <> 0 -> P x.
+ intros.
+ tauto.
+\end{coq_example}
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
+Moreover, if it has nothing else to do, {\tt tauto} performs
+introductions. Therefore, the use of {\tt intros} in the previous
+proof is unnecessary. {\tt tauto} can for instance prove the
+following:
+\begin{coq_example}
+(* auto would fail *)
+Goal forall (A:Prop) (P:nat -> Prop),
+ A \/ (forall x:nat, ~ A -> P x) -> forall x:nat, ~ A -> P x.
+
+ tauto.
+\end{coq_example}
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
+\Rem In contrast, {\tt tauto} cannot solve the following goal
+
+\begin{coq_example*}
+Goal forall (A:Prop) (P:nat -> Prop),
+ A \/ (forall x:nat, ~ A -> P x) -> forall x:nat, ~ ~ (A \/ P x).
+\end{coq_example*}
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
+because \verb=(forall x:nat, ~ A -> P x)= cannot be treated as atomic and an
+instantiation of \verb=x= is necessary.
+
+\subsection{\tt intuition {\tac}
+\tacindex{intuition}
+\label{intuition}}
+
+The tactic \texttt{intuition} takes advantage of the search-tree built
+by the decision procedure involved in the tactic {\tt tauto}. It uses
+this information to generate a set of subgoals equivalent to the
+original one (but simpler than it) and applies the tactic
+{\tac} to them \cite{Mun94}. If this tactic fails on some goals then
+{\tt intuition} fails. In fact, {\tt tauto} is simply {\tt intuition
+ fail}.
+
+For instance, the tactic {\tt intuition auto} applied to the goal
+\begin{verbatim}
+(forall (x:nat), P x)/\B -> (forall (y:nat),P y)/\ P O \/B/\ P O
+\end{verbatim}
+internally replaces it by the equivalent one:
+\begin{verbatim}
+(forall (x:nat), P x), B |- P O
+\end{verbatim}
+and then uses {\tt auto} which completes the proof.
+
+Originally due to C{\'e}sar~Mu{\~n}oz, these tactics ({\tt tauto} and {\tt intuition})
+have been completely re-engineered by David~Delahaye using mainly the tactic
+language (see Chapter~\ref{TacticLanguage}). The code is now much shorter and
+a significant increase in performance has been noticed. The general behavior
+with respect to dependent types, unfolding and introductions has
+slightly changed to get clearer semantics. This may lead to some
+incompatibilities.
+
+\begin{Variants}
+\item {\tt intuition}\\
+ Is equivalent to {\tt intuition auto with *}.
+\end{Variants}
+
+% En attente d'un moyen de valoriser les fichiers de demos
+%\SeeAlso file \texttt{contrib/Rocq/DEMOS/Demo\_tauto.v}
+
+
+\subsection{\tt rtauto
+\tacindex{rtauto}
+\label{rtauto}}
+
+The {\tt rtauto} tactic solves propositional tautologies similarly to what {\tt tauto} does. The main difference is that the proof term is built using a reflection scheme applied to a sequent calculus proof of the goal. The search procedure is also implemented using a different technique.
+
+Users should be aware that this difference may result in faster proof-search but slower proof-checking, and {\tt rtauto} might not solve goals that {\tt tauto} would be able to solve (e.g. goals involving universal quantifiers).
+
+\subsection{{\tt firstorder}
+\tacindex{firstorder}
+\label{firstorder}}
+
+The tactic \texttt{firstorder} is an {\it experimental} extension of
+\texttt{tauto} to
+first-order reasoning, written by Pierre Corbineau.
+It is not restricted to usual logical connectives but
+instead may reason about any first-order class inductive definition.
\begin{Variants}
-\item {\tt Scheme {\ident$_1$} := Minimality for \ident'$_1$ Sort {\sort$_1$} \\
- with\\
- \mbox{}\hspace{0.1cm} \dots\ \\
- with {\ident$_m$} := Minimality for {\ident'$_m$} Sort
- {\sort$_m$}}
+ \item {\tt firstorder {\tac}}
+ \tacindex{firstorder {\tac}}
- Same as before but defines a non-dependent elimination principle more
- natural in case of inductively defined relations.
+ Tries to solve the goal with {\tac} when no logical rule may apply.
-\item {\tt Scheme Equality for \ident$_1$\comindex{Scheme Equality}}
+ \item {\tt firstorder with \ident$_1$ \dots\ \ident$_n$ }
+ \tacindex{firstorder with}
- Tries to generate a boolean equality and a proof of the
- decidability of the usual equality. If \ident$_i$ involves
- some other inductive types, their equality has to be defined first.
+ Adds lemmas \ident$_1$ \dots\ \ident$_n$ to the proof-search
+ environment.
-\item {\tt Scheme Induction for \ident$_1$ Sort {\sort$_1$} \\
- with\\
- \mbox{}\hspace{0.1cm} \dots\\
- with Induction for {\ident$_m$} Sort
- {\sort$_m$}}
+ \item {\tt firstorder using {\qualid}$_1$ , \dots\ , {\qualid}$_n$ }
+ \tacindex{firstorder using}
- If you do not provide the name of the schemes, they will be automatically
- computed from the sorts involved (works also with Minimality).
+ Adds lemmas in {\tt auto} hints bases {\qualid}$_1$ \dots\ {\qualid}$_n$
+ to the proof-search environment. If {\qualid}$_i$ refers to an inductive
+ type, it is the collection of its constructors which is added as hints.
+
+\item \texttt{firstorder using {\qualid}$_1$ , \dots\ , {\qualid}$_n$ with \ident$_1$ \dots\ \ident$_n$}
+
+ This combines the effects of the {\tt using} and {\tt with} options.
\end{Variants}
-\SeeAlso Section~\ref{Scheme-examples}
-
-\subsection{Automatic declaration of schemes}
-\comindex{Set Equality Schemes}
-\comindex{Set Elimination Schemes}
-It is possible to deactivate the automatic declaration of the induction
- principles when defining a new inductive type with the
- {\tt Unset Elimination Schemes} command. It may be
-reactivated at any time with {\tt Set Elimination Schemes}.
-\\
-
-You can also activate the automatic declaration of those boolean equalities
-(see the second variant of {\tt Scheme}) with the {\tt Set Equality Schemes}
- command. However you have to be careful with this option since
-\Coq~ may now reject well-defined inductive types because it cannot compute
-a boolean equality for them.
-
-\subsection{\tt Combined Scheme\label{CombinedScheme}
-\comindex{Combined Scheme}}
-The {\tt Combined Scheme} command is a tool for combining
-induction principles generated by the {\tt Scheme} command.
-Its syntax follows the schema :
-
-\noindent
-{\tt Combined Scheme {\ident$_0$} from {\ident$_1$}, .., {\ident$_n$}}\\
-\ident$_1$ \ldots \ident$_n$ are different inductive principles that must belong to
-the same package of mutual inductive principle definitions. This command
-generates {\ident$_0$} to be the conjunction of the principles: it is
-built from the common premises of the principles and concluded by the
-conjunction of their conclusions.
-
-\SeeAlso Section~\ref{CombinedScheme-examples}
-
-\section{Generation of induction principles with {\tt Functional Scheme}
-\label{FunScheme}
-\comindex{Functional Scheme}}
-
-The {\tt Functional Scheme} command is a high-level experimental
-tool for generating automatically induction principles
-corresponding to (possibly mutually recursive) functions. Its
-syntax follows the schema:
-\begin{quote}
-{\tt Functional Scheme {\ident$_1$} := Induction for \ident'$_1$ Sort {\sort$_1$} \\
- with\\
- \mbox{}\hspace{0.1cm} \dots\ \\
- with {\ident$_m$} := Induction for {\ident'$_m$} Sort
- {\sort$_m$}}
-\end{quote}
-where \ident'$_1$ \dots\ \ident'$_m$ are different mutually defined function
-names (they must be in the same order as when they were defined).
-This command generates the induction principles
-\ident$_1$\dots\ident$_m$, following the recursive structure and case
-analyses of the functions \ident'$_1$ \dots\ \ident'$_m$.
+Proof-search is bounded by a depth parameter which can be set by typing the
+{\nobreak \tt Set Firstorder Depth $n$} \comindex{Set Firstorder Depth}
+vernacular command.
-\paragraph{\texttt{Functional Scheme}}
-There is a difference between obtaining an induction scheme by using
-\texttt{Functional Scheme} on a function defined by \texttt{Function}
-or not. Indeed \texttt{Function} generally produces smaller
-principles, closer to the definition written by the user.
+\subsection{\tt congruence
+\tacindex{congruence}
+\label{congruence}}
+The tactic {\tt congruence}, by Pierre Corbineau, implements the standard Nelson and Oppen
+congruence closure algorithm, which is a decision procedure for ground
+equalities with uninterpreted symbols. It also include the constructor theory
+(see \ref{injection} and \ref{discriminate}).
+If the goal is a non-quantified equality, {\tt congruence} tries to
+prove it with non-quantified equalities in the context. Otherwise it
+tries to infer a discriminable equality from those in the context. Alternatively, congruence tries to prove that a hypothesis is equal to the goal or to the negation of another hypothesis.
+
+{\tt congruence} is also able to take advantage of hypotheses stating quantified equalities, you have to provide a bound for the number of extra equalities generated that way. Please note that one of the members of the equality must contain all the quantified variables in order for {\tt congruence} to match against it.
+
+\begin{coq_eval}
+Reset Initial.
+Variable A:Set.
+Variables a b:A.
+Variable f:A->A.
+Variable g:A->A->A.
+\end{coq_eval}
+
+\begin{coq_example}
+Theorem T:
+ a=(f a) -> (g b (f a))=(f (f a)) -> (g a b)=(f (g b a)) -> (g a b)=a.
+intros.
+congruence.
+\end{coq_example}
-\SeeAlso Section~\ref{FunScheme-examples}
+\begin{coq_eval}
+Reset Initial.
+Variable A:Set.
+Variables a c d:A.
+Variable f:A->A*A.
+\end{coq_eval}
+
+\begin{coq_example}
+Theorem inj : f = pair a -> Some (f c) = Some (f d) -> c=d.
+intros.
+congruence.
+\end{coq_example}
+
+\begin{Variants}
+ \item {\tt congruence {\sl n}}\\
+ Tries to add at most {\tt \sl n} instances of hypotheses stating quantified equalities to the problem in order to solve it. A bigger value of {\tt \sl n} does not make success slower, only failure. You might consider adding some lemmas as hypotheses using {\tt assert} in order for congruence to use them.
+
+\end{Variants}
+
+\begin{Variants}
+\item {\tt congruence with \term$_1$ \dots\ \term$_n$}\\
+ Adds {\tt \term$_1$ \dots\ \term$_n$} to the pool of terms used by
+ {\tt congruence}. This helps in case you have partially applied
+ constructors in your goal.
+\end{Variants}
+
+\begin{ErrMsgs}
+ \item \errindex{I don't know how to handle dependent equality} \\
+ The decision procedure managed to find a proof of the goal or of
+ a discriminable equality but this proof couldn't be built in {\Coq}
+ because of dependently-typed functions.
+ \item \errindex{I couldn't solve goal} \\
+ The decision procedure didn't find any way to solve the goal.
+ \item \errindex{Goal is solvable by congruence but some arguments are missing. Try "congruence with \dots", replacing metavariables by arbitrary terms.} \\
+ The decision procedure could solve the goal with the provision
+ that additional arguments are supplied for some partially applied
+ constructors. Any term of an appropriate type will allow the
+ tactic to successfully solve the goal. Those additional arguments
+ can be given to {\tt congruence} by filling in the holes in the
+ terms given in the error message, using the {\tt with} variant
+ described above.
+\end{ErrMsgs}
+
+
+\section{Things that do not fit other sections}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+\section{Everything after this point has yet to be sorted}
+
+
+\subsection{\tt constr\_eq \term$_1$ \term$_2$
+\tacindex{constr\_eq}
+\label{constreq}}
+
+This tactic applies to any goal. It checks whether its arguments are
+equal modulo alpha conversion and casts.
+
+\ErrMsg \errindex{Not equal}
+
+\subsection{\tt unify \term$_1$ \term$_2$
+\tacindex{unify}
+\label{unify}}
+
+This tactic applies to any goal. It checks whether its arguments are
+unifiable, potentially instantiating existential variables.
+
+\ErrMsg \errindex{Not unifiable}
+
+\begin{Variants}
+\item {\tt unify \term$_1$ \term$_2$ with \ident}
+
+ Unification takes the transparency information defined in the
+ hint database {\tt \ident} into account (see Section~\ref{HintTransparency}).
+\end{Variants}
+
+\subsection{\tt is\_evar \term
+\tacindex{is\_evar}
+\label{isevar}}
+
+This tactic applies to any goal. It checks whether its argument is an
+existential variable. Existential variables are uninstantiated
+variables generated by e.g. {\tt eapply} (see Section~\ref{apply}).
+
+\ErrMsg \errindex{Not an evar}
+
+\subsection{\tt has\_evar \term
+\tacindex{has\_evar}
+\label{hasevar}}
+
+This tactic applies to any goal. It checks whether its argument has an
+existential variable as a subterm. Unlike {\tt context} patterns
+combined with {\tt is\_evar}, this tactic scans all subterms,
+including those under binders.
+
+\ErrMsg \errindex{No evars}
+
+\subsection{\tt is\_var \term
+\tacindex{is\_var}
+\label{isvar}}
+
+This tactic applies to any goal. It checks whether its argument is a
+variable or hypothesis in the current goal context or in the opened sections.
+
+\ErrMsg \errindex{Not a variable or hypothesis}
+
+\section{Equality}
+
+\subsection{\tt f\_equal
+\label{f-equal}
+\tacindex{f\_equal}}
+
+This tactic applies to a goal of the form $f\ a_1\ \ldots\ a_n = f'\
+a'_1\ \ldots\ a'_n$. Using {\tt f\_equal} on such a goal leads to
+subgoals $f=f'$ and $a_1=a'_1$ and so on up to $a_n=a'_n$. Amongst
+these subgoals, the simple ones (e.g. provable by
+reflexivity or congruence) are automatically solved by {\tt f\_equal}.
+
+
+\section{Equality and inductive sets}
+
+We describe in this section some special purpose tactics dealing with
+equality and inductive sets or types. These tactics use the equality
+{\tt eq:forall (A:Type), A->A->Prop}, simply written with the
+infix symbol {\tt =}.
+
+\subsection{\tt decide equality
+\label{decideequality}
+\tacindex{decide equality}}
+
+This tactic solves a goal of the form
+{\tt forall $x$ $y$:$R$, \{$x$=$y$\}+\{\verb|~|$x$=$y$\}}, where $R$
+is an inductive type such that its constructors do not take proofs or
+functions as arguments, nor objects in dependent types.
+It solves goals of the form {\tt \{$x$=$y$\}+\{\verb|~|$x$=$y$\}} as well.
+
+\subsection{\tt compare \term$_1$ \term$_2$
+\tacindex{compare}}
+
+This tactic compares two given objects \term$_1$ and \term$_2$
+of an inductive datatype. If $G$ is the current goal, it leaves the sub-goals
+\term$_1${\tt =}\term$_2$ {\tt ->} $G$ and \verb|~|\term$_1${\tt =}\term$_2$
+{\tt ->} $G$. The type
+of \term$_1$ and \term$_2$ must satisfy the same restrictions as in the tactic
+\texttt{decide equality}.
+
+\subsection{\tt simplify\_eq {\term}
+\tacindex{simplify\_eq}
+\tacindex{esimplify\_eq}
+\label{simplify-eq}}
+
+Let {\term} be the proof of a statement of conclusion {\tt
+ {\term$_1$}={\term$_2$}}. If {\term$_1$} and
+{\term$_2$} are structurally different (in the sense described for the
+tactic {\tt discriminate}), then the tactic {\tt simplify\_eq} behaves as {\tt
+ discriminate {\term}}, otherwise it behaves as {\tt injection
+ {\term}}.
+
+\Rem If some quantified hypothesis of the goal is named {\ident}, then
+{\tt simplify\_eq {\ident}} first introduces the hypothesis in the local
+context using \texttt{intros until \ident}.
+
+\begin{Variants}
+\item \texttt{simplify\_eq} \num
+
+ This does the same thing as \texttt{intros until \num} then
+\texttt{simplify\_eq \ident} where {\ident} is the identifier for the last
+introduced hypothesis.
+
+\item \texttt{simplify\_eq} \term{} {\tt with} {\bindinglist}
+
+ This does the same as \texttt{simplify\_eq {\term}} but using
+ the given bindings to instantiate parameters or hypotheses of {\term}.
+
+\item \texttt{esimplify\_eq} \num\\
+ \texttt{esimplify\_eq} \term{} \zeroone{{\tt with} {\bindinglist}}
+
+ This works the same as {\tt simplify\_eq} but if the type of {\term},
+ or the type of the hypothesis referred to by {\num}, has uninstantiated
+ parameters, these parameters are left as existential variables.
+
+\item{\tt simplify\_eq}
+
+If the current goal has form $t_1\verb=<>=t_2$, it behaves as
+\texttt{intro {\ident}; simplify\_eq {\ident}}.
+\end{Variants}
+
+\subsection{\tt dependent rewrite -> {\ident}
+\tacindex{dependent rewrite ->}
+\label{dependent-rewrite}}
+
+This tactic applies to any goal. If \ident\ has type
+\verb+(existT B a b)=(existT B a' b')+
+in the local context (i.e. each term of the
+equality has a sigma type $\{ a:A~ \&~(B~a)\}$) this tactic rewrites
+\verb+a+ into \verb+a'+ and \verb+b+ into \verb+b'+ in the current
+goal. This tactic works even if $B$ is also a sigma type. This kind
+of equalities between dependent pairs may be derived by the injection
+and inversion tactics.
+
+\begin{Variants}
+\item{\tt dependent rewrite <- {\ident}}
+\tacindex{dependent rewrite <-} \\
+Analogous to {\tt dependent rewrite ->} but uses the equality from
+right to left.
+\end{Variants}
+
+\section{Inversion
+\label{inversion}}
+
+\subsection[\tt functional inversion \ident]{\tt functional inversion \ident\label{sec:functional-inversion}}
+
+\texttt{functional inversion} is a \emph{highly} experimental tactic
+which performs inversion on hypothesis \ident\ of the form
+\texttt{\qualid\ \term$_1$\dots\term$_n$\ = \term} or \texttt{\term\ =
+ \qualid\ \term$_1$\dots\term$_n$} where \qualid\ must have been
+defined using \texttt{Function} (see Section~\ref{Function}).
+
+\begin{ErrMsgs}
+\item \errindex{Hypothesis {\ident} must contain at least one Function}
+\item \errindex{Cannot find inversion information for hypothesis \ident}
+ This error may be raised when some inversion lemma failed to be
+ generated by Function.
+\end{ErrMsgs}
+
+\begin{Variants}
+\item {\tt functional inversion \num}
+
+ This does the same thing as \texttt{intros until \num} then
+ \texttt{functional inversion \ident} where {\ident} is the
+ identifier for the last introduced hypothesis.
+\item {\tt functional inversion \ident\ \qualid}\\
+ {\tt functional inversion \num\ \qualid}
+
+ In case the hypothesis {\ident} (or {\num}) has a type of the form
+ \texttt{\qualid$_1$\ \term$_1$\dots\term$_n$\ =\ \qualid$_2$\
+ \term$_{n+1}$\dots\term$_{n+m}$} where \qualid$_1$ and \qualid$_2$
+ are valid candidates to functional inversion, this variant allows to
+ choose which must be inverted.
+\end{Variants}
+
+
+
+\subsection{\tt quote \ident
+\tacindex{quote}
+\index{2-level approach}}
+
+This kind of inversion has nothing to do with the tactic
+\texttt{inversion} above. This tactic does \texttt{change (\ident\
+ t)}, where \texttt{t} is a term built in order to ensure the
+convertibility. In other words, it does inversion of the function
+\ident. This function must be a fixpoint on a simple recursive
+datatype: see~\ref{quote-examples} for the full details.
+
+\begin{ErrMsgs}
+\item \errindex{quote: not a simple fixpoint}\\
+ Happens when \texttt{quote} is not able to perform inversion properly.
+\end{ErrMsgs}
+
+\begin{Variants}
+\item \texttt{quote {\ident} [ \ident$_1$ \dots \ident$_n$ ]}\\
+ All terms that are built only with \ident$_1$ \dots \ident$_n$ will be
+ considered by \texttt{quote} as constants rather than variables.
+\end{Variants}
+
+% En attente d'un moyen de valoriser les fichiers de demos
+% \SeeAlso file \texttt{theories/DEMOS/DemoQuote.v} in the distribution
+
+\section[Classical tactics]{Classical tactics\label{ClassicalTactics}}
+
+In order to ease the proving process, when the {\tt Classical} module is loaded. A few more tactics are available. Make sure to load the module using the \texttt{Require Import} command.
+
+\subsection{{\tt classical\_left, classical\_right} \tacindex{classical\_left} \tacindex{classical\_right}}
+
+The tactics \texttt{classical\_left} and \texttt{classical\_right} are the analog of the \texttt{left} and \texttt{right} but using classical logic. They can only be used for disjunctions.
+Use \texttt{classical\_left} to prove the left part of the disjunction with the assumption that the negation of right part holds.
+Use \texttt{classical\_right} to prove the right part of the disjunction with the assumption that the negation of left part holds.
+
+\section{Automatizing
+\label{Automatizing}}
+
+% EXISTE ENCORE ?
+%
+% \subsection{\tt Prolog [ \term$_1$ \dots\ \term$_n$ ] \num}
+% \tacindex{Prolog}\label{Prolog}
+% This tactic, implemented by Chet Murthy, is based upon the concept of
+% existential variables of Gilles Dowek, stating that resolution is a
+% kind of unification. It tries to solve the current goal using the {\tt
+% Assumption} tactic, the {\tt intro} tactic, and applying hypotheses
+% of the local context and terms of the given list {\tt [ \term$_1$
+% \dots\ \term$_n$\ ]}. It is more powerful than {\tt auto} since it
+% may apply to any theorem, even those of the form {\tt (x:A)(P x) -> Q}
+% where {\tt x} does not appear free in {\tt Q}. The maximal search
+% depth is {\tt \num}.
+
+% \begin{ErrMsgs}
+% \item \errindex{Prolog failed}\\
+% The Prolog tactic was not able to prove the subgoal.
+% \end{ErrMsgs}
+
+
+%% \subsection{{\tt jp} {\em (Jprover)}
+%% \tacindex{jp}
+%% \label{jprover}}
+
+%% The tactic \texttt{jp}, due to Huang Guan-Shieng, is an experimental
+%% port of the {\em Jprover}\cite{SLKN01} semi-decision procedure for
+%% first-order intuitionistic logic implemented in {\em
+%% NuPRL}\cite{Kre02}.
+
+%% The tactic \texttt{jp}, due to Huang Guan-Shieng, is an {\it
+%% experimental} port of the {\em Jprover}\cite{SLKN01} semi-decision
+%% procedure for first-order intuitionistic logic implemented in {\em
+%% NuPRL}\cite{Kre02}.
+
+%% Search may optionnaly be bounded by a multiplicity parameter
+%% indicating how many (at most) copies of a formula may be used in
+%% the proof process, its absence may lead to non-termination of the tactic.
+
+%% %\begin{coq_eval}
+%% %Variable S:Set.
+%% %Variables P Q:S->Prop.
+%% %Variable f:S->S.
+%% %\end{coq_eval}
+
+%% %\begin{coq_example*}
+%% %Lemma example: (exists x |P x\/Q x)->(exists x |P x)\/(exists x |Q x).
+%% %jp.
+%% %Qed.
+
+%% %Lemma example2: (forall x ,P x->P (f x))->forall x,P x->P (f(f x)).
+%% %jp.
+%% %Qed.
+%% %\end{coq_example*}
+
+%% \begin{Variants}
+%% \item {\tt jp $n$}\\
+%% \tacindex{jp $n$}
+%% Tries the {\em Jprover} procedure with multiplicities up to $n$,
+%% starting from 1.
+%% \item {\tt jp}\\
+%% Tries the {\em Jprover} procedure without multiplicity bound,
+%% possibly running forever.
+%% \end{Variants}
+
+%% \begin{ErrMsgs}
+%% \item \errindex{multiplicity limit reached}\\
+%% The procedure tried all multiplicities below the limit and
+%% failed. Goal might be solved by increasing the multiplicity limit.
+%% \item \errindex{formula is not provable}\\
+%% The procedure determined that goal was not provable in
+%% intuitionistic first-order logic, no matter how big the
+%% multiplicity is.
+%% \end{ErrMsgs}
+
+
+% \subsection[\tt Linear]{\tt Linear\tacindex{Linear}\label{Linear}}
+% The tactic \texttt{Linear}, due to Jean-Christophe Filli{\^a}atre
+% \cite{Fil94}, implements a decision procedure for {\em Direct
+% Predicate Calculus}, that is first-order Gentzen's Sequent Calculus
+% without contraction rules \cite{KeWe84,BeKe92}. Intuitively, a
+% first-order goal is provable in Direct Predicate Calculus if it can be
+% proved using each hypothesis at most once.
+
+% Unlike the previous tactics, the \texttt{Linear} tactic does not belong
+% to the initial state of the system, and it must be loaded explicitly
+% with the command
+
+% \begin{coq_example*}
+% Require Linear.
+% \end{coq_example*}
+
+% For instance, assuming that \texttt{even} and \texttt{odd} are two
+% predicates on natural numbers, and \texttt{a} of type \texttt{nat}, the
+% tactic \texttt{Linear} solves the following goal
+
+% \begin{coq_eval}
+% Variables even,odd : nat -> Prop.
+% Variable a:nat.
+% \end{coq_eval}
+
+% \begin{coq_example*}
+% Lemma example : (even a)
+% -> ((x:nat)((even x)->(odd (S x))))
+% -> (EX y | (odd y)).
+% \end{coq_example*}
+
+% You can find examples of the use of \texttt{Linear} in
+% \texttt{theories/DEMOS/DemoLinear.v}.
+% \begin{coq_eval}
+% Abort.
+% \end{coq_eval}
+
+% \begin{Variants}
+% \item {\tt Linear with \ident$_1$ \dots\ \ident$_n$}\\
+% \tacindex{Linear with}
+% Is equivalent to apply first {\tt generalize \ident$_1$ \dots
+% \ident$_n$} (see Section~\ref{generalize}) then the \texttt{Linear}
+% tactic. So one can use axioms, lemmas or hypotheses of the local
+% context with \texttt{Linear} in this way.
+% \end{Variants}
+
+% \begin{ErrMsgs}
+% \item \errindex{Not provable in Direct Predicate Calculus}
+% \item \errindex{Found $n$ classical proof(s) but no intuitionistic one}\\
+% The decision procedure looks actually for classical proofs of the
+% goals, and then checks that they are intuitionistic. In that case,
+% classical proofs have been found, which do not correspond to
+% intuitionistic ones.
+% \end{ErrMsgs}
+
+
+\subsection{\tt omega
+\tacindex{omega}
+\label{omega}}
+
+The tactic \texttt{omega}, due to Pierre Cr{\'e}gut,
+is an automatic decision procedure for Presburger
+arithmetic. It solves quantifier-free
+formulas built with \verb|~|, \verb|\/|, \verb|/\|,
+\verb|->| on top of equalities, inequalities and disequalities on
+both the type \texttt{nat} of natural numbers and \texttt{Z} of binary
+integers. This tactic must be loaded by the command \texttt{Require Import
+ Omega}. See the additional documentation about \texttt{omega}
+(see Chapter~\ref{OmegaChapter}).
+
+\subsection{{\tt ring} and {\tt ring\_simplify \term$_1$ \dots\ \term$_n$}
+\tacindex{ring}
+\tacindex{ring\_simplify}
+\comindex{Add Ring}}
+
+The {\tt ring} tactic solves equations upon polynomial expressions of
+a ring (or semi-ring) structure. It proceeds by normalizing both hand
+sides of the equation (w.r.t. associativity, commutativity and
+distributivity, constant propagation) and comparing syntactically the
+results.
+
+{\tt ring\_simplify} applies the normalization procedure described
+above to the terms given. The tactic then replaces all occurrences of
+the terms given in the conclusion of the goal by their normal
+forms. If no term is given, then the conclusion should be an equation
+and both hand sides are normalized.
+
+See Chapter~\ref{ring} for more information on the tactic and how to
+declare new ring structures.
+
+\subsection{{\tt field}, {\tt field\_simplify \term$_1$\dots\ \term$_n$}
+ and {\tt field\_simplify\_eq}
+\tacindex{field}
+\tacindex{field\_simplify}
+\tacindex{field\_simplify\_eq}
+\comindex{Add Field}}
+
+The {\tt field} tactic is built on the same ideas as {\tt ring}: this
+is a reflexive tactic that solves or simplifies equations in a field
+structure. The main idea is to reduce a field expression (which is an
+extension of ring expressions with the inverse and division
+operations) to a fraction made of two polynomial expressions.
+
+Tactic {\tt field} is used to solve subgoals, whereas {\tt
+ field\_simplify \term$_1$\dots\term$_n$} replaces the provided terms
+by their reduced fraction. {\tt field\_simplify\_eq} applies when the
+conclusion is an equation: it simplifies both hand sides and multiplies
+so as to cancel denominators. So it produces an equation without
+division nor inverse.
+
+All of these 3 tactics may generate a subgoal in order to prove that
+denominators are different from zero.
+
+See Chapter~\ref{ring} for more information on the tactic and how to
+declare new field structures.
+
+\Example
+\begin{coq_example*}
+Require Import Reals.
+Goal forall x y:R,
+ (x * y > 0)%R ->
+ (x * (1 / x + x / (x + y)))%R =
+ ((- 1 / y) * y * (- x * (x / (x + y)) - 1))%R.
+\end{coq_example*}
+
+\begin{coq_example}
+intros; field.
+\end{coq_example}
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
+
+\SeeAlso file {\tt plugins/setoid\_ring/RealField.v} for an example of instantiation,\\
+\phantom{\SeeAlso}theory {\tt theories/Reals} for many examples of use of {\tt
+field}.
+
+\subsection{\tt fourier
+\tacindex{fourier}}
+
+This tactic written by Lo{\"\i}c Pottier solves linear inequalities on
+real numbers using Fourier's method~\cite{Fourier}. This tactic must
+be loaded by {\tt Require Import Fourier}.
+
+\Example
+\begin{coq_example*}
+Require Import Reals.
+Require Import Fourier.
+Goal forall x y:R, (x < y)%R -> (y + 1 >= x - 1)%R.
+\end{coq_example*}
+
+\begin{coq_example}
+intros; fourier.
+\end{coq_example}
+
+\begin{coq_eval}
+Reset Initial.
+\end{coq_eval}
\section{Simple tactic macros
@@ -4389,7 +4501,7 @@ principles, closer to the definition written by the user.
\comindex{Tactic Definition}
\label{TacticDefinition}}
-A simple example has more value than a long explanation:
+A simple example has more value than a long explanation:
\begin{coq_example}
Ltac Solve := simpl; intros; auto.
@@ -4399,7 +4511,7 @@ Ltac ElimBoolRewrite b H1 H2 :=
The tactics macros are synchronous with the \Coq\ section mechanism:
a tactic definition is deleted from the current environment
-when you close the section (see also \ref{Section})
+when you close the section (see also \ref{Section})
where it was defined. If you want that a
tactic macro defined in a module is usable in the modules that
require it, you should put it outside of any section.
@@ -4408,8 +4520,8 @@ Chapter~\ref{TacticLanguage} gives examples of more complex
user-defined tactics.
-%%% Local Variables:
+%%% Local Variables:
%%% mode: latex
%%% TeX-master: "Reference-Manual"
%%% TeX-master: "Reference-Manual"
-%%% End:
+%%% End:
diff --git a/doc/refman/RefMan-tacex.tex b/doc/refman/RefMan-tacex.tex
index 8330a434..83a8cd11 100644
--- a/doc/refman/RefMan-tacex.tex
+++ b/doc/refman/RefMan-tacex.tex
@@ -3,590 +3,6 @@
This chapter presents detailed examples of certain tactics, to
illustrate their behavior.
-\section[\tt refine]{\tt refine\tacindex{refine}
-\label{refine-example}}
-
-This tactic applies to any goal. It behaves like {\tt exact} with a
-big difference : the user can leave some holes (denoted by \texttt{\_} or
-{\tt (\_:}{\it type}{\tt )}) in the term.
-{\tt refine} will generate as many
-subgoals as they are holes in the term. The type of holes must be
-either synthesized by the system or declared by an
-explicit cast like \verb|(\_:nat->Prop)|. This low-level
-tactic can be useful to advanced users.
-
-%\firstexample
-\Example
-
-\begin{coq_example*}
-Inductive Option : Set :=
- | Fail : Option
- | Ok : bool -> Option.
-\end{coq_example}
-\begin{coq_example}
-Definition get : forall x:Option, x <> Fail -> bool.
-refine
- (fun x:Option =>
- match x return x <> Fail -> bool with
- | Fail => _
- | Ok b => fun _ => b
- end).
-intros; absurd (Fail = Fail); trivial.
-\end{coq_example}
-\begin{coq_example*}
-Defined.
-\end{coq_example*}
-
-% \example{Using Refine to build a poor-man's ``Cases'' tactic}
-
-% \texttt{Refine} is actually the only way for the user to do
-% a proof with the same structure as a {\tt Cases} definition. Actually,
-% the tactics \texttt{case} (see \ref{case}) and \texttt{Elim} (see
-% \ref{elim}) only allow one step of elementary induction.
-
-% \begin{coq_example*}
-% Require Bool.
-% Require Arith.
-% \end{coq_example*}
-% %\begin{coq_eval}
-% %Abort.
-% %\end{coq_eval}
-% \begin{coq_example}
-% Definition one_two_or_five := [x:nat]
-% Cases x of
-% (1) => true
-% | (2) => true
-% | (5) => true
-% | _ => false
-% end.
-% Goal (x:nat)(Is_true (one_two_or_five x)) -> x=(1)\/x=(2)\/x=(5).
-% \end{coq_example}
-
-% A traditional script would be the following:
-
-% \begin{coq_example*}
-% Destruct x.
-% Tauto.
-% Destruct n.
-% Auto.
-% Destruct n0.
-% Auto.
-% Destruct n1.
-% Tauto.
-% Destruct n2.
-% Tauto.
-% Destruct n3.
-% Auto.
-% Intros; Inversion H.
-% \end{coq_example*}
-
-% With the tactic \texttt{Refine}, it becomes quite shorter:
-
-% \begin{coq_example*}
-% Restart.
-% \end{coq_example*}
-% \begin{coq_example}
-% Refine [x:nat]
-% <[y:nat](Is_true (one_two_or_five y))->(y=(1)\/y=(2)\/y=(5))>
-% Cases x of
-% (1) => [H]?
-% | (2) => [H]?
-% | (5) => [H]?
-% | n => [H](False_ind ? H)
-% end; Auto.
-% \end{coq_example}
-% \begin{coq_eval}
-% Abort.
-% \end{coq_eval}
-
-\section[\tt eapply]{\tt eapply\tacindex{eapply}
-\label{eapply-example}}
-\Example
-Assume we have a relation on {\tt nat} which is transitive:
-
-\begin{coq_example*}
-Variable R : nat -> nat -> Prop.
-Hypothesis Rtrans : forall x y z:nat, R x y -> R y z -> R x z.
-Variables n m p : nat.
-Hypothesis Rnm : R n m.
-Hypothesis Rmp : R m p.
-\end{coq_example*}
-
-Consider the goal {\tt (R n p)} provable using the transitivity of
-{\tt R}:
-
-\begin{coq_example*}
-Goal R n p.
-\end{coq_example*}
-
-The direct application of {\tt Rtrans} with {\tt apply} fails because
-no value for {\tt y} in {\tt Rtrans} is found by {\tt apply}:
-
-\begin{coq_eval}
-Set Printing Depth 50.
-(********** The following is not correct and should produce **********)
-(**** Error: generated subgoal (R n ?17) has metavariables in it *****)
-\end{coq_eval}
-\begin{coq_example}
-apply Rtrans.
-\end{coq_example}
-
-A solution is to rather apply {\tt (Rtrans n m p)}.
-
-\begin{coq_example}
-apply (Rtrans n m p).
-\end{coq_example}
-
-\begin{coq_eval}
-Undo.
-\end{coq_eval}
-
-More elegantly, {\tt apply Rtrans with (y:=m)} allows to only mention
-the unknown {\tt m}:
-
-\begin{coq_example}
-
- apply Rtrans with (y := m).
-\end{coq_example}
-
-\begin{coq_eval}
-Undo.
-\end{coq_eval}
-
-Another solution is to mention the proof of {\tt (R x y)} in {\tt
-Rtrans}...
-
-\begin{coq_example}
-
- apply Rtrans with (1 := Rnm).
-\end{coq_example}
-
-\begin{coq_eval}
-Undo.
-\end{coq_eval}
-
-... or the proof of {\tt (R y z)}:
-
-\begin{coq_example}
-
- apply Rtrans with (2 := Rmp).
-\end{coq_example}
-
-\begin{coq_eval}
-Undo.
-\end{coq_eval}
-
-On the opposite, one can use {\tt eapply} which postpone the problem
-of finding {\tt m}. Then one can apply the hypotheses {\tt Rnm} and {\tt
-Rmp}. This instantiates the existential variable and completes the proof.
-
-\begin{coq_example}
-eapply Rtrans.
-apply Rnm.
-apply Rmp.
-\end{coq_example}
-
-\begin{coq_eval}
-Reset R.
-\end{coq_eval}
-
-\section[{\tt Scheme}]{{\tt Scheme}\comindex{Scheme}
-\label{Scheme-examples}}
-
-\firstexample
-\example{Induction scheme for \texttt{tree} and \texttt{forest}}
-
-The definition of principle of mutual induction for {\tt tree} and
-{\tt forest} over the sort {\tt Set} is defined by the command:
-
-\begin{coq_eval}
-Reset Initial.
-Variables A B :
- Set.
-\end{coq_eval}
-
-\begin{coq_example*}
-Inductive tree : Set :=
- node : A -> forest -> tree
-with forest : Set :=
- | leaf : B -> forest
- | cons : tree -> forest -> forest.
-
-Scheme tree_forest_rec := Induction for tree Sort Set
- with forest_tree_rec := Induction for forest Sort Set.
-\end{coq_example*}
-
-You may now look at the type of {\tt tree\_forest\_rec}:
-
-\begin{coq_example}
-Check tree_forest_rec.
-\end{coq_example}
-
-This principle involves two different predicates for {\tt trees} and
-{\tt forests}; it also has three premises each one corresponding to a
-constructor of one of the inductive definitions.
-
-The principle {\tt forest\_tree\_rec} shares exactly the same
-premises, only the conclusion now refers to the property of forests.
-
-\begin{coq_example}
-Check forest_tree_rec.
-\end{coq_example}
-
-\example{Predicates {\tt odd} and {\tt even} on naturals}
-
-Let {\tt odd} and {\tt even} be inductively defined as:
-
-% Reset Initial.
-\begin{coq_eval}
-Open Scope nat_scope.
-\end{coq_eval}
-
-\begin{coq_example*}
-Inductive odd : nat -> Prop :=
- oddS : forall n:nat, even n -> odd (S n)
-with even : nat -> Prop :=
- | evenO : even 0
- | evenS : forall n:nat, odd n -> even (S n).
-\end{coq_example*}
-
-The following command generates a powerful elimination
-principle:
-
-\begin{coq_example}
-Scheme odd_even := Minimality for odd Sort Prop
- with even_odd := Minimality for even Sort Prop.
-\end{coq_example}
-
-The type of {\tt odd\_even} for instance will be:
-
-\begin{coq_example}
-Check odd_even.
-\end{coq_example}
-
-The type of {\tt even\_odd} shares the same premises but the
-conclusion is {\tt (n:nat)(even n)->(Q n)}.
-
-\subsection[{\tt Combined Scheme}]{{\tt Combined Scheme}\comindex{Combined Scheme}
-\label{CombinedScheme-examples}}
-
-We can define the induction principles for trees and forests using:
-\begin{coq_example}
-Scheme tree_forest_ind := Induction for tree Sort Prop
- with forest_tree_ind := Induction for forest Sort Prop.
-\end{coq_example}
-
-Then we can build the combined induction principle which gives the
-conjunction of the conclusions of each individual principle:
-\begin{coq_example}
-Combined Scheme tree_forest_mutind from tree_forest_ind, forest_tree_ind.
-\end{coq_example}
-
-The type of {\tt tree\_forest\_mutrec} will be:
-\begin{coq_example}
-Check tree_forest_mutind.
-\end{coq_example}
-
-\section[{\tt Functional Scheme} and {\tt functional induction}]{{\tt Functional Scheme} and {\tt functional induction}\comindex{Functional Scheme}\tacindex{functional induction}
-\label{FunScheme-examples}}
-
-\firstexample
-\example{Induction scheme for \texttt{div2}}
-
-We define the function \texttt{div2} as follows:
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
-
-\begin{coq_example*}
-Require Import Arith.
-Fixpoint div2 (n:nat) : nat :=
- match n with
- | O => 0
- | S O => 0
- | S (S n') => S (div2 n')
- end.
-\end{coq_example*}
-
-The definition of a principle of induction corresponding to the
-recursive structure of \texttt{div2} is defined by the command:
-
-\begin{coq_example}
-Functional Scheme div2_ind := Induction for div2 Sort Prop.
-\end{coq_example}
-
-You may now look at the type of {\tt div2\_ind}:
-
-\begin{coq_example}
-Check div2_ind.
-\end{coq_example}
-
-We can now prove the following lemma using this principle:
-
-
-\begin{coq_example*}
-Lemma div2_le' : forall n:nat, div2 n <= n.
-intro n.
- pattern n , (div2 n).
-\end{coq_example*}
-
-
-\begin{coq_example}
-apply div2_ind; intros.
-\end{coq_example}
-
-\begin{coq_example*}
-auto with arith.
-auto with arith.
-simpl; auto with arith.
-Qed.
-\end{coq_example*}
-
-We can use directly the \texttt{functional induction}
-(\ref{FunInduction}) tactic instead of the pattern/apply trick:
-
-\begin{coq_example*}
-Reset div2_le'.
-Lemma div2_le : forall n:nat, div2 n <= n.
-intro n.
-\end{coq_example*}
-
-\begin{coq_example}
-functional induction (div2 n).
-\end{coq_example}
-
-\begin{coq_example*}
-auto with arith.
-auto with arith.
-auto with arith.
-Qed.
-\end{coq_example*}
-
-\Rem There is a difference between obtaining an induction scheme for a
-function by using \texttt{Function} (see Section~\ref{Function}) and by
-using \texttt{Functional Scheme} after a normal definition using
-\texttt{Fixpoint} or \texttt{Definition}. See \ref{Function} for
-details.
-
-
-\example{Induction scheme for \texttt{tree\_size}}
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
-
-We define trees by the following mutual inductive type:
-
-\begin{coq_example*}
-Variable A : Set.
-Inductive tree : Set :=
- node : A -> forest -> tree
-with forest : Set :=
- | empty : forest
- | cons : tree -> forest -> forest.
-\end{coq_example*}
-
-We define the function \texttt{tree\_size} that computes the size
-of a tree or a forest. Note that we use \texttt{Function} which
-generally produces better principles.
-
-\begin{coq_example*}
-Function tree_size (t:tree) : nat :=
- match t with
- | node A f => S (forest_size f)
- end
- with forest_size (f:forest) : nat :=
- match f with
- | empty => 0
- | cons t f' => (tree_size t + forest_size f')
- end.
-\end{coq_example*}
-
-Remark: \texttt{Function} generates itself non mutual induction
-principles {\tt tree\_size\_ind} and {\tt forest\_size\_ind}:
-
-\begin{coq_example}
-Check tree_size_ind.
-\end{coq_example}
-
-The definition of mutual induction principles following the recursive
-structure of \texttt{tree\_size} and \texttt{forest\_size} is defined
-by the command:
-
-\begin{coq_example*}
-Functional Scheme tree_size_ind2 := Induction for tree_size Sort Prop
-with forest_size_ind2 := Induction for forest_size Sort Prop.
-\end{coq_example*}
-
-You may now look at the type of {\tt tree\_size\_ind2}:
-
-\begin{coq_example}
-Check tree_size_ind2.
-\end{coq_example}
-
-
-
-
-\section[{\tt inversion}]{{\tt inversion}\tacindex{inversion}
-\label{inversion-examples}}
-
-\subsection*{Generalities about inversion}
-
-When working with (co)inductive predicates, we are very often faced to
-some of these situations:
-\begin{itemize}
-\item we have an inconsistent instance of an inductive predicate in the
- local context of hypotheses. Thus, the current goal can be trivially
- proved by absurdity.
-\item we have a hypothesis that is an instance of an inductive
- predicate, and the instance has some variables whose constraints we
- would like to derive.
-\end{itemize}
-
-The inversion tactics are very useful to simplify the work in these
-cases. Inversion tools can be classified in three groups:
-
-\begin{enumerate}
-\item tactics for inverting an instance without stocking the inversion
- lemma in the context; this includes the tactics
- (\texttt{dependent}) \texttt{inversion} and
- (\texttt{dependent}) \texttt{inversion\_clear}.
-\item commands for generating and stocking in the context the inversion
- lemma corresponding to an instance; this includes \texttt{Derive}
- (\texttt{Dependent}) \texttt{Inversion} and \texttt{Derive}
- (\texttt{Dependent}) \texttt{Inversion\_clear}.
-\item tactics for inverting an instance using an already defined
- inversion lemma; this includes the tactic \texttt{inversion \ldots using}.
-\end{enumerate}
-
-As inversion proofs may be large in size, we recommend the user to
-stock the lemmas whenever the same instance needs to be inverted
-several times.
-
-\firstexample
-\example{Non-dependent inversion}
-
-Let's consider the relation \texttt{Le} over natural numbers and the
-following variables:
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
-
-\begin{coq_example*}
-Inductive Le : nat -> nat -> Set :=
- | LeO : forall n:nat, Le 0 n
- | LeS : forall n m:nat, Le n m -> Le (S n) (S m).
-Variable P : nat -> nat -> Prop.
-Variable Q : forall n m:nat, Le n m -> Prop.
-\end{coq_example*}
-
-For example, consider the goal:
-
-\begin{coq_eval}
-Lemma ex : forall n m:nat, Le (S n) m -> P n m.
-intros.
-\end{coq_eval}
-
-\begin{coq_example}
-Show.
-\end{coq_example}
-
-To prove the goal we may need to reason by cases on \texttt{H} and to
- derive that \texttt{m} is necessarily of
-the form $(S~m_0)$ for certain $m_0$ and that $(Le~n~m_0)$.
-Deriving these conditions corresponds to prove that the
-only possible constructor of \texttt{(Le (S n) m)} is
-\texttt{LeS} and that we can invert the
-\texttt{->} in the type of \texttt{LeS}.
-This inversion is possible because \texttt{Le} is the smallest set closed by
-the constructors \texttt{LeO} and \texttt{LeS}.
-
-\begin{coq_example}
-inversion_clear H.
-\end{coq_example}
-
-Note that \texttt{m} has been substituted in the goal for \texttt{(S m0)}
-and that the hypothesis \texttt{(Le n m0)} has been added to the
-context.
-
-Sometimes it is
-interesting to have the equality \texttt{m=(S m0)} in the
-context to use it after. In that case we can use \texttt{inversion} that
-does not clear the equalities:
-
-\begin{coq_example*}
-Undo.
-\end{coq_example*}
-
-\begin{coq_example}
-inversion H.
-\end{coq_example}
-
-\begin{coq_eval}
-Undo.
-\end{coq_eval}
-
-\example{Dependent Inversion}
-
-Let us consider the following goal:
-
-\begin{coq_eval}
-Lemma ex_dep : forall (n m:nat) (H:Le (S n) m), Q (S n) m H.
-intros.
-\end{coq_eval}
-
-\begin{coq_example}
-Show.
-\end{coq_example}
-
-As \texttt{H} occurs in the goal, we may want to reason by cases on its
-structure and so, we would like inversion tactics to
-substitute \texttt{H} by the corresponding term in constructor form.
-Neither \texttt{Inversion} nor {\tt Inversion\_clear} make such a
-substitution.
-To have such a behavior we use the dependent inversion tactics:
-
-\begin{coq_example}
-dependent inversion_clear H.
-\end{coq_example}
-
-Note that \texttt{H} has been substituted by \texttt{(LeS n m0 l)} and
-\texttt{m} by \texttt{(S m0)}.
-
-\example{using already defined inversion lemmas}
-
-\begin{coq_eval}
-Abort.
-\end{coq_eval}
-
-For example, to generate the inversion lemma for the instance
-\texttt{(Le (S n) m)} and the sort \texttt{Prop} we do:
-
-\begin{coq_example*}
-Derive Inversion_clear leminv with (forall n m:nat, Le (S n) m) Sort
- Prop.
-\end{coq_example*}
-
-\begin{coq_example}
-Check leminv.
-\end{coq_example}
-
-Then we can use the proven inversion lemma:
-
-\begin{coq_example}
-Show.
-\end{coq_example}
-
-\begin{coq_example}
-inversion H using leminv.
-\end{coq_example}
-
-\begin{coq_eval}
-Reset Initial.
-\end{coq_eval}
-
\section[\tt dependent induction]{\tt dependent induction\label{dependent-induction-example}}
\def\depind{{\tt dependent induction}~}
\def\depdestr{{\tt dependent destruction}~}
diff --git a/doc/refman/RefMan-uti.tex b/doc/refman/RefMan-uti.tex
index bda4cff9..f5178445 100644
--- a/doc/refman/RefMan-uti.tex
+++ b/doc/refman/RefMan-uti.tex
@@ -78,47 +78,47 @@ See the man page of {\tt coqdep} for more details and options.
\index{Makefile@{\tt Makefile}}
\index{CoqMakefile@{\tt coq\_Makefile}}}
-When a proof development becomes large and is split into several files,
-it becomes crucial to use a tool like {\tt make} to compile \Coq\
-modules.
+When a proof development becomes large, is split into several files or contains
+Ocaml plugins, it becomes crucial to use a tool like {\tt make} to compile
+\Coq\ modules.
The writing of a generic and complete {\tt Makefile} may be a tedious work
and that's why \Coq\ provides a tool to automate its creation,
{\tt coq\_makefile}.
-Arguments are explain by \texttt{\% coq\_makefile --help}. They can be directly
-written in the command line but it is recommended to write them in a file (called
-for example {\tt Make}) and then call {\tt coq\_makefile -f Make -o
- Makefile}. That means options are in {\tt Make} file and output is {\tt
- Makefile} This way, {\tt Makefile} will be automatically regenerated if
-something changes in {\tt Make}.
+You can get a description of the arguments by the command \texttt{\% coq\_makefile
+ --help}. Arguments can be directly written on the command line interface but it is recommended
+to write them in a file ({\tt \_CoqProject} by default) and then call {\tt
+ coq\_makefile -f \_CoqProject -o Makefile}. That means options are read from {\tt
+ \_CoqProject} and written in {\tt Makefile}. This way, {\tt Makefile} will be
+automagically regenerated when something changes in {\tt \_CoqProject}.
The first time you use this tool, you may be happy with:
\begin{quotation}
\texttt{\% \{ echo '-R .} {\em MyFancyLib} \texttt{' ; find -name '*.v' -print \} >
- Make \&\& coq\_makefile -f Make -o Makefile}
+ \_CoqProject \&\& coq\_makefile -f \_CoqProject -o Makefile}
\end{quotation}
-To customize things afterwards, remember:
+To customize things further, remember the following:
\begin{itemize}
-\item Coq files must end in {\tt .v}, caml modules in {\tt .ml4} if they
- require camlp preproccessing (and in {\tt .ml} otherwise), and caml module signatures in {\tt
- .mli}.
-\item If you give a directory directly as argument, it is because you provide a
- Makefile for it in it.
-\item {\tt -R} option is for Coq, {\tt -I} for caml. The same directory can
+\item \Coq files must end in {\tt .v}, \ocaml modules in {\tt .ml4} if they
+ require camlp preproccessing (and in {\tt .ml} otherwise), and \ocaml module
+ signatures in {\tt .mli}.
+\item Whenever a directory is passed as argument, any inner {\tt Makefile} will be
+ recursively called.
+\item {\tt -R} option is for \Coq, {\tt -I} for \ocaml. The same directory can be
``included'' by both.
- Using {\tt -R} option gives a right logical path and a correct installation
+
+ Using {\tt -R} option gives a correct logical path and a correct installation
emplacement to your coq files.
-\item If your files depend on an external library that isn't install somewhere
- looked by coqc, use {\tt OTHERFLAGS = '-R path/to/lib lib\_name'} option in your {\tt
- Make} but don't do {\tt -R \dots} directly, the {\em make clean} command would
- erase it!
+\item If your files depend on an external library, never use {\tt -R \dots} to
+ include it in the path, the {\em make clean} command would erase it! Take
+ advantage of the \verb:COQPATH: variable (see \ref{envars}) instead if
+ necessary.
\end{itemize}
-\Warning To compile a project containing \ocaml{} files you must keep
-the sources of \Coq{} somewhere and have an environment variable named
-\texttt{COQTOP} that points to that directory.
+Under normal circumstances, the only other variable that you may use is
+\verb:$COQBIN: to specify the directory where the binaries are.
\section[Documenting \Coq\ files with coqdoc]{Documenting \Coq\ files with coqdoc\label{coqdoc}
\index{Coqdoc@{\sf coqdoc}}}
@@ -142,7 +142,7 @@ after each phrase.
Starting with a file {\em file}{\tt.tex} containing \Coq\ phrases,
the {\tt coq-tex} filter produces a file named {\em file}{\tt.v.tex} with
-the \Coq\ outcome.
+the \Coq\ outcome.
There are options to produce the \Coq\ parts in smaller font, italic,
between horizontal rules, etc.
diff --git a/doc/refman/Reference-Manual.tex b/doc/refman/Reference-Manual.tex
index cc42c2ef..4380f544 100644
--- a/doc/refman/Reference-Manual.tex
+++ b/doc/refman/Reference-Manual.tex
@@ -35,7 +35,7 @@
\input{../common/title.tex}% extension .tex pour htmlgen
%\input{headers}
-\usepackage[linktocpage,colorlinks,bookmarks=false]{hyperref}
+\usepackage[linktocpage,colorlinks]{hyperref}
% The manual advises to load hyperref package last to be able to redefine
% necessary commands.
% The above should work for both latex and pdflatex. Even if PDF is produced
@@ -88,15 +88,16 @@ Options A and B of the licence are {\em not} elected.}
\part{The proof engine}
\include{RefMan-oth.v}% Vernacular commands
-\include{RefMan-pro}% Proof handling
+\include{RefMan-pro.v}% Proof handling
\include{RefMan-tac.v}% Tactics and tacticals
\include{RefMan-ltac.v}% Writing tactics
\include{RefMan-tacex.v}% Detailed Examples of tactics
\include{RefMan-decl.v}% The mathematical proof language
\part{User extensions}
-\include{RefMan-syn.v}% The Syntax and the Grammad commands
+\include{RefMan-syn.v}% The Syntax and the Grammar commands
%%SUPPRIME \include{RefMan-tus.v}% Writing tactics
+\include{RefMan-sch.v}% The Scheme commands
\part{Practical tools}
\include{RefMan-com}% The coq commands (coqc coqtop)
diff --git a/doc/refman/coqdoc.tex b/doc/refman/coqdoc.tex
index 271a13f7..c2591a7b 100644
--- a/doc/refman/coqdoc.tex
+++ b/doc/refman/coqdoc.tex
@@ -43,8 +43,8 @@ remember: ``garbage in, garbage out''.
\Coq\ material is quoted between the
delimiters \texttt{[} and \texttt{]}. Square brackets may be nested,
the inner ones being understood as being part of the quoted code (thus
-you can quote a term like $[x:T]u$ by writing
-\texttt{[[x:T]u]}). Inside quotations, the code is pretty-printed in
+you can quote a term like \texttt{fun x => u} by writing
+\texttt{[fun x => u]}). Inside quotations, the code is pretty-printed in
the same way as it is in code parts.
Pre-formatted vernacular is enclosed by \texttt{[[} and
@@ -63,7 +63,7 @@ or
(** printing \emph{token} $...\LaTeX\ math...$ #...HTML...# *)
\end{alltt}
It gives the \LaTeX\ and HTML texts to be produced for the given \Coq\
-token. One of the \LaTeX\ or HTML text may be ommitted, causing the
+token. One of the \LaTeX\ or HTML text may be omitted, causing the
default pretty-printing to be used for this token.
The printing for one token can be removed with
@@ -94,7 +94,7 @@ Any of these can be overwritten or suppressed using the
Important note: the recognition of tokens is done by a (ocaml)lex
automaton and thus applies the longest-match rule. For instance,
\verb!->~! is recognized as a single token, where \Coq\ sees two
-tokens. It is the responsability of the user to insert space between
+tokens. It is the responsibility of the user to insert space between
tokens \emph{or} to give pretty-printing rules for the possible
combinations, e.g.
\begin{verbatim}
@@ -153,7 +153,7 @@ emphasis. Usually, these are spaces or punctuation.
This sentence contains some _emphasized text_.
\end{verbatim}
-\paragraph{Escapings to \LaTeX\ and HTML.}
+\paragraph{Escaping to \LaTeX\ and HTML.}
Pure \LaTeX\ or HTML material can be inserted using the following
escape sequences:
\begin{itemize}
@@ -318,7 +318,7 @@ suffix \verb!.tex!.
\item[\texttt{\mm{}files-from }\textit{file}] ~\par
Read file names to process in file `\textit{file}' as if they were
- given on the command line. Useful for program sources splitted in
+ given on the command line. Useful for program sources split up into
several directories.
\item[\texttt{-q}, \texttt{\mm{}quiet}] ~\par
diff --git a/doc/stdlib/hidden-files b/doc/stdlib/hidden-files
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/doc/stdlib/hidden-files
diff --git a/doc/stdlib/index-list.html.template b/doc/stdlib/index-list.html.template
index 35c13f3b..0ee101c8 100644
--- a/doc/stdlib/index-list.html.template
+++ b/doc/stdlib/index-list.html.template
@@ -1,17 +1,5 @@
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
-<link rel="stylesheet" href="css/context.css" type="text/css"/>
-<title>The Coq Standard Library</title>
-</head>
-
-<body>
-
-<H1>The Coq Standard Library</H1>
+<h1>The Coq Standard Library</h1>
<p>Here is a short description of the Coq standard library, which is
distributed with the system.
@@ -68,6 +56,7 @@ through the <tt>Require Import</tt> command.</p>
theories/Logic/Epsilon.v
theories/Logic/IndefiniteDescription.v
theories/Logic/FunctionalExtensionality.v
+ theories/Logic/ExtensionalityFacts.v
</dd>
<dt> <b>Structures</b>:
@@ -184,6 +173,8 @@ through the <tt>Require Import</tt> command.</p>
theories/ZArith/Zpow_def.v
theories/ZArith/Zpow_alt.v
theories/ZArith/Zpower.v
+ theories/ZArith/ZOdiv_def.v
+ theories/ZArith/ZOdiv.v
theories/ZArith/Zdiv.v
theories/ZArith/Zquot.v
theories/ZArith/Zeuclid.v
@@ -414,6 +405,16 @@ through the <tt>Require Import</tt> command.</p>
theories/Lists/ListTactics.v
</dd>
+ <dt> <b>Vectors</b>:
+ Dependent datastructures storing their length
+ </dt>
+ <dd>
+ theories/Vectors/Fin.v
+ theories/Vectors/VectorDef.v
+ theories/Vectors/VectorSpec.v
+ (theories/Vectors/Vector.v)
+ </dd>
+
<dt> <b>Sorting</b>:
Axiomatizations of sorts
</dt>
@@ -454,7 +455,9 @@ through the <tt>Require Import</tt> command.</p>
theories/MSets/MSetEqProperties.v
theories/MSets/MSetWeakList.v
theories/MSets/MSetList.v
+ theories/MSets/MSetGenTree.v
theories/MSets/MSetAVL.v
+ theories/MSets/MSetRBT.v
theories/MSets/MSetPositive.v
theories/MSets/MSetToFiniteSet.v
(theories/MSets/MSets.v)
@@ -576,4 +579,11 @@ through the <tt>Require Import</tt> command.</p>
theories/Program/Combinators.v
</dd>
+ <dt> <b>Unicode</b>:
+ Unicode-based notations
+ </dt>
+ <dd>
+ theories/Unicode/Utf8_core.v
+ theories/Unicode/Utf8.v
+ </dd>
</dl>
diff --git a/doc/stdlib/make-library-index b/doc/stdlib/make-library-index
index 8e496fdd..1a70567f 100755
--- a/doc/stdlib/make-library-index
+++ b/doc/stdlib/make-library-index
@@ -3,37 +3,55 @@
# Instantiate links to library files in index template
FILE=$1
+HIDDEN=$2
cp -f $FILE.template tmp
echo -n Building file index-list.prehtml ...
-LIBDIRS="Init Logic Structures Bool Arith PArith NArith ZArith QArith Relations Sets Classes Setoids Lists Sorting Wellfounded MSets FSets Reals Program Numbers Numbers/Natural/Abstract Numbers/Natural/Peano Numbers/Natural/Binary Numbers/Natural/BigN Numbers/Natural/SpecViaZ Numbers/Integer/Abstract Numbers/Integer/NatPairs Numbers/Integer/Binary Numbers/Integer/SpecViaZ Numbers/Integer/BigZ Numbers/NatInt Numbers/Cyclic/Abstract Numbers/Cyclic/Int31 Numbers/Cyclic/ZModulo Numbers/Cyclic/DoubleCyclic Numbers/Rational/BigQ Numbers/Rational/SpecViaQ Strings"
+#LIBDIRS="Init Logic Structures Bool Arith PArith NArith ZArith QArith Relations Sets Classes Setoids Lists Vectors Sorting Wellfounded MSets FSets Reals Program Numbers Numbers/Natural/Abstract Numbers/Natural/Peano Numbers/Natural/Binary Numbers/Natural/BigN Numbers/Natural/SpecViaZ Numbers/Integer/Abstract Numbers/Integer/NatPairs Numbers/Integer/Binary Numbers/Integer/SpecViaZ Numbers/Integer/BigZ Numbers/NatInt Numbers/Cyclic/Abstract Numbers/Cyclic/Int31 Numbers/Cyclic/ZModulo Numbers/Cyclic/DoubleCyclic Numbers/Rational/BigQ Numbers/Rational/SpecViaQ Strings"
+LIBDIRS=`find theories/* -type d | sed -e "s:^theories/::"`
for k in $LIBDIRS; do
i=theories/$k
echo $i
d=`basename $i`
- if [ "$d" != "Num" -a "$d" != "CVS" ]; then
+ if [ "$d" != "CVS" ]; then
+ ls $i | grep -q \.v'$'
+ if [ $? = 0 ]; then
for j in $i/*.v; do
b=`basename $j .v`
rm -f tmp2
grep -q theories/$k/$b.v tmp
a=$?
+ grep -q theories/$k/$b.v $HIDDEN
+ h=$?
if [ $a = 0 ]; then
- p=`echo $k | sed 's:/:.:g'`
- sed -e "s:theories/$k/$b.v:<a href=\"Coq.$p.$b.html\">$b</a>:g" tmp > tmp2
- mv -f tmp2 tmp
+ if [ $h = 0 ]; then
+ echo Error: $FILE and $HIDDEN both mention theories/$k/$b.v; exit 1
+ else
+ p=`echo $k | sed 's:/:.:g'`
+ sed -e "s:theories/$k/$b.v:<a href=\"Coq.$p.$b.html\">$b</a>:g" tmp > tmp2
+ mv -f tmp2 tmp
+ fi
else
- echo Warning: theories/$k/$b.v is missing in the template file
- fi
+ if [ $h = 0 ]; then
+ echo Error: theories/$k/$b.v is missing in the template file
+ exit 1
+ else
+ echo Error: none of $FILE and $HIDDEN mention theories/$k/$b.v
+ exit 1
+ fi
+
+ fi
done
+ fi
fi
rm -f tmp2
sed -e "s/#$d#//" tmp > tmp2
mv -f tmp2 tmp
done
a=`grep theories tmp`
-if [ $? = 0 ]; then echo Warning: extra files:; echo $a; fi
+if [ $? = 0 ]; then echo Error: extra files:; echo $a; exit 1; fi
mv tmp $FILE
echo Done