考慮下述Prolog程式:
ancestor(x,x).
ancestor(x,y) :- ancestor(z,y), parent(x,z).
parent(Allen, John).
用一個subgoal的搜尋樹(search tree),描述此Prolog程式在執行查詢:
ancestor(Allen,X)時的執行步驟。
可以請問大家 為什麼右邊是stop嗎 ?
上完課還是有點聽不懂
ancestor(Allen,X)
/ \
/ \
1 / \ 2
/ \
/ \
ancestor(Allen,Allen) Stop
{ X = Allen }
success
--
All Comments