Java 嵌入式 Prolog 解释器/编译器

发布于 2024-08-12 14:45:02 字数 406 浏览 5 评论 0原文

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

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

  • 应该可嵌入 Java(例如,可以与我的 java 包捆绑在一起,而不需要在外部程序上进行任何本机安装)
  • 从 Java 使用简单的接口(用于启动推演、检查结果和添加规则) )
  • 至少有一些关于如何使用它的示例,
  • 不一定非得是 Prolog,但具有上述标准的其他逻辑/约束编程语言也能满足我的需求。

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

沧笙踏歌 2024-08-19 14:45:02

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

祝您搜索顺利!

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!

酸甜透明夹心 2024-08-19 14:45:02

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

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

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.

挖个坑埋了你 2024-08-19 14:45:02

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

我还尝试过 100% 用 Ja​​va 实现并且不需要外部程序的替代方案。它们都存在缺陷或难以使用。不要浪费你的时间。

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.

难得心□动 2024-08-19 14:45:02

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

Clojure is 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.

情丝乱 2024-08-19 14:45:02

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

Amzi prolog has 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.

遗失的美好 2024-08-19 14:45:02

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

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

陌路黄昏 2024-08-19 14:45:02

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

Jinni Prolog

内核 Prolog

Prof. Paul Tarau made available from his page several implementations

Jinni Prolog

Kernel Prolog

不弃不离 2024-08-19 14:45:02

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

Clive

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

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

Clive

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

我做我的改变 2024-08-19 14:45:02

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

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

猫九 2024-08-19 14:45:02

Prova 3.0 http://www.prova.ws 即将完成。然而,它不仅仅是另一个 Prolog,而是多种编程风格的混合体,尤其对于简单的双向 Java 集成、反应式代理编程、与 ESB 集成、工作流逻辑和事件处理非常有用。此版本是从零开始的完全重写,因此缺少一些较旧的功能(例如 OWL 集成),但一定会在下一个版本中返回。

Prova 3.0 http://www.prova.ws is nearing completion. It is, however, not just another Prolog but a mix of programming styles, particularly, useful for easy bi-directional Java integration, reactive agent programming, integration with ESB's, workflow logic, and event processing. This version is a complete rewrite from zero so some older features, like OWL integration, are missing, but are bound to return in the next revision.

心碎的声音 2024-08-19 14:45:02

Mini-Kanren for Scala,它为您提供了精益的本机 JVM 实现,可破解的、基于现代霍恩子句的逻辑编程语言。

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

数理化全能战士 2024-08-19 14:45:02

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

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

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

硪扪都還晓 2024-08-19 14:45:02

Java 中有多种 Prolog 实现。它们不是非常快,但是在 Java 中使用起来很方便。
例子有:
TuProlog
PrologCafe
您还可以查看以下主题的学士论文
Java Prolog 程序的执行和分析

There are a number of Prolog implementations in Java. They are not terribly fast, but convenient to use from within Java.
Examples are:
TuProlog or
PrologCafe
You can also have a look at the following Bachelor's thesis on the subject of
Execution and Analysis of Prolog Programs in Java.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文