Source-to-source optimizing transformations of Prolog programs based on abstract interpretation

Making a Prolog program more efficient by transforming its source code, without changing its operational semantics, is not an obvious task. It requires the user to have a clear understanding of how the Prolog compiler works, and in particular, of the effects of impure features like the cut. The way a Prolog code is written - e.g., the order of clauses, the order of literals in a clause, the use of cuts or negations - influences its efficiency. Furthermore, different optimization techniques may be redundant or conflicting when they are applied together, depending on the way a procedure is called - e.g., inserting cuts and enabling indexing. We present an optimiser, based on abstract interpretation, that automatically performs safe code transformations of Prolog procedures in the context of some class of input calls. The method is more effective if procedures are annotated with additional information about modes, types, sharing, number of solutions and the like. Thus the approach is similar to Mercury. It applies to any Prolog program, however.

[1]  Yves Deville,et al.  Logic programming - systematic program development , 1990, International series in logic programming.

[2]  Pascal Van Hentenryck,et al.  Sequence-based abstract interpretation of Prolog , 2000, Theory and Practice of Logic Programming.

[3]  Maurice Bruynooghe,et al.  A Practical Framework for the Abstract Interpretation of Logic Programs , 1991, J. Log. Program..

[4]  B. L. Charlier,et al.  Sequence-based Abstract Interpretation of Prolog 1 , 2022 .

[5]  Saumya K. Debray,et al.  Towards Banishing the Cut from Prolog , 1990, IEEE Trans. Software Eng..

[6]  Pascal Van Hentenryck,et al.  Combinations of abstract domains for logic programming: open product and generic pattern construction , 2000, Sci. Comput. Program..

[7]  Zoltan Somogyi,et al.  The Execution Algorithm of Mercury, an Efficient Purely Declarative Logic Programming Language , 1996, J. Log. Program..

[8]  Leon Sterling,et al.  The Art of Prolog - Advanced Programming Techniques , 1986 .

[9]  Agostino Cortesi,et al.  Automated Verification of Prolog Programs , 1999, J. Log. Program..

[10]  Hassan Aït-Kaci,et al.  Warren's Abstract Machine: A Tutorial Reconstruction , 1991 .

[11]  Krzysztof R. Apt,et al.  From logic programming to Prolog , 1996, Prentice Hall International series in computer science.

[12]  SWI-Prolog 5.6 Reference Manual , 2004 .

[13]  Manuel V. Hermenegildo,et al.  Integrated program debugging, verification, and optimization using abstract interpretation (and the Ciao system preprocessor) , 2005, Sci. Comput. Program..

[14]  Pascal Van Hentenryck,et al.  Experimental evaluation of a generic abstract interpretation algorithm for Prolog , 1992, ICCL.