Hello! I’m new to prolog and found this unexpected behavior when using ‘findnsols’ (which calls '‘findall’). Not all solutions returned satisfy the goal, which really confuses me. Do I misunderstand something?
This is the program:
predneg_on_obj(block1,block1).
predneg_on_obj(block2,block1).
predneg_on_obj(block2,block2).
istypeobj(block1).
istypeobj(block2).
goal(V_1) :-
forall(member(O, [block1,block2]), predneg_on_obj(O,V_1)),
istypeobj(V_1).
And this is the query:
findnsols(99999, V, goal(V), L)
The result is:
L=[block1, block2]
It’s obvious that block2 is not part of the solution, and we can verify it by calling the command below, which returns False.
goal(block2)
So we can see while ‘block2’ appeared in the solution, it does not satisfy the goal.
Any help is greatly appreciated!