next up previous contents
Next: What You Should Up: Rules as Terms Previous: 2

3

The above rule in prefix form
 
		 :-(happy(X),rich(X)).
 [-5pt]

But what about
 
happy(X):-

healthy(X),

wealthy(X),

wise(X).

Trying to rewrite in prefix form:
 
		:-(happy(X),whatgoeshere?).
 [-5pt]

Note that the comma `,' in this expression is an argument separator. In the definition of happy/1 above, the commas are read as ``and''.

Yes,

 
healthy(X),wealthy(X),wise(X).
 [-5pt]

is also a compound term with principal functor
 
,
 [-5pt]

and arity 2. Since we have to represent three subgoals and the arity of `,' is 2 we again have a nested compound term. The correct prefix form for the example is:
 
		','(healthy(X),','(wealthy(X),wise(X))).

Note: try the goal display((healthy(X),wealthy(X),wise(X))) to see the ``truth''. Also, note that, for a reason as yet unexplained, you need an extra pair of brackets around the goal you want printed via display/1.

Here is the tree:



Paul Brna
Mon May 24 20:14:48 BST 1999