aboutsummaryrefslogtreecommitdiff
path: root/doc/refman/RefMan-syn.tex
diff options
context:
space:
mode:
Diffstat (limited to 'doc/refman/RefMan-syn.tex')
-rw-r--r--doc/refman/RefMan-syn.tex98
1 files changed, 58 insertions, 40 deletions
diff --git a/doc/refman/RefMan-syn.tex b/doc/refman/RefMan-syn.tex
index ecaf82806e..084317776b 100644
--- a/doc/refman/RefMan-syn.tex
+++ b/doc/refman/RefMan-syn.tex
@@ -13,7 +13,7 @@ described in Section~\ref{scopes}.
were present for a while in {\Coq} are no longer available from {\Coq}
version 8.0. The underlying AST structure is also no longer available.
The functionalities of the command {\tt Syntactic Definition} are
-still available, see Section~\ref{Abbreviations}.
+still available; see Section~\ref{Abbreviations}.
\section[Notations]{Notations\label{Notation}
\comindex{Notation}}
@@ -35,8 +35,8 @@ The expression \texttt{(and A B)} is the abbreviated term and the
string \verb="A /\ B"= (called a {\em notation}) tells how it is
symbolically written.
-A notation is always surrounded by double quotes (excepted when the
-abbreviation is a single identifier, see \ref{Abbreviations}). The
+A notation is always surrounded by double quotes (except when the
+abbreviation is a single identifier; see \ref{Abbreviations}). The
notation is composed of {\em tokens} separated by spaces. Identifiers
in the string (such as \texttt{A} and \texttt{B}) are the {\em
parameters} of the notation. They must occur at least once each in the
@@ -68,7 +68,7 @@ declaration of the notation.
\subsection[Precedences and associativity]{Precedences and associativity\index{Precedences}
\index{Associativity}}
-Mixing different symbolic notations in a same text may cause serious
+Mixing different symbolic notations in the same text may cause serious
parsing ambiguity. To deal with the ambiguity of notations, {\Coq}
uses precedence levels ranging from 0 to 100 (plus one extra level
numbered 200) and associativity rules.
@@ -88,8 +88,8 @@ precedence level to each notation, knowing that a lower level binds
more than a higher level. Hence the level for disjunction must be
higher than the level for conjunction.
-Since connectives are the less tight articulation points of a text, it
-is reasonable to choose levels not so far from the higher level which
+Since connectives are not tight articulation points of a text, it
+is reasonable to choose levels not so far from the highest level which
is 100, for example 85 for disjunction and 80 for
conjunction\footnote{which are the levels effectively chosen in the
current implementation of {\Coq}}.
@@ -102,10 +102,10 @@ even consider that the expression is not well-formed and that
parentheses are mandatory (this is a ``no associativity'')\footnote{
{\Coq} accepts notations declared as no associative but the parser on
which {\Coq} is built, namely {\camlpppp}, currently does not implement the
-no-associativity and replace it by a left associativity; hence it is
+no-associativity and replaces it by a left associativity; hence it is
the same for {\Coq}: no-associativity is in fact left associativity}.
We don't know of a special convention of the associativity of
-disjunction and conjunction, let's apply for instance a right
+disjunction and conjunction, so let's apply for instance a right
associativity (which is the choice of {\Coq}).
Precedence levels and associativity rules of notations have to be
@@ -701,11 +701,11 @@ Notation}.
% Introduction
An {\em interpretation scope} is a set of notations for terms with
-their interpretation. Interpretation scopes provides with a weak,
-purely syntactical form of notations overloading: a same notation, for
-instance the infix symbol \verb=+= can be used to denote distinct
-definitions of an additive operator. Depending on which interpretation
-scopes is currently open, the interpretation is different.
+their interpretation. Interpretation scopes provide a weak,
+purely syntactical form of notation overloading: the same notation, for
+instance the infix symbol \verb=+=, can be used to denote distinct
+definitions of the additive operator. Depending on which interpretation
+scope is currently open, the interpretation is different.
Interpretation scopes can include an interpretation for
numerals and strings. However, this is only made possible at the
{\ocaml} level.
@@ -889,7 +889,8 @@ statically. For instance, if {\tt f} is a polymorphic function of type
recognized as an argument to be interpreted in scope {\scope}.
\comindex{Bind Scope}
-More generally, any {\class} (see Chapter~\ref{Coercions-full}) can be
+\label{bindscope}
+More generally, any coercion {\class} (see Chapter~\ref{Coercions-full}) can be
bound to an interpretation scope. The command to do it is
\begin{quote}
{\tt Bind Scope} {\scope} \texttt{with} {\class}
@@ -908,7 +909,7 @@ Open Scope nat_scope. (* Define + on the nat as the default for + *)
Check (fun x y1 y2 z t => P _ (x + t) ((f _ (y1 + y2) + z))).
\end{coq_example}
-\Rem The scope {\tt type\_scope} has also a local effect on
+\Rem The scopes {\tt type\_scope} and {\tt function\_scope} also have a local effect on
interpretation. See the next section.
\SeeAlso The command to show the scopes bound to the arguments of a
@@ -940,10 +941,21 @@ Check # @@%mybool #.
The scope {\tt type\_scope} has a special status. It is a primitive
interpretation scope which is temporarily activated each time a
-subterm of an expression is expected to be a type. This includes goals
-and statements, types of binders, domain and codomain of implication,
-codomain of products, and more generally any type argument of a
-declared or defined constant.
+subterm of an expression is expected to be a type. It is delimited by
+the key {\tt type}, and bound to the coercion class {\tt Sortclass}. It is also
+used in certain situations where an expression is statically known to
+be a type, including the conclusion and the type of hypotheses within
+an {\tt Ltac} goal match (see Section~\ref{ltac-match-goal})
+the statement of a theorem, the type of
+a definition, the type of a binder, the domain and codomain of
+implication, the codomain of products, and more generally any type
+argument of a declared or defined constant.
+
+\subsection[The {\tt function\_scope} interpretation scope]{The {\tt function\_scope} interpretation scope\index{function\_scope@\texttt{function\_scope}}}
+
+The scope {\tt function\_scope} also has a special status.
+It is temporarily activated each time the argument of a global reference is
+recognized to be a {\tt Funclass instance}, i.e., of type {\tt forall x:A, B} or {\tt A -> B}.
\subsection{Interpretation scopes used in the standard library of {\Coq}}
@@ -953,38 +965,39 @@ commands {\tt Print Scopes} or {\tt Print Scope {\scope}}.
\subsubsection{\tt type\_scope}
-This includes infix {\tt *} for product types and infix {\tt +} for
-sum types. It is delimited by key {\tt type}.
+This scope includes infix {\tt *} for product types and infix {\tt +} for
+sum types. It is delimited by key {\tt type}, and bound to the coercion class
+{\tt Sortclass}, as described at \ref{bindscope}.
\subsubsection{\tt nat\_scope}
-This includes the standard arithmetical operators and relations on
+This scope includes the standard arithmetical operators and relations on
type {\tt nat}. Positive numerals in this scope are mapped to their
canonical representent built from {\tt O} and {\tt S}. The scope is
-delimited by key {\tt nat}.
+delimited by key {\tt nat}, and bound to the type {\tt nat} (see \ref{bindscope}).
\subsubsection{\tt N\_scope}
-This includes the standard arithmetical operators and relations on
+This scope includes the standard arithmetical operators and relations on
type {\tt N} (binary natural numbers). It is delimited by key {\tt N}
and comes with an interpretation for numerals as closed term of type {\tt Z}.
\subsubsection{\tt Z\_scope}
-This includes the standard arithmetical operators and relations on
+This scope includes the standard arithmetical operators and relations on
type {\tt Z} (binary integer numbers). It is delimited by key {\tt Z}
and comes with an interpretation for numerals as closed term of type {\tt Z}.
\subsubsection{\tt positive\_scope}
-This includes the standard arithmetical operators and relations on
+This scope includes the standard arithmetical operators and relations on
type {\tt positive} (binary strictly positive numbers). It is
delimited by key {\tt positive} and comes with an interpretation for
numerals as closed term of type {\tt positive}.
\subsubsection{\tt Q\_scope}
-This includes the standard arithmetical operators and relations on
+This scope includes the standard arithmetical operators and relations on
type {\tt Q} (rational numbers defined as fractions of an integer and
a strictly positive integer modulo the equality of the
numerator-denominator cross-product). As for numerals, only $0$ and
@@ -993,13 +1006,13 @@ interpretations are $\frac{0}{1}$ and $\frac{1}{1}$ respectively).
\subsubsection{\tt Qc\_scope}
-This includes the standard arithmetical operators and relations on the
+This scope includes the standard arithmetical operators and relations on the
type {\tt Qc} of rational numbers defined as the type of irreducible
fractions of an integer and a strictly positive integer.
\subsubsection{\tt real\_scope}
-This includes the standard arithmetical operators and relations on
+This scope includes the standard arithmetical operators and relations on
type {\tt R} (axiomatic real numbers). It is delimited by key {\tt R}
and comes with an interpretation for numerals as term of type {\tt
R}. The interpretation is based on the binary decomposition. The
@@ -1014,35 +1027,40 @@ those of {\tt R}.
\subsubsection{\tt bool\_scope}
-This includes notations for the boolean operators. It is
-delimited by key {\tt bool}.
+This scope includes notations for the boolean operators. It is
+delimited by key {\tt bool}, and bound to the type {\tt bool} (see \ref{bindscope}).
\subsubsection{\tt list\_scope}
-This includes notations for the list operators. It is
-delimited by key {\tt list}.
+This scope includes notations for the list operators. It is
+delimited by key {\tt list}, and bound to the type {\tt list} (see \ref{bindscope}).
+
+\subsubsection{\tt function\_scope}
+
+This scope is delimited by the key {\tt function}, and bound to the coercion class {\tt Funclass},
+as described at \ref{bindscope}.
\subsubsection{\tt core\_scope}
-This includes the notation for pairs. It is delimited by key {\tt core}.
+This scope includes the notation for pairs. It is delimited by key {\tt core}.
\subsubsection{\tt string\_scope}
-This includes notation for strings as elements of the type {\tt
+This scope includes notation for strings as elements of the type {\tt
string}. Special characters and escaping follow {\Coq} conventions
on strings (see Section~\ref{strings}). Especially, there is no
convention to visualize non printable characters of a string. The
file {\tt String.v} shows an example that contains quotes, a newline
-and a beep (i.e. the ascii character of code 7).
+and a beep (i.e. the ASCII character of code 7).
\subsubsection{\tt char\_scope}
-This includes interpretation for all strings of the form
-\verb!"!$c$\verb!"! where $c$ is an ascii character, or of the form
+This scope includes interpretation for all strings of the form
+\verb!"!$c$\verb!"! where $c$ is an ASCII character, or of the form
\verb!"!$nnn$\verb!"! where $nnn$ is a three-digits number (possibly
with leading 0's), or of the form \verb!""""!. Their respective
-denotations are the ascii code of $c$, the decimal ascii code $nnn$,
-or the ascii code of the character \verb!"! (i.e. the ascii code
+denotations are the ASCII code of $c$, the decimal ASCII code $nnn$,
+or the ASCII code of the character \verb!"! (i.e. the ASCII code
34), all of them being represented in the type {\tt ascii}.
\subsection{Displaying informations about scopes}