when X
is thirsty, X
should go to the bar.
Looking at the first part of this sentence, "when X
is thirsty”, there’s clearly a property thirsty that X
can have, so thirsty
sounds like a good predicate (thirsty(X)
means X
is thirsty).
Then there’s a few ways to look at the second part of the sentence, "X
should go to the bar”, I’ll write some below in order of increasing complexity with the last being what I think you want:
- One is that “should go to the bar” is a property of
X
, in which case you can define the predicate should_go_to_the_bar
as a predicate so that should_go_to_the_bar(X)
means X
should go to the bar.
Then your program can be:
thirsty(bob).
should_go_to_the_bar(X) :- thirsty(X).
?- should_go_to_the_bar(bob).
True
- Another is that “should go to” may be a relation between
X
and the_bar
, so that should_go_to(X, the_bar)
means that X should go to the_bar.
Then your program can be:
thirsty(bob).
should_go_to_the_bar(X, the_bar) :- thirsty(X).
?- should_go_to(bob, X).
X = the_bar
- Another is that "should" may be a property of actions like
go_to(X, the_bar)
, so that should(go_to(the_bar))
means that it should be that go_to(X, the_bar).
Then your program can be:
thirsty(bob).
should(go_to(X, the_bar)) :- thirsty(X).
?- should(X).
X = should(go_to(bob, the_bar))
- Last I’ll go into is that "should" may be a relation between a person
X
and an action they can do like go_to(X, the_bar)
, so that should(X, go_to(X, the_bar)
means that X should go_to(X, the_bar) i.e. X should make it true that “X goes to the bar".
Then your program can be:
thirsty(bob).
should(X, go_to(X, the_bar)) :- thirsty(X).
?- should(bob, Action).
Action = go_to(bob, the_bar)
I think this last interpretation is closest to what you want.