]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/papers/matita/matita2.tex
Snapshot
[helm.git] / helm / papers / matita / matita2.tex
index 516eacbdecf0eca85014b6b26d46f2ee21097fee..86c7d4230f61779e45be54c1645dfd18002f6ab2 100644 (file)
@@ -9,35 +9,23 @@
 \newcommand{\component}{component}
 \newcommand{\components}{components}
 
-\newcommand{\AUTO}{\textsc{Auto}}
 \newcommand{\BOXML}{BoxML}
 \newcommand{\COQ}{Coq}
-\newcommand{\COQIDE}{CoqIde}
-\newcommand{\ELIM}{\textsc{Elim}}
 \newcommand{\GDOME}{Gdome}
 \newcommand{\GTK}{GTK+}
 \newcommand{\GTKMATHVIEW}{\textsc{GtkMathView}}
 \newcommand{\HELM}{Helm}
 \newcommand{\HINT}{\textsc{Hint}}
-\newcommand{\IN}{\ensuremath{\dN}}
-\newcommand{\INSTANCE}{\textsc{Instance}}
-\newcommand{\IR}{\ensuremath{\dR}}
-\newcommand{\IZ}{\ensuremath{\dZ}}
-\newcommand{\LIBXSLT}{LibXSLT}
+% \newcommand{\IN}{\ensuremath{\dN}}
 \newcommand{\LEGO}{Lego}
-\newcommand{\LOCATE}{\textsc{Locate}}
-\newcommand{\MATCH}{\textsc{Match}}
 \newcommand{\MATHML}{MathML}
 \newcommand{\MATITA}{Matita}
 \newcommand{\MATITAC}{\texttt{matitac}}
 \newcommand{\MATITADEP}{\texttt{matitadep}}
 \newcommand{\MOWGLI}{MoWGLI}
 \newcommand{\MOWGLIIST}{IST-2001-33562}
-\newcommand{\NAT}{\ensuremath{\mathit{nat}}}
-\newcommand{\NATIND}{\mathit{nat\_ind}}
 \newcommand{\NUPRL}{NuPRL}
 \newcommand{\OCAML}{OCaml}
