]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/calculemus-2003/hbugs-calculemus-2003.tex
first checkin
[helm.git] / helm / papers / calculemus-2003 / hbugs-calculemus-2003.tex
1 \documentclass[runningheads]{llncs}
2 \pagestyle{headings}
3 \setcounter{page}{1}
4 \usepackage{graphicx}
5 \usepackage{amsfonts}
6
7 % \myincludegraphics{filename}{place}{width}{caption}{label}
8 \newcommand{\myincludegraphics}[5]{
9    \begin{figure}[#2]
10    \begin{center}
11    \includegraphics[width=#3]{XFIG-EPS/#1.eps}
12    \caption[#4]{#5}
13    \label{#1}
14    \end{center}
15    \end{figure}
16 }
17
18 \newcommand{\todo}[1]{\footnote{\textbf{TODO: #1}}}
19 \newcommand{\ws}{Web-Service}
20 \newcommand{\wss}{Web-Services}
21 \newcommand{\hbugs}{H-Bugs}
22 \newcommand{\helm}{HELM}
23
24 \title{Brokers and Web-Services for Automatic Deduction: a Case Study}
25
26 \author{Claudio Sacerdoti Coen \and Stefano Zacchiroli}
27
28 \institute{
29   Department of Computer Science\\
30   University of Bologna\\
31   Via di Mura Anteo Zamboni 7, 40127 Bologna, ITALY\\
32   \email{sacerdot@cs.unibo.it}
33   \and
34   Department of Computer Science\\
35   \'Ecole Normale Sup\'erieure\\
36   45, Rue d'Ulm, F-75230 Paris Cedex 05, FRANCE\\
37   \email{zack@cs.unibo.it}
38 }
39
40 \date{ }
41
42 \begin{document}
43 \sloppy
44 \maketitle
45
46 \begin{abstract}
47   We present a planning broker and several Web-Services for automatic deduction.
48   Each Web-Service implements one of the tactics usually available in an
49   interactive proof-assistant. When the broker is submitted a "proof status" (an
50   unfinished proof tree and a focus on an open goal) it dispatches the proof to
51   the Web-Services, collects the successfull results, and send them back to the
52   client as "hints" as soon as they are available.
53   
54   In our experience this architecture turns out to be helpful both for
55   experienced users (who can take benefit of distributing heavy computations)
56   and beginners (who can learn from it).
57 \end{abstract}
58
59 \section{Introduction}
60   The \ws\ approach at software development seems to be a working solution for
61   getting rid of a wide range of incompatibilities between communicating
62   software applications. W3C's efforts in standardizing related technologies
63   grant longevity and implementations availability for frameworks based on \wss\
64   for information exchange. As a direct conseguence, the number of such
65   frameworks in increasing and the World Wide Web is moving from a disorganized
66   repository of human-understandable HTML documents to a disorganized repository
67   of applications working on machine-understandable XML documents both for input
68   and output.
69   
70   This lack of organization along with the huge amount of documents available,
71   have posed not a few problems for data location. If this limitation could be
72   overcome using heuristic-based search engine for HTML pages, a satisfying
73   solution has yet to be found for \ws\ location \todo{location non mi piace, ma
74   "localization" e' anche peggio, "retrieval"?}. A promising architecture seems
75   to be the use of \emph{brokers}, which access point (usually an URI) is known
76   by the potential clients or by \emph{registries}, to which the \wss\ subscribe
77   to publish their functionalities.
78
79   Since the \emph{Declaration of Linz}, the MONET Consortium \cite{MONET} is
80   working on the development of a framework aimed at providing a set of software
81   tools for the advertisement and discovering of mathematical web services. This
82   framework turns out to be strongly based on both \wss\ and brokers.
83
84   Several examples of CAS (Computer Algebra System) and Theorem Prover related
85   \wss\ have been shown to be useful and to fit well in the MONET Architecture
86   \todo{citarne qualcuno: CSC???}. On the other hand \todo{troppo informale?}
87   the set of \wss\ related to Proof Assistants tends to be ... rather ...
88   empty!\todo{gia' mi immagino il tuo commento: BUHM! :-)}
89
90   Despite of that the proof assistant case seems to be well suited to
91   investigate the usage of many different mathematical \wss. Indeed: most proof
92   assistants are still based on non-client/server architectures, are
93   application-centric instead of document-centric, offer a scarce level of
94   automation leaving entirely to the user the choice of which macro (usually
95   called \emph{tactic}) to use in order to make progress in a proof.
96
97   The average proof assistant can be, for example, a client of a \ws\
98   interfacing a specific or generic purpose theorem prover, or a client of a
99   \ws\ interfacing a CAS to simplify expressions in a particular mathematical
100   domain.
101
102   The Omega Ants project \todo{date, autori e paperi}, developed before the
103   \emph{\ws\ era}, enrich the Omega \cite{Omega} proof assistant with an
104   architecture able to distribute subparts of a proof to agents (Ants)
105   implemented as separate processes running on the same hosts of the proof
106   assistant \todo{controllare ...}.
107
108   In this paper we present an architecture, namely \hbugs\, implementing a
109   \emph{suggestion engine} for the proof assistant developed on behalf of the
110   \helm\ project. This architecture is based on a set of \wss\ and a broker (a
111   \ws\ itself) and is able to distribute a proof status from a client to several
112   \emph{tutor}, each of them can try to make progress in the proof and, in case
113   of success, notify the user sending him an \emph{hint}. Both the broker and
114   the tutors are instances of the homonymous entities of the MONET framework.
115
116 % \section{Introduction}
117 % Since the development of the first proof-assistants based on the
118 % Curry-Howard isomorphism, it became clear that directly writing
119 % lambda-terms (henceforth called simply terms) was a difficult, repetitive,
120 % time-expensive and error prone activity; hence the introduction of
121 % meta-languages to describe procedures that are able to automatically
122 % generate the low-level terms.
123 % Nowadays, almost all the proof-assistants
124 % using terms description of proofs have many levels of abstractions, i.e.
125 % meta-languages, to create the terms, with the only remarkable exception
126 % of the ALF family \cite{ALF} in which terms are still directly written
127 % without any over-standing level of abstraction.
128
129 % In particular, there are
130 % usually at least two levels, that of tactics and that of the language in
131 % which the whole system and hence the tactics are written; once the tactics
132 % are implemented, to do a proof the user enters to the system a sequence of
133 % tactics, called a script; the script is then executed to create the term
134 % encoding of the proof, which is type-checked by the kernel of the
135 % proof-assistant. Writing a script interactively is much simpler than
136 % writing the term by hands; once written, though, it becomes impossible
137 % to understand a script without replaying it interactively. For this reason,
138 % we can hardly speak of the language of tactics as a high level language,
139 % even if it is ``compiled'' to the language of terms.
140
141 % To avoid confusion, in the rest of this paper we will
142 % avoid the use of the term ``proof'', using only ``script'' and ``term'';
143 % moreover, we will avoid also the terms ``proof-checking'' and ``type-checking'',
144 % replacing them with ``retyping'' to mean the type-checking of an already
145 % generated term; finally, we will use the term ``compiling'' to mean the
146 % execution of a script. Usually, compilation ends with
147 % the type-checking of the generated term; hence the choice of ``retyping'' for
148 % the type-checking of an already generated term.
149
150 % A long term consequence of the introduction of tactics has been the
151 % progressive lowering of interest in terms. In particular, users of
152 % modern proof-assistants as Coq \cite{Coq} may even ignore the existence of
153 % commands to show the terms generated by their scripts. These terms are
154 % usually very huge and quite unreadable, so they don't add any easily
155 % accessible information to the scripts. Hence implementors have loosed
156 % interest in terms too, as far as their size and compilation time are
157 % small enough to make the system response-time acceptable.
158 % When this is not the case, it is sometimes possible to trade space
159 % with time using reflexive tactics, in which the potentiality of complex
160 % type-systems to speak about themselves are exploited: reflexive tactics
161 % usually leads to a polynomial asympotical reduction in the size of the
162 % terms, at the cost of an increased reduction time during retyping and
163 % compilation. Often, though, reflexive tactics could not be used; moreover,
164 % reflexive tactics suffer of the same implementative problems of other tactics
165 % and so could be implemented in such a way to create huger than
166 % needed terms, even if asymptotically smaller than the best ones created
167 % without reflection.
168
169 % The low level of interest in terms of the implementors of
170 % tactics often leads to naive implementations (``If it works, it is OK'') and
171 % this to low-quality terms, which:
172 % \begin{enumerate}
173 %  \item are huger than needed because particular cases are not taken
174 %   into account during tactic development
175 %  \item require more time than needed for retyping due to
176 %   their size
177 %  \item are particularly unreadable because they don't
178 %   correspond to the ``natural'' way of writing the proof by hand
179 % \end{enumerate}
180 % To cope with the second problem, retyping is usually avoided allowing
181 % systems to reload saved terms without retyping them and using a
182 % checksum to ensure that the saved file has not been modified. This is
183 % perfectly reasonable accordingly to the traditional application-centric
184 % architecture of proof-assistants in which you have only one tool integrating
185 % all the functionalities and so you are free to use a proprietary format for data
186 % representation.
187
188 % In the last months, though, an ever increasing number of people and projects
189 % (see, for example, HELM \cite{EHELM}, MathWeb \cite{MATHWEB} and
190 % Formavie \cite{FORMAVIE})
191 % have been interested to switch from the application-centric model to the
192 % newer content-centric one, in which information is stored in
193 % standard formats (that is, XML based) to allow different applications to work
194 % on the same set of data. As a consequence, term size really becomes an
195 % important issue, due to the redundancy of standard formats, and retyping
196 % is needed because the applications can not trust each other, hence needing
197 % retyping and making retyping time critical.
198 % Moreover, as showed by Yann Coscoy in its PhD.
199 % thesis \cite{YANNTHESIS} or by the Alfa interface to the Agda system
200 % \cite{ALFA}, it is perfectly reasonable and also feasible to try
201 % to produce descriptions in natural languages of formal proofs encoded as
202 % terms.
203 % This approach, combined with the further possibility of applying the usual
204 % two-dimensional mathematic notation to the formulas that appears in the
205 % terms, is being followed by projects HELM \cite{HELM}, PCOQ \cite{PCOQ} and
206 % MathWeb \cite{MATHWEB} with promising results. It must be understood, though,
207 % that the quality (in terms of naturality and readability) of this kind of
208 % proofs rendering heavily depends on the quality of terms, making also
209 % the third characteristic of low-quality terms a critical issue.
210
211 % A totally different scenario in which term size and retyping time are
212 % critical is the one introduced by Necula and Lee \cite{Necula} under
213 % the name Proof Carrying Code (PCC). PCC is a technique that can be used
214 % for safe execution of untrusted code. In a typical instance of PCC, a code
215 % receiver establishes a set of safety rules that guarantee safe behavior
216 % of programs, and the code producer creates a formal safety proof that
217 % proves, for the untrusted code, adherence to the safety rules. Then, the
218 % proof is transmitted to the receiver together with the code and it is
219 % retyped before code execution. While very compact representation of the
220 % terms, highly based on type-inference and unification, could be used
221 % to reduce the size and retyping time \cite{Necula2}, designing proof-assistants
222 % to produce terms characterized by an high level of quality is still necessary.
223
224 % In the next section we introduce a particular class of metrics for
225 % tactics evaluation. In section \ref{equivalence} we consider the
226 % notion of tactics equivalence and we describe one of the bad habits
227 % of tactics implementors, which is overkilling; we also provide and analyze
228 % a simple example of overkilling tactic. In the last section we describe
229 % a concrete experience of fixing overkilling in the implementation of a
230 % reflexive tactic in system Coq and we analyze the gain with respect to
231 % term-size, retyping time and term readability.
232
233 % \section{From Metrics for Terms Evaluation to Metrics for Tactics Evaluation}
234 % The aim of this section is to show how metrics for term evaluation could
235 % induce metrics for tactic evaluation. Roughly speaking, this allows us to
236 % valuate tactics in terms of the quality of the terms produced. Even if
237 % we think that these kinds of metrics are interesting and worth studying,
238 % it must be understood that many other valuable forms of metrics could be
239 % defined on tactics, depending on what we are interested in. For example,
240 % we could be interested on compilation time, that is the sum of the time
241 % required to generate the term and the retyping time for it. Clearly, only
242 % the second component could be measured with a term metric and a good
243 % implementation of a tactic with respect to the metric considered could
244 % effectively decide to sacrifice term quality (and hence retyping time) to
245 % minimize the time spent to generate the term. The situation is very close to
246 % the one already encountered in compilers implementation, where there is
247 % always a compromise, usually user configurable, between minimizing compiling
248 % time and maximizing code quality.
249
250 % The section is organized as follows: first we recall the definition of
251 % tactic and we introduce metrics on terms; then we give the definition
252 % of some metrics induced by term metrics on tactics.
253
254 % \begin{definition}[Of tactic]
255 % We define a \emph{tactic} as a function that, given a goal $G$ (that is, a local
256 % context plus a type to inhabit) that satisfies a list of assumptions
257 % (preconditions) $P$,
258 % returns a couple $(L,t)$ where
259 % $L = {L_1,\ldots,L_n}$ is a (possible empty) list of proof-obligations
260 % (i.e. goals) and $t$ is a function that, given a list $l = {l_1,\ldots,l_n}$
261 % of terms such that $l_i$ inhabits\footnote{We say, with a small abuse of
262 % language, that a term $t$ inhabits a goal $G=(\Gamma,T)$ when $t$ is of type
263 % $T$ in the context $\Gamma$.} $L_i$ for each $i$ in ${1,\ldots,n}$, returns a
264 % term $t(l)$ inhabiting $G$.
265 % \end{definition}
266
267 % % You can get another looser definition of tactic just saying that a tactic
268 % % is a partial function instead than a total one. In this paper when referring
269 % % to tactics we always refer to the first definition.
270
271 % \begin{definition}[Of term metric]
272 % For any goal $G$, a term metric $\mu_G$ is any function in
273 % $\mathbb{N}^{\{t/t\;\mbox{inhabits}\;G\}}$.
274 % Two important class of term metrics are functional metrics and monotone
275 % metrics:
276 % \begin{enumerate}
277 % \item {\bf Functional metrics:} a metric $\mu_G$ is \emph{functional}
278 %  if for each term context (=term with an hole) $C[]$ and for all terms
279 %  $t_1$,$t_2$ if $\mu_G(t_1)=\mu_G(t_2)$ then $\mu_G(C[t_1])=\mu_G(C[t_2])$.
280 %  An equivalent definition is that a metric $\mu_G$ is functional
281 %  if for each term context $C[]$ the function
282 %  $\lambda t.\mu_G(C[\mu_G^{-1}(t)])$ is well defined.
283 % \item {\bf Monotone metrics:} a metric $\mu_G$ is \emph{monotone} if for
284 %  each term context $C[]$ and for all terms $t_1$,$t_2$ if
285 %  $\mu_G(t_1)\le\mu_G(t_2)$ then $\mu_G(C[t_1])\le\mu_G(C[t_2])$.
286 %  An equivalent definition is that a metric $\mu_G$ is functional if
287 %  for each term context $C[]$ the function
288 %  $\lambda t.\mu_G(C[\mu_G^{-1}(t)])$ is well defined and monotone.
289 % \end{enumerate}
290
291 % % Vecchie definizioni
292 % %\begin{enumerate}
293 % %\item {\bf Monotony:} a metric $\mu_G$ is \emph{monotone} if for each term
294 %  %context (=term with an hole) $C[]$ and for all terms $t_1$,$t_2$ if
295 %  %$\mu_G(t_1)\le\mu_G(t_2)$ then $\mu_G(C[t_1])\le\mu_G(C[t_2])$
296 % %\item {\bf Strict monotony:} a monotone metric $\mu_G$ is \emph{strictly
297 %  %monotone} if for each term context $C[]$ and
298 %  %for all terms $t_1$,$t_2$ if $\mu_G(t_1)=\mu_G(t_2)$ then
299 %  %$\mu_G(C[t_1])=\mu_G(C[t_2])$
300 % %\end{enumerate}
301 % \end{definition}
302
303 % Typical examples of term metrics are the size of a term, the time required
304 % to retype it or even an estimate of its ``naturality'' (or simplicity) to be
305 % defined somehow; the first two are also examples of monotone metrics
306 % and the third one could probably be defined as to be. So, in the rest
307 % of this paper, we will restrict to monotone metrics, even if the
308 % following definitions also work with weaker properties for general metrics.
309 % Here, however, we are not interested in defining such metrics, but in showing
310 % how they naturally induce metrics for tactics.
311
312 % Once a term metric is chosen, we get the notion of a best term (not unique!)
313 % inhabiting a goal:
314 % \begin{definition}[Of best terms inhabiting a goal]
315 % the term $t$ inhabiting a goal $G$ is said to be a best term inhabiting $G$
316 % w.r.t. the metric $\mu_G$ when
317 % $\mu_G(t) = min\{\mu_G(t') / t'\;\mbox{inhabits}\;G\}$.
318 % \end{definition}
319
320 % Using the previous notion, we can confront the behavior of two tactics
321 % on the same goal:
322
323 % \begin{definition}
324 % Let $\tau_1$ and $\tau_2$ be two tactics both applyable to a goal $G$
325 % such that $\tau_1(G) = (L_1,t_1)$ and $\tau_2(G) = (L_2,t_2)$.
326 % We say that $\tau_1$ is better or equal than $\tau_2$ for the goal $G$
327 % with respect to $\mu_G$ if, for all $l_1$ and $l_2$ lists of best terms
328 % inhabiting respectively $L_1$ and $L_2$, $\mu_G(t_1(l_1)) \le \mu_G(t_2(l_2))$
329 % holds.
330 % \end{definition}
331 % Note that confronting in this way ``equivalent'' tactics
332 % (whose definition is precised in the next section) gives us information
333 % on which implementation is better; doing the same thing on tactics that
334 % are not equivalent, instead, gives us information about what tactic to
335 % apply to obtain the best proof.
336
337 % A (functional) metric to confront two tactics only on a particular goal
338 % has the nice property to be a total order, but is quite useless. Hence,
339 % we will now
340 % define a bunch of different tactic metrics induced by term metrics
341 % that can be used to confront the behavior of tactics when applied to
342 % a generic goal. Some of them will be \emph{deterministic} partial orders;
343 % others will be total orders, but will provide only a \emph{probabilistic}
344 % estimate of the behavior. Both kinds of metrics are useful in practice
345 % when rating tactics implementation.
346 % \begin{definition}[Of locally deterministic better or equal tactic]
347 % $\tau_1$ is a locally deterministic (or locally
348 % uniform) better or equal tactic
349 % than $\tau_2$ w.r.t. $\mu$ (and in that case we write $\tau_1 \le_{\mu} \tau_2$
350 % or simply $\tau_1 \le \tau_2$), when
351 % for all goals $G$ satisfying the preconditions of both tactics we have that
352 % $\tau_1$ is better or equal than $\tau_2$ w.r.t. the metric $\mu_G$.
353 % \end{definition}
354
355 % \begin{definition}[Of locally deterministic better tactic]
356 % $\tau_1$ is a locally deterministic (or locally uniform)
357 % better tactic than $\tau_2$ 
358 % w.r.t. $\mu$ (and in that case we write $\tau_1 <_{\mu} \tau_2$
359 % or simply $\tau_1 < \tau_2$), when $\tau_1 \le_{\mu} \tau_2$ and
360 % exists a goal $G$ satisfying the preconditions of both tactics such that
361 % $\tau_1$ is better (but not equal!) than $\tau_2$ w.r.t. the metric $\mu_G$.
362 % \end{definition}
363
364 % \begin{definition}[Of locally probabilistic better or equal tactic of a factor K]
365 % $\tau_1$ is said to be a tactic locally probabilistic better or equal of a
366 % factor $0.5 \le K \le 1$ than $\tau_2$ w.r.t. $\mu$ and a particular expected
367 % goals distribution when the probability of having $\tau_1$ better or equal than
368 % $\tau_2$ w.r.t. the metric $\mu_G$ is greater or equal to $K$ when $G$ is
369 % chosen randomly according to the distribution.
370 % \end{definition}
371 % The set of terms being discrete, you can note that a deterministically better
372 % or equal tactic is a tactic probabilistically better or equal of a factor 1.
373
374
375 % To end this section, we can remark the strong dependence of the $\le$
376 % relation on the choice of metric $\mu$, so that it is easy to find
377 % two metrics $\mu_1,\mu_2$ such that $\tau_1 <_{\mu_1} \tau_2$ and
378 % $\tau_2 <_{\mu_2} \tau_1$. Luckily, tough, the main interesting metrics,
379 % term size, retyping time and naturality, are in practice highly correlated,
380 % though the correlation of the third one with the previous two could be a
381 % bit surprising. So, in the following section, we
382 % will not state what is the chosen term metric; you may think as
383 % any of them or even at some kind of weighted mean.
384
385
386 % \section{Equivalent Tactics and Overkilling}
387 % \label{equivalence}
388 % We are now interested in using the metrics defined in the previous section
389 % to confront tactics implementation. Before doing so, though, we have to
390 % identify what we consider to be different implementations of the
391 % same tactic. Our approach consists in identifying every implementation
392 % with the tactic it implements and then defining appropriate notions of
393 % equivalence for tactics: two equivalent tactics will then be considered
394 % as equivalent implementations and will be confronted using metrics.
395
396 % Defining two tactics as equivalent when they can solve exactly the same
397 % set of goals generating the same set of proof-obligations seems quite natural,
398 % but is highly unsatisfactory if not completely wrong. The reason is that, for
399 % equivalent tactics, we would like to have the \emph{property of substitutivity},
400 % that is substituting a tactic for an equivalent one in a script should give
401 % back an error-free script\footnote{A weaker notion of substitutivity is that
402 % substituting the term generated by a tactic for the term generated by an
403 % equivalent one in a generic well-typed term should always give back a
404 % well-typed term.}. In logical frameworks with dependent types,
405 % without proof-irrelevance and with universes as CIC \cite{Werner} though,
406 % it is possible for a term to inspect the term of a previous proof, behaving
407 % in a different way, for example, if the constructive proof of a conjunction
408 % is made proving the left or right side.
409 % So, two tactics, equivalent w.r.t.  the previous
410 % definition, that prove $A \vee A$ having at their disposal an
411 % hypothesis $A$ proving the first one the left and the second one
412 % the right part of the conjunction, could not be substituted one for the
413 % other if a subsequent term inspects the form of the generated proof.
414
415 % Put in another way, it seems quite reasonable to derive equivalence for
416 % tactics from the definition of an underlying equivalence for terms.
417 % The simplest form of such an equivalence relation is convertibility
418 % (up to proof-irrelevance) of closed terms and this is the relation
419 % we will use in this section and the following one. In particular,
420 % we will restrict ourselves to CIC and hence to
421 % $\beta\delta\iota$-convertibility\footnote{The Coq proof-assistant
422 % introduces the notion of \emph{opaque} and \emph{transparent} terms,
423 % differing only for the possibility of being inspected. Because the
424 % user could change the opacity status at any time, the notion of
425 % convertibility we must conservatively choose for the terms of Coq is
426 % $\beta\delta\iota$-convertibility after having set all the definitions
427 % as transparent.}.
428 % Convertibility, though, is a too restrictive notion that does not take
429 % in account, for example, commuting conversions. Looking for more suitable
430 % notions of equivalence is our main open issue for future work.
431
432 % \begin{definition}[Of terms closed in a local environment]
433 % A term $t$ is \emph{closed} in a local environment $\Gamma$ when $\Gamma$
434 % is defined on any free variable of $t$.
435 % \end{definition}
436
437 % \begin{definition}[Of equivalent tactics]
438 % We define two tactics $\tau_1$ and $\tau_2$ to be equivalent (and
439 % we write $\tau_1 \approx \tau_2$) when for each goal $G = (\Gamma,T)$ and for
440 % each list of terms closed in $\Gamma$ and inhabiting the proof-obligations
441 % generated respectively by $\tau_1$ and $\tau_2$, we have that the result terms
442 % produced by $\tau_1$ and $\tau_2$ are $\beta\delta\iota$-convertible.
443 % \end{definition}
444
445 % Once we have the definition of equivalent tactics, we can use metrics,
446 % either deterministic or probabilistic, to confront them. In particular,
447 % in the rest of this section and in the following one we will focus on the
448 % notion of deterministically overkilling tactic, defined as follows:
449
450 % \begin{definition}[Of overkilling tactics]
451 % A tactic $\tau_1$ is (deterministically) overkilling w.r.t. a metric
452 % $\mu$ when there exists another tactic $\tau_2$ such that
453 % $\tau_1 \approx \tau_2$ and $\tau_2 <_\mu \tau_1$.
454 % \end{definition}
455
456 % Fixing an overkilling tactic $\tau_1$ means replacing it with the
457 % tactic $\tau_2$ which is the witness of $\tau_1$ being overkilling.
458 % Note that the fixed tactic could still be overkilling.
459
460 % The name overkilling has been chosen because most of the time overkilling
461 % tactics are tactics that do not consider special cases, following the general
462 % algorithm. While in computer science it is often a good design pattern to
463 % prefer general solutions to ad-hoc ones, this is not a silver bullet:
464 % an example comes another time from compiler technology, where
465 % ad-hoc cases, i.e. optimizations, are greatly valuable if not necessary.
466 % In our context, ad-hoc cases could be considered either as optimizations,
467 % or as applications of Occam's razor to proofs to keep the simplest one.
468
469 % \subsection{A Simple Example of Overkilling Tactic}
470 % A first example of overkilling tactic in system Coq is
471 % \emph{Replace}, that works in this way: when the current goal
472 % is $G = (\Gamma,T)$, the
473 % tactic ``{\texttt Replace E$_1$ with E$_2$.}'' always produces a new
474 % principal proof-obligation $(\Gamma, T\{E_2/E_1\})$ and an auxiliary
475 % proof-obligation $(\Gamma, E_1=E_2)$ and uses the elimination scheme
476 % of equality on the term $E_1 = E_2$ and the two terms that inhabit the
477 % obligations to prove the current goal.
478
479 % To show that this tactic is overkilling, we will provide an example
480 % in which the tactic fails to find the best term, we will
481 % propose a different implementation that produces the best term and we will
482 % show the equivalence with the actual one.
483
484 % The example consists in applying the tactic in the case in which $E_1$ is
485 % convertible to $E_2$: the tactic proposes to the user the two
486 % proof-obligations and then builds the term as described above. We claim
487 % that the term inhabiting the principal proof-obligation also inhabits
488 % the goal and, used as the generated term, is surely smaller
489 % and quicker to retype than the one that is generated in the
490 % implementation; moreover, it
491 % is also as natural as the previous one, in the sense that the apparently
492 % lost information has simply become implicit in the reduction and could
493 % be easily rediscovered using type-inference algorithms as the one described
494 % in Coscoy's thesis \cite{YANNTHESIS}. So, a new implementation could
495 % simply recognize this special case and generate the better term.
496
497 % We will now show that the terms provided by the two implementations are
498 % $\beta\delta\iota$-convertible.
499 % Each closed terms in $\beta\delta\iota$-normal form
500 % inhabiting the proof that $E_1$ is equal to $E_2$ is equal to the only
501 % constructor of equality applied to a term convertible to the type of
502 % $E_1$ and to another term convertible to $E_1$; hence, once the principle
503 % of elimination of equality is applied to this term, we can first apply
504 % $\beta$-reduction and then $\iota$-reduction to obtain the term inhabiting
505 % the principal proof-obligation in which $E_1$ has been replaced by $E_2$.
506 % Since $E_1$ and $E_2$ are $\beta\delta\iota$-convertible by hypothesis and
507 % for the congruence properties of convertibility in CIC, we have that the
508 % generated term is $\beta\delta\iota$-convertible to the one inhabiting the
509 % principal proof-obligation.
510
511 % %The simplest example is when $E_1$ and $E_2$ are syntactically equal:
512 % %in this case the principal obligation proposed is identical to the current goal
513 % %and the equality elimination introduced could be replaced by the proof of
514 % %this obligation, leading to a smaller, quicker to retype and also more
515 % %natural\footnote{Even if naturality is in some way a subjective metric,
516 % %who would dare say that a proof in which you rewrite an expression with
517 % %itself is natural?} term. To show that handling this special case in this
518 % %way is equivalent to the current solution, we have to show that the two
519 % %terms are $\beta\delta\iota$-convertible when so are the subterms inhabiting
520 % %the obligations.
521 % %The only closed term in $\beta\delta\iota$-normal form
522 % %inhabiting the proof that $E_1$ is equal to $E_1$ is the only constructor
523 % %of equality applied to the type of $E_1$ and to $E_1$; hence we can
524 % %first apply $\beta$-reduction and then $\iota$-reduction to obtain
525 % %the second proof in which $E_1$ has been replaced by $E_1$, i.e. the
526 % %second proof.
527
528 % %So, for this example, the simple fix to avoid overkilling is checking
529 % %if $E_1$ and $E_2$ are syntactically equal and in case omitting the elimination;
530 % %curiously, this is done in Coq in the implementation of a very similar tactic
531 % %called \emph{Rewriting}.
532
533
534 % %A second, more involved, example is when $E_1$ and $E_2$ are not
535 % %syntactically equal, but $E_1$ reduces to $E_2$. Even in this case
536 % %the elimination could simply be avoided because the typing rules of
537 % %the logical system ensures us that a term that inhabits the principal
538 % %obligation also inhabits the current goal: the proof is equivalent to the
539 % %previous one, but for the last step in which $E_2$ is actually substituted for
540 % %$E_1$; by hypothesis, though, the two terms are $\beta\delta\iota$-convertible
541 % %and hence the thesis.
542
543 % %Surely smaller and faster to retype, the new term is also as natural
544 % %as the previous one, in the sense that the apparently lost information has
545 % %simply become implicit in the reduction and could be easily rediscovered
546 % %using type-inference algorithms as the one described in chapter ???
547 % %of Coscoy's thesis \ref{YANNTHESIS}.
548
549 % This example may seem quite stupid because, if the user is already able to
550 % prove the principal proof-obligation and because this new goal is totally
551 % equivalent to the original one, the user could simply redo the same steps
552 % without applying the rewriting at all. Most of the time, though, the
553 % convertibility of the two terms could be really complex to understand,
554 % greatly depending on the exact definitions given; indeed, the user could
555 % often be completely unaware of the convertibility of the two terms. Moreover,
556 % even in the cases in which the user understands the convertibility, the
557 % tactic has the important effect of changing the form of the current
558 % goal in order to simplify the task of completing the proof, which is the reason
559 % for the user to apply it.
560
561 % ~\\
562
563 % The previous example shows only a very small improvement in the produced
564 % term and could make you wonder if the effort of fixing overkilling and
565 % more in general if putting more attention to terms when implementing
566 % tactics is really worth the trouble. In the next section we describe as
567 % another example a concrete experience of fixing a complex reflexive tactic
568 % in system Coq that has lead to really significant improvements in term
569 % size, retyping time and naturality.
570
571 % \section{Fixing Overkilling: a Concrete Experience}
572 % Coq provides a reflexive tactic called \emph{Ring} to do associative-commutative
573 % rewriting in ring and semi-ring structures. The usual usage is,
574 % given the goal $E_1 = E_2$ where $E_1$ and $E_2$ are two expressions defined
575 % on the ring-structure, to prove the goal reducing it to proving
576 % $E'_1 = E'_2$ where $E'_i$ is the normal form of $E_i$. In fact, once
577 % obtained the goal $E'_1 = E'_2$, the tactic also tries to apply simple
578 % heuristics to automatically solve the goal.
579
580 % The actual implementation of the tactic by reflexion is quite complex and
581 % is described in \cite{Ring}. The main idea is described in Fig. \ref{ring1}:
582 % first of all, an inductive data type to describe abstract polynomial is
583 % made available. On this abstract polynomial, using well-founded recursion in
584 % Coq, a normalization function named $apolynomial\_normalize$ is defined;
585 % for technical reasons, the abstract data type of normalized polynomials
586 % is different from the one of un-normalized polynomials. Then, two
587 % interpretation functions, named $interp\_ap$ and $interp\_sacs$ are given
588 % to map the two forms of abstract polynomials to the concrete one. Finally,
589 % a theorem named $apolynomial\_normalize\_ok$ stating the equality of
590 % the interpretation of an abstract polynomial and the interpretation of
591 % its normal form is defined in Coq using well-founded induction. The above
592 % machinery could be used in this way: to prove that $E^I$ is equal to its
593 % normal form $E^{IV}$, the tactic computes an abstract polynomial $E^{II}$ that,
594 % once interpreted, reduces to $E^{I}$, and such that the interpretation
595 % of $E^{III} = (apolynomial\_normalize E^{II})$ could be shown to be equal
596 % to $E^{IV}$ applying $apolynomial\_normalize\_ok$.
597
598 % %such that $(interp\_ap\;E^{II})$ could be proved (theorem
599 % %$apolynomial\_normalize\_ok$) in Coq to be equal to
600 % %$(interp\_sacs\;E^{III})$ where
601 % %$E^{III} = (apolynomial\_normalize E^{II})$ is another abstract polynomial
602 % %in normal form and the three functions $interp\_ap$, $interp\_sacs$ and
603 % %$apolynomial\_normalize$ could all be defined inside Coq using well-founded
604 % %recursion/induction on the abstract polynomial definition.
605
606 % % \myincludegraphics{ring1}{t}{12cm}{Reflexion in Ring}{Reflexion in Ring}
607 % % \myincludegraphics{ring2}{t}{10cm}{Ring implementation (first half)}{Ring implementation (first half)}
608
609 % In Fig. \ref{ring2} the first half of the steps taken
610 % by the Ring tactic to prove $E_1 = E_2$ are shown\footnote{Here $E_1$
611 % stands for $E^I$.}.
612 % The first step is replacing $E_1 = E_2$ with $(interp\_ap\;E^{II}_1) = E_2$,
613 % justifying the rewriting using the only one constructor of equality due to
614 % the $\beta\delta\iota$-convertibility of $(interp\_ap\;E^{II}_1)$ with $E_1$.
615 % The second one is replacing $(interp\_ap\;E^{II})$ with
616 % $(interp\_sacs\;E^{III})$, justifying the rewriting using
617 % $apolynomial\_normalize\_ok$.
618
619 % Next, the two steps are done again on the left part of the equality,
620 % obtaining $(interp\_sacs\;E^{III}_1) = (interp\_sacs\;E^{III}_2)$,
621 % that is eventually solved trying simpler tactics as \emph{Reflexivity} or left
622 % to the user.
623
624 % The tactic is clearly overkilling, at least due to the usage of rewriting for
625 % convertible terms. Let's consider as a simple example the session in Fig.
626 % \ref{session}:
627 % \begin{figure}[t]
628 % %\begin{verbatim}
629 % \mbox{\hspace{3cm}\tt Coq $<$ Goal ``0*0==0``.}\\
630 % \mbox{\hspace{3cm}\tt 1 subgoal}\\
631 % ~\\
632 % \mbox{\hspace{3cm}\tt ~~=================}\\
633 % \mbox{\hspace{3cm}\tt ~~~~``0*0 == 0``}\\
634 % ~\\
635 % \mbox{\hspace{3cm}\tt Unnamed\_thm $<$ Ring.}\\
636 % \mbox{\hspace{3cm}\tt Subtree proved!}
637 % %\end{verbatim}
638 % \caption{A Coq session.}
639 % \label{session}
640 % \end{figure}
641 % in Fig. \ref{before} the $\lambda$-term created by the
642 % original overkilling implementation of Ring is shown. Following the previous
643 % explanation, it should be easily understandable. In particular, the
644 % four rewritings are clearly visible as applications of $eqT\_ind$, as
645 % are the two applications of $apolynomial\_normalize\_ok$ and the
646 % three usage of reflexivity, i.e. the two applications of $refl\_eqT$
647 % to justify the rewritings on the left and right members of the equality
648 % and the one that ends the proof.
649
650 % Let's start the analysis of overkilling in this implementation:
651 % \begin{description}
652 % \item[Always overkilling rewritings:] as already stated, four of the rewriting
653 %  steps are always overkilling because the rewritten term is convertible to
654 %  the original one due to the tactic implementation.
655 %  As proved in the previous section, all these rewritings could be simply
656 %  removed obtaining an equivalent tactic.
657 % \item[Overkilling rewritings due to members already normalized:] it may happen,
658 %  as in our example, that one (or even both) of the two members is already in
659 %  normal form. In this case the two rewriting steps for that member could be
660 %  simply removed obtaining an equivalent tactic as shown in the previous section.
661 % \item[Rewriting followed by reflexivity:] after having removed all
662 %  the overkilling rewritings, the general form of the $\lambda$-term produced
663 %  for $E_1 = E_2$ is the application of two rewritings ($E'_1$ for $E_1$ and
664 %  $E'_2$ for $E_2$), followed by a proof of $E'_1 = E'_2$. In many cases,
665 %  $E'_1$ and $E'_2$ are simply convertible and so the tactic finishes the
666 %  proof with an application of reflexivity to prove the equivalent goal
667 %  $E'_1 = E'_1$.
668 %  A smaller and also more natural solution is just to
669 %  rewrite $E'_1$ for $E_1$ and then proving $E'_1 = E_2$ applying the lemma
670 %  stating the symmetry of equality to the proof of $E_2 = E'_2$.
671 %  The equivalence to the original
672 %  tactic is trivial by $\beta\iota$-reduction because the lemma is proved
673 %  exactly doing the rewriting and then applying reflexivity:
674 %  $$
675 %  \begin{array}{l}
676 %  \lambda A:Type.\\
677 %  \hspace{0.2cm}\lambda x,y:A.\\
678 %  \hspace{0.4cm}\lambda H:(x==y).\\
679 %  \hspace{0.6cm}(eqT\_ind~A~x~ [x:A]a==x~(refl\_eqT~A~x)~y~H)
680 %  \end{array}
681 %  $$
682 % \end{description}
683 % In Fig. \ref{after} is shown the $\lambda$-term created by the same
684 % tactic after having fixed all the overkilling problems described above.
685
686 % \begin{figure}
687 % \begin{verbatim}
688 % Unnamed_thm < Show Proof.
689 % LOC: 
690 % Subgoals
691 % Proof:
692 % (eqT_ind R
693 %   (interp_ap R Rplus Rmult ``1`` ``0`` Ropp (Empty_vm R)
694 %     (APmult AP0 AP0)) [r:R]``r == 0``
695 %   (eqT_ind R
696 %     (interp_sacs R Rplus Rmult ``1`` ``0`` Ropp (Empty_vm R)
697 %       Nil_varlist) [r:R]``r == 0``
698 %     (eqT_ind R
699 %       (interp_ap R Rplus Rmult ``1`` ``0`` Ropp (Empty_vm R) AP0)
700 %       [r:R]
701 %        ``(interp_sacs R Rplus Rmult 1 r Ropp (Empty_vm R) Nil_varlist)
702 %        == r``
703 %       (eqT_ind R
704 %         (interp_sacs R Rplus Rmult ``1`` ``0`` Ropp (Empty_vm R)
705 %           Nil_varlist)
706 %         [r:R]
707 %          ``(interp_sacs R Rplus Rmult 1 r Ropp (Empty_vm R)
708 %            Nil_varlist) == r`` (refl_eqT R ``0``)
709 %         (interp_ap R Rplus Rmult ``1`` ``0`` Ropp (Empty_vm R) AP0)
710 %         (apolynomial_normalize_ok R Rplus Rmult ``1`` ``0`` Ropp
711 %           [_,_:R]false (Empty_vm R) RTheory AP0)) ``0``
712 %       (refl_eqT R ``0``))
713 %     (interp_ap R Rplus Rmult ``1`` ``0`` Ropp (Empty_vm R)
714 %       (APmult AP0 AP0))
715 %     (apolynomial_normalize_ok R Rplus Rmult ``1`` ``0`` Ropp
716 %       [_,_:R]false (Empty_vm R) RTheory (APmult AP0 AP0))) ``0*0``
717 %   (refl_eqT R ``0*0``))
718 % \end{verbatim}
719 % \caption{The $\lambda$-term created by the original overkilling implementation}
720 % \label{before}
721 % \end{figure}
722
723 % \begin{figure}
724 % \begin{verbatim}
725 % Unnamed_thm < Show Proof.
726 % LOC: 
727 % Subgoals
728 % Proof:
729 % (sym_eqT R ``0`` ``0*0``
730 %   (apolynomial_normalize_ok R Rplus Rmult ``1`` ``0`` Ropp
731 %     [_,_:R]false (Empty_vm R) RTheory (APmult AP0 AP0)))
732 % \end{verbatim}
733 % \caption{The $\lambda$-term created by the new implementation}
734 % \label{after}
735 % \end{figure}
736
737 % \clearpage
738 % \subsection{A Quantitative Analysis of the Gain Obtained}
739 % Let's now try a quantitative analysis of the gain with respect to term size,
740 % retyping time and naturality, considering the two interesting cases of
741 % no member or only one member already in normal form\footnote{If the two
742 % members are already in normal form, the new implementation simply applies
743 % once the only constructor of the equality to one of the two members. The tactic
744 % is also implemented to do the same thing also when the two members are not yet
745 % in normal forms, but are already convertible. We omit this other improvement
746 % in our analysis.}.
747
748 % \subsubsection{Term Size.}
749 % \paragraph{Terms metric definition:} given a term $t$, the metric $|.|$ associates to it its number of nodes $|t|$.
750 % \paragraph{Notation}: $|T|$ stands for the number of nodes in the actual parameters
751 %  given to $interp\_ap$, $interp\_sacs$ and $apolynomial\_normalize\_ok$ to
752 %  describe the concrete (semi)ring theory and the list of non-primitive
753 %  terms occurring in the goal to solve. In the example in figures \ref{before}
754 %  and \ref{after}, $|T|$ is the number of nodes in
755 %  \begin{texttt}[R Rplus Rmult ``1`` ``0`` Ropp (Empty\_vm R)]\end{texttt}.
756 %  $|R|$ stands for the number of nodes in the term which is the carrier
757 %  of the ring structure. In the same examples, $|R|$ is simply 1, i.e.
758 %  the number of nodes in \begin{texttt}R\end{texttt}.
759
760 % \begin{displaymath}
761 % \begin{array}{l}
762 % \mbox{\bf Original version:}\\
763 % \begin{array}{ll}
764 % 1 + (|E^{II}_1| + |T| + 1) + |E_2| + |E_1| + &
765 % \mbox{(I rewriting Left)} \\
766 % 1 + |E_1| +  &
767 % \mbox{(justification)} \\
768 % 1 + (|E^{III}_1| + |T| + 1) + |E_2| + (|E^{II}_1| + |T| + 1) + &
769 % \mbox{(II rewriting Left)} \\
770 % (|E^{II}_1| + |T| + 1) + &
771 % \mbox{(justification)} \\
772 % 1 + (|E^{II}_2| + |T| + 1) + (|E^{III}_1| + |T| + 1) + |E_2| + &
773 % \mbox{(I rewriting Right)} \\
774 % 1 + |E_2| + &
775 % \mbox{(justification)} \\
776 % 1 + (|E^{III}_2| + |T| + 1) + (|E^{III}_1| + |T| + 1) + &
777 % \mbox{(II rewriting Right)} \\
778 % ~(|E^{II}_2| + |T| + 1) +& \\
779 % (|E^{II}_2| + |T| + 1) + &
780 % \mbox{(justification)} \\
781 % 1 + |E_1| = &
782 % \mbox{(reflexivity application)} \\
783 % \hline
784 % 4|E_1| + 2|E_2| + 3|E^{II}_1| + 3|E^{II}_2| + 3|E^{III}_1| + |E^{III}_2| +~ &
785 % \mbox{\bf Total number} \\
786 % ~10|T| + 17 &
787 % \end{array}
788 % \end{array}
789 % \end{displaymath}
790
791 % \begin{displaymath}
792 % \begin{array}{l}
793 % \mbox{\bf New version, both members not in normal form:}\\
794 % \begin{array}{ll}
795 % 1 + |R| + |E_1| + |E'_2| + &
796 % \mbox{(Rewriting Right)} \\
797 % 1 + |T| + |E^{II}_2| + &
798 % \mbox{(justification)} \\
799 % 1 + |R| + |E'_2| + |E'_1| + |E_2| + &
800 % \mbox{(Symmetry application)} \\
801 % 1 + |T| + |E^{II}_1| = &
802 % \mbox{(justification)} \\
803 % \hline
804 % 2|E_1| + |E_2| + |E^{II}_1| + |E^{II}_2| + 2|E'_2| + 2|T| +~ &
805 % \mbox{\bf Total number} \\
806 % ~2|R| + 4  & \\
807 % ~ &
808 % \end{array}
809 % \end{array}
810 % \end{displaymath}
811 % \begin{displaymath}
812 % \begin{array}{l}
813 % \mbox{\bf New version, only the first member not in normal form:}\\
814 % \begin{array}{ll}
815 % 1 + |R| + |E_1| + |E'_2| + &
816 % \mbox{(Rewriting)} \\
817 % 1 + |T| + |E^{II}_2| = &
818 % \mbox{(justification)} \\
819 % \hline
820 % |E_1| + |E'_2| + |E^{II}_2| + |T| + |R| + 2~~~  &
821 % \mbox{\bf Total number} \\
822 % ~ &
823 % \end{array}
824 % \end{array}
825 % \end{displaymath}
826
827 % While the overall space complexity of the terms generated by the new
828 % implementation is asymptotically equal to the one of the old implementation,
829 % all the constants involved are much smaller, but for the one of
830 % $E'_2$ (the two normal forms) that before was 0 and now is
831 % equal to 2. Is it possible to have goals for which the new implementation
832 % behaves worst than the old one? Unfortunately, yes. This happens when
833 % the size of the two normal forms $E'_1$ and $E'_2$ is greatly huger than
834 % ($E^{II}_1 + |T| + 1)$ and $(E^{II}_2 + |T| + 1)$. This happens when
835 % the number of occurrences of non-primitive terms is much higher than
836 % the number of non-primitive terms and the size of them is big. More
837 % formally, being $m$ the number of non-primitive terms, $d$ the average
838 % size and $n$ the number of occurrences, the new implementation creates bigger
839 % terms than the previous one if
840 % \begin{displaymath}
841 % n \log_2 m + m  d < n  d
842 % \end{displaymath}
843 % where the difference between the two members is great enough to hide the gain
844 % achieved lowering all the other constants.
845 % The logarithmic factor in the previous
846 % formula derives from the implementation of the map of variables to
847 % non-primitive terms as a tree and the representation of occurrences with
848 % the path inside the tree to retrieve the term.
849
850 % To fix the problem, for each non-primitive term occurring more than once
851 % inside the normal forms, we can use a \emph{let \ldots in} local definition
852 % to bind it to a fresh identifier; then we replace every occurrence of
853 % the term inside the normal forms with the appropriate
854 % identifier\footnote{This has not yet been implemented in Coq.}.
855 % In this way, the above inequation becomes
856 % \begin{displaymath}
857 % n \log_2 m + m  d < n + m  d
858 % \end{displaymath}
859 % that is never satisfied.
860
861 % Here it is important to stress how the latest problem was easily
862 % overlooked during the implementation and has been discovered
863 % only during the previous analysis, strengthening our belief in
864 % the importance of this kind of analysis for tactic implementations.
865
866 % In the next two paragraphs we will consider only the new implementation
867 % with the above fixing.
868
869 % \subsubsection{Retyping Time.}
870 % \paragraph{Terms metric definition:} given a term $t$, the metric $|.|$ associates to it the time $|t|$ required to retype it.
871
872 % Due to lack of space, we will omit a detailed analysis as the one given
873 % for terms size. Nevertheless, we can observe that the retyping time required
874 % is surely smaller because all the type-checking operations required for
875 % the new implementation are already present in the old one, but for the
876 % type-checking of the two normal forms, that have fewer complexity
877 % than the type-checking of the two abstract normal forms, and the
878 % \emph{let \ldots in} definitions that have the same complexity of the
879 % type-checking of the variable map. Moreover, the quite expensive operation
880 % of computing the two normal forms is already done during proof construction.
881
882 % %In the case in which both the members of the equality are not in normal form,
883 % %we can't expect a great improvement in retyping time but for very cheap
884 % %normalizations; this because retyping time is dominated by the factor due to
885 % %$apolynomial\_normalize$ that is present in both implementations and is
886 % %usually much higher than the factor due to the removed applications of
887 % %$interp\_ap$, $interp\_sacs$ and the eliminations of equality.
888
889 % %The situation is very different if one of the two members is already
890 % %convertible to its normal form and the reduction involved in the normalization
891 % %is expensive. In this rather unlikely case, the new implementation
892 % %avoids the reduction at all, roughly halving the overall retyping time.
893
894 % In section \ref{benchmarks} we present some benchmarks to give an idea of
895 % the real gain obtained.
896
897 % \subsubsection{Naturality.}~\\~\\
898 % The idea behind the \emph{Ring} tactic is to be able to prove
899 % an equality showing that both members have the same normal form.
900 % This simply amounts to show that each member is equal to the same
901 % normal form, that is exactly what is done in the new implementation.
902 % Indeed, every step that belonged to the old implementation and has been
903 % changed or removed to fix overkilling used to lead to some unnatural step:
904 % \begin{enumerate}
905 % \item The fact that the normalization is not done on the concrete
906 %  representation, but passing through two abstract ones that are
907 %  interpreted on the concrete terms is an implementative detail that
908 %  was not hidden as much as possible as it should be.
909 % \item Normalizing a member of the equality that is already in normal form,
910 %  is illogical and so unnatural. Hence it should be avoided, but it was not.
911 % \item The natural way to show $A=B$ under the hypothesis $B=A$ is just
912 %  to use the symmetric property of equality. Instead, the old implementation
913 %  rewrote $B$ with $A$ using the hypothesis and proved the goal by reflexivity.
914 % \item Using local definitions (\emph{let \ldots in}) as abbreviations
915 %  rises the readability of the proof by shrinking its size removing
916 %  subexpressions that are not involved in the computation.
917 % \end{enumerate}
918
919 % \subsection{Some Benchmarks}
920 % \label{benchmarks}To understand the actual gain in term size and retyping
921 % time on real-life examples, we have done some benchmarks on the whole set
922 % of theorems in the standard library of Coq that use the Ring tactic. The
923 % results are shown in table~\ref{benchs}.
924
925 % Term size is the size of the disk dump of the terms. Re-typing time is the
926 % user time spent by Coq in proof-checking already parsed terms. The reduction
927 % of the terms size implies also a reduction in Coq parsing time, that is
928 % difficult to compute because Coq files do not hold single terms, but whole
929 % theories. Hence, the parsing time shown is really the user time spent by Coq
930 % to parse not only the terms on which we are interested, but also all the
931 % terms in their theories and the theories on which they depend. So, this last
932 % measure greatly under-estimates the actual gain.
933
934 % Every benchmark has been repeated 100 times under different load conditions on
935 % a 600Mhz Pentium III bi-processor equipped with 256Mb RAM. The timings shown
936 % are mean values.
937
938 % \begin{table}
939 % \begin{center}
940 % \begin{tabular}{|l|c|c|c|}
941 % \hline
942 %  & ~Term size~ & Re-typing time & Parsing time\\
943 % \hline
944 % Old implementation & 20.27Mb & 4.59s & 2.425s \\
945 % \hline
946 % New implementation & 12.99Mb & 2.94s & 2.210s \\
947 % \hline
948 % Percentage reduction & 35.74\% & 35.95\% & 8.87\% \\
949 % \hline
950 % \end{tabular}
951 % \end{center}
952 % \caption{Some benchmarks}
953 % \label{benchs}
954 % \end{table}
955
956 % \section{Conclusions and Future Work}
957 % Naive ways of implementing tactics lead to low quality terms that are
958 % difficult to inspect and process. To improve the situation, we show
959 % how metrics defined for terms naturally induce metrics for tactics and
960 % tactics implementation and we advocate the usage of such metrics for
961 % tactics evaluation and implementation. In particular, metrics could
962 % be used to analyze the quality of an implementation or could be used at run
963 % time by a tactic to choose what is the best way to proceed.
964
965 % To safely replace a tactic implementation with another one, it is important
966 % to define when two tactics are equivalent, i.e. generate equivalent terms.
967 % In this work, the equivalence relation chosen for terms has simply been 
968 % $\beta\delta\iota$-convertibility, that in many situations seems too strong.
969 % Hence, an important future work is the study of weaker forms of term
970 % equivalence and the equivalence relations they induce on tactics. In particular,
971 % it seems that proof-irrelevance, $\eta$-conversion and commuting conversions
972 % must all be considered in the definition of a suitable equivalence relation.
973
974 \begin{thebibliography}{01}
975
976 % \bibitem{ALF} The ALF family of proof-assistants:\\
977 % {\tt http://www.cs.chalmers.se/ComputingScience/Research/\\Logic/implementation.mhtml}
978
979 % \bibitem{Coq} The Coq proof-assistant:\\
980 %  {\tt http://coq.inria.fr/}
981
982 % \bibitem{FORMAVIE} The Formavie project:\\
983 %  {\tt http://http://www-sop.inria.fr/oasis/Formavie/}
984
985 % \bibitem{EHELM} The HELM project:\\
986 %  {\tt http://www.cs.unibo.it/helm/}
987
988 % \bibitem{MATHWEB} The MathWeb project:\\
989 %  {\tt http://www.mathweb.org/}
990
991 % \bibitem{PCOQ} The PCoq project:\\
992 %  {\tt http://www-sop.inria.fr/lemme/pcoq/}
993
994 % \bibitem{HELM} A.Asperti, L.Padovani, C.Sacerdoti Coen, I.Schena.
995 % Towards a library of formal mathematics. Panel session of
996 % the 13th International Conference on Theorem Proving in Higher Order Logics (TPHOLS'2000),
997 % Portland, Oregon, USA.
998
999 % \bibitem{Ring} S. Boutin. Using reflection to build efficient and certified
1000 %  decision procedures. In Martin Abadi and Takahashi Ito, editors, TACS'97,
1001 %  volume 1281. LNCS, Springer-Verlag, 1997.
1002
1003 % \bibitem{YANNTHESIS} Y.Coscoy. \emph{Explication textuelle de preuves pour le
1004 % Calcul des Constructions Inductives}, PhD. Thesis, Universit\'e de Nice-Sophia
1005 % Antipolis, 2000.
1006
1007 % \bibitem{ALFA} T. Hallgreen, Aarne Ranta. An Extensible Proof Text Editor.
1008 % Presented at LPAR2000.
1009
1010 % \bibitem{Necula} G. Necula, P. Lee. Safe Kernel Extensions Without Run-Time
1011 %  Checking. Presented at OSDI'96, October 1996.
1012
1013 % \bibitem{Necula2} G. Necula, P. Lee. Efficient Representation and Validation of Proofs. Presented at LICS'98, June 1998
1014
1015 % \bibitem{Werner} B. Werner. \emph{Une Th\'eorie des Constructions Inductives},
1016 %  PhD. Thesis, Universit\'e Paris VII, May 1994.
1017
1018 \end{thebibliography}
1019  
1020 \end{document}