Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设您在 prolog 中加载了以下程序:
?- listing. fast(ann). slow(bob). slow(norm). true. ?-
如何将以下规则添加到该程序中?
faster(X,Y) :- fast(X), slow(Y).
有人可以帮我写吗?
有两种选择。
faster.pl
[faster].
[user].
Prolog数据库是动态的:可以使用assertz /1 和retract/1 来完成对规则库的修改。然后,添加到@larsman 答案,你可以写
?- assertz((faster(X,Y) :- fast(X), slow(Y))).
之后,根据您的事实基础:
?- faster(X,Y). X = ann, Y = bob ; X = ann, Y = norm.