-\newcommand{\PROP}{\mathit{Prop}}
 \newcommand{\REF}[3]{\ensuremath{\mathit{Ref}_{#1}(#2,#3)}}
 \newcommand{\REWRITEHINT}{\textsc{RewriteHint}}
 \newcommand{\TEXMACRO}[1]{\texttt{\char92 #1}}
@@ -60,7 +48,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
  \runningtitle{The \MATITA{} proof assistant}
  \runningauthor{Asperti, Sacerdoti Coen, Tassi, Zacchiroli}
 
- \begin{motto}
-  ``We are nearly bug-free'' -- \emph{CSC, Oct 2005}
- \end{motto}
+%\begin{motto}
+%  ``We are nearly bug-free'' -- \emph{CSC, Oct 2005}
+% \end{motto}
 
  \begin{abstract}
   \TODO{scrivere abstract}
@@ -136,10 +124,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:
@@ -194,7 +183,7 @@ tools and software components:
   language~\cite{remathematization};
 
  \item an innovative, \MATHML-compliant rendering widget~\cite{padovani}
-  for the \GTK{} graphical environment,\footnote{\url{http://www.gtk.org/}}
+  for the \GTK{}\footnote{\url{http://www.gtk.org}} graphical environment,
   supporting high-quality bidimensional
   rendering, and semantic selection, i.e. the possibility to select semantically
   meaningful rendering expressions, and to paste the respective content into
@@ -224,19 +213,25 @@ theorem prover~\cite{lcf}. \COQ, \NUPRL, PVS, Isabelle are all examples of
 others systems
 whose proof language is procedural. Traditionally, in a procedural system
 the user interacts only with the \emph{script}, while proof terms are internal
-records kept by the system. On the contrary, in \MATITA{} proof terms are
-praised as declarative versions of the proof. Playing that role, they are the
-primary mean of communication of proofs (once rendered to natural language
-for human audiences).
-
-The user interfaces now adopted by all the proof assistants based on a
-procedural proof language have been inspired by the CtCoq pioneering
+records kept by the system. 
+In \MATITA{}, which has been conceived for a potentially distributed
+library, proof terms are also meant as the primary representation for 
+storage and communication with other systems (e.g. \COQ). 
+%On the contrary, in \MATITA{} proof terms are
+%praised as declarative versions of the proof. Playing that role, they are the
+%primary mean of communication of proofs (once rendered to natural language
+%for human audiences).
+
+All the user interfaces currently adopted by proof assistants based on a
+procedural proof language have been influenced by the CtCoq pioneering
 system~\cite{ctcoq1}. One successful incarnation of the ideas introduced
 by CtCoq is the Proof General generic interface~\cite{proofgeneral},
 that has set a sort of
-standard way to interact with the system. Several procedural proof assistants
-have either adopted or cloned Proof General as their main user interface.
-The authoring interface of \MATITA{} is a clone of the Proof General interface.
+standard way to interact with the system. 
+%Several procedural proof assistants
+%have either adopted or cloned Proof General as their main user interface.
+The authoring interface of \MATITA{} essentially offers the same 
+functionalities of the Proof General interface or CoqIde.
 On the contrary, the interface to interact with the library is rather
 innovative and directly inspired by the Web interfaces to our Web servers.
 
@@ -253,8 +248,8 @@ above than the result of a deliberate design. In particular, we
 Calculus of (Co)Inductive Constructions), the same implementation
 language (\OCAML\footnote{\url{http://caml.inria.fr/}}),
 and the same (procedural, script based) authoring philosophy.
-However, the analogy essentially stops here and no code is shared
-between the two systems.
+However, the analogy essentially stops here; in particular, no code is shared
+between the two systems and the algorithms are often different.
 
 In a sense, we like to think of \MATITA{} as the way \COQ{} would 
 look like if entirely rewritten from scratch: just to give an
@@ -273,18 +268,20 @@ assistants. Among them, the advanced indexing tools over the library and
 the parser for ambiguous mathematical notation.
 
 The size and complexity improvements over \COQ{} must be understood
-historically. \COQ{}\cite{CoqArt} is a quite old
+historically. \COQ~\cite{CoqArt} is a quite old
 system whose development started 20 years ago. Since then,
 several developers have took over the code and several new research ideas
-that were not considered in the original architecture have been experimented
+and optimizations that were not considered in the original architecture 
+have been experimented
 and integrated in the system. Moreover, there exists a lot of developments
 for \COQ{} that require backward compatibility between each pair of releases;
 since many central functionalities of a proof assistant are based on heuristics
 or arbitrary choices to overcome undecidability (e.g. for higher order
 unification), changing these functionalities maintaining backward compatibility
-is very difficult. Finally, the code of \COQ{} has been greatly optimized
-over the years; optimization reduces maintainability and rises the complexity
-of the code.
+is very difficult. 
+%Finally, the code of \COQ{} has been greatly optimized
+%over the years; optimization reduces maintainability and rises the complexity
+%of the code.
 
 In writing \MATITA{} we have not been hindered by backward compatibility and
 we have took advantage of the research results and experiences previously
@@ -328,9 +325,9 @@ at different scales. Applications that require only a few functionalities
 depend on a restricted set of \components.
 
 Only the proof assistant \MATITA{} and the \WHELP{} search engine are
-applications meant to be used directly by the user. All the other applications
-are Web services developed in the \HELM{} and \MOWGLI{} projects and already
-described elsewhere. In particular:
+applications meant to be used directly by the user; all the other applications
+are Web services developed in the \HELM{} and \MOWGLI{} projects. The 
+following applications have already been described elsewhere:
 \begin{itemize}
 
  \item The \emph{\GETTER}~\cite{zack-master} is a Web service to
@@ -424,7 +421,7 @@ presentation level terms.
    The Proof Checker application is the Web service that provides an interface
    to the \texttt{cic\_proof\_checking} \component.
 
-   We use metadata and a sort of crawler to index the mathematical concepts
+   We use metadata to index the mathematical concepts
    in the distributed library. We are interested in retrieving a concept
    by matching, instantiation or generalization of a user or system provided
    mathematical formula. Thus we need to collect metadata over the fully
@@ -439,7 +436,7 @@ presentation level terms.
    The \texttt{whelp} \component{} implements a search engine that performs
    approximated queries by matching/instantiation/generalization. The queries
    operate only on the metadata and do not involve any actual matching
-   (see the \texttt{cic\_unification} \component in
+   (see the \texttt{cic\_unification} \component{} in
    Sect.~\ref{sec:partiallyintro}). Not performing any actual matching
    a query only returns a complete and hopefully small set of matching
    candidates. The process that has issued the query is responsible of
@@ -462,11 +459,12 @@ presentation level terms.
 \label{sec:partiallyintro}
 
 \emph{Partially specified terms} are CIC terms where subterms can be omitted.
-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
-occurrence of a metavariable. A metavariable stands for a term whose type is
+Omitted subterms come in two flavours:
+\emph{implicit terms} that do not require a declaration, but can only occur
+linearly; and \emph{metavariables}~\cite{geuvers-jojgov,munoz} whose declaration
+associates with them a sequent and whose occurrences are coupled with an
+explicit substitution.
+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.
 The explicit substitution instantiates every hypothesis with an actual
@@ -478,10 +476,11 @@ a type-inference procedure that can instantiate implicit terms and
 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.
+in the \texttt{cic\_unification} \component. In the same way as the 
+type checker is based on
+convertibility, the refiner is based on \emph{unification}~\cite{strecker}
+that is a procedure that makes two partially specified term convertible by
+instantiating as few metavariables as possible 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
@@ -513,9 +512,9 @@ information that can be inferred by the refiner.
 \label{sec:contentintro}
 
 The language used to communicate proofs and especially formulae with the
-user does not only needs to be extendible and accommodate the usual mathematical
-notation. It must also reflect the comfortable degree of imprecision and
-ambiguity that the mathematical language provides.
+user does not only need to be extendible and accommodate the usual mathematical
+notation. It must also reflect the comfortable and suggestive degree of
+notational abuse so typical of the mathematical language.
 
 For instance, it is common practice in mathematics to speak of a generic
 equality that can be used to compare any two terms. However, it is well known
@@ -530,7 +529,7 @@ properties of addition over the binary representation are very different from
 those of addition over the unary representation. And addition over two natural
 numbers is definitely different from addition over two real numbers.
 
-Formalized mathematics cannot hide these differences and obliges the user to be
+Formalized mathematics cannot hide these differences and forces the user to be
 very precise on the types he is using and their representation. However,
 to communicate formulae with the user and with external tools, it seems good
 practice to stick to the usual imprecise mathematical ontology. In the
@@ -538,15 +537,13 @@ Mathematical Knowledge Management community this imprecise language is called
 the \emph{content level}~\cite{adams} representation of formulae.
 
 In \MATITA{} we provide translations from partially specified terms
-to content level terms and the other way around. The first translation can also
-be applied to fully specified terms since a fully specified term is a special
-case of partially specified term where no metavariable or implicit term occurs.
-
-The translation from partially specified terms to content level terms must
+to content level terms and the other way around. 
+The former translation must
 discriminate between terms used to represent proofs and terms used to represent
-formulae. The firsts are translated to a content level representation of
-proof steps that can in turn easily be rendered in natural language
-using techniques inspired by~\cite{natural,YANNTHESIS}. The representation
+formulae. Using techniques inspired by~\cite{natural,YANNTHESIS}, the firsts 
+are translated to a content level representation of
+proof steps that can in turn easily be rendered in natural language.
+The representation
 adopted has greatly influenced the OMDoc~\cite{omdoc} proof format that is now
 isomorphic to it. Terms that represent formulae are translated to \MATHML{}
 Content formulae. \MATHML{} Content~\cite{mathml} is a W3C standard
@@ -554,18 +551,13 @@ for the representation of content level formulae in an extensible XML format.
 
 The translation to content level is implemented in the
 \texttt{acic\_content} \component. Its input are \emph{annotated partially
-specified terms}, that are maximally unshared
+specified terms}, that are
 partially specified terms enriched with additional typing information for each
 subterm. This information is used to discriminate between terms that represent
 proofs and terms that represent formulae. Part of it is also stored at the
 content level since it is required to generate the natural language rendering
-of proofs. The terms need to be maximally unshared (i.e. they must be a tree
-and not a DAG). The reason is that to different occurrences of a subterm
-we need to associate different typing information.
-This association is made easier when the term is represented as a tree since
-it is possible to label each node with an unique identifier and associate
-the typing information using a map on the identifiers.
-The \texttt{cic\_acic} \component{} unshares and annotates terms. It is used
+of proofs. 
+The \texttt{cic\_acic} \component{} annotates terms. It is used
 by the \texttt{library} \component{} since fully specified terms are stored
 in the library in their annotated form.
 
@@ -596,8 +588,8 @@ The elegant solution we have implemented consists in representing terms
 in a command as functions from a context to a partially refined term. The
 function is obtained by partially applying our disambiguation function to
 the content level term to be disambiguated. Our solution should be compared with
-the one adopted in the \COQ{} systemwhere ambiguity is only relative to
-De Brujin indexes.
+the one adopted in the \COQ{} system (where ambiguity is only relative to
+De Bruijn indexes).
 In \COQ, variables can be bound either by name or by position. A term
 occurring in a command has all its variables bound by name to avoid the need of
 a context during disambiguation.  This makes more complex every
@@ -679,7 +671,7 @@ disambiguation algorithm that are used to control and speed up disambiguation.
 These mechanisms will be further discussed in Sect.~\ref{sec:disambiguation}.
 
 Finally, the \texttt{grafite\_parser} \component{} implements a parser for
-the concrete syntax of the commands of \MATITA. The parser process a stream
+the concrete syntax of the commands of \MATITA. The parser processes a stream
 of characters and returns a stream of abstract syntax trees (the ones
 defined by the \texttt{grafite} component and whose semantics is given
 by \texttt{grafite\_engine}). When the parser meets a command that changes
@@ -717,7 +709,7 @@ services missing from the standard library of the programming language.
 \label{sec:library}
 
 A proof assistant provides both an interface to interact with its library and
-an \emph{authoring} interface to develop new proofs and theories. According
+an authoring interface to develop new proofs and theories. According
 to its historical origins, \MATITA{} strives to provide innovative
 functionalities for the interaction with the library. It is more traditional
 in its script based authoring interface. In the remaining part of the paper we
@@ -815,10 +807,10 @@ effective way, assuming as little knowledge as possible about the
 library. To this aim, \MATITA{} uses a sophisticated indexing mechanism
 for mathematical concepts, based on a rich metadata set that has been 
 tuned along the European project \MOWGLIIST{} \MOWGLI. The metadata
-set, and the searching facilites built on top of them --- collected 
+set, and the searching facilities built on top of them --- collected 
 in the so called \WHELP{} search engine --- have been
 extensively described in~\cite{whelp}. Let us just recall here that
-the \WHELP{} metadata model is essentially based a single ternary relation 
+the \WHELP{} metadata model is essentially based on a single ternary relation 
 \REF{p}{s}{t} stating that a concept $s$ refers a concept $t$ at a
 given position $p$, where the position specify the place of the 
 occurrence of $t$ inside $s$ (we currently work with a fixed set of 
@@ -832,17 +824,17 @@ Every time a new mathematical concept is created and saved by the user it gets
 indexed, and becomes immediately visible in the library. Several 
 interesting and innovative features of \MATITA{} described in the following
 sections rely in a direct or indirect way on its metadata system and
-the search features. Here, we shall just recall some of its most
+the search functionalities. Here, we shall just recall some of its most
 direct applications.
 
-A first, very simple but not negligeable feature is the \emph{duplicate check}.
+A first, very simple but not negligible feature is the \emph{duplicate check}.
 As soon as a theorem is stated, just before starting its proof, 
 the library is searched 
 to check that no other equivalent statement has been already proved
 (based on the pattern matching functionality of \WHELP); if this is the case,
 a warning is raised to the user. At present, the notion of equivalence 
 adopted by \MATITA{} is convertibility, but we may imagine to weaken it 
-in the future, covering for instance isomorphisms.    
+in the future, covering for instance isomorphisms~\cite{delahaye}.    
 
 Another useful \WHELP{} operation is \HINT; we may invoke this query
 at any moment during the authoring of a proof, resulting in the list
@@ -866,10 +858,10 @@ can be applied to rewrite the current goal.
 Software applications that involve input of mathematical content should strive
 to require the user as less drift from informal mathematics as possible. We
 believe this to be a fundamental aspect of such applications user interfaces.
-Being that drift in general very large when inputing
-proofs~\cite{debrujinfactor}, in \MATITA{} we achieved good results for
-mathematical formulae which can be input using a \TeX-like encoding (the
-concrete syntax corresponding to presentation level terms) and are then
+The drift is still very large for
+proofs~\cite{debrujinfactor}, while better results may be achieved for
+mathematical formulae. In \MATITA{} formulae can be written using a
+\TeX-like syntax (corresponding to presentation level terms) and are then
 translated (in multiple steps) to partially specified terms as sketched in
 Sect.~\ref{sec:contentintro}.
 
@@ -881,14 +873,14 @@ mathematics. We will see that using multiple passes of the algorithm, varying
 some of its parameters, helps in keeping the input terse without sacrificing
 expressiveness.
 
-\subsubsection{Disambiguation aliases}
+\subsubsection{Disambiguation preferences}
 \label{sec:disambaliases}
 
 Consider the following command that states a theorem over integer numbers:
 
 \begin{grafite}
 theorem Zlt_compat:
-  \forall x, y, z. x < y \to y < z \to x < z.
+  \forall x,y,z. x < y \to y < z \to x < z.
 \end{grafite}
 
 The symbol \OP{<} is likely to be overloaded in the library
@@ -908,10 +900,10 @@ specified terms. In case of overloaded sources there exists multiple aliases
 with the same source. It is possible to record \emph{disambiguation
 preferences} to select one of the aliases of an overloaded source.
 
-Preferences can be explicitely given in the script (using the
-misleading \texttt{alias} commands), but
+Preferences can be explicitly given in the script (using the \texttt{alias}
+command), but
 are also implicitly added when a new concept is introduced (\emph{implicit
-preferences}) or after a sucessfull disambiguation that did not require
+preferences}) or after a successful disambiguation that did not require
 user interaction. Explicit preferences are added automatically by \MATITA{} to
 record the disambiguation choices of the user. For instance, after the
 disambiguation of the command above, the script is altered as follows:
@@ -919,7 +911,7 @@ disambiguation of the command above, the script is altered as follows:
 \begin{grafite}
 alias symbol "lt" = "integer 'less than'".
 theorem Zlt_compat:
-  \forall x, y, z. x < y \to y < z \to x < z.
+  \forall x,y,z. x < y \to y < z \to x < z.
 \end{grafite}
 
 The ``alias'' command in the example sets the preferred alias for the
@@ -938,12 +930,16 @@ status.  Unlike aliases, they are not part of the library.
 When starting a new authoring session the set of disambiguation preferences
 is empty. Until it contains a preference for each overloaded symbol to be
 used in the script, the user can be faced with questions from the disambiguator.
-To reduce the likelyhood of user interactions, we introduced
+To reduce the likelihood of user interactions, we introduced
 the \texttt{include} command. With \texttt{include} it is possible to import
 at once in the current session the set of preferences that was in effect
 at the end of the execution of a given script.
+The inclusion mechanism is thus sensibly different from that of other systems
+where concepts are effectively loaded and made visibible by inclusion; in \MATITA{} 
+all concepts are always visible, and inclusion, that is optional, is only used 
+to set up preferences.
 
-Preferences can be changed. For instance, at the start of the development
+Preferences can be changed. For instance, at the beginning of the development
 of integer numbers the preference for the symbol \OP{<} is likely
 to be the one over natural numbers; sooner or later it will be set to the one
 over integer numbers.
@@ -953,17 +949,17 @@ the disambiguator cannot always respect the user preferences.
 Consider, for example:
 \begin{grafite}
 theorem Zlt_mono:
-  \forall x, y, k. x < y \to x < y + k.
+  \forall x,y,k. x < y \to x < y + k.
 \end{grafite}
 
 No refinable partially specified term corresponds to the preferences:
 \OP{+} over natural numbers, \OP{<} over integer numbers. To overcome this
 limitation we organized disambiguation in \emph{multiple passes}: when the
-disambiguator fails, disambiguation is tried again with a less strict set of
+disambiguator fails, disambiguation is tried again with a less restrictive 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
@@ -979,10 +975,12 @@ have more chances of success.
 \subsubsection{Operator instances}
 \label{sec:disambinstances}
 
-Consider now the following theorem:
+Consider now the following theorem, where \texttt{pos} injects natural numbers
+into positive integers:
+
 \begin{grafite}
 theorem lt_to_Zlt_pos_pos:
-  \forall n, m: nat. n < m \to pos n < pos m. 
+  \forall n,m: nat. n < m \to pos n < pos m. 
 \end{grafite}
 and assume that there exist in the library aliases for \OP{<} over natural
 numbers and over integer numbers. None of the passes described above is able to
@@ -1004,15 +1002,15 @@ an alias for one instance does not constraint the choice of the others). For
 this reason we always attempt a fresh instances pass only after attempting a
 shared instances pass.
 
-\paragraph{One-shot preferences} Disambiguation preferences as seen so far are
-instance-independent. However, implicit preferences obtained as a result of a
-disambiguation pass which uses fresh instances ought to be instance-dependent.
-Informally, the set of preferences that can be respected by the disambiguator on
-the theorem above is: ``the first instance of the \OP{<} symbol is over natural
-numbers, while the second is on integer numbers''.
+%\paragraph{One-shot preferences} Disambiguation preferences as seen so far are
+%instance-independent. However, implicit preferences obtained as a result of a
+%disambiguation pass which uses fresh instances ought to be instance-dependent.
+%Informally, the set of preferences that can be respected by the disambiguator on
+%the theorem above is: ``the first instance of the \OP{<} symbol is over natural
+%numbers, while the second is on integer numbers''.
 
 Instance-dependent preferences are meaningful only for the term whose
-disambiguation generated it. For this reason we call them \emph{one-shot
+disambiguation generated them. For this reason we call them \emph{one-shot
 preferences} and \MATITA{} does not use them to disambiguate further terms in
 the script.
 
@@ -1022,7 +1020,7 @@ the script.
 Consider the following theorem about derivation:
 \begin{grafite}
 theorem power_deriv:
-  \forall n: nat, x: R. d x ^ n dx = n * x ^ (n - 1).
+  \forall n: nat, x: R. d x^n dx = n * x^(n - 1).
 \end{grafite}
 and assume that in the library there is an alias mapping \OP{\^} to a partially
 specified term having type: \texttt{R \TEXMACRO{to} nat \TEXMACRO{to} R}. In
@@ -1035,42 +1033,40 @@ partially specified term where in place of \texttt{n} the application of a
 coercion from \texttt{nat} to \texttt{R} appears (assuming such a coercion has
 been defined in advance).
 
-Implicitc coercions are not always desirable. For example, in disambiguating
-\texttt{\TEXMACRO{forall} x: nat. n < n + 1} we do not want the term which uses
-2 coercions from \texttt{nat} to \texttt{R} around \OP{<} arguments to show up
-among the possible partially specified term choices. For this reason we always
-attempt a disambiguation pass which require the refiner not to use the coercions
-before attempting a coercion-enabled pass.
-
-The choice of whether implicit coercions are enabled or not interact with the
+Implicit coercions are not always desirable. For example, consider the term
+\texttt{\TEXMACRO{forall} x. x < x + 1} and assume that the preferences for \OP{<}
+and \OP{+} are over real numbers. The expected interpretation assignes the 
+type \texttt{R} to \texttt{x}. 
+However, if we had a coercion from natural to real numbers an alternative
+interpretation is to assign the type \texttt{nat} to \texttt{x} inserting the coercion
+as needed. Clearly, the latter interpretation looks artificial and
+for this reason we enable coercions only in case of failure of previous 
+attempts.
+
+The choice of whether implicit coercions are enabled or not interacts with the
 choice about operator instances. Indeed, consider again
 \texttt{lt\_to\_Zlt\_pos\_pos}, which can be disambiguated using fresh operator
-instances. In case there exists a coercion from natural numbers to (positive)
-integers (which indeed does), the
-theorem can be disambiguated using twice that coercion on the left hand side of
-the implication. The obtained partially specified term however would not
-probably be the expected one, being a theorem which proves a trivial
-implication.
-Motivated by this and similar examples we choose to always prefer fresh
-instances over implicit coercions, i.e.  we always attempt disambiguation
-passes with fresh instances
-and no implicit coercions before attempting passes with implicit coercions.
+instances. In case there exists a coercion from natural numbers to positive
+integers ({\texttt{pos} itself), the command 
+can be disambiguated as 
+\texttt{\TEXMACRO{forall} n,m: nat. pos n < pos m \TEXMACRO{to} pos n < pos m}. 
+This is not the expected interpretation; 
+by this and similar examples we choose to always prefer fresh
+instances over implicit coercions.
 
 \subsubsection{Disambiguation passes}
 \label{sec:disambpasses}
 
 According to the criteria described above, in \MATITA{} we perform the
 disambiguation passes depicted in Tab.~\ref{tab:disambpasses}. In
-our experience that choice gives reasonable performance and minimizes the need
+our experience that choice gives reasonable performance and reduces the need
 of user interaction during the disambiguation.
 
 \begin{table}[ht]
- \caption{Disambiguation passes sequence\strut}
- \label{tab:disambpasses} 
  \begin{center}
   \begin{tabular}{c|c|c|c}
    \multicolumn{1}{p{1.5cm}|}{\centering\raisebox{-1.5ex}{\textbf{Pass}}}
-   & \multicolumn{1}{p{3.1cm}|}{\centering\textbf{Preferences}}
+   & \multicolumn{1}{p{3.1cm}|}{\centering\raisebox{-1.5ex}{\textbf{Preferences}}}
    & \multicolumn{1}{p{2.5cm}|}{\centering\textbf{Operator instances}}
    & \multicolumn{1}{p{2.5cm}}{\centering\textbf{Implicit coercions}} \\
    \hline
@@ -1083,9 +1079,11 @@ of user interaction during the disambiguation.
    \PASS & Library-preferences  & Fresh instances   & Enabled
   \end{tabular}
  \end{center}
+ \caption{Disambiguation passes sequence\strut}
+ \label{tab:disambpasses}
 \end{table}
 
-\subsection{Generation and invalidation}
+\subsection{Invalidation and regeneration}
 \label{sec:libmanagement}
 
 %The aim of this section is to describe the way \MATITA{} 
@@ -1117,11 +1115,11 @@ 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
+The first one is the computation of all the concepts that recursively
 depend on the ones we are invalidating. It can be performed
-using the relational database that stores the metadata.
+from the metadata stored in the relational database.
 This technique is the same used by the \emph{Dependency Analyzer}
 and is described in~\cite{zack-master}.
 
@@ -1152,9 +1150,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 +1163,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 +1203,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 weighting 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 +1265,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,14 +1275,14 @@ 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.
 
-Similarly, consider the theorem:
+Similarly, consider the statement
 \begin{grafite}
- \forall n, m: nat. n < m to n \leq m
+\forall n,m: nat. n < m to n \leq m
 \end{grafite}
 In this case \texttt{lt\_to\_le} is a legal name, 
 while \texttt{lt\_le} is not.
@@ -1294,9 +1293,9 @@ The correct approach,
 in this case, is the following. You should start with defining the 
 symmetric property for relations:
 \begin{grafite}
-definition symmetric =
-  \lambda A: Type. \lambda R. \forall x, y: A.
-    R x y \to R y x
+definition symmetric \def
+  \lambda A: Type. \lambda R. \forall x,y: A.
+    R x y \to R y x.
 \end{grafite}
 Then, you may state the symmetry of equality as:
 \begin{grafite}
@@ -1322,10 +1321,10 @@ The other special case is that of statements whose conclusion is a
 match expression. 
 A typical example is the following:
 \begin{grafite}
-\forall n,m:nat. 
+\forall n,m: nat. 
   match (eqb n m) with
   [ true  \Rightarrow n = m 
-  | false \Rightarrow n \neq m]
+  | false \Rightarrow n \neq m ]
 \end{grafite}
 where \texttt{eqb} is boolean equality.
 In this cases, the name can be build starting from the matched
@@ -1335,25 +1334,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 +1381,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 +1398,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 +1422,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 +1433,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,87 +1463,67 @@ 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}
 
 \subsubsection{Examples}
-%To explain how the first phase works let us give an example. Consider
-%you want to prove the uniqueness of the identity element $0$ for natural
-%sum, and that you can rely on the previously demonstrated left
-%injectivity of the sum, that is $inj\_plus\_l:\forall x,y,z.x+y=z+y \to x =z$.
-%Typing
-%\begin{grafite}
-%theorem valid_name: \forall n,m. m + n = n \to m = O.
-%  intros (n m H).
-%\end{grafite}
-
-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
+
+Consider the following sequent:
+\sequent{n: nat\\m: nat\\H: m + n = n}{m = O}
+
+To change the right part of the equality of the $H$
+hypothesis with $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$.
+To understand the pattern (or produce it by hand) the user should be aware that
+the notation $m + n = n$ hides the term $\mathrm{eq}~\mathrm{nat}~(m + n)~n$, so
+that the pattern selects only the third argument of $\mathrm{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$:
+The experienced user may also write by hand a concise pattern to change at once
+all the occurrences of $n$ in the hypothesis $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
+In this case the \NT{sequent\_path} selects the whole $H$, while
 the second phase locates $n$.
 
 The latter pattern is equivalent to the following one, that the system
@@ -1549,81 +1532,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$
+would have resulted in the sequent:
+\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 behavior.
 
 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 +1597,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 occur 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,80 +1635,22 @@ 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
@@ -1765,42 +1674,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 +1692,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 +1761,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 a collaborative 
+developing Wiki-technologies to support collaborative 
 development of the library, encouraging people to expand, 
 modify and elaborate previous contributions.
 
@@ -1916,10 +1779,6 @@ and V.~Tamburrelli.
 
 \theendnotes
 
-\TODO{rivedere bibliografia, \'e un po' povera}
-
-\TODO{aggiungere entry per le coercion implicite}
-
 \bibliography{matita}
 
 \end{document}