gpt4 book ai didi

prolog - Prolog 中的逻辑

转载 作者:行者123 更新时间:2023-12-02 07:25:30 25 4
gpt4 key购买 nike

如何用 Prolog 表达接下来的 3 个句子?

All summers are warm. If it not summer, then it is winter. Now it is winter.

最佳答案

问得好。正如@larsman(好吧,我认为现在是@FredFoo)正确地说,可以是一个大主题。他的回答确实很好。

由于您的问题可能是由自定义语言的必要性(Prolog 的主要用途之一)驱动的,因此我在这里提出了虚拟 DSL 的语法糖(这意味着现在它完全是空的。 ..)

:- op(500, fx, all).
:- op(500, fx, now).
:- op(600, xfx, are).
:- op(700, fx, if).
:- op(399, fx, it).
:- op(398, fx, is).
:- op(397, fx, not).
:- op(701, xfx, then).

all summers are warm.
if it is not summer then it is winter.
now it is winter.

SWI-Prolog 足够友善,可以将那些被存储的操作标记为红色,即可以轻松查询。这些是声明的较高优先级单词:即 are、then、now。

?- now X.
X = it is winter.

关于prolog - Prolog 中的逻辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10928544/

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