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