next up previous
Next: Experimental results Up: Incremental Needed Narrowing Previous: Matching dagsindex trees,

Incremental evaluation

 

Consider a needed narrowing sequence tex2html_wrap_inline2245 . Since each step tex2html_wrap_inline2247 is scheduled by tex2html_wrap_inline2249 (where tex2html_wrap_inline2011 is a definitional tree for tex2html_wrap_inline2253 ), and it usually changes only small parts of tex2html_wrap_inline2255 , it is obvious that, if tex2html_wrap_inline2257 , then the needed narrowing step for tex2html_wrap_inline2259 (i.e., the computation of tex2html_wrap_inline2261 ) might wastefully examine some of the symbols already considered in the preceding step and take almost the same decisions. In order to avoid this wasting, we look for an incremental definition of tex2html_wrap_inline1801 which is able to locally resume the search from tex2html_wrap_inline2265 for some tex2html_wrap_inline2267 . Intuitively, whenever tex2html_wrap_inline2099 and tex2html_wrap_inline2271 , we can be sure that the symbols occurring at the position immediately above p have not been modified. On the other hand, the term tex2html_wrap_inline2275 may or may not be operation-rooted. If tex2html_wrap_inline2277 , then tex2html_wrap_inline2275 should be further narrowed until a constructor-rooted term or a variable is obtained. If tex2html_wrap_inline2281 , then the next needed narrowing step is determined by the definitional tree tex2html_wrap_inline1787 of tex2html_wrap_inline2285 , where q<p is the position of the defined symbol occurring at the position immediately above p.

  pro506

-Proof. us first consider the case when tex2html_wrap_inline2311 (note that, since we impose tex2html_wrap_inline2313 , it follows that tex2html_wrap_inline2315 is not empty; i.e., q does exist.). Then, the computation of tex2html_wrap_inline2063 has reached a branch node tex2html_wrap_inline2119 and there is an operation-rooted subterm tex2html_wrap_inline2323 at the inductive position o. Thus the computation of tex2html_wrap_inline2327 first reaches the same branch node and then proceeds by checking whether tex2html_wrap_inline2329 is a constructor-rooted term or a variable, since it cannot be an operation-rooted term unless q=p, which contradicts the original assumption. In both cases, a subtree tex2html_wrap_inline2011 for tex2html_wrap_inline2129 is selected before resuming the computation. If tex2html_wrap_inline2011 is a branch subtree, then the computed position p' will be below q; otherwise (that is, tex2html_wrap_inline2011 is a rule subtree), p'=q.

Now consider the case when q=p. Then tex2html_wrap_inline2275 is operation-rooted and this position needs to be further narrowed in order to compute a constructor-rooted term. Then, the computed position is trivially q or below q. tex2html_wrap_inline2355

  coro514

