I'm trying to find a way to put the following first order logic expression into Prolog:
(p(0) or p(1)) and not (p(0) and p(1))
This means that it should respond in the following way to queries:
?- p(0)
Yes.
?- p(1)
Yes.
?- p(0),p(1).
No.
I tried to translate the logical expression:
(p(0) or p(1)) and not (p(0) and p(1)) <=>
(not p(0) -> p(1)) and (p(0) -> not p(1)) <=>
p(0) <-> not p(1)
Using Clarks completion (that states that every definitional theory can be put in a logical program by giving the if-halves), I can obtain:
p(0) :- not p(1).
Unfortunately, this resulting theory is only sound (it will not derive false information), but not complete (for example: p(1) cannot be derived). This is a consequence of Clarks theorem.
Does anybody know if there is a better solution? Thanks!
p(0)
, are you asking it of the system, or telling it to the system? Is everything non-specified assumed to be false (like in Prolog's closed world) or can it take on any value? – Will Ness?- p(0)
is equivalent to asking whetherp(0)
can be proved from the theory. – marczoid