Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FOL expression in Prolog

Status
Not open for further replies.

marczoid

Programmer
Sep 28, 2012
2
SE
Hi all, I'm trying to find a way to put the following first order logic expression into Prolog

Code:
(p(0) or p(1)) and not (p(0) and p(1))

This means that it should respond in the following way to queries:

Code:
?- p(0)
Yes.
?- p(1)
Yes.
?- p(0),p(1).
No.

I tried to translate the logical expression:

Code:
(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) <-> 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:

Code:
p(0) :- 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!
 
I made a mistake in my post, and since I don't see an edit button I will post the correction here:

The derivation of the logical expression should have: p(0) <-> not p(1) as the last formula, and the Prolog code is: p(0) :- not p(1).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top