On-demand Evaluation by Program Transformation

Abstract Strategy annotations are used in eager programming languages (e.g., OBJ2 , OBJ3 , CafeOBJ , and Maude ) for improving efficiency and/or reducing the risk of nontermination. Syntactically, they are given either as lists of natural numbers or as lists of integers associated to function symbols whose (absolute) values refer to the arguments of the corresponding symbol. A positive index forces the evaluation of an argument whereas a negative index means “evaluation on-demand”. Recently, we have introduced a formal description of the operational meaning of such on-demand strategy annotations which improves previous formalizations that were lacking satisfactory computational properties. In this paper, we introduce an automatic, semantics-preserving program transformation which produces a program (without negative annotations) which can be then correctly executed by typical OBJ interpreters. Moreover, to demonstrate the practicality of our ideas, the program transformation has been implemented (in Haskell ) and we compare the evaluation of transformed programs with the original ones on a set of representative benchmarks.

[1]  Salvador Lucas,et al.  Demandness in Rewriting and Narrowing , 2002, WFLP.

[2]  Ataru T. Nakagawa,et al.  An overview of CAFE specification environment-an algebraic approach for creating, verifying, and maintaining formal specifications over networks , 1997, First IEEE International Conference on Formal Engineering Methods.

[3]  Salvador Lucas Lazy Rewriting and Context-Sensitive Rewriting , 2002, Electron. Notes Theor. Comput. Sci..

[4]  José Meseguer,et al.  Principles of OBJ2 , 1985, POPL.

[5]  Salvador Lucas,et al.  Correct and Complete (Positive) Strategy Annotations for OBJ , 2002, Electron. Notes Theor. Comput. Sci..

[6]  Salvador Lucas,et al.  Termination of on-demand rewriting and termination of OBJ programs , 2001, PPDP '01.

[7]  Wan Fokkink,et al.  Lazy rewriting on eager machinery , 2000, TOPL.

[8]  Juan José Moreno-Navarro,et al.  Logic Programming with Functions and Predicates: The Language BABEL , 1992, J. Log. Program..

[9]  M. Clavel,et al.  Principles of Maude , 1996, WRLA.

[10]  Salvador Lucas Termination of (Canonical) Context-Sensitive Rewriting , 2002, RTA.

[11]  Rita Loogen,et al.  A Demand Driven Computation Strategy for Lazy Narrowing , 1993, PLILP.

[12]  Steven Eker Term rewriting with operator evaluation strategies , 1998, WRLA.

[13]  Salvador Lucas,et al.  Context-sensitive Computations in Functional and Functional Logic Programs , 1998, J. Funct. Log. Program..

[14]  Kazuhiro Ogata,et al.  Operational semantics of rewriting with the on-demand evaluation strategy , 2000, SAC '00.

[15]  長谷 崇 Reduction strategies for term rewriting systems , 1999 .

[16]  Salvador Lucas,et al.  OnDemandOBJ: A Laboratory for Strategy Annotations , 2003, Electron. Notes Theor. Comput. Sci..

[17]  Tobias Nipkow,et al.  Term rewriting and all that , 1998 .

[18]  Salvador Lucas,et al.  Improving On-Demand Strategy Annotations , 2002, LPAR.

[19]  Kazuhiro Ogata,et al.  The evaluation strategy for head normal form with and without on-demand flags , 2000, WRLA.

[20]  María Alpuente,et al.  Specialization of lazy functional logic programs , 1997 .

[21]  Hans Zantema,et al.  Termination of Context-Sensitive Rewriting , 1997, RTA.

[22]  Terese Term rewriting systems , 2003, Cambridge tracts in theoretical computer science.