按年被提到
20162022 · 2 次2026
编程语言与编译器›类型系统与函数式语言·arXiv:1607.01590 · cs.PL

Indexing dif/2

为 dif/2 建立索引
Ulrich Neumerkel, Stefan Kral · 2016

用 if_/3 等谓词为 Prolog 的 dif/2 做高效索引,免去不纯写法

开始阅读 ↗PDFalphaXiv 讨论
被推荐 · 4 人首次 2017-05-29 · 最近 2022-12-31
4不同的人
5活跃月份
5讨论串
0被引(OpenAlex)

许多 Prolog 程序因缺少表达语法不等的手段而被迫写得不纯;内置的 dif/2 虽能给出正确答案,但直接使用常导致定义复杂且低效,主要因为缺少索引机制。论文提出用具现化(reification)统一等于与不等的新谓词,并基于 call/N 给出单调的高阶 if-then-else 构造,在可比的纯用法下做到与不纯写法同样确定、效率相近。

HN 为什么提它

HN 上的 Prolog 爱好者用它说明如何不靠 cut 写出纯净的条件判断,它也是 if_/3 和 library(reif) 的出处。

方法难度 4 / 5约 40 分钟经得起时间
读之前最好知道
1Prolog 编程
2逻辑编程中的纯度与单调性(monotonicity)
3合一(unification)
4谓词索引(indexing)

HN 书评

推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及
推荐zmonx · 2017-05

“In particular, I recommend the following publication:”

推荐这篇关于 Prolog 中 dif/2 和 if_/3 的研究
Ask HN: Why isn't Prolog more popular?原评论 ↗
推荐grose · 2022-09

“this paper about dif/2 intrigues me:”

称这篇讲 dif/2 的论文引起了自己的兴趣
Lunatic: Erlang-Inspired Runtime for WebAssembly原评论 ↗
引用triska · 2019-10

“One important building block pertaining to this concrete example was recently found with the new language construct if_/3”

指出新结构 if_/3 是解决该问题的重要构件
Swish: SWI Prolog Notebook原评论 ↗
引用triska · 2022-12

“in 2016, Neumerkel and Kral introduced if_/3 and related predicates, which are now available as library(reif) in Scryer Prolog:”

指出 if_/3 等谓词于 2016 年提出,现已进 Scryer Prolog
Prolog at Work原评论 ↗
被提交为 story · 1 次