Visual Prolog 5.2 The variable is not bound in this clause

388 Views Asked by At

I have "in" predicate that goes through "people". But the X doesnt get a "person" and returns false, as i understood. Test goal and Run throw the same error

domains
person = c(name, nationality)
people = person*
name, nationality = symbol

predicates
name(person, name)
nationality (person, nationality)
in(person, people)
solve

clauses
name(c(N,_), N).
nationality (c(_,T), T).

in(X,[X,_,_,_]). %Error here
in(X,[_,X,_,_]).
in(X,[_,_,X,_]).
in(X,[_,_,_,X]).

solve :- in(C1, People), name(C1, brown),
in(C2, People), name(C2, clemens),
in(C3, People), name(C3, grifit),
in(C4, People), name(C4, grin),
in(C5, People), nationality(C5, canadian),
in(C6, People), nationality(C6, american),
in(C7, People), nationality(C7, australian),
in(C8, People), nationality(C8, british),

not(nationality(C1, british)),
not(nationality(C2, british)),
not(nationality(C3, american)),
not(nationality(C3, australian)),
not(nationality(C1, australian)),
not(nationality(C4, australian)),

write(People), nl.

goal
solve.

I expect X to be bound to the person (people item). What am I doing wrong?

0

There are 0 best solutions below