一个用于 trilog 的 ZIP 风格 Prolog 虚拟机
A ZIP-style Prolog VM for trilog

原始链接: https://github.com/no382001/zipc

这个项目的目标是将虚拟机搭建到可以与当前 trilog 运行时进行比较的程度。它包含一个从 Prolog 到 ZIP 虚拟机的编译器,以及用 C 编写的 VM 本身。ZIP 是 Clocksin《Design and Simulation of a Sequential Prolog Machine》(1984)中的抽象机;相关论文在 doc/ 目录中。zipc 的目的是如果 MVP 成功就成为 trilog 的后端,或者仅作为更快的独立可编译 Prolog 运行时,我还不太确定。无论如何,trilog 使用 ABC 算法将子句解释为项,将它们编译为 ZIP 应该使相同程序以更少的指令和更少的内存运行,这应该有助于 trilog 的主要目标。编译器用 Prolog 编写,运行在 Scryer Prolog 上。它写入一个二进制镜像,由 src/ 中的 VM 加载并运行。

一个 Hacker News 讨论帖讨论了 trilog 的 ZIP 风格 Prolog 虚拟机。评论者争论 Prolog 是否有现代用途。多人认为有:它有助于填空式配置和类似约束的问题;结合 LLM,Prolog 可以建模系统并找出竞态条件或过期数据;Dialog 对交互式小说使用 Prolog 风格求值;Datalog 有实际应用,如 Rust 的 Polonius 借用检查器;Prolog 可能适合图数据库查询和不完整数据的路径查找;SWI-Prolog 支持业务后端、Web 应用和 GUI。其他人指出 Datalog 在语义和执行上与 Prolog 不同,尤其在否定和函数符号方面,尽管它本质上是没有函数符号的 Prolog。帖子还质疑 GOFAI 的相关性,一位评论者认为基于规则的系统应该支持更薄的 LLM 层以提高可靠性和安全性。总体而言,Prolog 仍然小众,但对逻辑、约束和数据建模有用,尤其是配合 LLM 辅助的事实生成。
相关文章

原文

The goal of the project is to scaffold the VM to a degree where I can compare it with the current trilog runtime.

A compiler from Prolog to the ZIP virtual machine, and the VM itself, in C. ZIP is the abstract machine from Clocksin's Design and Simulation of a Sequential Prolog Machine (1984); the papers are in doc/.

zipc is meant to become the backend of trilog if the MVP succeeds, or just stay as a faster separate Prolog compilable runtime, I am not really sure yet. Either way, trilog interprets clauses as terms with the ABC algorithm, and compiling them to ZIP should make the same programs run in fewer instructions and less memory, which should help with trilog's main target.

The compiler is written in Prolog and runs on Scryer Prolog. It writes a binary image, which the VM in src/ loads and runs.

联系我们 contact @ memedata.com