]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/papers/matita/matita2.tex
community review, solved a couple of TODO
[helm.git] / helm / papers / matita / matita2.tex
index 516eacbdecf0eca85014b6b26d46f2ee21097fee..88f664c2dcbf911e5acffd7fa2d8841a184f4077 100644 (file)
@@ -60,7 +60,7 @@
 \newcommand{\URI}[1]{\texttt{#1}}
 \newcommand{\OP}[1]{``\texttt{#1}''}
 \newcommand{\FILE}[1]{\texttt{#1}}
-\newcommand{\NOTE}[1]{\ednote{#1}{}}
+\newcommand{\TAC}[1]{\texttt{#1}}
 \newcommand{\TODO}[1]{\textbf{TODO: #1}}
 
 \definecolor{gray}{gray}{0.85} % 1 -> white; 0 -> black
@@ -136,10 +136,11 @@ features.
 The origins of \MATITA{} go back to 1999. At the time we were mostly 
 interested in developing tools and techniques to enhance the accessibility
 via Web of libraries of formalized mathematics. Due to its dimension, the
-library of the \COQ~\cite{CoqManual} proof assistant (of the order of 35'000 theorems) 
+library of the \COQ~\cite{CoqManual} proof assistant (of the order of
+35'000 theorems) 
 was chosen as a privileged test bench for our work, although experiments
 have been also conducted with other systems, and notably 
-with \NUPRL~\cite{nuprl-book}.\TODO{citare la tesi di vincenzo(?)}
+with \NUPRL~\cite{nuprl-book}.
 The work, mostly performed in the framework of the recently concluded 
 European project \MOWGLIIST{} \MOWGLI~\cite{pechino}, mainly consisted in the 
 following steps:
@@ -465,7 +466,8 @@ presentation level terms.
 Omitted subterms can bear no information at all or they may be associated to
 a sequent. The formers are called \emph{implicit terms} and they occur only
 linearly. The latters may occur multiple times and are called
-\emph{metavariables}. An \emph{explicit substitution} is applied to each
+\emph{metavariables}~\cite{geuvers-jojgov,munoz}.
+An \emph{explicit substitution} is applied to each
 occurrence of a metavariable. A metavariable stands for a term whose type is
 given by the conclusion of the sequent. The term must be closed in the
 context that is given by the ordered list of hypotheses of the sequent.
@@ -479,9 +481,9 @@ metavariables and that can introduce
 \emph{implicit coercions}~\cite{barthe95implicit} to make a
 partially specified term well-typed. The refiner of \MATITA{} is implemented
 in the \texttt{cic\_unification} \component. As the type checker is based on
-the conversion check, the refiner is based on \emph{unification} that is
-a procedure that makes two partially specified term convertible by instantiating
-as few as possible metavariables that occur in them.
+the conversion check, the refiner is based on \emph{unification}~\cite{strecker}
+that is a procedure that makes two partially specified term convertible by
+instantiating as few as possible metavariables that occur in them.
 
 Since terms are used in CIC to represent proofs, correct incomplete
 proofs are represented by refinable partially specified terms. The metavariables
@@ -963,7 +965,7 @@ disambiguator fails, disambiguation is tried again with a less strict set of
 preferences.
 
 Several disambiguation parameters can vary among passes. With respect to
-preference handling we implemented 3 passes.  In the first pass, called
+preference handling we implemented three passes.  In the first pass, called
 \emph{mono-preferences}, we consider only the aliases corresponding to the
 current set of preferences.  In the second pass, called
 \emph{multi-preferences}, we
@@ -1117,7 +1119,7 @@ library.
 
 \subsubsection{Invalidation}
 
-Invalidation (see Sect.~\ref{sec:library}) is implemented in 2 phases.
+Invalidation (see Sect.~\ref{sec:library}) is implemented in two phases.
 
 The first one is the calculation of all the concepts that recursively
 depend on the ones we are invalidating. It can be performed
@@ -1152,9 +1154,9 @@ To compute dependencies it is enough to look at the script files for
 literal of included explicit disambiguation preferences
 (see Sect.~\ref{sec:disambaliases}). 
 
-\TODO{da rivedere: da dove salta fuori ``regenerating content''?}
-Regenerating the content of a modified script file involves the preliminary
-invalidation of all its old content.
+The re-execution of a script to regenerate part of the library
+requires the preliminary invalidation of the concepts generated by the
+script.
 
 \subsubsection{Batch vs Interactive}
 
@@ -1165,37 +1167,38 @@ Only the former is intended to be used directly by the
 user, the latter is automatically invoked by \MATITA{}
 to regenerate parts of the library previously invalidated.
 
-\TODO{come sopra: ``content of a script''?}
 While they share the same engine for generation and invalidation, they
 provide different granularity. \MATITAC{} is only able to re-execute a
-whole script and similarly to invalidate the whole content of a script
-(together with all the other scripts that rely on a concept defined
+whole script and similarly to invalidate all the concepts generated
+by a script (together with all the other scripts that rely on a concept defined
 in it). 
 
 \subsection{Automation}
 \label{sec:automation}
-In the long run, one would expect to work with a Proof Assistant 
-like Matita, using only three basic tactics: Intro, Elim, and Auto
-(possibly integrated by a moderate use of Cut). The state of the art
+
+In the long run, one would expect to work with a proof assistant 
+like \MATITA, using only three basic tactics: \TAC{intro}, \TAC{elim},
+and \TAC{auto}
+(possibly integrated by a moderate use of \TAC{cut}). The state of the art
 in automated deduction is still far away from this goal, but 
-this is one of the main development direction of Matita
+this is one of the main development direction of \MATITA
 
-Even in this field, the underlying phisolophy of Matita is to 
+Even in this field, the underlying philosophy of \MATITA{} is to 
 free the user from any burden relative to the overall management
-of the library. For instance, in Coq, the user is responsible to 
+of the library. For instance, in \COQ, the user is responsible to 
 define small collections of theorems to be used as a parameter 
-by the Auto tactic;
-in Matita, it is the system itself that authomatically retrieves, from
+by the \TAC{auto} tactic;
+in \MATITA, it is the system itself that automatically retrieves, from
 the whole library, a subset of theorems worth to be considered 
 according to the signature of the current goal and context. 
 
-The basic tactic merely performs an iterated use of the Apply tactic
-(with no Intro). The research tree may be pruned according to two 
-main parameters: the {\em depth} (whit the obvious meaning), and the 
-{\em width} that is the maximum number of (new) open goals allowed at
-any instant. Matita has only one notion of metavariable, corresponding
-to the so called existential variables of Coq; so, Matita's Auto tactic
-should be compared with Coq's EAuto. 
+The basic tactic merely iterates the use of the \TAC{apply} tactic
+(with no \TAC{intro}). The search tree may be pruned according to two
+main parameters: the \emph{depth} (whit the obvious meaning), and the 
+\emph{width} that is the maximum number of (new) open goals allowed at
+any instant. \MATITA{} has only one notion of metavariable, corresponding
+to the so called existential variables of Coq; so, \MATITA's \TAC{auto}
+tactic should be compared with \COQ's \TAC{EAuto} tactic.
 
 Recently we have extended automation with paramodulation based 
 techniques. At present, the system works reasonably well with
@@ -1204,51 +1207,51 @@ and can be specified by the user: the system only requires
 a proof of {\em reflexivity} and {\em paramodulation} (or rewriting, 
 as it is usually called in the proof assistant community).
 
-Given an equational goal, Matita recovers all known equational facts
+Given an equational goal, \MATITA{} recovers all known equational facts
 from the library (and the local context), applying a variant of
-the so called {\em given-clause algorithm} \cite{paramodulation}, 
-that is the the procedure currently used by the majority of modern theorem 
-provers. 
+the so called {\em given-clause algorithm}~\cite{paramodulation}, 
+that is the the procedure currently used by the majority of modern
+automatic theorem provers. 
 
 The given-clause algorithm is essentially composed by an alternation
-of a {\em saturation} phase, deriving new facts by a set of active
-facts and a new {\em given} clause suitably selected from a set of passive
-equations, 
-and a {\em demodulation} phase that tries to simplify the equations
-orienting them according to a suitable weight associated with terms.
-Matita currently supports several different weigthing functions
+of a \emph{saturation} phase and a \emph{demodulation} phase.
+The former derives new facts by a set of active
+facts and a new \emph{given} clause suitably selected from a set of passive
+equations. The latter tries to simplify the equations
+orienting them according to a suitable weight associated to terms.
+\MATITA{} currently supports several different weigthing functions
 comprising Knuth-Bendix ordering (kbo) and recursive path ordering (rpo), 
-that integrates particualry well with normalization.
+that integrates particularly well with normalization.
 
 Demodulation alone is already a quite powerful technique, and 
-it has been turned into a tactic by itself: the {\em demodulate}
-tactic, which can be seen as a kind of generalization of {\em simplify}. 
+it has been turned into a tactic by itself: the \TAC{demodulate}
+tactic, which can be seen as a kind of generalization of \TAC{simplify}. 
 The following portion of script describes two
 interesting cases of application of this tactic (both of them relying 
 on elementary arithmetic equations):
 
-\begin{verbatim}
+\begin{grafite}
 theorem example1: 
-  \forall x:nat. (x+1)*(x-1)=x*x - 1.
+  \forall x: nat. (x+1)*(x-1) = x*x - 1.
 intro.
-apply (nat_case x)
-[simplify;reflexivity
-|intro;demodulate;reflexivity]
+apply (nat_case x);
+  [ simplify; reflexivity
+  | intro; demodulate; reflexivity ]
 qed.
+\end{grafite}
 
+\begin{grafite}
 theorem example2: 
-  \forall x,y:nat. (x+y)*(x+y) = x*x + 2*x*y + y*y.
-intros;demodulate;reflexivity.
+  \forall x, y: nat. (x+y)*(x+y) = x*x + 2*x*y + y*y.
+intros; demodulate; reflexivity
 qed.
-\end{verbatim}
+\end{grafite}
 
 In the future we expect to integrate applicative and equational 
 rewriting. In particular, the overall idea would be to integrate
 applicative rewriting with demodulation, treating saturation as an
 operation to be performed in batch mode, e.g. during the night. 
 
-
-
 \subsection{Naming convention}
 \label{sec:naming}
 
@@ -1266,7 +1269,7 @@ The basic rules are the following:
  \item all names should (but this is not strictly compulsory) 
   separated by an underscore;
 
- \item names occurring in 2 different hypotheses, or in an hypothesis
+ \item names occurring in two different hypotheses, or in an hypothesis
   and in the conclusion must be separated by the string \texttt{\_to\_};
 
  \item the identifier may be followed by a numerical suffix, or a
@@ -1276,7 +1279,7 @@ The basic rules are the following:
 
 Take for instance the statement:
 \begin{grafite}
- \forall n: nat. n = plus n O
+\forall n: nat. n = plus n O
 \end{grafite}
 Possible legal names are: \texttt{plus\_n\_O}, \texttt{plus\_O}, 
 \texttt{eq\_n\_plus\_n\_O} and so on.
@@ -1294,9 +1297,9 @@ The correct approach,
 in this case, is the following. You should start with defining the 
 symmetric property for relations:
 \begin{grafite}
-definition symmetric =
+definition symmetric \def
   \lambda A: Type. \lambda R. \forall x, y: A.
-    R x y \to R y x
+    R x y \to R y x.
 \end{grafite}
 Then, you may state the symmetry of equality as:
 \begin{grafite}
@@ -1335,25 +1338,29 @@ expression and the suffix \texttt{\_to\_Prop}. In the above example,
 \section{The authoring interface}
 \label{sec:authoring}
 
-The authoring interface of \MATITA{} is very similar to Proof General.  We
+The authoring interface of \MATITA{} is very similar to Proof
+General~\cite{proofgeneral}.  We
 chose not to build the \MATITA{} UI over Proof General for two reasons. First
 of all we wanted to integrate our XML-based rendering technologies, mainly
-\GTKMATHVIEW. At the time of writing Proof General supports only text based
-rendering.\footnote{This may change with the future release of Proof General
-based on Eclipse, but is not yet the case.} The second reason is that we wanted
-to build the \MATITA{} UI on top of a state-of-the-art and widespread toolkit
-as \GTK{} is.
+\GTKMATHVIEW, in the UI.
+At the time of writing Proof General supports only text based
+rendering.\footnote{This may change with future releases of Proof General
+based on Eclipse (\url{http://www.eclipse.org/}), but is not yet the
+case.} The second reason is that we wanted
+to build the \MATITA{} UI on top of a state-of-the-art and widespread graphical
+toolkit as \GTK{} is.
 
 Fig.~\ref{fig:screenshot} is a screenshot of the \MATITA{} authoring interface,
 featuring two windows. The background one is very like to the Proof General
 interface. The main difference is that we use the \GTKMATHVIEW{} widget to
 render sequents. Since \GTKMATHVIEW{} renders \MATHML{} markup we take
 advantage of the whole bidimensional mathematical notation. The foreground
-window is an instance of the cicBrowser used to render the proof being
-developed.
+window is an instance of the cicBrowser (see Sect.~\ref{sec:library}) used to
+render in natural language the proof being developed.
 
-Note that the syntax used in the script view is \TeX-like, however Unicode is 
-fully supported so that mathematical glyphs can be input as such.
+Note that the syntax used in the script view is \TeX-like, but
+Unicode\footnote{\url{http://www.unicode.org/}} is 
+also fully supported so that mathematical glyphs can be input as such.
 
 \begin{figure}[!ht]
  \begin{center}
@@ -1378,14 +1385,14 @@ layout schemata like radicals and matrices) and the use of a
 concise and widespread textual syntax.
 
 Keeping pointers from the presentations level terms down to the
-partially specified ones \MATITA{} enable direct manipulation of
+partially specified ones, \MATITA{} enables direct manipulation of
 rendered (sub)terms in the form of hyperlinks and semantic selection.
 
 \emph{Hyperlinks} have anchors on the occurrences of constant and
 inductive type constructors and point to the corresponding definitions
 in the library. Anchors are available notwithstanding the use of
 user-defined mathematical notation: as can be seen on the right of
-Fig.~\ref{fig:directmanip}, where we clicked on $\not|$, symbols
+Fig.~\ref{fig:directmanip}, where we clicked on $\nmid$, symbols
 encoding complex notations retain all the hyperlinks of constants or
 constructors used in the notation.
 
@@ -1395,9 +1402,8 @@ representing meaningful CIC (sub)terms. In the example on the left of
 Fig.~\ref{fig:directmanip} is thus possible to select the subterm
 $\mathrm{prime}~n$, whereas it would not be possible to select
 $\to n$ since the former denotes an application while the
-latter it not a subterm. Once a meaningful (sub)term has been
-selected actions can be done on it like reductions or tactic
-applications.
+latter is not a subterm. Once a meaningful (sub)term has been
+selected actions like reductions or tactic applications can be performed on it.
 
 \begin{figure}[!ht]
  \begin{center}
@@ -1420,8 +1426,9 @@ Nonetheless we need to record actions and selections in scripts.
 
 In \MATITA{} \emph{patterns} are textual representations of selections.
 Users can select using the GUI and then ask the system to paste the
-corresponding pattern in this script, but more often this process is
-transparent: once an action is performed on a selection, the corresponding
+corresponding pattern in this script. More often this process is
+transparent to the user: once an action is performed on a selection,
+the corresponding
 textual command is computed and inserted in the script.
 
 \subsubsection{Pattern syntax}
@@ -1430,8 +1437,8 @@ Patterns are composed of two parts: \NT{sequent\_path} and
 \NT{wanted}; their concrete syntax is reported in Tab.~\ref{tab:pathsyn}.
 
 \NT{sequent\_path} mocks-up a sequent, discharging unwanted subterms
-with $?$ and selecting the interesting parts with the placeholder
-$\%$.  \NT{wanted} is a term that lives in the context of the
+with \OP{?} and selecting the interesting parts with the placeholder
+\OP{\%}.  \NT{wanted} is a term that lives in the context of the
 placeholders.
 
 Textual patterns produced from a graphical selection are made of the
@@ -1460,46 +1467,40 @@ help the users in writing concise and elegant patterns by hand.
 \subsubsection{Pattern evaluation}
 
 Patterns are evaluated in two phases. The first selects roots
-(subterms) of the sequent, using the $\NT{sequent\_path}$,  while the
-second searches the $\NT{wanted}$ term starting from these roots.
+(subterms) of the sequent, using the \NT{sequent\_path}, while the
+second searches the \NT{wanted} term starting from that roots.
 % Both are optional steps, and by convention the empty pattern selects
 % the whole conclusion.
 
 \begin{description}
 \item[Phase 1]
-  concerns only the $[~\verb+in+~\NT{sequent\_path}~]$
-  part of the syntax. $\NT{ident}$ is an hypothesis name and
-  selects the assumption where the following optional $\NT{multipath}$
-  will operate. \verb+\vdash+ can be considered the name for the goal.
-  If the whole pattern is omitted, the whole goal will be selected.
-  If one or more hypotheses names are given the selection is restricted to 
-  these assumptions. If a $\NT{multipath}$ is omitted the whole
-  assumption is selected. Remember that the user can be mostly
-  unaware of this syntax, since the system is able to write down a 
-  $\NT{sequent\_path}$ starting from a visual selection.
-  \NOTE{Questo ancora non va in matita}
-
-  A $\NT{multipath}$ is a CIC term in which a special constant $\%$
-  is allowed.
-  The roots of discharged subterms are marked with $?$, while $\%$
-  is used to select roots. The default $\NT{multipath}$, the one that
-  selects the whole term, is simply $\%$.
-  Valid $\NT{multipath}$ are, for example, $(?~\%~?)$ or $\%~\verb+\to+~(\%~?)$
-  that respectively select the first argument of an application or
-  the source of an arrow and the head of the application that is
-  found in the arrow target.
-
-  The first phase not only selects terms (roots of subterms) but
-  determines also their context that will be eventually used in the
-  second phase.
+  concerns only \NT{sequent\_path}. \NT{ident} is an hypothesis name and selects
+  the assumption where the following optional \NT{multipath} will operate.
+  \verb+\vdash+ can be considered the name for the goal.  If the whole pattern
+  is omitted, the whole goal will be selected.  If one or more hypothesis names
+  are given, the selection is restricted to that assumptions. If a
+  $\NT{multipath}$ is omitted the whole assumption is selected. Remember that
+  the user can be mostly unaware of patterns concrete syntax, since the system
+  is able to write down a \NT{sequent\_path} starting from a graphical
+  selection.
+
+  A \NT{multipath} is a CIC term in which a special constant \OP{\%} is allowed.
+  The roots of discharged subterms are marked with \OP{?}, while \OP{\%} is used
+  to select roots.  The default \NT{multipath}, the one that selects the whole
+  term, is simply \OP{\%}.  Valid \NT{multipath} are, for example, \texttt{(? \%
+  ?)} or \texttt{\% \TEXMACRO{to} (\% ?)} that respectively select the first
+  argument of an application or the source of an arrow and the head of the
+  application that is found in the arrow target.
+
+  This phase not only selects terms (roots of subterms) but determines also
+  their context that will be possibly used in the next phase.
 
 \item[Phase 2] 
-  plays a role only if the $[~\verb+match+~\NT{wanted}~]$
-  part is specified. From the first phase we have some terms, that we
-  will see as subterm roots, and their context. For each of these
-  contexts the $\NT{wanted}$ term is disambiguated in it and the
-  corresponding root is searched for a subterm that can be unified to
-  $\NT{wanted}$. The result of this search is the selection the
+  plays a role only if \NT{wanted} is specified. From the first phase we
+  have some terms, that we will use as roots, and their context.
+  For each of these contexts the \NT{wanted} term is disambiguated in it
+  and the corresponding root is searched for a subterm that can be unified to
+  \NT{wanted}. The result of this search is the selection the
   pattern represents.
 
 \end{description}
@@ -1515,33 +1516,30 @@ second searches the $\NT{wanted}$ term starting from these roots.
 %  intros (n m H).
 %\end{grafite}
 
-Consider the following sequent 
-\sequent{
-n:nat\\
-m:nat\\
-H: m + n = n}{
-m=O
-}
+Consider the following sequent:
+\sequent{n: nat\\m: nat\\H: m + n = n}{m = O}
 
-To change the right part of the equivalence of the $H$
-hypothesis with $O + n$ the user selects and pastes it as the pattern
+To change the right part of the equality of the \texttt{H}
+hypothesis with \texttt{O + n}, the user selects and pastes it as the pattern
 in the following statement.
 \begin{grafite}
   change in H:(? ? ? %) with (O + n).
 \end{grafite}
 
 To understand the pattern (or produce it by hand) the user should be
-aware that the notation $m+n=n$ hides the term $(eq~nat~(m+n)~n)$, so
-that the pattern selects only the third argument of $eq$.
+aware that the notation \texttt{m + n = n} hides the term
+\texttt{eq nat (m + n) n}, so
+that the pattern selects only the third argument of \texttt{eq}.
 
 The experienced user may also write by hand a concise pattern
-to change at once all the occurrences of $n$ in the hypothesis $H$:
+to change at once all the occurrences of \texttt{n} in the hypothesis
+\texttt{H}:
 \begin{grafite}
   change in H match n with (O + n).
 \end{grafite}
 
-In this case the $\NT{sequent\_path}$ selects the whole $H$, while
-the second phase locates $n$.
+In this case the \NT{sequent\_path} selects the whole \texttt{H}, while
+the second phase locates \texttt{n}.
 
 The latter pattern is equivalent to the following one, that the system
 can automatically generate from the selection.
@@ -1549,81 +1547,64 @@ can automatically generate from the selection.
   change in H:(? ? (? ? %) %) with (O + n).
 \end{grafite}
 
-\subsubsection{Tactics supporting patterns}
-
-\TODO{Grazie ai pattern, rispetto a Coq noi abbiamo per esempio la possibilita' di fare riduzioni profonde!!!}
-
-\TODO{mergiare con il successivo facendo notare che i patterns sono una
-interfaccia comune per le tattiche}
-
-In \MATITA{} all the tactics that can be restricted to subterm of the working
-sequent accept the pattern syntax. In particular these tactics are: simplify,
-change, fold, unfold, generalize, replace and rewrite.
+\subsubsection{Comparison with \COQ{}}
 
-\NOTE{attualmente rewrite e fold non supportano phase 2. per
-supportarlo bisogna far loro trasformare il pattern phase1+phase2 
-in un pattern phase1only come faccio nell'ultimo esempio. lo si fa
-con una pattern\_of(select(pattern))}
+In \MATITA{} all the tactics that act on subterms of the current sequent
+accept pattern arguments. Additional arguments can be disambiguated in the
+contexts of the terms selected by the pattern
+(\emph{context-dependent arguments}).
 
-\subsubsection{Comparison with \COQ{}}
+%\NOTE{attualmente rewrite e fold non supportano fase 2. per
+%supportarlo bisogna far loro trasformare il pattern phase1+phase2 
+%in un pattern phase1only come faccio nell'ultimo esempio. lo si fa
+%con una pattern\_of(select(pattern))}
 
 \COQ{} has two different ways of restricting the application of tactics to
-subterms of the sequent, both relaying on the same special syntax to identify
-a term occurrence.
+subterms of the current sequent, both relying on the same special syntax to
+identify a term occurrence.
 
 The first way is to use this special syntax to tell the
 tactic what occurrences of a wanted term should be affected.
 The second is to prepare the sequent with another tactic called
-pattern and then apply the real tactic. Note that the choice is not
+\TAC{pattern} and then apply the real tactic. Note that the choice is not
 left to the user, since some tactics needs the sequent to be prepared
 with pattern and do not accept directly this special syntax.
 
-The base idea is that to identify a subterm of the sequent we can
-write it and say that we want, for example, the third and the fifth
-occurrences of it (counting from left to right). In our previous example,
+The idea is that to identify a subterm of the sequent we can
+write it and say that we want, for example, its third and fifth
+occurrences (counting from left to right). In our previous example,
 to change only the left part of the equivalence, the correct command
-is:
-
+would be:
 \begin{grafite}
   change n at 2 in H with (O + n)
 \end{grafite} 
+meaning that in the hypothesis \texttt{H} the \texttt{n} we want to change is
+the second we encounter proceeding from left to right.
 
-meaning that in the hypothesis $H$ the $n$ we want to change is the
-second we encounter proceeding from left to right.
-
-The tactic pattern computes a
+The tactic \TAC{pattern} computes a
 $\beta$-expansion of a part of the sequent with respect to some
 occurrences of the given term. In the previous example the following
 command:
 \begin{grafite}
   pattern n at 2 in H
 \end{grafite}
-
 would have resulted in this sequent:
-
-\begin{grafite}
-  n : nat
-  m : nat
-  H : (fun n0 : nat => m + n = n0) n
-  ============================
-   m = 0
-\end{grafite}
-
-where $H$ is $\beta$-expanded over the second $n$
+\sequent{n: nat\\m : nat\\H: (fun n0: nat => m + n = n0) n}{m = 0}
+where \texttt{H} is $\beta$-expanded over the second \texttt{n}
 occurrence. 
 
-At this point, since \COQ{} unification algorithm is essentially
-first-order, the application of an elimination principle (of the
-form $\forall P.\forall x.(H~x)\to (P~x)$) will unify 
-$x$ with \texttt{n} and $P$ with \texttt{(fun n0 : nat => m + n = n0)}.
+At this point, since \COQ{} unification algorithm is essentially first-order,
+the application of an elimination principle (of the form $\forall P.\forall
+x.(H~x)\to (P~x)$) will unify \texttt{x} with \texttt{n} and \texttt{P} with
+\texttt{(fun n0: nat => m + n = n0)}.
 
-Since rewriting, replacing and several other tactics boils down to
+Since \TAC{rewrite}, \TAC{replace} and several other tactics boils down to
 the application of the equality elimination principle, the previous
-trick deals the expected behaviour.
+trick implements the expected behaviour.
 
 The idea behind this way of identifying subterms in not really far
 from the idea behind patterns, but fails in extending to
-complex notation, since it relays on a mono-dimensional sequent representation.
+complex notation, since it relies on a mono-dimensional sequent representation.
 Real math notation places arguments upside-down (like in indexed sums or
 integrations) or even puts them inside a bidimensional matrix.  
 In these cases using the mouse to select the wanted term is probably the 
@@ -1631,31 +1612,32 @@ more effective way to tell the system what to do.
 
 One of the goals of \MATITA{} is to use modern publishing techniques, and
 adopting a method for restricting tactics application domain that discourages 
-using heavy math notation, would definitively be a bad choice.
+using heavy math notation would have definitively been a bad choice.
+
+In \MATITA{}, tactics accepting pattern arguments can be more expressive than
+the equivalent tactics in \COQ{} since variables bound in the pattern context,
+can occurr in context-dependent arguments. For example, consider the sequent:
+\sequent{n: nat\\x: nat\\H: \forall m. n + m*n = x + m}{m = O}
+In \MATITA{} the user can issue the command:
+\begin{grafite}
+change in H: \forall _. (? ? % ?) with (S m) * n.
+\end{grafite}
+to change $n+m*n$ with $(S~m)*n$. To achieve the same effect in \COQ, the
+user is obliged to change the whole hypothesis rewriting its right hand side
+as well.
 
 \subsection{Tacticals}
 \label{sec:tinycals}
 
-%There are mainly two kinds of languages used by proof assistants to recorder
-%proofs: tactic based and declarative. We will not investigate the philosophy
-%around the choice that many proof assistant made, \MATITA{} included, and we
-%will not compare the two different approaches. We will describe the common
-%issues of the tactic-based language approach and how \MATITA{} tries to solve
-%them.
-
 The procedural proof language implemented in \MATITA{} is pretty standard,
 with a notable exception for tacticals.
 
-%\subsubsection{Tacticals overview}
-
-Tacticals first appeared in LCF as higher order tactics.  They can be
-seen as control flow constructs, like looping, branching, error
-recovery or sequential composition. 
-
-
-The following simple example
-shows a Coq script made of four dot-terminated commands
+Tacticals first appeared in LCF~\cite{lcf} as higher order tactics.
+They can be seen as control flow constructs like looping, branching,
+error recovery and sequential composition. 
 
+The following simple example shows a \COQ{} script made of four dot-terminated
+commands:
 \begin{grafite}
 Theorem trivial: 
   forall A B:Prop,
@@ -1668,85 +1650,27 @@ Theorem trivial:
 Qed.
 \end{grafite}
 
-The third command is an application of the sequencing tactical
-``$\ldots$\texttt{;}$\ldots$'', that combines the tactic
-\texttt{split} with the application of the branching tactical
-``$\ldots$\texttt{;[}$\ldots$\texttt{|}$\ldots$\texttt{|}$\ldots$\texttt{]}''
-to other tactics and tacticals.
+The third command is an application of the sequencing tactical \OP{$\ldots$~;~$\ldots$},
+that combines the tactic \TAC{split} with the application of the branching
+tactical \OP{$\ldots$~;[~$\ldots$~|~$\ldots$~|~$\ldots$~]} to other tactics or tacticals.
 
 The usual implementation of tacticals executes them atomically as any
-other command. In \MATITA{} thi is not true since each punctuation is
-executed as a single command.
+other command. In \MATITA{} this is not the case: each punctuation
+symbol is executed as a single command.
 
-%The latter is applied to all the goals opened by \texttt{split}
-%
-%(here we have two goals, the two sides of the logic and).  The first
-%goal $B$ (with $A$ in the context) is proved by the first sequence of
-%tactics \texttt{rewrite} and \texttt{assumption}. Then we move to the
-%second goal with the separator ``\texttt{|}''. 
-%
-%Giving serious examples here is rather difficult, since they are hard
-%to read without the interactive tool. To help the reader in
-%understanding the following considerations we just give few common
-%usage examples without a proof context.
-%
-%\begin{grafite}
-%  elim z; try assumption; [ ... | ... ].
-%  elim z; first [ assumption | reflexivity | id ].
-%\end{grafite}
-%
-%The first example goes by induction on a term \texttt{z} and applies
-%the tactic \texttt{assumption} to each opened goal eventually recovering if
-%\texttt{assumption} fails. Here we are asking the system to close all
-%trivial cases and then we branch on the remaining with ``\texttt{[}''.
-%The second example goes again by induction on \texttt{z} and tries to
-%close each opened goal first with \texttt{assumption}, if it fails it
-%tries \texttt{reflexivity} and finally \texttt{id}
-%that is the tactic that leaves the goal untouched without failing. 
-%
-%Note that in the common implementation of tacticals both lines are
-%compositions of tacticals and in particular they are a single
-%statement (i.e. derived from the same non terminal entry of the
-%grammar) ended with ``\texttt{.}''. As we will see later in \MATITA{}
-%this is not true, since each atomic tactic or punctuation is considered 
-%a single statement.
-
-\subsubsection{Common issues of tactic(als)-based proof languages}
-We will examine the two main problems of tactic(als)-based proof script:
+\subsubsection{Common issues of tacticals}
+We will examine the two main problems of procedural proof languages:
 maintainability and readability. 
 
-%Huge libraries of formal mathematics have been developed, and backward
-%compatibility is a really time consuming task. \\
-%A real-life example in the history of \MATITA{} was the reordering of
-%goals opened by a tactic application. We noticed that some tactics
-%were not opening goals in the expected order. In particular the
-%\texttt{elim} tactic on a term of an inductive type with constructors
-%$c_1, \ldots, c_n$ used to open goals in order $g_1, g_n, g_{n-1}
-%\ldots, g_2$. The library of \MATITA{} was still in an embryonic state
-%but some theorems about integers were there. The inductive type of
-%$\mathcal{Z}$ has three constructors: $zero$, $pos$ and $neg$. All the
-%induction proofs on this type where written without tacticals and,
-%obviously, considering the three induction cases in the wrong order.
-%Fixing the behavior of the tactic broke the library and two days of
-%work were needed to make it compile again. The whole time was spent in
-%finding the list of tactics used to prove the third induction case and
-%swap it with the list of tactics used to prove the second case.  If
-%the proofs was structured with the branch tactical this task could
-%have been done automatically. 
-%
-%From this experience we learned that the use of tacticals for
-%structuring proofs gives some help but may have some drawbacks in
-%proof script readability. 
-
 Tacticals are not only used to make scripts shorter by factoring out
-common cases and repeating commands. They are a primary way of making
-scripts more mainteable. Moreover, they also have the well-known
-role of structuring the proof.
+common cases and repeating commands. They are the primary way of making
+scripts more maintainable. They also have the well-known duty of
+structuring the proof using the branching tactical.
 
 However, authoring a proof structured with tacticals is annoying.
 Consider for example a proof by induction, and imagine you
-are using one of the state of the art graphical interfaces for proof assistant
-like Proof General. After applying the induction principle you have to choose:
+are using one of the state of the art graphical interfaces for proof assistant:
+Proof General. After applying the induction principle you have to choose:
 immediately structure the proof or postpone the structuring.
 If you decide for the former you have to apply the branching tactical and write
 at once tactics for all the cases. Since the user does not even know the
@@ -1765,42 +1689,13 @@ intermediate proof status. Tacticals make this operation uncomfortable.
 Indeed, a tactical is executed atomically, while it is obvious that it
 performs lot of smaller steps we are interested in.
 To show the intermediate steps, the proof must be de-structured on the
-fly, for example replacing ``\texttt{;}'' with ``\texttt{.}'' where
-possible.\\
-
-%Proof scripts
-%readability is poor by itself, but in conjunction with tacticals it
-%can be nearly impossible. The main cause is the fact that in proof
-%scripts there is no trace of what you are working on. It is not rare
-%for two different theorems to have the same proof script.\\
-%Bad readability is not a big deal for the user while he is
-%constructing the proof, but is considerably a problem when he tries to
-%reread what he did or when he shows his work to someone else.  The
-%workaround commonly used to read a script is to execute it again
-%step-by-step, so that you can see the proof goal changing and you can
-%follow the proof steps. This works fine until you reach a tactical.  A
-%compound statement, made by some basic tactics glued with tacticals,
-%is executed in a single step, while it obviously performs lot of proof
-%steps.  In the fist example of the previous section the whole branch
-%over the two goals (respectively the left and right part of the logic
-%and) result in a single step of execution. The workaround does not work
-%anymore unless you de-structure on the fly the proof, putting some
-%``\texttt{.}'' where you want the system to stop.\\
-
-%Now we can understand the tradeoff between script readability and
-%proof structuring with tacticals. Using tacticals helps in maintaining
-%scripts, but makes it really hard to read them again, cause of the way
-%they are executed.
+fly, for example replacing \OP{;} with \OP{.} where possible.
 
 \MATITA{} has a peculiar tacticals implementation that provides the
 same benefits as classical tacticals, while not burdening the user
 during proof authoring and re-playing.
 
-%\MATITA{} uses a language of tactics and tacticals, but tries to avoid
-%this tradeoff, alluring the user to write structured proof without
-%making it impossible to read them again.
-
-\subsubsection{The \MATITA{} approach: Tinycals}
+\subsubsection{The \MATITA{} approach}
 
 \begin{table}
  \caption{Concrete syntax of tacticals\strut}
@@ -1812,69 +1707,52 @@ during proof authoring and re-playing.
     ::= & \SEMICOLON \quad|\quad \DOT \quad|\quad \SHIFT \quad|\quad \BRANCH \quad|\quad \MERGE \quad|\quad \POS{\mathrm{NUMBER}~} & \\
   \NT{block\_kind} & 
     ::= & \verb+focus+ ~|~ \verb+try+ ~|~ \verb+solve+ ~|~ \verb+first+ ~|~ \verb+repeat+ ~|~ \verb+do+~\mathrm{NUMBER} & \\
-  \NT{block\_delimiter} & 
+  \NT{block\_delim} & 
     ::= & \verb+begin+ ~|~ \verb+end+ & \\
-  \NT{tactical} & 
-    ::= & \verb+skip+ ~|~ \NT{tactic} ~|~ \NT{block\_delimiter} ~|~ \NT{block\_kind} ~|~ \NT{punctuation} ~|~& \\
+  \NT{command} & 
+    ::= & \verb+skip+ ~|~ \NT{tactic} ~|~ \NT{block\_delim} ~|~ \NT{block\_kind} ~|~ \NT{punctuation} \\
 \end{array}
 \]
 \hrule
 \end{table}
 
 \MATITA{} tacticals syntax is reported in Tab.~\ref{tab:tacsyn}.
-While one would expect to find structured constructs like 
-$\verb+do+~n~\NT{tactic}$ the syntax allows pieces of tacticals to be written.
-This is essential for the base idea behind \MATITA{} tacticals: step-by-step
-execution.
-
-The low-level tacticals implementation of \MATITA{} allows a step-by-step
-execution of a tactical, that substantially means that a $\NT{block\_kind}$ is
-not executed as an atomic operation. This has major benefits for the
-user during proof structuring and re-playing.
+LCF tacticals have been replaced by unstructured more primitive commands;
+every LCF tactical is semantically equivalent to a sequential composition of
+them. As usual, each command is executed atomically, so that a sequence
+corresponding to an LCF tactical is now executed in multiple steps.
 
 For instance, reconsider the previous example of a proof by induction.
-With step-by-step tacticals the user can apply the induction principle, and just
-open the branching tactical ``\texttt{[}''. Then he can interact with the
-system until the proof of the first case is terminated. After that
-``\texttt{|}'' is used to move to the next goal, until all goals are
-closed. After the last goal, the user closes the branching tactical with
-``\texttt{]}'' and is done with a structured proof. \\
-While \MATITA{} tacticals help in structuring proofs they allow you to 
-choose the amount of structure you want. There are no constraints imposed by
-the system, and if the user wants he can even write completely plain proofs.
-  
-Re-playing a proof is also made simpler. There is no longer any need
-to destructure the proof on the fly since \MATITA{} executes each
-tactical not atomically.
-
-%\item[Rereading]
-%  is possible. Going on step by step shows exactly what is going on.  Consider
-%  again a proof by induction, that starts applying the induction principle and
-%  suddenly branches with a ``\texttt{[}''. This clearly separates all the
-%  induction cases, but if the square brackets content is executed in one single
-%  step you completely loose the possibility of rereading it and you have to
-%  temporary remove the branching tactical to execute in a satisfying way the
-%  branches.  Again, executing step-by-step is the way you would like to review
-%  the demonstration. Remember that understanding the proof from the script is
-%  not easy, and only the execution of tactics (and the resulting transformed
-%  goal) gives you the feeling of what is going on.
-%\end{description}
+In \MATITA{} the user can apply the induction principle, and just
+open the branching punctuation symbol \OP{[}. Then he can interact with the
+system (applying tactics and so forth) until he decides to move to the
+next branch using \OP{|}. After the last branch, the punctuation symbol
+\OP{]} must be used to collect goals possibly left open, accordingly to
+the semantics of the LCF branching tactical \OP{$\ldots$~;[~$\ldots$~|~$\ldots$~|~$\ldots$~]}. The result effortlessly obtained is a structured script.
+
+The user is not forced to fully structure his script. If he wants, he
+can even write completely unstructured proofs using only the \OP{.}
+punctuation symbol.
+
+Re-playing a proof is also straightforward since there is no longer any need
+to manually destructure the proof.
 
 \section{Standard library}
 \label{sec:stdlib}
 
-\MATITA{} is \COQ{} compatible, in the sense that every theorem of \COQ{}
-can be read, checked and referenced in further developments. 
-However, in order to test the actual usability of the system, a
-new library of results has been started from scratch. In this case, 
-of course, we wrote (and offer) the source script files, 
-while, in the case of \COQ, \MATITA{} may only rely on XML files of
-\COQ{} objects. 
+\MATITA{} is \COQ{} compatible, in the sense that every theorem of \COQ{} can be
+read, checked and referenced in further developments.  However, in order to test
+the actual usability of the system, a new library of results has been started
+from scratch. In this case, of course, we wrote (and offer) the source scripts,
+while in the case of \COQ{} \MATITA{} may only rely on XML files of \COQ{}
+objects. 
+
 The current library just comprises about one thousand theorems in 
 elementary aspects of arithmetics up to the multiplicative property for 
 Eulers' totient function $\phi$.
+
 The library is organized in five main directories: \texttt{logic} (connectives,
-quantifiers, equality, \ldots), \texttt{datatypes} (basic datatypes and type 
+quantifiers, equality, \ldots), \texttt{datatypes} (basic datatypes and type
 constructors), \texttt{nat} (natural numbers), \texttt{Z} (integers), \texttt{Q}
 (rationals). The most complex development is \texttt{nat}, organized in 25
 scripts, listed in Tab.~\ref{tab:scripts}.
@@ -1898,7 +1776,7 @@ scripts, listed in Tab.~\ref{tab:scripts}.
 
 We do not plan to maintain the library in a centralized way, 
 as most of the systems do. On the contrary we are currently
-developing wiki-technologies to support collaborative 
+developing wiki-technologies to support collaborative 
 development of the library, encouraging people to expand, 
 modify and elaborate previous contributions.
 
@@ -1916,10 +1794,6 @@ and V.~Tamburrelli.
 
 \theendnotes
 
-\TODO{rivedere bibliografia, \'e un po' povera}
-
-\TODO{aggiungere entry per le coercion implicite}
-
 \bibliography{matita}
 
 \end{document}