New Generation Computing, 6 (1988) 211-225 OHMSHA, LTD. and Springer-Verlag (~) OHMSHA, LTD. 1988 Composing Recursive Logic Programs with Clausal Join A. LAKHOTIA and L. STERLING Computer Engineering and Science Department, Case Western Reserve University, Cleveland, Ohio, 44106, USA. Received 10 March 1988 Abstract A family of methods for composing logic programs from simpler components is presented. Specifically, simple pairs of programs operating on lists, trees and other recursive structures are composed to generate a single program with composite functionality. The methods are based on clausal join, a specific sequence of unfold/fold transformations for deriving a new clause from a given pair of clauses and a join specification. Procedural join composes a new procedure from two given procedures by applying clausal join to all pairs of their clauses. 1-1 Join composes a new procedure from closely related procedures by applying clausal join to corre- sponding pairs only. Meta join is a modification of 1-1 join for composing meta-interpreters. The transformations are straightforward to implement in Prolog, as is demonstrated in the paper. Keywords: Program Transformation, Unfold/Fold Transformations, Logic Programming, Program Composition, Specification, Meta- Programming. w Introduction There is often a trade-off between the elegance and simplicity of a program on one hand, and its efficiency on the other. One way to achieve both is to write the elegant program and then transform it into an equivalent, more efficient version. Program transformation techniques have been described 2'9) which are capable of transforming simple programs. These papers give examples of using these techniques to derive more efficient versions of recursive programs. Program transformation is not, however, a widely used technique in software development. A major reason is the lack of clear guidelines of when and how to transform programs: there are too many plausible transformations. We believe that the appropriate use of program transformation is in finding and