]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/matita/matita.tex
tex macros, checked in disambiguation section from whelp paper
[helm.git] / helm / papers / matita / matita.tex
1 \documentclass[a4paper]{llncs}
2 \pagestyle{headings}
3 \usepackage{graphicx}
4 \usepackage{amssymb,amsmath}
5 \usepackage{hyperref}
6 \usepackage{picins}
7
8 %\newcommand{\logo}[3]{
9 %\parpic(0cm,0cm)(#2,#3)[l]{\includegraphics[width=#1]{whelp-bw}}
10 %}
11
12 \newcommand{\AUTO}{\textsc{Auto}}
13 \newcommand{\COQ}{Coq}
14 \newcommand{\ELIM}{\textsc{Elim}}
15 \newcommand{\HELM}{Helm}
16 \newcommand{\HINT}{\textsc{Hint}}
17 \newcommand{\IN}{\ensuremath{\mathbb{N}}}
18 \newcommand{\INSTANCE}{\textsc{Instance}}
19 \newcommand{\IR}{\ensuremath{\mathbb{R}}}
20 \newcommand{\LIBXSLT}{LibXSLT}
21 \newcommand{\LOCATE}{\textsc{Locate}}
22 \newcommand{\MATCH}{\textsc{Match}}
23 \newcommand{\MATITA}{Matita}
24 \newcommand{\METAHEADING}{Symbol & Position \\ \hline\hline}
25 \newcommand{\MOWGLI}{MoWGLI}
26 \newcommand{\NAT}{\ensuremath{\mathit{nat}}}
27 \newcommand{\NATIND}{\mathit{nat\_ind}}
28 \newcommand{\NUPRL}{NuPRL}
29 \newcommand{\OCAML}{OCaml}
30 \newcommand{\PROP}{\mathit{Prop}}
31 \newcommand{\REF}[3]{\ensuremath{\mathit{Ref}_{#1}(#2,#3)}}
32 \newcommand{\TEXMACRO}[1]{\texttt{\char92 #1}}
33 \newcommand{\UWOBO}{UWOBO}
34 \newcommand{\WHELP}{Whelp}
35
36 \newcommand{\ASSIGNEDTO}[1]{\textbf{Assigned to:} #1}
37 \newcommand{\NOTE}[1]{\marginpar{\scriptsize #1}}
38
39 \title{The Matita proof assistant}
40 \author{Andrea Asperti, Claudio Sacerdoti Coen, Enrico Tassi
41  and Stefano Zacchiroli}
42 \institute{Department of Computer Science, University of Bologna\\
43  Mura Anteo Zamboni, 7 --- 40127 Bologna, ITALY\\
44  \email{$\{$asperti,sacerdot,tassi,zacchiro$\}$@cs.unibo.it}}
45
46 \begin{document}
47 \maketitle
48
49 \begin{abstract}
50 \end{abstract}
51
52 \section{Introduction}
53 \label{sec:intro}
54 {\em Matita} is the proof assistant under development by the \HELM{} team
55 \cite{annals} at the University of Bologna, under the direction of 
56 Prof.~Asperti. 
57 The origin of the system goes back to 1999. At the time we were mostly 
58 interested to develop tools and techniques to enhance the accessibility
59 via web of formal libraries of mathematics. Due to its dimension, the
60 library of the \COQ{} proof assistant (of the order of 35'000 theorems) 
61 was choosed as a privileged test bench for our work, although experiments
62 have been also conducted with other systems, and notably with \NUPRL{}.
63 The work, mostly performed in the framework of the recently concluded 
64 European project IST-33562 \MOWGLI{}~\cite{pechino}, mainly consisted in the 
65 following teps:
66 \begin{itemize}
67 \item exporting the information from the internal representation of
68  \COQ{} to a system and platform independent format. Since XML was at the 
69 time an emerging standard, we naturally adopted this technology, fostering
70 a content-based architecture for future system, where the documents
71 of the library were the the main components around which everything else 
72 has to be build;
73 \item developing indexing and searching techniques supporting semantic
74  queries to the library; these efforts gave birth to our \WHELP{}
75 search engine, described in~\cite{whelp};
76 \item developing languages and tools for a high-quality notational 
77 rendering of mathematical information; in particular, we have been 
78 active in the MathML Working group since 1999, and developed inside
79 \HELM{} a MathML-compliant widget for the GTK graphical environment
80 which can be integrated in any application.
81 \end{itemize}
82 The exportation issue, extensively discussed in \cite{exportation},
83 has several major implications worth to be discussed. 
84
85 The first
86 point concerns the kind of content information to be exported. In a
87 proof assistant like \COQ{}, proofs are represented in at least three clearly
88 distinguishable formats: \emph{scripts} (i.e. sequences of commands issued by the
89 user to the system during an interactive session of proof), \emph{proof objects}
90 (which is the low-level representation of proofs in the form of
91 lambda-terms readable to and checked by kernel) and \emph{proof-trees} (which
92 is a kind of intermediate representation, vaguely inspired by a sequent
93 like notation, that inherits most of the defects but essentially
94 none of the advantages of the previous representations). 
95 Partially related to this problem, there is the
96 issue of the {\em granularity} of the library: scripts usually comprise
97 small developments with many definitions and theorems, while 
98 proof objects correspond to individual mathemtical items. 
99
100 In our case, the choice of the content encoding was eventually dictated
101 by the methodological assumption of offering the information in a
102 stable and system-independent format. The language of scripts is too
103 oriented to \COQ, and it changes too rapidly to be of any interest
104 to third parties. On the other side, the language of proof objects 
105 merely depend on
106 the logical framework (the Calculus of Inductive Constructions, in
107 the case of \COQ), is grammatically simple, semantically clear and, 
108 especially, is very stable (as kernels of proof assistants 
109 often are). 
110 So the granularity of the library is at the level of individual 
111 objects, that also justifies from another point of view the need
112 for efficient searching techniques for retrieving individual 
113 logical items from the repository. 
114
115 The main (possibly only) problem with proof objects is that they are
116 difficult to read and do not directly correspond to what the user typed
117 in. An analogy frequently made in the proof assistant community is that of
118 comparing the vernacular language of scripts to a high level source language
119 and lambda terms to the assembly language they are compiled in. We do not
120 share this view and prefer to look at scripts as an imperative language, 
121 and to lambda terms as their denotational semantics; still, however,
122 denotational semantics is possibly more formal but surely not more readable 
123 than the imperative source.
124
125 For all the previous reasons, a huge amount of work inside \MOWGLI{} has
126 been devoted to automatic reconstruction of proofs in natural language
127 from lambda terms. Since lambda terms are in close connection 
128 with natural deduction 
129 (that is still the most natural logical language discovered so far)
130 the work is not hopeless as it may seem, especially if rendering
131 is combined, as in our case, with dynamic features supporting 
132 in-line expansions or contractions of subproofs. The final 
133 rendering is probably not entirely satisfactory (see \cite{ida} for a
134 discussion), but surely
135 readable (the actual quality largely depends by the way the lambda 
136 term is written). 
137
138 Summing up, we already disposed of the following tools/techniques:
139 \begin{itemize}
140 \item XML specifications for the Calculus of Inductive Constructions,
141 with tools for parsing and saving mathematical objects in such a format;
142 \item metadata specifications and tools for indexing and querying the
143 XML knowledge base;
144 \item a proof checker (i.e. the {\em kernel} of a proof assistant), 
145  implemented to check that we exported form the \COQ{} library all the 
146 logically relevant content;
147 \item a sophisticated parser (used by the search engine), able to deal 
148 with potentially ambiguous and incomplete information, typical of the 
149 mathematical notation \cite{};
150 \item a {\em refiner}, i.e. a type inference system, based on complex 
151 existential variables, used by the disambiguating parser;
152 \item complex transformation algorithms for proof rendering in natural
153 language;
154 \item an innovative rendering widget, supporting high-quality bidimensional
155 rendering, and semantic selection, i.e. the possibility to select semantically
156 meaningfull rendering expressions, and to past the respective content into
157 a different text area.
158 \NOTE{il widget\\ non ha sel\\ semantica}
159 \end{itemize}
160 Starting from all this, the further step of developing our own 
161 proof assistant was too
162 small and too tempting to be neglected. Essentially, we ``just'' had to
163 add an authoring interface, and a set of functionalities for the
164 overall management of the library, integrating everything into a
165 single system. \MATITA{} is the result of this effort. 
166
167 At first sight, \MATITA{} looks as (and partly is) a \COQ{} clone. This is
168 more the effect of the circumstances of its creation described 
169 above than the result of a deliberate design. In particular, we
170 (essentially) share the same foundational dialect of \COQ{} (the
171 Calculus of Inductive Constructions), the same implementative
172 language (\OCAML{}), and the same (script based) authoring philosophy.
173 However, as we shall see, the analogy essentially stops here. 
174
175 In a sense; we like to think of \MATITA{} as the way \COQ{} would 
176 look like if entirely rerwritten from scratch: just to give an
177 idea, although \MATITA{} currently supports almost all functionalities of
178 \COQ{}, it links 60'000 lins of \OCAML{} code, against ... of \COQ{} (and
179 we are convinced that, starting from scratch againg, we could furtherly
180 reduce our code in sensible way).\NOTE{righe\\\COQ{}}
181
182 \begin{itemize}
183  \item scelta del sistema fondazionale
184  \item sistema indipendente (da Coq)
185   \begin{itemize}
186    \item possibilit\`a di sperimentare (soluzioni architetturali, logiche,
187     implementative, \dots)
188    \item compatibilit\`a con sistemi legacy
189   \end{itemize}
190 \end{itemize}
191
192 \section{Features}
193
194 \subsection{mathml}
195 \ASSIGNEDTO{zack}
196
197 \subsection{metavariabili}
198 \ASSIGNEDTO{csc}
199
200 \subsection{pattern}
201 \ASSIGNEDTO{gares}
202
203 \subsection{tatticali}
204 \ASSIGNEDTO{gares}
205
206 \subsection{Disambiguation}
207 \label{sec:disambiguation}
208 \ASSIGNEDTO{zack}
209
210 %The disambiguation phase builds CIC terms from ASTs of user inputs (also called
211 %\emph{ambiguous terms}). Ambiguous terms may carry three different \emph{sources
212 %of ambiguity}: unbound identifiers, literal numbers, and literal symbols.
213 %\emph{Unbound identifiers} are sources of ambiguity since the same name
214 %could have been used to represent different objects. For example, three
215 %different theorems of the \COQ{} library share the name $\mathit{plus\_assoc}$
216 %(locating them is an exercise for the interested reader. Hint: use \WHELP's
217 %\LOCATE{} query).
218 %
219 %\emph{Numbers} are ambiguous since several different encodings of them could be
220 %provided in logical systems. In the \COQ{} standard library for example we found
221 %naturals (in their unary encoding), positives (binary encoding), integers
222 %(signed positives), and reals. Finally, \emph{symbols} (instances of the
223 %\emph{binop} and \emph{unop} syntactic categories of Table~\ref{tab:syntax}) are
224 %ambiguous as well: infix \texttt{+} for example is overloaded to represent
225 %addition over the four different kinds of numbers available in the \COQ{}
226 %standard library. Note that given a term with more than one sources of
227 %ambiguity, not all possible disambiguation choices are valid: for example, given
228 %the input \texttt{1+1} we must choose an interpretation of \texttt{+} which is
229 %typable in CIC according to the chosen interpretation for \texttt{1}; choosing
230 %as \texttt{+} the addition over natural numbers and as \texttt{1} the real
231 %number $1$ will lead to a type error.
232 %
233 %A \emph{disambiguation algorithm} takes as input an ambiguous term and return a
234 %fully determined CIC term. The \emph{naive disambiguation algorithm} takes as
235 %input an ambiguous term $t$ and proceeds as follows:
236 %
237 %\begin{enumerate}
238 %
239 % \item Create disambiguation domains $\{D_i | i\in\mathit{Dom}(t)\}$, where
240 %  $\mathit{Dom}(t)$ is the set of ambiguity sources of $t$. Each $D_i$ is a set
241 %  of CIC terms.
242 %
243 % \item Let $\Phi = \{\phi_i | {i\in\mathit{Dom}(t)},\phi_i\in D_i\}$
244 %%  such that $\forall i\in\mathit{Dom}(t),\exists\phi_j\in\Phi,i=j$
245 %  be an interpretation for $t$. Given $t$ and an interpretation $\Phi$, a CIC
246 %  term is fully determined. Iterate over all possible interpretations of $t$ and
247 %  type-check them, keep only typable interpretations (i.e. interpretations that
248 %  determine typable terms).
249 %
250 % \item Let $n$ be the number of interpretations who survived step 2. If $n=0$
251 %  signal a type error. If $n=1$ we have found exactly one CIC term
252 %  corresponding to $t$, returns it as output of the disambiguation phase.
253 %  If $n>1$ let the user choose one of the $n$ interpretations and returns the
254 %  corresponding term.
255 %
256 %\end{enumerate}
257 %
258 %The above algorithm is highly inefficient since the number of possible
259 %interpretations $\Phi$ grows exponentially with the number of ambiguity sources.
260 %The actual algorithm used in \WHELP{} is far more efficient being, in the
261 %average case, linear in the number of ambiguity sources.
262 %
263 %The efficient algorithm can be applied if the logic can be extended with
264 %metavariables and a refiner can be implemented. This is the case for CIC and
265 %several other logics.
266 %\emph{Metavariables}~\cite{munoz} are typed, non linear placeholders that can
267 %occur in terms; $?_i$ usually denotes the $i$-th metavariable, while $?$ denotes
268 %a freshly created metavariable. A \emph{refiner}~\cite{mcbride} is a
269 %function whose input is a term with placeholders and whose output is either a
270 %new term obtained instantiating some placeholder or $\epsilon$, meaning that no
271 %well typed instantiation could be found for the placeholders occurring in
272 %the term (type error).
273 %
274 %The efficient algorithm starts with an interpretation $\Phi_0 = \{\phi_i |
275 %\phi_i = ?, i\in\mathit{Dom}(t)\}$,
276 %which associates a fresh metavariable to each
277 %source of ambiguity. Then it iterates refining the current CIC term (i.e. the
278 %term obtained interpreting $t$ with $\Phi_i$). If the refinement succeeds the
279 %next interpretation $\Phi_{i+1}$ will be created \emph{making a choice}, that is
280 %replacing a placeholder with one of the possible choice from the corresponding
281 %disambiguation domain. The placeholder to be replaced is chosen following a
282 %preorder visit of the ambiguous term. If the refinement fails the current set of
283 %choices cannot lead to a well-typed term and backtracking is attempted.
284 %Once an unambiguous correct interpretation is found (i.e. $\Phi_i$ does no
285 %longer contain any placeholder), backtracking is attempted
286 %anyway to find the other correct interpretations.
287 %
288 %The intuition which explain why this algorithm is more efficient is that as soon
289 %as a term containing placeholders is not typable, no further instantiation of
290 %its placeholders could lead to a typable term. For example, during the
291 %disambiguation of user input \texttt{\TEXMACRO{forall} x. x*0 = 0}, an
292 %interpretation $\Phi_i$ is encountered which associates $?$ to the instance
293 %of \texttt{0} on the right, the real number $0$ to the instance of \texttt{0} on
294 %the left, and the multiplication over natural numbers (\texttt{mult} for short)
295 %to \texttt{*}. The refiner will fail, since \texttt{mult} require a natural
296 %argument, and no further instantiation of the placeholder will be tried.
297 %
298 %If, at the end of the disambiguation, more than one possible interpretations are
299 %possible, the user will be asked to choose the intended one (see
300 %Fig.~\ref{fig:disambiguation}).
301 %
302 %\begin{figure}[htb]
303 %%   \centerline{\includegraphics[width=0.9\textwidth]{disambiguation-1}}
304 %  \caption{\label{fig:disambiguation} Disambiguation: interpretation choice}
305 %\end{figure}
306 %
307 %Details of the disambiguation algorithm of \WHELP{} can
308 %be found in~\cite{disambiguation}, where an equivalent algorithm
309 %that avoids backtracking is also presented.
310
311 \subsection{notazione}
312 \ASSIGNEDTO{zack}
313
314 \subsection{libreria tutta visibile}
315 \ASSIGNEDTO{csc}
316
317 \subsection{ricerca e indicizzazione}
318 \ASSIGNEDTO{andrea}
319
320 \subsection{auto}
321 \ASSIGNEDTO{andrea}
322
323 \subsection{xml / gestione della libreria}
324 \ASSIGNEDTO{gares}
325
326 \subsection{named variable}
327 \ASSIGNEDTO{csc}
328
329 \subsection{assenza di proof tree / resa in linguaggio naturale}
330 \ASSIGNEDTO{andrea}
331
332 \subsection{selezione semantica, cut paste, hyperlink}
333 \ASSIGNEDTO{zack}
334
335 \subsection{sostituzioni esplicite vs moduli}
336 \ASSIGNEDTO{csc}
337
338 \section{Drawbacks, missing, \dots}
339
340 \subsection{moduli}
341 \ASSIGNEDTO{}
342
343 \subsection{ltac}
344 \ASSIGNEDTO{}
345
346 \subsection{estrazione}
347 \ASSIGNEDTO{}
348
349 \subsection{localizzazione errori}
350 \ASSIGNEDTO{}
351
352 \textbf{Acknowledgements}
353 We would like to thank all the students that during the past
354 five years collaborated in the \HELM{} project and contributed to 
355 the development of Matita, and in particular
356 A.Griggio, F.Guidi, P. Di Lena, L.Padovani, I.Schena, M.Selmi, 
357 V.Tamburrelli.
358
359
360 \begin{thebibliography}{}
361
362  \bibitem{ida}A.Asperti, H.Geuvers, I.Loeb, L.E.Mamane, C.Sacerdoti Coen.
363   An Interactive Algebra Course with Formalised Proofs and Definitions. 
364   Post-Proceedings of the Fourth International Conference on
365   Mathemtical Knowledge Management. Bremen, Germany, July 2005. LNCS, 
366   to appear.
367
368  \bibitem{annals} A.~Asperti, F.~Guidi, L.~Padovani, C.~Sacerdoti Coen,
369   I.~Schena. \emph{Mathematical Knowledge Management in HELM}. Annals of
370   Mathematics and Artificial Intelligence, 38(1): 27--46; May 2003.
371
372  \bibitem{whelp} A.~Asperti, F.~Guidi, C.~Sacerdoti Coen,
373   E.Tassi, S.Zacchiroli. \emph{A content based mathematical search
374   engine: whelp}. Post-proceedings of the Types 2004 International 
375   Conference, Jouy-en-Josas, France, December 2004. LNCS (to appear). 
376
377  \bibitem{metadata2} A. Asperti, M. Selmi. \emph{Efficient Retrieval of
378   Mathematical Statements}. In Proceeding of the Third International Conference
379   on Mathematical Knowledge Management, MKM 2004. Bialowieza, Poland. LNCS 3119.
380  \bibitem{pechino} A.Asperti, B.Wegner. \emph{An Approach to
381   Machine-Understandable Representation of the Mathematical Information in
382   Digital Documents}.  In: Fengshai Bai and Bernd Wegner (eds.): Electronic
383   Information and Communication in Mathematics, LNCS vol. 2730, 
384   pp. 14--23, 2003
385
386  \bibitem{coq} The Coq proof-assistant, \url{http://coq.inria.fr}
387
388  \bibitem{metadata1} F. Guidi, C. Sacerdoti Coen. \emph{Querying Distributed
389   Digital Libraries of Mathematics}. In Proceedings of Calculemus 2003, 11th
390   Symposium on the Integration of Symbolic Computation and Mechanized 
391   Reasoning. Aracne Editrice.
392  
393  \bibitem{exportation} C. Sacerdoti Coen. \emph{From Proof-Assistans to
394   Distributed Libraries of Mathematics: Tips and Pitfalls}.
395   In Proc. Mathematical Knowledge Management 2003, Lecture Notes in Computer
396   Science, Vol. 2594, pp. 30--44, Springer-Verlag.
397
398  \bibitem{disambiguation} C. Sacerdoti Coen, S. Zacchiroli. \emph{Efficient
399   Ambiguous Parsing of Mathematical Formulae}. In Proceedings of the Third
400   International Conference on Mathematical Knowledge Management, MKM 2004. 
401   LNCS,3119.
402
403 \end{thebibliography}
404
405 \end{document}
406