Flora-2 钻石传承

发布于 2024-10-28 19:28:07 字数 1055 浏览 7 评论 0原文

Flora-2 是一种古怪的语言,我知道这是一个不太可能的事情,但我还没有找到任何专门用于它的活跃资源,所以我在这里尝试。它是如此受欢迎......它没有 stackoverflow 标签。如果您了解 Flora-2 和 XSB Prolog 的现状和未来,我也很乐意听听。

有人可以向我解释一下 Flora-2 钻石继承规则吗?该手册有一个示例,但没有显示示例的结果。该措辞似乎与我在解释器和 Diamond.flr 演示中看到的相反。这是演示:(

c[f*->g].
c1[f(a)*->a]::c.
c2[f(b)*->b]::c.
o:c1.
o:c2.

?- ?X[?Y->?Z].

我所看到的情况在有或没有基类 c 的情况下都会发生)

手册说:

在 arity 方法级别 > 1、如果同一方法有两个未覆盖的定义附加到两个不同的超类,则认为发生了冲突。在决定是否发生冲突时,我们忽略该方法的参数。例如,在

a:c. c[m(k)*->f]. a:d. d[m(u)*->f].

中,即使在一种情况下方法 m 应用于对象 k,而在另一种情况下它应用于对象 u,也发生了多重继承冲突。

(I'我很确定他们的意思是 arity >= 1 但结果对于 arity 2 也相似)

所以我认为这意味着 f 的继承有冲突所以它是未定义的(尽管我对什么是 'undefined 有点困惑' 的意思是,在相关部分中它说“继承不会发生”)。这是我运行钻石时得到的结果:

?X = o
?Y = f
?Z = g

?X = o
?Y = f(a)
?Z = a

我只期望第一个解决方案,尽管我认为如果第二个解决方案也有解决方案,那么它至少会有意义

?X = o
?Y = f(b)
?Z = b

......但事实并非如此。

仅供参考,我正在使用最新的稳定 XSB 和最新的 Flora-2 版本...0.95。

Flora-2 is an eccentric language and I know this is a long shot but I haven't found any active resources devoted to it so I'm trying here. Its so popular... there is no stackoverflow tag for it. If you know anything about the status and future of Flora-2 and XSB Prolog, I'd love to hear that, too.

Can someone explain Flora-2 diamond-inheritance rules to me? The manual has an example but doesn't show the results of the example. The wording seems to be the opposite of what I see in the interpreter and in the diamond.flr demo. Here's the demo:

c[f*->g].
c1[f(a)*->a]::c.
c2[f(b)*->b]::c.
o:c1.
o:c2.

?- ?X[?Y->?Z].

(What I see happens with or without the base class c)

The manual says:

At the level of methods of arity > 1, a conflict is considered to have taken place if there are two non-overwritten definitions of the same method attached to two different superclasses. When deciding whether a conflict has taken place we disregard the arguments of the method. For instance, in

a:c. c[m(k)*->f]. a:d. d[m(u)*->f].

a multiple inheritance conflict has taken place even though in one case the method m is applied to object k, while in the other it is applied to object u.

(I'm pretty sure they mean arity >= 1 but the results are similar for arity 2 as well)

So I take that to mean that the inheritance of f has a conflict so its undefined (although I'm a bit confused about what 'undefined' means, in a related section it says "inheritance does not take place"). Here's what I get when I run the diamond:

?X = o
?Y = f
?Z = g

?X = o
?Y = f(a)
?Z = a

I expected only the first solution, although I'd think that the second solution would at least make some sense if it also had the solution

?X = o
?Y = f(b)
?Z = b

... but it didn't.

FYI, I'm using the latest stable XSB and the latest Flora-2 release... 0.95.

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

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

发布评论

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

评论(2

挽你眉间 2024-11-04 19:28:07

在提出问题两年多后偶然发现了这个问题。您应该在 flora-users 邮件列表上询问。

不管怎样,这似乎是那个版本的 Flora-2 中的一个错误。我看到当前版本给出了正确的答案

?X = o

?Y = f

?Z = g

也就是说,两个冲突的继承相互抵消,正如手册中所描述的那样。

Stumbled upon this 2+ years after the question was asked. You should have asked it on the flora-users mailing list.

Anyway, this seems to have been a bug in that version of Flora-2. I see that the current version gives a correct answer

?X = o

?Y = f

?Z = g

That is, the two conflicting inheritances canceled each other out, as the manual describes.

我喜欢麦丽素 2024-11-04 19:28:07

我不熟悉 Flora-2 语法,但我在 Logtalk 中有一个著名的钻石继承问题的类似示例。您可以在这里找到它:

https://github.com/LogtalkDotOrg/logtalk3/tree /master/examples/diamonds

有关语义、默认继承规则和用户覆盖默认继承规则的信息,请参阅NOTES.txt 和源文件注释。您可以使用 XSB 的最新 CVS 版本运行该示例。请参阅 SCRIPT.txt 文件以获取示例查询。

I'm not familiar with Flora-2 syntax but I have a smilar example of the well-known diamond-inheritance problem in Logtalk. You can find it here:

https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/diamonds

See the NOTES.txt and source file comments for information on semantics, default inheritance rules, and user-overriding of default inheritance rules. You can run the example using the latest CVS version of XSB. See the SCRIPT.txt file for sample queries.

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