06.03.2013 Views

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

Artificial Intelligence and Soft Computing: Behavioral ... - Arteimi.info

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In the SLD tree for the Taxpayer problem, the control first attempts to<br />

find solutions from the leftmost sub-tree. On getting the fail predicate<br />

following CUT, it backtracks to the root node <strong>and</strong> attempts to generate the<br />

second alternative solution. Then exp<strong>and</strong>ing the second sub-tree, it finds FAIL<br />

following CUT predicate <strong>and</strong> returns to the root. Finally, the third sub-tree<br />

yields the solution: X = lakshman.<br />

6.7 The NOT Predicate<br />

An alternative of the CUT-FAIL combination in PROLOG is the NOT<br />

predicate, defined below:<br />

1. NOT (P) CALL (P), !, FAIL.<br />

2. NOT (P) <br />

In the above definition of NOT predicate, a CALL predicate has been<br />

used. The CALL predicate simply treats its argument as a goal <strong>and</strong> attempts to<br />

satisfy it. The first rule of the NOT predicate is applicable, if P can be shown<br />

<strong>and</strong> the second rule is applicable otherwise. As a matter of fact, if PROLOG<br />

satisfies CALL (P), it ab<strong>and</strong>ons satisfying NOT goal. If P is not provable,<br />

CALL (P) fails, thus forcing the control to backtrack to the root from CALL<br />

(P). Consequently, PROLOG uses the second definition of NOT predicate <strong>and</strong><br />

it succeeds, signifying that P is not provable.<br />

Example 6.7: Consider the definition of income through a pension of<br />

persons using a CUT-FAIL combination, which can be re-written using a NOT<br />

predicate as follows:<br />

Rule using CUT-FAIL combination<br />

Annual-Inc (X, Y) ← Receives-Pension (X, P),<br />

P < 30,000,<br />

!, fail.<br />

Annual-Inc (X,Y) ← Receives-Pension (X, P), Y = P.<br />

The same rule using NOT predicate<br />

Annual-Inc (X, Y) ← Receives-Pension (X, P),<br />

NOT (P < 30,000),<br />

Y= P.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!