|
When we were talking about the definition of multiplication: mult(s(x),y,z) :- mult(x,y,w), add(w,y,z). We saw that in the stack in multiplying s(0) by some y that we immediatly get that z=0 from mult, which allows us to infer that add(w,y,z) gives z=s(0). To see whether this inference can be made backwards, I changed the definition to be: mult(s(x),y,z) :- add(w,y,z), mult(x,y,w). and it gave me the following: | ?- mult(s(0),s(s(0)),X). X = s(s(0)) ? Fatal Error: local stack overflow (size: 3192 Kb, environment variable used: LOCALSZ) What is the reason for this screw up? It gave the correct answer, then bombed trying to find others... Matthew |
Think of Prolog as searching an infinite tree of proofs by Mike O'Donnell, 2001, Nov 29
to: