Information Technology Reference
In-Depth Information
(2) strong(X):- tuberculosis(X),!, fail.
(3) strong(X):- nearsight(X), !, fail.
Then, according to first clause of the program, a backtracking will be triggered
by the “fail” after the unification of the goal “strong(Zhang)” and unification of
the new generated sub-goal “heart_disease(Zhang)”. Since “strong(Zhang)” is the
father-goal of the CUT that contained in the first clause of P, it will be poped
from the goal stack also. Therefore, the SLD resolution will be finished right
away and return a negative result.
Since first-order logic is undecidable, there is no terminable algorithm to
decide whether G is a logic inference of P, for G and P any program and any goal
respectively. Certainly, SLD resolution algorithm will return a corresponding
result if G is a logic inference of P. However, in the case that G is not a logic
inference of P, the SLD resolution process (or any other algorithm) will fall into
endless loop. In order to solve this problem, the rule “negation as failure” is
introduced into logic programming. For any clause G, if it can not be proved,
then the rule will enable the result that ¬G is reasonable.
Based on the “negation as failure” rule, the predication “not” is defined in
Prolog as follows:
not(A) :- call(A), !, fail.
not(A).
Here “call” is a system predication and “call(A)” will trigger the system to solve
the sub-goal “A”. If the answer of the sub-goal “A” is positive, then a
backtracking will be triggered by the “fail” occurring in the first clause, and the
SLD resolution will be finished right away; in this case, result for the clause
“not(A)” is negative. However, if the answer of the sub-goal “A” is negative,
then a backtracking will be triggered right away so that the “fail” occurring in the
first clause will not be visited; in this case, result for the clause “not(A)” is
positive according to the second clause.
Search WWH ::




Custom Search