# Re: [CS3304_1381] Prolog Question

Stephen Edwards (edwards@CS.VT.EDU)
Thu, 30 Mar 2000 09:04:38 -0500

```Message-ID:  <38E35EF6.DE08686A@cs.vt.edu>
Date:         Thu, 30 Mar 2000 09:04:38 -0500
From: Stephen Edwards <edwards@CS.VT.EDU>
Subject:      Re: [CS3304_1381] Prolog Question
```

Ian Elliott wrote:
>
> What exactly do the \+ and the \= mean in Prolog.

\+ means "not".

\= means "not equal".

In general, a backslash as part of a predicate name implies
negation of something.

> I'm having trouble in the "tennis.pro" file with the rule:
>
> same_age(A, B) :-
> (\+ father(A); \+ child(B)),
> (\+ father(B); \+ child(A)).

Even when one understands that \+ means the same as "not", this
one can be hard to figure out. Also remember that "," means "and"
and that ";" means "or". Written out in English, the right-hand
side of this rule might appear as:

(A is not a father, or B is not a child) and
(B is not a father, or A is not a child)

Applying a little boolean logic (deMorgan's law, applied three times)
allows you to convert this to an equivalent expression:

not ((A is a father and B is a child) or
(B is a father and A is a child))

This representation probably makes more intuitive sense. An interesting
exercise is running the original program, and then trying to phrase
the above right-hand side in Prolog to create a different rule for
same_age(A, B). You can then replace the definition in the source
file, run the program again, and see if you get the same answer.

-- Steve

```--
Stephen Edwards            641 McBryde Hall          Dept. of Computer Science
e-mail      : edwards@cs.vt.edu           U.S. mail: Virginia Tech (VPI&SU)
office phone: (540)-231-5723                         Blacksburg, VA  24061-0106
-------------------------------------------------------------------------------
```

This archive was generated by hypermail 2.0b3 on Thu Mar 30 2000 - 09:05:13 EST