适用于 Java 的嵌入式 Prolog 解释器/编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1817010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:07:13  来源:igfitidea点击:

Embedded Prolog Interpreter/Compiler for Java

javaprologembedded-languagelogic-programmingconstraint-programming

提问by Sami

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.

我正在开发一个 Java 应用程序,它需要进行一些复杂的逻辑规则推导,作为其功能的一部分。我想用 Prolog 或其他一些逻辑/约束编程语言来编写我的逻辑推论,而不是 Java,因为我相信生成的代码会更简单,更易于维护。

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

我在 Prolog 上搜索了嵌入式 Java 实现,并找到了很多,每个都有很少的文档。我的(适度)选择标准是:

  • 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.
  • 应该可以嵌入到 Java 中(例如可以与我的 java 包捆绑在一起,而不需要在外部程序上进行任何本机安装)
  • 从 Java 使用的简单接口(用于启动推导、检查结果和添加规则)
  • 至少提供几个关于如何使用它的例子
  • 不一定必须是 Prolog,但具有上述标准的其他逻辑/约束编程语言也能满足我的需求。

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

我有哪些选择,它们的优缺点是什么?

采纳答案by Chip Uni

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

根据Wikipedia,以下版本的 Prolog 具有 Java 接口。我已经链接到他们的主页:

Good luck with your search!

祝您搜索顺利!

回答by Hassan Syed

SWI prolog A very popular implementation seems to have a Java interface as does SiCStuswhich 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 factoimplementation.

SWI prolog 一个非常流行的实现似乎有一个Java 接口,就像 SiCStus 一样,这比使用 JNI 在你的 Java 进程中实例化一个实例更容易。我很久以前从 C 中使用过两者,并且推荐它们。我更喜欢 SWI,因为它是开源的,而且根据我的经验,它是事实上的实现。

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

SWI 的 Java 接口的文档似乎足够了,嵌入过程非常简单。

回答by Juanjo Conti

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.

2 年前我也需要这样做。我使用了称为 JPL 的 SWI 接口。它允许您加载 Prolog 文件,对其进行断言并对其进行查询。它确实需要安装 SWI Prolog,但这根本不是问题。SWI Prolog可用于许多平台

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.

我还尝试了 100% 用 Ja​​va 实现并且不需要外部程序的替代方案。所有这些都有问题或难以使用。不要浪费你的时间。

回答by Vincent Ramdhanie

Amzi prologhas been around for a while. I have used it briefly but not the embedded version. however they do have good documentation and support can be bought. They have Java port so it might be worth a look.

Amzi prolog已经有一段时间了。我使用过它,但没有使用过嵌入式版本。但是他们确实有很好的文档并且可以购买支持。他们有 Java 端口,所以可能值得一看。

回答by clive spenser

LPA does offer the LPA Intelligence Server as a way of embedding its Prolog engine within a whole variety of mainstream languages including Java, .Net etc

LPA 确实提供 LPA Intelligence Server 作为将其 Prolog 引擎嵌入到包括 Java、.Net 等在内的各种主流语言中的一种方式

Clive

克莱夫

http://www.lpa.co.uk/int.htm

http://www.lpa.co.uk/int.htm

回答by Igor M.

You can also take a look at the Prol enginethat I created. It allows you to embed Prolog into your Java programs (but it is not very fast one)

您还可以查看我创建的 Prol 引擎。它允许您将 Prolog 嵌入到您的 Java 程序中(但速度不是很快)

回答by false

Two commercial Prologs written in Java: Minerva by IF Computer Japan and Jekejeke. Both are very close to ISO.

两个用 Java 编写的商业 Prolog:IF Computer Japan 和 Jekejeke 的 Minerva。两者都非常接近ISO。

回答by deterb

Clojureis a JVM based Lisp-like language with a library (core.logic) supporting logic and constraint based programming. Clojure also has a large number of facilities for generating java classes and working with java code, so inter-op between the two languages is trivial.

Clojure是一种基于 JVM 的类 Lisp 语言,具有支持基于逻辑和约束的编程的库 ( core.logic)。Clojure 还具有大量用于生成 java 类和处理 java 代码的工具,因此两种语言之间的互操作是微不足道的。

回答by CapelliC

Prof. Paul Tarau made available from his pageseveral implementations

Paul Tarau 教授从他的页面中提供几种实现

Jinni Prolog

金妮序言

Kernel Prolog

内核序言

回答by Sami

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.

我最近遇到的另一个有价值的选择是 JSetL。它不是 Prolog,而是 Java 的约束编程库,支持逻辑变量、统一、约束求解和非确定性。

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

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