Hi everyone, thanks in advance to anyone who can help me here.
I'm new to Prolog and couldn't find an equivalent question to the one I'm posting so, given this knowledgebase:
t(pb(4)).
t(pb(4),L):-
member(pb(11),L).
tt(P,L):-
findall(T,t(P),R),
findall(T,t(P,L),R).
pv(A):-
tt(pb(4),[pb(A)]).
When I give the queries:
?- pv1(11).
true.
?- pv1(12).
false.
These are as I'd expect but, when I give:
This too is right except it doesn't bind anything to A for me. Can anyone explain what's going on here and how i can sensibly get the binding?
With trace I can clearly see the correct unification taking place, highlighted purple:
Call: (6) pv1(_G19347) ? creep
Call: (7) tt(pb(4), [pb(_G19347)]) ? creep
^ Call: (8) findall(_G19430, t(pb(4)), _G19432) ? creep
Call: (13) t(pb(4)) ? creep
Exit: (13) t(pb(4)) ? creep
^ Exit: (8) findall(_G19426, user:t(pb(4)), [_G19440]) ? creep
^ Call: (8) findall(_G19426, t(pb(4), [pb(_G19347)]), [_G19440]) ? creep
Call: (13) t(pb(4), [pb(_G19347)]) ? creep
Call: (14) lists:member(pb(11), [pb(_G19347)]) ? creep
Exit: (14) lists:member(pb(11), [pb(11)]) ? creep
Exit: (13) t(pb(4), [pb(11)]) ? creep
^ Exit: (8) findall(_G19426, user:t(pb(4), [pb(_G19347)]), [_G19440]) ? creep
Exit: (7) tt(pb(4), [pb(_G19347)]) ? creep
Exit: (6) pv1(_G19347) ? creep
So I just don't understand why there's no binding for A. This is all a simple instance of the code as I can get, the real version is validating a bunch of rules somewhat similar to 't' in the example against a list of things.
Thanks once again for any advice.
Steve.