0
101 Oct 03, 2005 at 01:30

Hi everyone,

I’ve tried solving the following very basic question in prolog but to no avail:

“I love cats or I love dogs”
“If I love cats, then I love dogs”

By constructing a truth table, i know that “I love dogs” is a logical conquence of the premise. The same cannot be said about “I love cats”. Howver, i just can’t seem to get prolog to proof this. Can someone help me please? Thanks so much in advance!

#### 3 Replies

0
101 Oct 05, 2005 at 16:39

I know some prolog, but I’m not sure what you’re asking.

Okay, say you have cat and dog. First you say that they’re animals

animal(cats)
animal(dogs)

Somewhere above, you may have defined one or both of these (or neither). For this example, let’s say you have both:

love(cats)
love(dogs)

animalsthatilove(X):-love(X)

will show:
cats
dogs

loverelations(cats,dogs)

loveofrelated(X):-loverelations(cats,X)

will show:
dogs

I’m not sure if this answers your question. I think you have a misconception about how prolog works, but hopefully this gave you a head start.

0
101 Oct 15, 2005 at 13:44

Maybe you’d like to check back sometime and let us know if you had any luck with prolog and if my advice helped. :)

0
101 Oct 16, 2005 at 03:42

Hi Rydinare,

Thank for your response. I’m pretty sure your program works fine in prolog. My apologies for perhaps not being explicit on my doubts. Do allow me to rephrase my question.
@Rydinare

I know some prolog, but I’m not sure what you’re asking.

Okay, say you have cat and dog. First you say that they’re animals

animal(cats)
animal(dogs)

Somewhere above, you may have defined one or both of these (or neither). For this example, let’s say you have both:

love(cats)
love(dogs)

By entering the above clauses into prolog, we’re saying that love(cat) and love(dog) are both true statements and thus are both logical consequence of our logic program.

However, if we let (cat = p) and (dog = q), the original question:

“I love cats or I love dogs” translate into “p v q”
“If I love cats then I love dogs” translate into “q <- p”

By constructing a truth table for the above, we get the following:

 p q p v q q <- p

 T T T T (1) T F T F (2) F T T T (3) F F F T (4)

It is shown that q is the only logical consequence of the program since it is true when both statements are also true (as shown in (1) and (3)). p on the other hand is not a logical consequence since it is false under (3). This would directly contredict our program clause earlier.

My question therefore is:
“Is there a way to use prolog to demonstrate what the truth table has just shown us?”