gpt4 book ai didi

prolog - HiLog 术语在现代 Prolog 中仍然有用吗?

转载 作者:行者123 更新时间:2023-12-04 08:26:49 26 4
gpt4 key购买 nike

Hilog 项(即具有任意项作为仿函数的化合物)是否仍然被视为 XSB Prolog(或任何其他 Prolog)中的强大功能?
目前有很多 XSB 项目使用这个功能吗?例如,他们中的哪一个?

我问,因为据我了解,使用 ISO 内置调用/N 同样可以进行高阶编程。

具体来说,我想了解 XSB 是否只是出于历史原因使用 Hilog 术语,或者与当前的 ISO 标准相比,Hilog 术语是否具有相当大的优势。

最佳答案

在 XSB 中,Hilog 术语与 XSB 独有的模块系统密切相关。 XSB 有一个基于仿函数的模块系统。即在同一范围内length(X)可能属于一个模块,而 length(L, N)可能属于另一个。因此,call(length(L), N)可能引用一个模块和 call(length(L, N))给另一个:

[Patch date: 2013/02/20 06:17:59]
| ?- use_module(basics,length/2).
yes
| ?- length(Xs,2).
Xs = [_h201,_h203]
yes
| ?- call(length(Xs),2).
Xs = [_h217,_h219]
yes
| ?- use_module(inex,length/1).
yes
| ?- length(Xs,2).
Xs = [_h201,_h203]
yes
| ?- call(length(Xs),2).
++Error[XSB/Runtime/P]: [Existence (No module inex exists)] in arg 1 of predicate load
| ?- call(call(length,Xs),2).
Xs = [_h228,_h230];
在这种情况下, call/N 之间可能存在差异。和 Hilog 条款。但是,到目前为止,我还没有找到一个。
从历史上看,Hilog 术语是在 1987-1989 年引入的。在那个时间点, call/N已经作为 NU 中的内置程序和 library(call) 存在在 Quintus Prolog 中使用 only cursory documentation .已提议 1984 by Richard O'Keefe .另一方面, call/N Hilog 的作者显然不知道,如 Weidong Chen、Michael Kifer、David Scott Warren 的 p.1101 所示:HiLog: A First-Order
高阶逻辑编程结构的语义。 NACLP
1989. 1090-1114。麻省理工学院出版社。

... Generic transitive closure can also be defined in Prolog:

    closure(R, X, Y) :- C =.. [R, X, Y], call(C).
closure(R, X, Y) :- C =.. [R, X, Z], call(C), closure(R, Z, Y).

However, this is obviously inelegant compared to HiLog (see Section 2.1), since this involves both constructing a term out of a list and reflecting this term into an atomic formula using "call". The point of this example is that the lack of theoretical foundations for higher-order constructs in Prolog resulted in an obscure syntax, which partially explains why Prolog programs involving such constructs are notoriously hard to understand.


现在,这可以通过 call/N 来完成。像这样:
closure(R, X, Y) :- call(R, X, Y).
closure(R, X, Y) :- call(R, X, Z), closure(R, Z, Y).
这比 (=..)/2 更通用-版本因为 R不再局限于成为一个原子。顺便说一句,我宁愿写:
closure(R_2, X0,X) :- call(R_2, X0,X1), closure0(R_2, X1,X).

closure0(_R_2, X,X).
closure0(R_2, X0,X) :- call(R_2, X0,X1), closure0(R_2, X1,X).

关于prolog - HiLog 术语在现代 Prolog 中仍然有用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15473065/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com