For the most part, logic variables are already exclusive because they can only be bound once.
You have defined here a rule color/1
with four bodies. When you query with an uninstantiated variable, Prolog is going to try binding each one of them in turn:
?- color(X).
X = red ;
X = green ;
X = blue ;
X = seafoam.
Now you have a nasty bit of backwards incorrectness here because red both is and is-not a color:
?- color(red).
true ;
false.
Predicates that look like foo(...) :- false.
often look suspicious to me, because part of the magic of Prolog is generating solutions, and explicit failures tend to read to me like playing games with the engine.
The problem here is that you are mixing your definition of the set "color" with the set of possible colors of your thing. If I wanted to say something can only be red, green or white, I would probably say:
color(thing, red).
color(thing, green).
color(thing, white).
Then I can still have color(blue)
because blue exists even if my thing can't be blue. When I want to generate possible colors of thing, color(thing, X)
gives me possibilities; color(thing, blue)
fails and color(X, blue)
will never generate thing
(though it may generate something else, in this example it does not).