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