Since each step tex2html_wrap_inline2247 in a needed narrowing sequence tex2html_wrap_inline2245 is performed using tex2html_wrap_inline2381 , where tex2html_wrap_inline2011 is a definitional tree for tex2html_wrap_inline2253 , Corollary 4.2 ensures that, whenever tex2html_wrap_inline2387 is operation-rooted, then tex2html_wrap_inline2389 . Thus, we take tex2html_wrap_inline2391 , where tex2html_wrap_inline2393 and tex2html_wrap_inline1787 is a definitional tree for tex2html_wrap_inline2397 . If tex2html_wrap_inline2387 is constructor-rooted or a variable, then it is necessary to resume the evaluation somewhere above tex2html_wrap_inline2401 . Proposition 4.1 allows us to come back to tex2html_wrap_inline2403 by taking the (`most defined') definitional subtree tex2html_wrap_inline2405 of the definitional tree of tex2html_wrap_inline2407 which has been used in the computation of tex2html_wrap_inline2249 immediately before obtaining tex2html_wrap_inline2011 . Thus, we let tex2html_wrap_inline2413 , where tex2html_wrap_inline2415 .

Thus, we define a data structure tex2html_wrap_inline2417 which contains the information needed to perform the needed narrowing steps incrementally. Given a term t, we let tex2html_wrap_inline2417 denote a list of pairs tex2html_wrap_inline2423 where p is a position and tex2html_wrap_inline1771 is an incremental definitional tree. The incremental needed narrowing strategy is denoted by tex2html_wrap_inline2429 . It takes as arguments a term t and an auxiliary list tex2html_wrap_inline2417 which plays the role of the definitional tree tex2html_wrap_inline1787 in the original strategy tex2html_wrap_inline2063 . Given an operation-rooted term t and a list tex2html_wrap_inline2441 with tex2html_wrap_inline2443 , we compute tex2html_wrap_inline2445 , where p is the position pointing to the subterm of t to be narrowed, R is the rule to be applied, tex2html_wrap_inline1885 is the computed substitution, and tex2html_wrap_inline2455 is a list containing the information which allows us to proceed with the subsequent evaluation steps incrementally. Formally,

displaymath2239

The following notations are helpful. Given a position p and a list tex2html_wrap_inline2417 of pairs position/incremental definitional tree, we define:

displaymath2240

We also use the standard operator ` tex2html_wrap_inline2499 ' for concatenating lists. The following auxiliary result is used below.

  lema589

-Proof. , by definition of tex2html_wrap_inline1805 . tex2html_wrap_inline2355

The following proposition states that tex2html_wrap_inline1805 is able to compute the same needed narrowing step than tex2html_wrap_inline1801 starting from a given term and an initial list of incremental information.

  pro598

-Proof. from the definition of tex2html_wrap_inline1801 and tex2html_wrap_inline1805 . tex2html_wrap_inline2355

Now, we have to ensure that the defined function symbols occurring at positions which are above (or at) a previously narrowed position are obtained by the strategy tex2html_wrap_inline1805 and thus considered for the subsequent narrowing steps.

  pro605

-Proof. noetherian induction on pairs tex2html_wrap_inline2563 (strictly) ordered by tex2html_wrap_inline2565 iff tex2html_wrap_inline2567 or tex2html_wrap_inline2569 and tex2html_wrap_inline2571 , i.e., tex2html_wrap_inline1787 is a subtree of tex2html_wrap_inline2575 [AEH94]. Here, tex2html_wrap_inline2577 is the number of defined function symbols in t.

tex2html_wrap_inline2355

The following theorem shows that the needed narrowing steps performed by the incremental strategy tex2html_wrap_inline1805 and the computation steps carried out by the original needed narrowing strategy tex2html_wrap_inline1801 are equivalent.

  teo645

-Proof. prove it by induction on the length of the derivation.

tex2html_wrap_inline2721
i = 1. This case is trivial, since by Proposition 4.4 it amounts to a call to tex2html_wrap_inline2725 .
tex2html_wrap_inline2721
i > 1. Let tex2html_wrap_inline2731 for some definitional tree tex2html_wrap_inline1787 . By the induction hypothesis, we have that tex2html_wrap_inline2735 if and only if tex2html_wrap_inline2737 . Since tex2html_wrap_inline2739 , by Proposition 4.5, q points to a defined symbol of tex2html_wrap_inline2255 which is above or at the position tex2html_wrap_inline2745 . By the ordering between the positions recorded in tex2html_wrap_inline2747 (see Lemma 4.3), q is the position of the defined symbol immediately above or at the position tex2html_wrap_inline2745 . By Proposition 4.1, tex2html_wrap_inline2753 , where tex2html_wrap_inline2755 . Then, by Proposition 4.4, tex2html_wrap_inline2757 . Now, since all positions in the first component of the position/incremental definitional tree lists correspond to operation-rooted subterms, by using Lemma 4.3 it is immediate that tex2html_wrap_inline2759 if tex2html_wrap_inline2761 .

Thus, tex2html_wrap_inline2763 .

tex2html_wrap_inline2355

Although we only provide in this paper the definition of tex2html_wrap_inline1805 in terms of incremental definitional trees, the function tex2html_wrap_inline1805 can be easily redefined to perform with standard definitional trees, similarly to tex2html_wrap_inline1801 . We make free with this in the following section, where different implementations of needed narrowing are compared.


next up previous
Next: Experimental results Up: Incremental Needed Narrowing Previous: Matching dagsindex trees,

Santiago Escobar
Fri Sep 3 14:51:16 MET DST 1999