动态查询prolog

动态查询prolog,prolog,swi-prolog,Prolog,Swi Prolog,是否有一种动态查询prolog知识库的方法 我在family.pl文件中有prolog逻辑(我在这里找到的一个示例)。内容如下: mother_child(trude, sally). father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). parent_child(X,

是否有一种动态查询prolog知识库的方法

我在family.pl文件中有prolog逻辑(我在这里找到的一个示例)。内容如下:

mother_child(trude, sally).

father_child(tom, sally).
father_child(tom, erica).
father_child(mike, tom).

sibling(X, Y)      :- parent_child(Z, X), parent_child(Z, Y).

parent_child(X, Y) :- father_child(X, Y).
parent_child(X, Y) :- mother_child(X, Y).
我希望能够在不进入prolog解释器的情况下进行查询

此命令不适用于我:

swipl -f family.pl -g "father_child(Father, Child)"
谢谢

查询确实有效:只是如果以这种方式调用程序,您看不到结果

因此,您可以自己打印结果,例如:

swipl -f family.pl -g "father_child(Father,Child), \ portray_clause(father_child(Father, Child))" 这就产生了:

father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). ?- 现在我们终于有了:

father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). 父亲和孩子(汤姆、萨利)。 父亲和孩子(汤姆、艾丽卡)。 父亲和孩子(迈克、汤姆)。 附言:这是一个非常好的谓词命名约定

查询确实有效:只是如果您以这种方式调用程序,就看不到结果

因此,您可以自己打印结果,例如:

swipl -f family.pl -g "father_child(Father,Child), \ portray_clause(father_child(Father, Child))" 这就产生了:

father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). ?- 现在我们终于有了:

father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). 父亲和孩子(汤姆、萨利)。 父亲和孩子(汤姆、艾丽卡)。 父亲和孩子(迈克、汤姆)。
附言:这是一个非常好的谓词命名约定

这正是我想要的。不,我可以从任何其他编程语言调用prolog查询。非常感谢,太好了!注意,虽然这样做有点…过时的天赋。现在,您可以在Prolog中实现REST服务,或者使用Pengines(基于HTTP的通信),以便其他程序可以轻松地查询Prolog引擎。这太棒了。谢谢这正是我想要的。不,我可以从任何其他编程语言调用prolog查询。非常感谢,太好了!注意,虽然这样做有点…过时的天赋。现在,您可以在Prolog中实现REST服务,或者使用Pengines(基于HTTP的通信),以便其他程序可以轻松地查询Prolog引擎。这太棒了。谢谢