Hi!
Below i want to check if p(a) and p(b) are members of the list. But after the fist call to member/2, L is instantiated to p(a) so the second call to member/2 fails. Is there a way to avoid this? Ie checking for membership without changing the list that involves anonymous variables?
Negation never binds variables in the negated goal. Thus, by using double negation you can verify that a goal succeeds without binding any of its variables.
I should have explained more clearly in my original post that i don’t know how many times member/2 will be called and what the first argument of the compound p will be. So what i have is something like
The predicate forall/2 is implemented as \+ ( Cond, \+ Action) , i.e., There is no instantiation of Cond for which Action is false. . The use of double negation implies that forall/2does not change any variable bindings . It proves a relation. The forall/2 control structure can be used for its side-effects.