Information Technology Reference
In-Depth Information
Figure 2.1. A SLD tree without ! Figure 2.2. A SLD tree with !
According to the example, soundness of SLD resolution might be destroyed
by the CUT mechanism. Furthermore, incorporation of the CUT mechanism will
cause the inconsistency between the declarative semantics and the operational
semantics of logic programming. For example, let P be the following program
which is designed to calculate the maximum value of two data.
max(X, Y, Y) :- X =< Y.
max(X, Y, X) :- X > Y.
We can check that declarative semantics and operational semantics of P are
consistent. Now, we insert a CUT predication into P and get the following
program P1:
max(X, Y, Y) :- X =< Y, !.
max(X, Y, X) :- X > Y.
Efficiency of the program is obviously increased; although both the declarative
semantics and the operational semantics of P1 are not changed with respect to
those of P. Efficiency of the program can be further increased if we replace P1
with the following program P2:
max(X, Y, Y) :- X =< Y, !.
max(X, Y, X).
Search WWH ::




Custom Search