PROLOG with lambda expressions

Is there any Java PROLOG implementation that supports lambda expressions? I know that there are Java implementations of other languages ​​that support lambda expressions such as LISP and Clojure, but I really need a PROLOG implementation.

http://en.wikipedia.org/wiki/Comparison_of_Prolog_implementations

+7
source share
3 answers

Lean Prolog is implemented in Java and can run Logtalk, which allows you to use lambda expressions for all supported Prolog backend compilers . For an overview of the syntax of Logtalk lambda expressions, see, for example:

http://blog.logtalk.org/2009/12/lambda-expressions-in-logtalk/

Examples of use see below:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/lambdas

+4
source

Ulrich Neumerkel implements the lambda project Prolog. For example, SWI-Prolog supports it. If you performed a search on Stackoverflow:

[swi-prolog] lambda 

You can also find many answers, using it for decisions.

In addition, a web page that explains it all

+4
source

Basically, there are two approaches for lambda expressions in Prolog that address only calling lambda expressions and not higher-level unification:

  • globally by default: Variables in the body of a lambda expression by default are globally if they are not mentioned using an additional binder.

  • local-by-default: Variables in the body of a lambda expression by default are local unless they are mentioned by an additional binder.

Representatives of local defaults are, for example, Ulrich Neumerkel's libraries (lambda) or lambda expressions found in Logtalk. Currently, the lambda expressions found in Jekejeke Prolog are applied according to the "global default" principle.

Both approaches allow you to simulate the same mathematical lambda of expressions and solve the following problems:

  • Control the exchange or non-distribution of variables in several calls.

  • Forming an alpha transform for binders and local variables in the body of a lambda expression.

Here is an example factorial through Y combinator:

  ? - Y = F \ X ^ call (X \ call (F, call (X, X)), X \ call (F, call (X, X))),
        Fact = F \ J ^ H ^ M ^ N ^ N \ J ^ H ^ M ^ M \ J ^ H ^ (N = 0, M = 1; N> 0, H is N-1, call (F, H , J), M is N * J),
        call (Y, Fact, 10, R). 
     R = 3628800.
  ? - Y = \ F ^ call ([F] + \ X ^ call (F, call (X, X)), [F] + \ X ^ call (F, call (X, X))),
        Fact = \ F ^ ([F] + \ N ^ ([N, F] + \ M ^ (N = 0, M = 1; N> 0, H is N-1, call (F, H, J) , M is N * J))),
        call (Y, Fact, 10, R).
     R = 3628800.

Bye

PS: The distinction between global defaults and local defaults is taken from, p. 10:
Language Features and B-Prolog Architecture
Neng-fa Zhou, Theory and Practice of Logical Programming, 2011
http://www.sci.brooklyn.cuny.edu/~zhou/papers/tplp11sips.pdf

+2
source

All Articles