What's the SLD tree for this query?

后端 未结 3 1147
野的像风
野的像风 2021-01-18 19:10

Let\'s consider the following Prolog program (from \"The Art of Prolog\"):

natural_number(0).
natural_number(s(X)) :- natural_number(X).

plus(X, 0, X) :- na         


        
3条回答
  •  死守一世寂寞
    2021-01-18 19:42

    To us, it's apparent that the two clauses for plus are 'disjunctive'. We can say that because we know that 0 \= s(Y). But (I think) such analysis in general is prohibitive, and Prolog then consider such branch still to be proved: here a trace showing that the call (7) is still 'open' for alternatives after the first solution has been found.

    enter image description here

提交回复
热议问题