I have a set of true statements and conditional statements in first order logic that I would like to use prolog to solve. However, I am having trouble elegantly expressing my facts and conditionals.
For example, suppose I want to express the following:
He drinks tea.
she does not drink tea if he does not drink tea.
either she likes soda or tea but not both
if she likes soda then he does not like tea.
The above is a silly example, and I am note interested in the logical deduction. I am interested in a direct translation into prolog so that we can start deducing. Here is my attempt:
Drink_Tea(He).
/* I can't seem to find a not operator, so I'll use !*/
!Drink_Tea(She) :- !Drink_Tea(He).
likes(Soda, She) ; likes(tea, She) , !likes(Soda, She) , !likes(Tea, She).
!likes(Tea, He) :- likes(Soda, She).
All help is greatly appreciated! Let me know if you need more information.
EDIT:
In a prolog file, why is it that I cannot write "Facts" such as not(p) ; not(q)
for variables p
and q
?
\+
. So you'd have, for example,\+ likes(Soda, She)
. – lurker(\+)/1
predicate means negation as failure and not logical negation (see e.g. en.wikipedia.org/wiki/Negation_as_failure). – Paulo Moura