prolog2curry - Transforming Prolog programs to Curry programs

This package contains an implementation of a tool (pl2curry) to transform Prolog programs to Curry programs. The idea of this tool is to demonstrate the advantages of functional logic languages compared to purely logic languages. Thus, the tool translates only pure logic programs (without side effecting predicates etc). The ideas of this tool are described in detail in a paper presented at ICLP 2022 and published in TPLP.

Tool options

The tool has various options to influence the kind of transformation, e.g.:

Since adding function directives to specify result argument positions is tedious, the tool also contains an analysis to derive automatic function directives (if not already explicitly provided and if the option --noanalysis is not set) for standard functions (i.e., where only the last argument is a result position). It is based on the following principle:

The information about the inferred sets of inductively sequential argument and result arguments of functions is printed if the verbosity is larger than 1.

A special case of the previous criterion are predicates defined by a single rule, e.g., predicate which define constants, as

two(s(s(o))).

This will be translated into

two = S (S O)

Although this is correct, it is sometimes unintended, e.g., if p is defined by the single clause

p(X,Y) :- q(X,Z), r(Z,Y).

In order to keep such predicates as predicates on the Curry level, the following heuristic is used. A predicate defined by a single rule is transformed as a function only if the last argument in the left-hand side is not a variable or a variable which occurs in a result argument position in the rule’s body.

Although these heuristics provide expected transformations in most case, one can always override them using an explicit function directive.

Technical remarks: