This paper presents some supporting transformations for the partial evaluation of logic programs. A logic language is often used to specify a program. If such a specification is to be implemented by means of a logic programming language it is desirable that the programmer should omly have to consider the declarative meaning of the predicates being defined. However, such a program may be very inefficient and the program may have to be transformed to another program which computes the same answers but with improved efficiency. Of the known transformation techniques there is one that is called‘unfolding’. This performs some of the computation at compile time. In addition, for a particular application, it may be possible to specialize a program so that the transformed program computes the required answers for only a restricted set of goals. Partial evaluation is a program transformation that combines the unfolding and specialization techniques. In order that any answer computed using a partially evaluated program could also have been computed using the original program, it is neccessary that the partial evaluation satisfies certian conditions (called coveredness and independence). Unfortunately, this may prevent the partial evalution achieving its aim of producing a more efficient program. By means of a transformation that dynamically introduces new predicates and their definitions, we show how the restrictions caused by these conditions can be overcome. A partial evaluation will, in general, contain redundant functions and unnecessary repetition of variables. This can cause inefficiency in the use of space and time by the transformed program. The second transformation described here cleans up a partial evaluation removing any unnecessary symb
展开▼