prolog - An infinite success tree, or not? -
i'm given following program:
edge(a,b). edge(b,c). edge(a,d). path(n,m):- path(n,new),edge(new,m). path(n,m):- edge(n,m).
and asked if when applying proof tree algorithm following query:
?- path(a,x).
the proof tree infinite success tree, or infinite failure tree?
now see it, during building of tree, stuck in applying rule 1 of path on , on again, creating infinite tree , never getting rule 2 of path..
thus creating infinite failure tree. solution have says infinite success tree, question is: right or professor right? :]
i call infinite loop. @ trace:
?- trace, path(a,x). call: (7) path(a, _g394) ? call: (8) path(a, _g511) ? call: (9) path(a, _g511) ? call: (10) path(a, _g511) ? ... call: (147) path(a, _g511) ? call: (148) path(a, _g511) ? ... error: out of local stack
i'm not familiar these terms, might able wing it. no solutions produced, hard me argue infinite success tree. given infinite time , space never produce successful solution. @ same time, failure in prolog sense immediate, , isn't happening either. i'm not sure such thing infinite failure tree exist, unless you'd call generates infinite number of choice points, of fail. there aren't failures here. more honest call is: infinite loop. such things exist outside realm of success , failure. why in haskell, ⊥ belongs every type. maybe in sense you're both right.
Comments
Post a Comment