In the case of KL1, clauses in a program have the following form.
![]() |
(1.1) |
where predicate is literally a predicate representing a relation among arguments. For example, predicate plus(2,3,5) represents the relation that 2 plus 3 is 5 [Sterling and Shapiro, 1986]. Generally speaking, logic programming languages have somewhat different and simple form:
![]() |
(1.2) |
that is, they have no guard part. For example, the following program
is one of the most typical programs in prolog.
append([],O,O). append([M|I1],I2,[M|O]) :- append(I1,I2,O).
Each line can be interpreted as an axiom in first-order predicate
logic. It means that ``if the right hand is true for symbol :-, the
left hand is true'' (symbol :- means ``is implies'' or
).
If the right hand is empty like the first line, the left hand is
always true. They can be rewritten as logic formulae:
The formula 1.3 means that ``for all o, A([],o,o) is held to be true''. Or if one wants, one might say that ``Anything joined with empty list is itself''. The formula 1.4 means that ``for all m,i1,i2,and o, if A(i1,i2,o) is true, A([m|i1],i2,[m|o]) is true''. One might say that ``if i1 and i2 are joined to cause o, [m|i1] and i2 are joined to cause [m|o].''
Therefore, the above program joins two of any list, and the concatenated list is given as the third argument of predicate append.
In corresponding clauses in logic programming languages with axiom,
a process in execution of a program can be considered as proof of a
given proposition. Consider the following program.
main :- append([1,2],[3,4,5],L).
This can be interpreted as a logic formula:
which means that ``for all l, A([1,2],[3,4,5],l) is not true. '' In other words, it means that there is no list such that [1,2] and [3,4,5] are joined. Execution of the program in logic programming languages is a process to prove that this proposition is false.
If we want to prove that a proposition is false, it is enough to find
a counterexample. Actually, computation in logic programming is to find
the counterexample, which is a result of the computation. In the case of
predicate append, it is enough to find a counterexample of
,
that is, to find l which satisfies
.
This is nothing but computation to find a
concatenated list joining [1,2] and [3,4,5].
The process of the proof is as follows:
l=[1|x] is a counterexample of the axiom 1.5. An x which satisfies axiom 1.6 is searched.
x=[2|y] is a counterexample of the axiom 1.6. A y which satisfies axiom 1.7 is searched.
Therefore, l=[1|x]=[1,2|y]=[1,2,3,4,5] is the counterexample of axiom 1.5, and this is the result.