因为Prolog使用按时间顺序回溯(来自Prolog维基百科页面)甚至在找到答案后(在这个例子中只能有一个解决方案),这是否可以证明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).
Run Code Online (Sandbox Code Playgroud)
使用以下输出:
?- sibling(sally, erica).
true ;
false.
Run Code Online (Sandbox Code Playgroud)