~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to refman/RefMan-lib.tex

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu, Stéphane Glondu, Samuel Mimram
  • Date: 2010-01-07 22:50:39 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100107225039-n3cq82589u0qt0s2
Tags: 8.2pl1-1
[ Stéphane Glondu ]
* New upstream release (Closes: #563669)
  - remove patches
* Packaging overhaul:
  - use git, advertise it in Vcs-* fields of debian/control
  - use debhelper 7 and dh with override
  - use source format 3.0 (quilt)
* debian/control:
  - set Maintainer to d-o-m, set Uploaders to Sam and myself
  - add Homepage field
  - bump Standards-Version to 3.8.3
* Register PDF documentation into doc-base
* Add debian/watch
* Update debian/copyright

[ Samuel Mimram ]
* Change coq-doc's description to mention that it provides documentation in
  pdf format, not postscript, closes: #543545.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
\chapter{The {\Coq} library}
2
 
\index{Theories}\label{Theories}
3
 
 
4
 
The \Coq\ library is structured into three parts:
5
 
 
6
 
\begin{description}
7
 
\item[The initial library:] it contains
8
 
  elementary logical notions and datatypes. It constitutes the
9
 
  basic state of the system directly available when running
10
 
  \Coq;
11
 
 
12
 
\item[The standard library:] general-purpose libraries containing
13
 
  various developments of \Coq\ axiomatizations about sets, lists,
14
 
  sorting, arithmetic, etc. This library comes with the system and its
15
 
  modules are directly accessible through the \verb!Require! command
16
 
  (see section~\ref{Require});
17
 
 
18
 
\item[User contributions:] Other specification and proof developments
19
 
  coming from the \Coq\ users' community. These libraries are
20
 
  available for download at \texttt{http://coq.inria.fr} (see
21
 
  section~\ref{Contributions}).
22
 
\end{description}
23
 
 
24
 
This chapter briefly reviews these libraries.
25
 
 
26
 
\section{The basic library}
27
 
\label{Prelude}
28
 
 
29
 
This section lists the basic notions and results which are directly
30
 
available in the standard \Coq\ system\footnote{Most 
31
 
of these constructions are defined in the
32
 
{\tt Prelude} module in directory {\tt theories/Init} at the {\Coq}
33
 
root directory; this includes the modules
34
 
{\tt Notations},
35
 
{\tt Logic},
36
 
{\tt Datatypes},
37
 
{\tt Specif},
38
 
{\tt Peano},
39
 
and {\tt Wf}.
40
 
Module {\tt Logic\_Type} also makes it in the initial state}.
41
 
 
42
 
\subsection{Notations} \label{Notations}
43
 
 
44
 
This module defines the parsing and pretty-printing of many symbols
45
 
(infixes, prefixes, etc.). However, it does not assign a meaning to these
46
 
notations. The purpose of this is to define precedence and
47
 
associativity of very common notations, and avoid users to use them
48
 
with other precedence, which may be confusing.
49
 
 
50
 
\begin{figure}
51
 
\begin{center}
52
 
\begin{tabular}{|cll|}
53
 
\hline
54
 
Notation & Precedence & Associativity \\
55
 
\hline
56
 
\verb!_ <-> _! & 95 & no \\
57
 
\verb!_ \/ _!  & 85 & right \\
58
 
\verb!_ /\ _!  & 80 & right \\
59
 
\verb!~ _!   & 75 & right \\
60
 
\verb!_ = _!   & 70 & no \\
61
 
\verb!_ = _ = _!   & 70 & no \\
62
 
\verb!_ = _ :> _!   & 70 & no \\
63
 
\verb!_ <> _!  & 70 & no \\
64
 
\verb!_ <> _ :> _!  & 70 & no \\
65
 
\verb!_ < _!   & 70 & no \\
66
 
\verb!_ > _!   & 70 & no \\
67
 
\verb!_ <= _!  & 70 & no \\
68
 
\verb!_ >= _!  & 70 & no \\
69
 
\verb!_ < _ < _! & 70 & no \\
70
 
\verb!_ < _ <= _! & 70 & no \\
71
 
\verb!_ <= _ < _! & 70 & no \\
72
 
\verb!_ <= _ <= _! & 70 & no \\
73
 
\verb!_ + _!   & 50 & left \\
74
 
\verb!_ - _!   & 50 & left \\
75
 
\verb!_ * _!   & 40 & left \\
76
 
\verb!_ / _!   & 40 & left \\
77
 
\verb!- _!  & 35 & right \\
78
 
\verb!/ _!  & 35 & right \\
79
 
\verb!_ ^ _!   & 30 & right \\
80
 
\hline
81
 
\end{tabular}
82
 
\end{center}
83
 
\caption{Notations in the initial state}
84
 
\label{init-notations}
85
 
\end{figure}
86
 
 
87
 
\subsection{Logic} 
88
 
\label{Logic}
89
 
 
90
 
\begin{figure}
91
 
\begin{centerframe}
92
 
\begin{tabular}{lclr}
93
 
{\form} & ::= & {\tt True} & ({\tt True})\\
94
 
  & $|$ & {\tt False} & ({\tt False})\\
95
 
  & $|$ & {\tt\char'176} {\form} & ({\tt not})\\
96
 
  & $|$ & {\form} {\tt /$\backslash$} {\form} & ({\tt and})\\
97
 
  & $|$ & {\form} {\tt $\backslash$/} {\form} & ({\tt or})\\
98
 
  & $|$ & {\form} {\tt ->} {\form} & (\em{primitive implication})\\
99
 
  & $|$ & {\form} {\tt <->} {\form} & ({\tt iff})\\
100
 
  & $|$ & {\tt forall} {\ident} {\tt :} {\type} {\tt ,}
101
 
  {\form} & (\em{primitive for all})\\
102
 
  & $|$ & {\tt exists} {\ident} \zeroone{{\tt :} {\specif}} {\tt
103
 
  ,} {\form}  & ({\tt ex})\\
104
 
  & $|$ & {\tt exists2} {\ident} \zeroone{{\tt :} {\specif}} {\tt
105
 
  ,} {\form}  {\tt \&} {\form} & ({\tt ex2})\\
106
 
  & $|$ & {\term} {\tt =} {\term} & ({\tt eq})\\
107
 
  & $|$ & {\term} {\tt =} {\term} {\tt :>} {\specif} & ({\tt eq})
108
 
\end{tabular}
109
 
\end{centerframe}
110
 
\caption{Syntax of formulas}
111
 
\label{formulas-syntax}
112
 
\end{figure}
113
 
 
114
 
The basic library of {\Coq} comes with the definitions of standard
115
 
(intuitionistic) logical connectives (they are defined as inductive
116
 
constructions). They are equipped with an appealing syntax enriching the
117
 
(subclass {\form}) of the syntactic class {\term}. The syntax
118
 
extension is shown on figure \ref{formulas-syntax}.
119
 
 
120
 
% The basic library of {\Coq} comes with the definitions of standard
121
 
% (intuitionistic) logical connectives (they are defined as inductive
122
 
% constructions). They are equipped with an appealing syntax enriching
123
 
% the (subclass {\form}) of the syntactic class {\term}. The syntax
124
 
% extension \footnote{This syntax is defined in module {\tt
125
 
%     LogicSyntax}} is shown on Figure~\ref{formulas-syntax}.
126
 
 
127
 
\Rem Implication is not defined but primitive (it is a non-dependent
128
 
product of a proposition over another proposition).  There is also a
129
 
primitive universal quantification (it is a dependent product over a
130
 
proposition). The primitive universal quantification allows both
131
 
first-order and higher-order quantification.
132
 
 
133
 
\subsubsection{Propositional Connectives} \label{Connectives}
134
 
\index{Connectives}
135
 
 
136
 
First, we find propositional calculus connectives:
137
 
\ttindex{True}
138
 
\ttindex{I}
139
 
\ttindex{False}
140
 
\ttindex{not}
141
 
\ttindex{and}
142
 
\ttindex{conj}
143
 
\ttindex{proj1}
144
 
\ttindex{proj2}
145
 
 
146
 
\begin{coq_eval}
147
 
Set Printing Depth 50.
148
 
\end{coq_eval}
149
 
\begin{coq_example*}
150
 
Inductive True : Prop := I.
151
 
Inductive False :  Prop := .
152
 
Definition not (A: Prop) := A -> False.
153
 
Inductive and (A B:Prop) : Prop := conj (_:A) (_:B).
154
 
Section Projections.
155
 
Variables A B : Prop.
156
 
Theorem proj1 : A /\ B -> A.
157
 
Theorem proj2 : A /\ B -> B.
158
 
End Projections.
159
 
\end{coq_example*}
160
 
\begin{coq_eval}
161
 
Abort All.
162
 
\end{coq_eval}
163
 
\ttindex{or}
164
 
\ttindex{or\_introl}
165
 
\ttindex{or\_intror}
166
 
\ttindex{iff}
167
 
\ttindex{IF\_then\_else}
168
 
\begin{coq_example*}
169
 
Inductive or (A B:Prop) : Prop :=
170
 
  | or_introl (_:A)
171
 
  | or_intror (_:B).
172
 
Definition iff (P Q:Prop) := (P -> Q) /\ (Q -> P).
173
 
Definition IF_then_else (P Q R:Prop) := P /\ Q \/ ~ P /\ R.
174
 
\end{coq_example*}
175
 
 
176
 
\subsubsection{Quantifiers} \label{Quantifiers}
177
 
\index{Quantifiers}
178
 
 
179
 
Then we find first-order quantifiers:
180
 
\ttindex{all}
181
 
\ttindex{ex}
182
 
\ttindex{exists}
183
 
\ttindex{ex\_intro}
184
 
\ttindex{ex2}
185
 
\ttindex{exists2}
186
 
\ttindex{ex\_intro2}
187
 
 
188
 
\begin{coq_example*}
189
 
Definition all (A:Set) (P:A -> Prop) := forall x:A, P x.
190
 
Inductive ex (A: Set) (P:A -> Prop) : Prop :=
191
 
    ex_intro (x:A) (_:P x).
192
 
Inductive ex2 (A:Set) (P Q:A -> Prop) : Prop :=
193
 
    ex_intro2 (x:A) (_:P x) (_:Q x).
194
 
\end{coq_example*}
195
 
 
196
 
The following abbreviations are allowed:
197
 
\begin{center}
198
 
  \begin{tabular}[h]{|l|l|}
199
 
    \hline
200
 
    \verb+exists x:A, P+     & \verb+ex A (fun x:A => P)+ \\
201
 
    \verb+exists x, P+       & \verb+ex _ (fun x => P)+ \\
202
 
    \verb+exists2 x:A, P & Q+ & \verb+ex2 A (fun x:A => P) (fun x:A => Q)+ \\
203
 
    \verb+exists2 x, P & Q+   & \verb+ex2 _ (fun x => P) (fun x => Q)+ \\
204
 
    \hline
205
 
  \end{tabular}
206
 
\end{center}
207
 
 
208
 
The type annotation \texttt{:A} can be omitted when \texttt{A} can be
209
 
synthesized by the system.
210
 
 
211
 
\subsubsection{Equality} \label{Equality}
212
 
\index{Equality}
213
 
 
214
 
Then, we find equality, defined as an inductive relation. That is,
215
 
given a \verb:Type: \verb:A: and an \verb:x: of type \verb:A:, the
216
 
predicate \verb:(eq A x): is the smallest one which contains \verb:x:.
217
 
This definition, due to Christine Paulin-Mohring, is equivalent to
218
 
define \verb:eq: as the smallest reflexive relation, and it is also
219
 
equivalent to Leibniz' equality.
220
 
 
221
 
\ttindex{eq}
222
 
\ttindex{refl\_equal}
223
 
 
224
 
\begin{coq_example*}
225
 
Inductive eq (A:Type) (x:A) : A -> Prop :=
226
 
    refl_equal : eq A x x.
227
 
\end{coq_example*}
228
 
 
229
 
\subsubsection{Lemmas} 
230
 
\label{PreludeLemmas}
231
 
 
232
 
Finally, a few easy lemmas are provided.
233
 
 
234
 
\ttindex{absurd}
235
 
 
236
 
\begin{coq_example*}
237
 
Theorem absurd : forall A C:Prop, A -> ~ A -> C.
238
 
\end{coq_example*}
239
 
\begin{coq_eval}
240
 
Abort.
241
 
\end{coq_eval}
242
 
\ttindex{sym\_eq}
243
 
\ttindex{trans\_eq}
244
 
\ttindex{f\_equal}
245
 
\ttindex{sym\_not\_eq}
246
 
\begin{coq_example*}
247
 
Section equality.
248
 
Variables A B : Type.
249
 
Variable f : A -> B.
250
 
Variables x y z : A.
251
 
Theorem sym_eq : x = y -> y = x.
252
 
Theorem trans_eq : x = y -> y = z -> x = z.
253
 
Theorem f_equal : x = y -> f x = f y.
254
 
Theorem sym_not_eq : x <> y -> y <> x.
255
 
\end{coq_example*}
256
 
\begin{coq_eval}
257
 
Abort.
258
 
Abort.
259
 
Abort.
260
 
Abort.
261
 
\end{coq_eval}
262
 
\ttindex{eq\_ind\_r}
263
 
\ttindex{eq\_rec\_r}
264
 
\ttindex{eq\_rect}
265
 
\ttindex{eq\_rect\_r}
266
 
%Definition eq_rect: (A:Set)(x:A)(P:A->Type)(P x)->(y:A)(x=y)->(P y).
267
 
\begin{coq_example*}
268
 
End equality.
269
 
Definition eq_ind_r :
270
 
  forall (A:Type) (x:A) (P:A -> Prop), P x -> forall y:A, y = x -> P y.
271
 
Definition eq_rec_r :
272
 
  forall (A:Type) (x:A) (P:A -> Set), P x -> forall y:A, y = x -> P y.
273
 
Definition eq_rect_r :
274
 
  forall (A:Type) (x:A) (P:A -> Type), P x -> forall y:A, y = x -> P y.
275
 
\end{coq_example*}
276
 
\begin{coq_eval}
277
 
Abort.
278
 
Abort.
279
 
Abort.
280
 
\end{coq_eval}
281
 
%Abort (for now predefined eq_rect)
282
 
\begin{coq_example*}
283
 
Hint Immediate sym_eq sym_not_eq : core.
284
 
\end{coq_example*}
285
 
\ttindex{f\_equal$i$}
286
 
 
287
 
The theorem {\tt f\_equal} is extended to functions with two to five
288
 
arguments. The theorem are names {\tt f\_equal2}, {\tt f\_equal3}, 
289
 
{\tt f\_equal4} and {\tt f\_equal5}.
290
 
For instance {\tt f\_equal3} is defined the following way.
291
 
\begin{coq_example*}
292
 
Theorem f_equal3 :
293
 
 forall (A1 A2 A3 B:Type) (f:A1 -> A2 -> A3 -> B) (x1 y1:A1) (x2 y2:A2)
294
 
   (x3 y3:A3), x1 = y1 -> x2 = y2 -> x3 = y3 -> f x1 x2 x3 = f y1 y2 y3.
295
 
\end{coq_example*}
296
 
\begin{coq_eval}
297
 
Abort.
298
 
\end{coq_eval}
299
 
 
300
 
\subsection{Datatypes}
301
 
\label{Datatypes}
302
 
\index{Datatypes}
303
 
 
304
 
\begin{figure}
305
 
\begin{centerframe}
306
 
\begin{tabular}{rclr}
307
 
{\specif} & ::= & {\specif} {\tt *} {\specif} & ({\tt prod})\\
308
 
  & $|$ & {\specif} {\tt +} {\specif} & ({\tt sum})\\
309
 
  & $|$ & {\specif} {\tt + \{} {\specif} {\tt \}} & ({\tt sumor})\\
310
 
  & $|$ & {\tt \{} {\specif} {\tt \} + \{} {\specif} {\tt \}} &
311
 
  ({\tt sumbool})\\  
312
 
  & $|$ & {\tt \{} {\ident} {\tt :} {\specif} {\tt |} {\form} {\tt \}}
313
 
  & ({\tt sig})\\
314
 
  & $|$ & {\tt \{} {\ident} {\tt :} {\specif} {\tt |} {\form}  {\tt \&}
315
 
  {\form} {\tt \}} & ({\tt sig2})\\
316
 
  & $|$ & {\tt \{} {\ident} {\tt :} {\specif} {\tt \&} {\specif} {\tt
317
 
    \}} & ({\tt sigS})\\
318
 
  & $|$ & {\tt \{} {\ident} {\tt :} {\specif} {\tt \&} {\specif} {\tt
319
 
    \&} {\specif} {\tt \}} & ({\tt sigS2})\\
320
 
  &  & & \\
321
 
{\term} & ::= & {\tt (} {\term} {\tt ,} {\term} {\tt )} & ({\tt pair})
322
 
\end{tabular}
323
 
\end{centerframe}
324
 
\caption{Syntax of datatypes and specifications}
325
 
\label{specif-syntax}
326
 
\end{figure}
327
 
 
328
 
 
329
 
In the basic library, we find the definition\footnote{They are in {\tt
330
 
    Datatypes.v}} of the basic data-types of programming, again
331
 
defined as inductive constructions over the sort \verb:Set:. Some of
332
 
them come with a special syntax shown on Figure~\ref{specif-syntax}.
333
 
 
334
 
\subsubsection{Programming} 
335
 
\label{Programming}
336
 
\index{Programming}
337
 
\label{libnats}
338
 
 
339
 
\ttindex{unit}
340
 
\ttindex{tt}
341
 
\ttindex{bool}
342
 
\ttindex{true}
343
 
\ttindex{false}
344
 
\ttindex{nat}
345
 
\ttindex{O}
346
 
\ttindex{S}
347
 
\ttindex{option}
348
 
\ttindex{Some}
349
 
\ttindex{None}
350
 
\ttindex{identity}
351
 
\ttindex{refl\_identity}
352
 
 
353
 
\begin{coq_example*}
354
 
Inductive unit : Set := tt.
355
 
Inductive bool : Set := true | false.
356
 
Inductive nat : Set := O | S (n:nat).
357
 
Inductive option (A:Set) : Set := Some (_:A) | None.
358
 
Inductive identity (A:Type) (a:A) : A -> Type :=
359
 
    refl_identity : identity A a a.
360
 
\end{coq_example*}
361
 
 
362
 
Note that zero is the letter \verb:O:, and {\sl not} the numeral
363
 
\verb:0:.
364
 
 
365
 
{\tt identity} is logically equivalent to equality but it lives in
366
 
sort {\tt Set}. Computationaly, it behaves like {\tt unit}.
367
 
 
368
 
We then define the disjoint sum of \verb:A+B: of two sets \verb:A: and
369
 
\verb:B:, and their product \verb:A*B:.
370
 
\ttindex{sum}
371
 
\ttindex{A+B}
372
 
\ttindex{+}
373
 
\ttindex{inl}
374
 
\ttindex{inr}
375
 
\ttindex{prod}
376
 
\ttindex{A*B}
377
 
\ttindex{*}
378
 
\ttindex{pair}
379
 
\ttindex{fst}
380
 
\ttindex{snd}
381
 
 
382
 
\begin{coq_example*}
383
 
Inductive sum (A B:Set) : Set := inl (_:A) | inr (_:B).
384
 
Inductive prod (A B:Set) : Set := pair (_:A) (_:B).
385
 
Section projections.
386
 
Variables A B : Set.
387
 
Definition fst (H: prod A B) := match H with
388
 
                                | pair x y => x
389
 
                                end.
390
 
Definition snd (H: prod A B) := match H with
391
 
                                | pair x y => y
392
 
                                end.
393
 
End projections.
394
 
\end{coq_example*}
395
 
 
396
 
\subsection{Specification}
397
 
 
398
 
The following notions\footnote{They are defined in module {\tt
399
 
Specif.v}} allows to build new datatypes and specifications. 
400
 
They are available with the syntax shown on
401
 
Figure~\ref{specif-syntax}\footnote{This syntax can be found in the module
402
 
{\tt SpecifSyntax.v}}.
403
 
 
404
 
For instance, given \verb|A:Set| and \verb|P:A->Prop|, the construct
405
 
\verb+{x:A | P x}+ (in abstract syntax \verb+(sig A P)+) is a
406
 
\verb:Set:. We may build elements of this set as \verb:(exist x p):
407
 
whenever we have a witness \verb|x:A| with its justification
408
 
\verb|p:P x|.
409
 
 
410
 
From such a \verb:(exist x p): we may in turn extract its witness
411
 
\verb|x:A| (using an elimination construct such as \verb:match:) but
412
 
{\sl not} its justification, which stays hidden, like in an abstract
413
 
data type. In technical terms, one says that \verb:sig: is a ``weak
414
 
(dependent) sum''.  A variant \verb:sig2: with two predicates is also
415
 
provided.
416
 
 
417
 
\index{\{x:A "| (P x)\}}
418
 
\index{"|}
419
 
\ttindex{sig}
420
 
\ttindex{exist}
421
 
\ttindex{sig2}
422
 
\ttindex{exist2}
423
 
 
424
 
\begin{coq_example*}
425
 
Inductive sig (A:Set) (P:A -> Prop) : Set := exist (x:A) (_:P x).
426
 
Inductive sig2 (A:Set) (P Q:A -> Prop) : Set := 
427
 
  exist2 (x:A) (_:P x) (_:Q x).
428
 
\end{coq_example*}
429
 
 
430
 
A ``strong (dependent) sum'' \verb+{x:A & (P x)}+ may be also defined,
431
 
when the predicate \verb:P: is now defined as a \verb:Set:
432
 
constructor.
433
 
 
434
 
\ttindex{\{x:A \& (P x)\}}
435
 
\ttindex{\&}
436
 
\ttindex{sigS}
437
 
\ttindex{existS}
438
 
\ttindex{projS1}
439
 
\ttindex{projS2}
440
 
\ttindex{sigS2}
441
 
\ttindex{existS2}
442
 
 
443
 
\begin{coq_example*}
444
 
Inductive sigS (A:Set) (P:A -> Set) : Set := existS (x:A) (_:P x).
445
 
Section sigSprojections.
446
 
Variable A : Set.
447
 
Variable P : A -> Set.
448
 
Definition projS1 (H:sigS A P) := let (x, h) := H in x.
449
 
Definition projS2 (H:sigS A P) :=
450
 
  match H return P (projS1 H) with
451
 
    existS x h => h
452
 
  end.
453
 
End sigSprojections.
454
 
Inductive sigS2 (A: Set) (P Q:A -> Set) : Set :=
455
 
    existS2 (x:A) (_:P x) (_:Q x).
456
 
\end{coq_example*}
457
 
 
458
 
A related non-dependent construct is the constructive sum
459
 
\verb"{A}+{B}" of two propositions \verb:A: and \verb:B:.
460
 
\label{sumbool}
461
 
\ttindex{sumbool}
462
 
\ttindex{left}
463
 
\ttindex{right}
464
 
\ttindex{\{A\}+\{B\}}
465
 
 
466
 
\begin{coq_example*}
467
 
Inductive sumbool (A B:Prop) : Set := left (_:A) | right (_:B).
468
 
\end{coq_example*}
469
 
 
470
 
This \verb"sumbool" construct may be used as a kind of indexed boolean
471
 
data type. An intermediate between \verb"sumbool" and \verb"sum" is
472
 
the mixed \verb"sumor" which combines \verb"A:Set" and \verb"B:Prop"
473
 
in the \verb"Set" \verb"A+{B}".
474
 
\ttindex{sumor}
475
 
\ttindex{inleft}
476
 
\ttindex{inright}
477
 
\ttindex{A+\{B\}}
478
 
 
479
 
\begin{coq_example*}
480
 
Inductive sumor (A:Set) (B:Prop) : Set := inleft (_:A) | inright (_:B).
481
 
\end{coq_example*}
482
 
 
483
 
We may define variants of the axiom of choice, like in Martin-L�f's
484
 
Intuitionistic Type Theory.
485
 
\ttindex{Choice}
486
 
\ttindex{Choice2}
487
 
\ttindex{bool\_choice}
488
 
 
489
 
\begin{coq_example*}
490
 
Lemma Choice :
491
 
 forall (S S':Set) (R:S -> S' -> Prop),
492
 
   (forall x:S, {y : S' | R x y}) ->
493
 
   {f : S -> S' | forall z:S, R z (f z)}.
494
 
Lemma Choice2 :
495
 
 forall (S S':Set) (R:S -> S' -> Set),
496
 
   (forall x:S, {y : S' &  R x y}) ->
497
 
   {f : S -> S' &  forall z:S, R z (f z)}.
498
 
Lemma bool_choice :
499
 
 forall (S:Set) (R1 R2:S -> Prop),
500
 
   (forall x:S, {R1 x} + {R2 x}) ->
501
 
   {f : S -> bool |
502
 
   forall x:S, f x = true /\ R1 x \/ f x = false /\ R2 x}.
503
 
\end{coq_example*}
504
 
\begin{coq_eval}
505
 
Abort.
506
 
Abort.
507
 
Abort.
508
 
\end{coq_eval}
509
 
 
510
 
The next constructs builds a sum between a data type \verb|A:Set| and
511
 
an exceptional value encoding errors:
512
 
 
513
 
\ttindex{Exc}
514
 
\ttindex{value}
515
 
\ttindex{error}
516
 
 
517
 
\begin{coq_example*}
518
 
Definition Exc := option.
519
 
Definition value := Some.
520
 
Definition error := None.
521
 
\end{coq_example*}
522
 
 
523
 
 
524
 
This module ends with theorems, 
525
 
relating the sorts \verb:Set: and
526
 
\verb:Prop: in a way which is consistent with the realizability
527
 
interpretation.
528
 
\ttindex{False\_rec}
529
 
\ttindex{eq\_rec}
530
 
\ttindex{Except}
531
 
\ttindex{absurd\_set}
532
 
\ttindex{and\_rec}
533
 
 
534
 
%Lemma False_rec : (P:Set)False->P.
535
 
%Lemma False_rect : (P:Type)False->P.
536
 
\begin{coq_example*}
537
 
Definition except := False_rec.
538
 
Notation Except := (except _).
539
 
Theorem absurd_set : forall (A:Prop) (C:Set), A -> ~ A -> C.
540
 
Theorem and_rec :
541
 
 forall (A B:Prop) (P:Set), (A -> B -> P) -> A /\ B -> P.
542
 
\end{coq_example*}
543
 
%\begin{coq_eval}
544
 
%Abort.
545
 
%Abort.
546
 
%\end{coq_eval}
547
 
 
548
 
\subsection{Basic Arithmetics}
549
 
 
550
 
The basic library includes a few elementary properties of natural
551
 
numbers, together with the definitions of predecessor, addition and
552
 
multiplication\footnote{This is in module {\tt Peano.v}}. It also
553
 
provides a scope {\tt nat\_scope} gathering standard notations for
554
 
common operations (+,*) and a decimal notation for numbers. That is he
555
 
can write \texttt{3} for \texttt{(S (S (S O)))}. This also works on
556
 
the left hand side of a \texttt{match} expression (see for example
557
 
section~\ref{refine-example}). This scope is opened by default.
558
 
 
559
 
%Remove the redefinition of nat
560
 
\begin{coq_eval}
561
 
Reset Initial.
562
 
\end{coq_eval}
563
 
 
564
 
The following example is not part of the standard library, but it
565
 
shows the usage of the notations:
566
 
 
567
 
\begin{coq_example*}
568
 
Fixpoint even (n:nat) : bool :=
569
 
  match n with
570
 
  | 0 => true
571
 
  | 1 => false
572
 
  | S (S n) => even n
573
 
  end.
574
 
\end{coq_example*}
575
 
 
576
 
 
577
 
\ttindex{eq\_S}
578
 
\ttindex{pred}
579
 
\ttindex{pred\_Sn}
580
 
\ttindex{eq\_add\_S}
581
 
\ttindex{not\_eq\_S}
582
 
\ttindex{IsSucc}
583
 
\ttindex{O\_S}
584
 
\ttindex{n\_Sn}
585
 
\ttindex{plus}
586
 
\ttindex{plus\_n\_O}
587
 
\ttindex{plus\_n\_Sm}
588
 
\ttindex{mult}
589
 
\ttindex{mult\_n\_O}
590
 
\ttindex{mult\_n\_Sm}
591
 
 
592
 
\begin{coq_example*}
593
 
Theorem eq_S : forall x y:nat, x = y -> S x = S y.
594
 
\end{coq_example*}
595
 
\begin{coq_eval}
596
 
Abort.
597
 
\end{coq_eval}
598
 
\begin{coq_example*}
599
 
Definition pred (n:nat) : nat :=
600
 
  match n with
601
 
  | 0 => 0
602
 
  | S u => u
603
 
  end.
604
 
Theorem pred_Sn : forall m:nat, m = pred (S m).
605
 
Theorem eq_add_S : forall n m:nat, S n = S m -> n = m.
606
 
Hint Immediate eq_add_S : core.
607
 
Theorem not_eq_S : forall n m:nat, n <> m -> S n <> S m.
608
 
\end{coq_example*}
609
 
\begin{coq_eval}
610
 
Abort All.
611
 
\end{coq_eval}
612
 
\begin{coq_example*}
613
 
Definition IsSucc (n:nat) : Prop :=
614
 
  match n with
615
 
  | 0 => False
616
 
  | S p => True
617
 
  end.
618
 
Theorem O_S : forall n:nat, 0 <> S n.
619
 
Theorem n_Sn : forall n:nat, n <> S n.
620
 
\end{coq_example*}
621
 
\begin{coq_eval}
622
 
Abort All.
623
 
\end{coq_eval}
624
 
\begin{coq_example*}
625
 
Fixpoint plus (n m:nat) {struct n} : nat :=
626
 
  match n with
627
 
  | 0 => m
628
 
  | S p => S (plus p m)
629
 
  end.
630
 
Lemma plus_n_O : forall n:nat, n = plus n 0.
631
 
Lemma plus_n_Sm : forall n m:nat, S (plus n m) = plus n (S m).
632
 
\end{coq_example*}
633
 
\begin{coq_eval}
634
 
Abort All.
635
 
\end{coq_eval}
636
 
\begin{coq_example*}
637
 
Fixpoint mult (n m:nat) {struct n} : nat :=
638
 
  match n with
639
 
  | 0 => 0
640
 
  | S p => m + mult p m
641
 
  end.
642
 
Lemma mult_n_O : forall n:nat, 0 = mult n 0.
643
 
Lemma mult_n_Sm : forall n m:nat, plus (mult n m) n = mult n (S m).
644
 
\end{coq_example*}
645
 
\begin{coq_eval}
646
 
Abort All.
647
 
\end{coq_eval}
648
 
 
649
 
Finally, it gives the definition of the usual orderings \verb:le:,
650
 
\verb:lt:, \verb:ge:, and \verb:gt:.
651
 
\ttindex{le}
652
 
\ttindex{le\_n}
653
 
\ttindex{le\_S}
654
 
\ttindex{lt}
655
 
\ttindex{ge}
656
 
\ttindex{gt}
657
 
\label{le}
658
 
 
659
 
\begin{coq_example*}
660
 
Inductive le (n:nat) : nat -> Prop :=
661
 
  | le_n : le n n
662
 
  | le_S : forall m:nat, le n m -> le n (S m).
663
 
Infix "+" := plus : nat_scope.
664
 
Definition lt (n m:nat) := S n <= m.
665
 
Definition ge (n m:nat) := m <= n.
666
 
Definition gt (n m:nat) := m < n.
667
 
\end{coq_example*}
668
 
 
669
 
Properties of these relations are not initially known, but may be
670
 
required by the user from modules \verb:Le: and \verb:Lt:.  Finally,
671
 
\verb:Peano: gives some lemmas allowing pattern-matching, and a double
672
 
induction principle.
673
 
 
674
 
\ttindex{nat\_case}
675
 
\ttindex{nat\_double\_ind}
676
 
 
677
 
\begin{coq_example*}
678
 
Theorem nat_case :
679
 
 forall (n:nat) (P:nat -> Prop), P 0 -> (forall m:nat, P (S m)) -> P n.
680
 
\end{coq_example*}
681
 
\begin{coq_eval}
682
 
Abort All.
683
 
\end{coq_eval}
684
 
\begin{coq_example*}
685
 
Theorem nat_double_ind :
686
 
 forall R:nat -> nat -> Prop,
687
 
   (forall n:nat, R 0 n) ->
688
 
   (forall n:nat, R (S n) 0) ->
689
 
   (forall n m:nat, R n m -> R (S n) (S m)) -> forall n m:nat, R n m.
690
 
\end{coq_example*}
691
 
\begin{coq_eval}
692
 
Abort All.
693
 
\end{coq_eval}
694
 
 
695
 
\subsection{Well-founded recursion}
696
 
 
697
 
The basic library contains the basics of well-founded recursion and 
698
 
well-founded induction\footnote{This is defined in module {\tt Wf.v}}.
699
 
\index{Well foundedness}
700
 
\index{Recursion}
701
 
\index{Well founded induction}
702
 
\ttindex{Acc}
703
 
\ttindex{Acc\_inv}
704
 
\ttindex{Acc\_rec}
705
 
\ttindex{well\_founded}
706
 
 
707
 
\begin{coq_example*}
708
 
Section Well_founded.
709
 
Variable A : Set.
710
 
Variable R : A -> A -> Prop.
711
 
Inductive Acc : A -> Prop :=
712
 
    Acc_intro : forall x:A, (forall y:A, R y x -> Acc y) -> Acc x.
713
 
Lemma Acc_inv : forall x:A, Acc x -> forall y:A, R y x -> Acc y.
714
 
\end{coq_example*}
715
 
\begin{coq_eval}
716
 
simple destruct 1; trivial.
717
 
Defined.
718
 
\end{coq_eval}
719
 
\begin{coq_example*}
720
 
Section AccRec.
721
 
Variable P : A -> Set.
722
 
Variable F :
723
 
    forall x:A,
724
 
      (forall y:A, R y x -> Acc y) -> (forall y:A, R y x -> P y) -> P x.
725
 
Fixpoint Acc_rec (x:A) (a:Acc x) {struct a} : P x :=
726
 
  F x (Acc_inv x a)
727
 
    (fun (y:A) (h:R y x) => Acc_rec y (Acc_inv x a y h)).
728
 
End AccRec.
729
 
Definition well_founded := forall a:A, Acc a.
730
 
Hypothesis Rwf : well_founded.
731
 
Theorem well_founded_induction :
732
 
 forall P:A -> Set,
733
 
   (forall x:A, (forall y:A, R y x -> P y) -> P x) -> forall a:A, P a.
734
 
Theorem well_founded_ind :
735
 
 forall P:A -> Prop,
736
 
   (forall x:A, (forall y:A, R y x -> P y) -> P x) -> forall a:A, P a.
737
 
\end{coq_example*}
738
 
\begin{coq_eval}
739
 
Abort All.
740
 
\end{coq_eval}
741
 
{\tt Acc\_rec} can be used to define functions by fixpoints using
742
 
well-founded relations to  justify termination. Assuming
743
 
extensionality of the functional used for the recursive call, the
744
 
fixpoint equation can be proved.
745
 
\ttindex{Fix\_F}
746
 
\ttindex{fix\_eq}
747
 
\ttindex{Fix\_F\_inv}
748
 
\ttindex{Fix\_F\_eq}
749
 
\begin{coq_example*}
750
 
Section FixPoint.
751
 
Variable P : A -> Set.
752
 
Variable F : forall x:A, (forall y:A, R y x -> P y) -> P x.
753
 
Fixpoint Fix_F (x:A) (r:Acc x) {struct r} : P x :=
754
 
  F x (fun (y:A) (p:R y x) => Fix_F y (Acc_inv x r y p)).
755
 
Definition Fix (x:A) := Fix_F x (Rwf x).
756
 
Hypothesis F_ext :
757
 
    forall (x:A) (f g:forall y:A, R y x -> P y),
758
 
      (forall (y:A) (p:R y x), f y p = g y p) -> F x f = F x g.
759
 
Lemma Fix_F_eq :
760
 
 forall (x:A) (r:Acc x),
761
 
   F x (fun (y:A) (p:R y x) => Fix_F y (Acc_inv x r y p)) = Fix_F x r.
762
 
Lemma Fix_F_inv : forall (x:A) (r s:Acc x), Fix_F x r = Fix_F x s.
763
 
Lemma fix_eq : forall x:A, Fix x = F x (fun (y:A) (p:R y x) => Fix y).
764
 
\end{coq_example*}
765
 
\begin{coq_eval}
766
 
Abort All.
767
 
\end{coq_eval}
768
 
\begin{coq_example*}
769
 
End FixPoint.
770
 
End Well_founded.
771
 
\end{coq_example*}
772
 
 
773
 
\subsection{Accessing the {\Type} level}
774
 
 
775
 
The basic library includes the definitions\footnote{This is in module
776
 
{\tt Logic\_Type.v}} of the counterparts of some datatypes and logical
777
 
quantifiers at the \verb:Type: level: negation, pair, and properties
778
 
of {\tt identity}.
779
 
 
780
 
\ttindex{notT}
781
 
\ttindex{prodT}
782
 
\ttindex{pairT}
783
 
\begin{coq_eval}
784
 
Reset Initial.
785
 
\end{coq_eval}
786
 
\begin{coq_example*}
787
 
Definition notT (A:Type) := A -> False.
788
 
Inductive prodT (A B:Type) : Type := pairT (_:A) (_:B).
789
 
\end{coq_example*}
790
 
 
791
 
 
792
 
At the end, it defines datatypes at the {\Type} level.
793
 
 
794
 
\section{The standard library}
795
 
 
796
 
\subsection{Survey}
797
 
 
798
 
The rest of the standard library is structured into the following 
799
 
subdirectories:
800
 
 
801
 
\begin{tabular}{lp{12cm}}
802
 
  {\bf Logic}   & Classical logic and dependent equality \\
803
 
  {\bf Arith}   & Basic Peano arithmetic \\
804
 
  {\bf NArith}  & Basic positive integer arithmetic \\
805
 
  {\bf ZArith}  & Basic relative integer arithmetic \\
806
 
  {\bf Bool}    & Booleans (basic functions and results) \\
807
 
  {\bf Lists}   & Monomorphic and polymorphic lists (basic functions and
808
 
            results), Streams (infinite sequences defined with co-inductive
809
 
            types) \\
810
 
  {\bf Sets}    & Sets (classical, constructive, finite, infinite, power set,
811
 
            etc.) \\
812
 
  {\bf FSets}   & Specification and implementations of finite sets and finite
813
 
                  maps (by lists and by AVL trees)\\
814
 
  {\bf IntMap}  & Representation of finite sets by an efficient
815
 
                  structure of map (trees indexed by binary integers).\\
816
 
 {\bf Reals}    & Axiomatization of real numbers (classical, basic functions, 
817
 
                  integer part, fractional part, limit, derivative, Cauchy 
818
 
                  series, power series and results,...)\\
819
 
 {\bf Relations} & Relations (definitions and basic results). \\
820
 
 {\bf Sorting}  & Sorted list (basic definitions and heapsort correctness). \\
821
 
 {\bf Strings}  & 8-bits characters and strings\\
822
 
 {\bf Wellfounded} & Well-founded relations (basic results). \\
823
 
 
824
 
\end{tabular}
825
 
\medskip
826
 
 
827
 
These directories belong to the initial load path of the system, and
828
 
the modules they provide are compiled at installation time. So they
829
 
are directly accessible with the command \verb!Require! (see
830
 
chapter~\ref{Other-commands}). 
831
 
 
832
 
The different modules of the \Coq\ standard library are described in the
833
 
additional document \verb!Library.dvi!. They are also accessible on the WWW
834
 
through the \Coq\ homepage
835
 
\footnote{\texttt{http://coq.inria.fr}}.
836
 
 
837
 
\subsection{Notations for integer arithmetics}
838
 
\index{Arithmetical notations}
839
 
 
840
 
On figure \ref{zarith-syntax} is described the syntax of expressions
841
 
for integer arithmetics. It is provided by requiring and opening the
842
 
module {\tt ZArith} and opening scope {\tt Z\_scope}.
843
 
 
844
 
\ttindex{+}
845
 
\ttindex{*}
846
 
\ttindex{-}
847
 
\ttindex{/}
848
 
\ttindex{<=}
849
 
\ttindex{>=}
850
 
\ttindex{<}
851
 
\ttindex{>}
852
 
\ttindex{?=}
853
 
\ttindex{mod}
854
 
 
855
 
\begin{figure}
856
 
\begin{center}
857
 
\begin{tabular}{l|l|l|l}
858
 
Notation & Interpretation & Precedence & Associativity\\
859
 
\hline
860
 
\verb!_ < _! & {\tt Zlt} &&\\
861
 
\verb!x <= y! & {\tt Zle} &&\\
862
 
\verb!_ > _! & {\tt Zgt} &&\\
863
 
\verb!x >= y! & {\tt Zge} &&\\
864
 
\verb!x < y < z! & {\tt x < y \verb!/\! y < z} &&\\
865
 
\verb!x < y <= z! & {\tt x < y \verb!/\! y <= z} &&\\
866
 
\verb!x <= y < z! & {\tt x <= y \verb!/\! y < z} &&\\
867
 
\verb!x <= y <= z! & {\tt x <= y \verb!/\! y <= z} &&\\
868
 
\verb!_ ?= _! & {\tt Zcompare} & 70 & no\\
869
 
\verb!_ + _! & {\tt Zplus} &&\\
870
 
\verb!_ - _! & {\tt Zminus} &&\\
871
 
\verb!_ * _! & {\tt Zmult} &&\\
872
 
\verb!_ / _! & {\tt Zdiv} &&\\
873
 
\verb!_ mod _! & {\tt Zmod} & 40 & no \\
874
 
\verb!- _!  & {\tt Zopp} &&\\
875
 
\verb!_ ^ _! & {\tt Zpower} &&\\
876
 
\end{tabular}
877
 
\end{center}
878
 
\label{zarith-syntax}
879
 
\caption{Definition of the scope for integer arithmetics ({\tt Z\_scope})}
880
 
\end{figure}
881
 
 
882
 
Figure~\ref{zarith-syntax} shows the notations provided by {\tt
883
 
Z\_scope}. It specifies how notations are interpreted and, when not
884
 
already reserved, the precedence and associativity.
885
 
 
886
 
\begin{coq_example}
887
 
Require Import ZArith.
888
 
Check  (2 + 3)%Z.
889
 
Open Scope Z_scope.
890
 
Check 2 + 3.
891
 
\end{coq_example}
892
 
 
893
 
\subsection{Peano's arithmetic (\texttt{nat})}
894
 
\index{Peano's arithmetic}
895
 
\ttindex{nat\_scope}
896
 
 
897
 
While in the initial state, many operations and predicates of Peano's
898
 
arithmetic are defined, further operations and results belong to other
899
 
modules. For instance, the decidability of the basic predicates are
900
 
defined here. This is provided by requiring the module {\tt Arith}.
901
 
 
902
 
Figure~\ref{nat-syntax} describes notation available in scope {\tt
903
 
nat\_scope}.
904
 
 
905
 
\begin{figure}
906
 
\begin{center}
907
 
\begin{tabular}{l|l}
908
 
Notation & Interpretation \\
909
 
\hline
910
 
\verb!_ < _! & {\tt lt} \\
911
 
\verb!x <= y! & {\tt le} \\
912
 
\verb!_ > _! & {\tt gt} \\
913
 
\verb!x >= y! & {\tt ge} \\
914
 
\verb!x < y < z! & {\tt x < y \verb!/\! y < z} \\
915
 
\verb!x < y <= z! & {\tt x < y \verb!/\! y <= z} \\
916
 
\verb!x <= y < z! & {\tt x <= y \verb!/\! y < z} \\
917
 
\verb!x <= y <= z! & {\tt x <= y \verb!/\! y <= z} \\
918
 
\verb!_ + _! & {\tt plus} \\
919
 
\verb!_ - _! & {\tt minus} \\
920
 
\verb!_ * _! & {\tt mult} \\
921
 
\end{tabular}
922
 
\end{center}
923
 
\label{nat-syntax}
924
 
\caption{Definition of the scope for natural numbers ({\tt nat\_scope})}
925
 
\end{figure}
926
 
 
927
 
\subsection{Real numbers library}
928
 
 
929
 
\subsubsection{Notations for real numbers}
930
 
\index{Notations for real numbers}
931
 
 
932
 
This is provided by requiring and opening the module {\tt Reals} and
933
 
opening scope {\tt R\_scope}. This set of notations is very similar to
934
 
the notation for integer arithmetics. The inverse function was added.
935
 
\begin{figure}
936
 
\begin{center}
937
 
\begin{tabular}{l|l}
938
 
Notation & Interpretation \\
939
 
\hline
940
 
\verb!_ < _! & {\tt Rlt} \\
941
 
\verb!x <= y! & {\tt Rle} \\
942
 
\verb!_ > _! & {\tt Rgt} \\
943
 
\verb!x >= y! & {\tt Rge} \\
944
 
\verb!x < y < z! & {\tt x < y \verb!/\! y < z} \\
945
 
\verb!x < y <= z! & {\tt x < y \verb!/\! y <= z} \\
946
 
\verb!x <= y < z! & {\tt x <= y \verb!/\! y < z} \\
947
 
\verb!x <= y <= z! & {\tt x <= y \verb!/\! y <= z} \\
948
 
\verb!_ + _! & {\tt Rplus} \\
949
 
\verb!_ - _! & {\tt Rminus} \\
950
 
\verb!_ * _! & {\tt Rmult} \\
951
 
\verb!_ / _! & {\tt Rdiv} \\
952
 
\verb!- _!  & {\tt Ropp} \\
953
 
\verb!/ _!  & {\tt Rinv} \\
954
 
\verb!_ ^ _! & {\tt pow} \\
955
 
\end{tabular}
956
 
\end{center}
957
 
\label{reals-syntax}
958
 
\caption{Definition of the scope for real arithmetics ({\tt R\_scope})}
959
 
\end{figure}
960
 
 
961
 
\begin{coq_eval}
962
 
Reset Initial.
963
 
\end{coq_eval}
964
 
\begin{coq_example}
965
 
Require Import Reals.
966
 
Check  (2 + 3)%R.
967
 
Open Scope R_scope.
968
 
Check 2 + 3.
969
 
\end{coq_example}
970
 
 
971
 
\subsubsection{Some tactics}
972
 
 
973
 
In addition to the \verb|ring|, \verb|field| and \verb|fourier|
974
 
tactics (see Chapter~\ref{Tactics}) there are:
975
 
\begin{itemize}
976
 
\item {\tt discrR} \tacindex{discrR}
977
 
  
978
 
  Proves that a real integer constant $c_1$ is different from another
979
 
  real integer constant $c_2$.  
980
 
 
981
 
\begin{coq_example*}
982
 
Require Import DiscrR.
983
 
Goal 5 <> 0.
984
 
\end{coq_example*}
985
 
 
986
 
\begin{coq_example}
987
 
discrR.
988
 
\end{coq_example}
989
 
 
990
 
\begin{coq_eval}
991
 
Abort.
992
 
\end{coq_eval}
993
 
 
994
 
\item {\tt split\_Rabs} allows to unfold {\tt Rabs} constant and splits 
995
 
corresponding conjonctions.
996
 
\tacindex{split\_Rabs}
997
 
 
998
 
\begin{coq_example*}
999
 
Require Import SplitAbsolu.
1000
 
Goal forall x:R, x <= Rabs x.
1001
 
\end{coq_example*}
1002
 
 
1003
 
\begin{coq_example}
1004
 
intro; split_Rabs.
1005
 
\end{coq_example}
1006
 
 
1007
 
\begin{coq_eval}
1008
 
Abort.
1009
 
\end{coq_eval}
1010
 
 
1011
 
\item {\tt split\_Rmult} allows to split a condition that a product is
1012
 
  non null into subgoals corresponding to the condition on each
1013
 
  operand of the product. 
1014
 
\tacindex{split\_Rmult}
1015
 
 
1016
 
\begin{coq_example*}
1017
 
Require Import SplitRmult.
1018
 
Goal forall x y z:R, x * y * z <> 0.
1019
 
\end{coq_example*}
1020
 
 
1021
 
\begin{coq_example}
1022
 
intros; split_Rmult.
1023
 
\end{coq_example}
1024
 
 
1025
 
\end{itemize}
1026
 
 
1027
 
All this tactics has been written with the tactic language Ltac
1028
 
described in Chapter~\ref{TacticLanguage}.  More details are available
1029
 
in document \url{http://coq.inria.fr/~desmettr/Reals.ps}.
1030
 
 
1031
 
\begin{coq_eval}
1032
 
Reset Initial.
1033
 
\end{coq_eval}
1034
 
 
1035
 
\subsection{List library}
1036
 
\index{Notations for lists}
1037
 
\ttindex{length}
1038
 
\ttindex{head}
1039
 
\ttindex{tail}
1040
 
\ttindex{app}
1041
 
\ttindex{rev}
1042
 
\ttindex{nth}
1043
 
\ttindex{map}
1044
 
\ttindex{flat\_map}
1045
 
\ttindex{fold\_left}
1046
 
\ttindex{fold\_right}
1047
 
 
1048
 
Some elementary operations on polymorphic lists are defined here. They
1049
 
can be accessed by requiring module {\tt List}.
1050
 
 
1051
 
It defines the following notions:
1052
 
\begin{center}
1053
 
\begin{tabular}{l|l}
1054
 
\hline
1055
 
{\tt length} & length \\
1056
 
{\tt head} & first element (with default) \\
1057
 
{\tt tail} & all but first element \\
1058
 
{\tt app} & concatenation \\
1059
 
{\tt rev} & reverse \\
1060
 
{\tt nth} & accessing $n$-th element (with default) \\
1061
 
{\tt map} & applying a function \\
1062
 
{\tt flat\_map} & applying a function returning lists \\
1063
 
{\tt fold\_left} & iterator (from head to tail) \\
1064
 
{\tt fold\_right} & iterator (from tail to head) \\
1065
 
\hline
1066
 
\end{tabular}
1067
 
\end{center}
1068
 
 
1069
 
Table show notations available when opening scope {\tt list\_scope}.
1070
 
 
1071
 
\begin{figure}
1072
 
\begin{center}
1073
 
\begin{tabular}{l|l|l|l}
1074
 
Notation & Interpretation & Precedence & Associativity\\
1075
 
\hline
1076
 
\verb!_ ++ _! & {\tt app} & 60 & right \\
1077
 
\verb!_ :: _! & {\tt cons} & 60 & right \\
1078
 
\end{tabular}
1079
 
\end{center}
1080
 
\label{list-syntax}
1081
 
\caption{Definition of the scope for lists ({\tt list\_scope})}
1082
 
\end{figure}
1083
 
 
1084
 
 
1085
 
\section{Users' contributions}
1086
 
\index{Contributions}
1087
 
\label{Contributions}
1088
 
 
1089
 
Numerous users' contributions have been collected and are available at
1090
 
URL \url{coq.inria.fr/contribs/}.  On this web page, you have a list
1091
 
of all contributions with informations (author, institution, quick
1092
 
description, etc.) and the possibility to download them one by one.
1093
 
There is a small search engine to look for keywords in all
1094
 
contributions.  You will also find informations on how to submit a new
1095
 
contribution.
1096
 
 
1097
 
The users' contributions may also be obtained by anonymous FTP from site
1098
 
\verb:ftp.inria.fr:, in directory \verb:INRIA/coq/: and
1099
 
searchable on-line at \url{http://coq.inria.fr/contribs-eng.html}
1100
 
 
1101
 
% $Id: RefMan-lib.tex 9594 2007-02-05 15:20:08Z herbelin $ 
1102
 
 
1103
 
%%% Local Variables: 
1104
 
%%% mode: latex
1105
 
%%% TeX-master: "Reference-Manual"
1106
 
%%% End: