Embedded Prolog Interpreter/Compiler for Java

2019-01-13 04:11发布

I'm working on an application in Java, that needs to do some complex logic rule deductions as part of its functionality. I'd like to code my logic deductions in Prolog or some other logic/constraint programming language, instead of Java, as I believe the resulting code will be significantly simpler and more maintainable.

I googled for embedded Java implementations on Prolog, and found number of them, each with very little documentation. My (modest) selection criteria are:

  • should be embeddable in Java (e.g. can be bundled up with my java package instead of requiring any native installations on external programs)
  • simple interface to use from Java (for initiating deductions, inspecting results, and adding rules)
  • come with at least a few examples on how to use it
  • doesn't necessarily have to be Prolog, but other logic/constraint programming languages with the above criteria would suit my needs, too.

What choices do I have and what are their advantages and disadvantages?

13条回答
爷的心禁止访问
2楼-- · 2019-01-13 04:45

SWI prolog A very popular implementation seems to have a Java interface as does SiCStus which would be easier than using JNI to instantiate an instance in your Java Process. I've used both from C quite a while ago and do recommend them. My prefference would be SWI as it is open-source and from my experience the de facto implementation.

The documentation for SWI's Java interface seems to be adequate, and the embedding process quite straight forward.

查看更多
Ridiculous、
3楼-- · 2019-01-13 04:45

Another worthwhile option I recently came across is JSetL. It's not a Prolog, but a constraint programming library for Java, with support for logic variables, unification, constraint solving and non-determinism.

http://prmat.math.unipr.it/~gianfr/JSetL/index.html

查看更多
对你真心纯属浪费
4楼-- · 2019-01-13 04:46

There's Mini-Kanren for Scala, which gives you a native JVM implementation of a lean, hackable, modern Horn-clause based logic programming language.

查看更多
该账号已被封号
5楼-- · 2019-01-13 04:49

I've needed to do the same 2 years ago. I used SWI interface which is called JPL. It lets you load a Prolog file, assert on it and query on it. It does required an installation of SWI Prolog but that's not problem at all. SWI Prolog is available for many platforms.

I've also tried alternatives that were 100% implemented in Java and didn't required external programs. All them were buggy or hard to use. Don't waste your time.

查看更多
Evening l夕情丶
6楼-- · 2019-01-13 04:49

Prof. Paul Tarau made available from his page several implementations

Jinni Prolog

Kernel Prolog

查看更多
等我变得足够好
7楼-- · 2019-01-13 04:55

According to Wikipedia, the following versions of Prolog have Java interfaces. I've linked to the main pages for them:

Good luck with your search!

查看更多
登录 后发表回答