We show that sometimes partial deduction produces poor program specializations because of its limited ability in (i) dealing with conjunctions of recursively defined predicates, (ii) combining partial evaluations of alternative computations, and (iii) taking into account unification failures. We propose to extend the standard partial deduction technique by using versions of the definition rule and the folding rule which allow us to specialize predicates defined by disjunctions of conjunctions of goals. We also consider a case split rule to take into account unification failures. Moreover, in order to perform program specialization via partial deduction in an automatic way, we propose a transformation strategy which takes as parameters suitable substrategies for directing the application of every transformation rule. Finally, we show through two examples that our partial deduction technique is superior to standard partial deduction, The first example refers to the automatic derivation of the Knuth-Morris-Pratt string matching algorithm, and the second example refers to the construction of a parser for a given regular expression. In both examples, the specialized programs are derived starting from naive, non-deterministic initial programs, whereas standard partial deduction can derive similar specialized programs only when complex, deterministic initial programs are provided.
Pettorossi, A., Proietti, M., Renault, S. (1997). Enhancing partial deduction via unfold/fold rules. In LOGIC PROGRAM SYNTHESIS AND TRANSFORMATION (pp.146-168). BERLIN 33 : SPRINGER-VERLAG BERLIN.
Enhancing partial deduction via unfold/fold rules
PETTOROSSI, ALBERTO;
1997-01-01
Abstract
We show that sometimes partial deduction produces poor program specializations because of its limited ability in (i) dealing with conjunctions of recursively defined predicates, (ii) combining partial evaluations of alternative computations, and (iii) taking into account unification failures. We propose to extend the standard partial deduction technique by using versions of the definition rule and the folding rule which allow us to specialize predicates defined by disjunctions of conjunctions of goals. We also consider a case split rule to take into account unification failures. Moreover, in order to perform program specialization via partial deduction in an automatic way, we propose a transformation strategy which takes as parameters suitable substrategies for directing the application of every transformation rule. Finally, we show through two examples that our partial deduction technique is superior to standard partial deduction, The first example refers to the automatic derivation of the Knuth-Morris-Pratt string matching algorithm, and the second example refers to the construction of a parser for a given regular expression. In both examples, the specialized programs are derived starting from naive, non-deterministic initial programs, whereas standard partial deduction can derive similar specialized programs only when complex, deterministic initial programs are provided.I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.