Merge 1
Merge 1
Propositional Logic
The other connectives are handled similarly and are left to Exercise 17. 0
This theorem corresponds to what is often called the unique readability of propo-
sitions: There is only one way to parse a proposition into its component parts
all the way down to the propositional letters. Along these lines, we, in informal
usage, abuse our notation by omitting parentheses whenever no confusion can
arise. Thus, for example, we write -xli for (-'0:) and 0: -t {J for (a ----..
(J). Formally,
unique readability gives us another way to define functions on the propositions
and prove facti; about them: induction on formation trees. Typically, we induct
on the depth of the formation tree associated with a proposition. The advantage
of using trees is that, if one defines a function on formation trees, one eutometi-
cally has one on the associated propositions. If instead, one defined an operation
directly on propositions by induction, one would not know that there is only
one way of analyzing a given proposition inductively so as to guarantee that
the operation is well defined. This is precisely unique readability. We see some
examples of such procedures in the next section. For now, we just note that the
theorem allows us to define the depth of a proposition. We can also use it to pick
out the propositional letters that are "relevant" to a given proposition:
Definition 2.5:
(i) The depth of a proposition is the depth of the associated formation tree.
(ii) The support of a proposition is the set of propositional letters that occur
as labels of the leaves of the associated formation tree. (That this notion
corresponds to the ones that occur syntactically in the proposition is proven
by another induction argument. See Exercise 16.)
~:~~ili)
:;e type of ~dudive definition given may clarify the role
(i) and (il) are'ro .:arant~ th~ only those exprfSSions generated by
eer 5 is c/o.sed~ . n&. We begin with the (algebraic) notion of cloeure. A
every ". "e a smgle (for example n-ary) operation f(a1, ... , s,,) iff for
operatio~'~ ."set
15
i:.I\"h"···
,"n) e S. The cl~t1reof. 5et S under (all) the
e mallest set C such that
I. s c c ee
2. if 1 E T is n-azy and
Ill, ... , "n e C, then 1("" ... ,II,,) e C.
closed under the operations of T. We could now define the set of propositions as
the closure of the set of propositional letteN! (i) under the operations 1\, v, ......
, .....
and ......as listed in (ii).
Turning now to semantics, we take the view that the meaning of a Propositional
letter is simply its truth value, that is, its truth or falsity. (Remember that we
are postponing the analysis of the internal structure of propositions to the next
chapter.) Each proposition then hes a unique truth value (T, for true or F, for
false). The truth value of a compound proposition is determined from the truth
values of its parts in accordance with the troth tables in Figure 3:
a P (a_pj
fffij
T T T -.>
T F F T F
F T F F T
F F T
FIGURE 3.
A B C (AAB) ((AAB)_C)
T T T T T
T T F T F
T F T F T
T F F F T
F T T F T
F T F F T
F F T F T
F F F F T
FIGURE 4.
A priori, we might have begun our definition of propositions with some other
list of basic connectives, In general, an n-ary connective is any function o that
assigns a proposition q(AI, ... ,An) to every a-tuple of propositions At, ... , ~n'
So -. is I-My (u.nary), while 1\ and V are 2-ary (or binary). An n-ary connective
is tndhfunctional if the truth value for q(Aj, .•• ,An) is uniquely determined by
the truth values for AI"., ,An' Our five connectives are truth functional since
their meaning was defined by truth tables. On the other hand a connective like
"because" is not. For let A symbolize "I bad prune juice for breakfast" and B
"there was an earthquake at noon". Even in the event that both A and B have
truth values T it is at least debatable whether (B because A) should have trutb
value T. The debate might be more or less heated in other cases depending on
the content of A and B. An n-ary connective that is truth functional can be
completely described by means of a truth table as in Figure 5 where each bj,
1 $ i ~ 2" is either T or P.
Conversely, two distinct abbreviated truth tables (with the conventional listing of
truth values for AI, .. " An) correspond to distinct truth functional connectives.
By counting we see that there are 22" distinct n-ary truth functional connectives.
(So there are 12 = 16 - 4 binary oonnectiYe!l that we are not using.)
Definition ~. 7: A set S of truth functional connectives is adeqtwte if, given any truW E
~nd;Io.nal connective a, we can find a proposition bUilt Up from the connectives
m S wnb the same abbreviated truth table as a.
2 Propositions, Connoctives end Truth Tables 19
FIGURES.
Proof: Let AI, ... ,Ak be distinct propositional letters and let aij denote the entry
(T or F) corresponding to the ith row and jth column of the truth table for
O'(Al, ... , AkJ as in Figure 6. Suppose that at least one T appears in the last
column.
a.j b,
FIGURE 6.
For any proposition a, let aT be a and of be ( 0). For the ith row denote
the conjunction (A~n A ... AA:'·) bra.. Let i1, ,i ... be the rows with a T in
the last column. The desired proposition is the disjunction (Git V ... Vai-)' The
proof that this proposition has the given truth table is left as Exercise 14. (Note
that we abused our notation by leaving out a lot of parentheses in the interest
of readability. The convention is that of right B.,!8ociativity, that is, A /\ B A 0
is an abbreviation for (A A (B A 0».) We also indicate a disjunction over a set
of propositions with the usual set-theoretic terminology. Thus, the disjunction
just constructed would be written as V{GiI bi = T}. 0
:xarnple 2.9: The procedure given in the above proof can be illustrated by construct,
ing a Proposition built using only A, V and ., which has the truth table given in
Figure 7.
20 I. Propositional Logic
A B C ?
1 T T T T
2 T T F F
3 T F T F
4 T F F F
5 F T T T
6 F T F F
7 F F T F
8 F F F T
FIGURE 7.
We begin by looking only at rows with a T in the last column. For each such
row we find a proposition which is true for that row and false for every other
tow. The Proposition we want is the disjunction of the propositions we obtain
fur all relevant rows (rows 1, 5, 8 in this case). For any particular row, the
proposition true for only that row is obtained by taking the conjunction of the
letters having a T in that row and the negations of letters having an F in that
row. In this case row 1 gives (AAB /I.e) (we abuse notation again!); row 5 gives
«(-..A) A B A C); and row 8 gives ((-,A) A (-.B) /I. (-,C)). Thus, the proposition
(A A B A C) v «"A) A B A C) v «"A) A ("B) A ("C)) has tho given truth
table.
Clearly, given any proposition Q we can COnstruct its truth table and then follow
the above procedure to find another proposition that has the same truth table
and is a disjunction of conjunctions of propositional letters and their negations.
A proposition of this form that bas the same (abbreviated) truth table es a is
called a dUjunctitie fi01T1lal form. (ONF) of o. There is also a conjunctive nonnal
form (CNf') equivalent of Q that is presented in Exercise 3.3. Another method of
finding DNF and CNF equiva.lents of Q is presented at the end of the exercises for
§4.
Remark 2,10: The above procedure does not tell us what to do in case the last
column consists entirely of F's. See Exercise 13.
Proof: We can easily ~ that (Ai /I. A'l) has the same truth table as.-.«-.(Ar)) V
~-,(A'l))). Thus, gIVen any proposition Q we can find a DNF of Q and then elim-
matesame
the any truth
use oftable.
/I. by this substitution. The re8lllting proposition will still have
0
2 Propoaitions, Connectivesand Truth Tables 21
Remark 2.12: By the adequacy theorems (Theorem 2.8 and Corollary 2.11) we could,
in theory, get by with just the connectives ...,. V and 1\ or even just ...,and V. The
induction clause in the definition of Propositions and many related definitions
and proofs (such as those involving tableaux in Sections 4, 5 and 6) could then
be considerably shortened. We, however, leave the list of connectives as it is but
generally explicitly deal with only a couple of cases in any Particular proof and
leave the rest as exercises.
F;xerr:ises
1. Which of the following expressions are official (i. e., unabbreviated) propo-
sitions of Propositional logic based on the propositional letters A, B, C, D?
(e) (HA V B» A C)
Cb) CAAB)vC
(c) A _ (B AC)
(I) (((CVB)AA)_D)
Cg) (CVA) A (~B»
2. Prove your answers to l(a), (b) and (f) by either giving the step by step
procedure producing the proposition in accordance with the inductive def-
inition of propositions (you can simply draw a correctly labeled formation
tree) or proving, by Induction on statements, that there is some property
enjoyed by all Prop06itions but not by this expression.
3. Prove that every proposition other than a propositional Jetter begins with
a left parenthesis and ends with 8 right parenthesis. Moreover, the number
of right and left parentheses are equal in every proposition.
5. Find DNF _,
.....uivalents for the following propositions:
(a) (A - 8) _ C
(b) (A _ 8) V (,C).
,
7. P ave that {...,, -') is an adequate set of connectives.
8. Prove that the binary connective (0 I (J) (Unat both, ... and") called the
Sheffer Jtroke whose truth table is given in Figure 8 IS adequate.
a 8 018
T T F
T F T
F T ·T
F F T
FIGURE 8.
9. Show that joint denial (neither 0: nor 13), written as Q 1 {j, is also adequate.
10. Prove that {A, V} is not adequate. .
Hint: Show by induction that -a is not equivalent to any statement built
up from a using only 1\ and v.
12. Prove that {V, ..... J .... } is not an adequate set of connectives. [
14. Prove that the expressions constructed in the proof of Theorem 2.8 (in-
cluding the case COnsidered in Exercise (3) have the desired truth tables.
15. We say that all PMpositionalletters are built at Stage o. If propositions a
and,B have been bullt by level 11., we say that (-.a), (aV.B), (0''''.8), (a -+ fJ)
and (Q ......P) have been built by level 11. + 1. Clause (iii) of Definition 2.1
sa", that every Pro""'itkm ~ ~ built by "'m, 1""1 n. E>plain how we can Th
rephrase proof by induction on the definition of propositions in terms of
ordinary induction on the natUral numbers N.
3 Truth AliSignments and ValuatiolUl 23
16. We say that each propositional letter A OCCUrs in itself and no Proposi.
tionalletters other than A Occur in A. The propositional letters that occur
in (-.0) are precisely the ones that OCcur in a. The ones that OCCur in
(a V 13), (a A P), (a - 13) and (a _ 13) are Precisely these that Occur in
either Q or 13 (or both). This notion clearly captures the idea of a syntactic
occurrence of a propositional letter A in a proposition a.
Prove that the support of a proposition a is Precisely the set of proposi-
tional letters that occur in a.
The truth values of all Propositions should now be determined by the assignment
to the propositional letters. The determinations are made in accordance with the
truth tables for the connectives given in the last section.
The basic result here is that a truth assignment to the propositional letters
uniquely determines the entire truth valuation on all Propositions. We analyze
the situation in terms of an induction on the depth of the propositions, that is,
the depth of the (unique) formation tree associated with the proposition.
eol"Qtn 3.3: Gi~n a truth assignment A tJun i.s a unique truth valuation V such
th4t V(a) == A(a) for I':tIery Propositionallettl':r Q.
24 I. Propositional Logic
Proof: Given a truth assignment.A., define (by induction on the depth of the associated
formation tree) a valuation Von all propositions by first setting V(a) = ..4(0) for
all propositional letters a, This takes care of all formation trees (propositions)
of depth O. Assuming that V has been defined on all propositions with depth at
most n, the inductive steps are simply given by the truth tables associated with
each connective. For example, suppose T(a_l') is the formation tree (of depth
n + 1) for (0 ......13). (It is built from Ta and TtJ (with the maximum of their
depths being exactly n) 6S in Theorem 2.4.) V((o ..... /1»
is then defined to be
F iff V(o) "" T and V(/1) "" F. The valuation is defined on a and P by induction
since they have depth at most n.
(ii) Suppose Vl(O) = V2(o) for all propositions a of depth at most n and that
0: and 13 have depth at most n. Thus, V1(0) = V2(0) and Vt(P) = V2(13) by
induction. VI ((0 A ti» and V2((0 A.8» are then both given by the truth table
for 1\ and so are equal. The same argument works for ell the other connectives
and so VI and V2 agree on every proposition. 0
D
Note that, by induction again on the depth of 0, the definition of V(a) in this
construction only depends on the values of.A. on the support of 0 (the propoel-
tionalletters occurring in 0). Thus, the proof of the theorem actually proves:
CoroU~ 3.4: If Vt a~d. V2 are two valuations that agree on the support of a, the
fimte set of proPOS1tional letters tUM in the construction of the prnpo.tition 0,
thfn Vt(a) = V2(a). 0
Definition 3.6: Two prop05itions 0 and fJ such that for ev ry val u V V( ) ""
V(,8) are called logically equivalent. We denote this by ~ := ti. ue IOn , a
Example 3.7:
AV
(I) (Pe . (~AI))~) d (((A - B) ~ A) - A) (Law o!the .xdud"" middle aod
tree s aware tautologies. See Exercise 1.
Note that, if E is empty, E 1= (1 (or just 1= (1) iff (1 is valid. We also write
this as 1= (1. This definition gives a semantic notion of consequence. We see
several syntactic notions in tbe coming sections that correspond to different
proof procedures. A major result is the equivalence of the syntactic and semantic
notions of COnsequence that is embodied in the soundness and completeness
theorems (§S).
etation: Rather tban"writing "'implies" and "if and only if" in our definitions,
theorems, eec., we often use ::::}and ~ instead. These are not symbols of the
language of Propositional logic but of the language (or metalanguage) in which
we discuss Propositional logic.
'oposltion 3.10: ut E, Et, £2 be 4et" ojpropontioru. Let Cn(E) denote the 4et
of consequencu 0/ E Qnd Taut the 6et 0/ all tl1utologiu.
The last esseruon of Proposition 3.10 tells us that testing whether o is a conse-
quence of a finite set E of propositions (sometimes called "premises") can be done
in finitely many steps by checking (for example, by using truth tables) whether
the proposition on the right-h8l1d side of (vii) is a tautology, But what do we do
If E is infinite? We had better learn how to prove that u is a consequence, The
first method we consider is that of tableaux,
Exercises
L Prove that the propositions in Example 3.7 (i) are tautologies by checking
directly, using Corollary 3.4, that they are true under all valuations.
Hint:. ~ not ~":teo~t the truth tables. Argue directly from the truth
condItions for dISJunct10ns and conjunctions.
3 A rc 't' . I:.~
. P ~ Ion l~a """rW if it is a propositional letter or its negation. A
proJ)OSltion 0 IS in conjunctive normal form (CNF) if there are literals
01,1, ... , lIII,n, , 0~,1, "" 0:2,n1' "" 0",1, ... , 0:2,n~ such that 0: is
V
(01,1 VQI,2 ... VO'I,n,)A(Q2,1 V02,~ V ... VO~,n.)/\ ... /\ (Q.,,1 V ... VOk,n.)'
(al {AABAC)_D,
I
{bl (A A B) _ (C V D),
We describe a system for building proofs of propositions. The proofs are labeled
binary trees called tableaux. The labels on the trees are signed propositions,
that is, a proposition preceded by either a T or an F (which we can think of
as indicating an assumed truth value for the proposition). We call the labels
of the nodes the entries of the tableau. Formally, we define (or describe how to
build) tableaux for propositions inductively by first specifying certain (labeled
binary) trees as tableaux (the so-called atomic tableaux) and then giving a
development rule defining tableaux for compound propositions from tableaux
for simple propositions.
The plan of the procedure is to start with some entry, i.c., some signed propo-
sition such as F( .....
(A 1\ (B V CD), and analyze it into its components. We say
that an entry is correct if our assumption about the truth value of the given
proposition is correct. For our current example, F( .....
(A 1\ (B V C))), this would
mean that ..,(A 1\ (B V C» is false. The guiding principle for the analysis is that,
if an entry is correct, then (at least) one of the sets of entries into which we
analyze it contains only correct entries. In our sample case, we would analyze
FHA A (8 V C))) 6", into T(A A (8 V C)). (rh(A A (8 V C)) Is false, then
(A 1\ (B V C» is true.) We would then analyze T(A 1\ (B V C» into T A and
T(Bv C). (If (A 1\ (B V C» is true, then so are both A and (B V C).) Next we
would analyze T(B V C) into either TB or TC, (If (B V C) is true, then so is
one of B or C.)
}efinition 4.1 (Tableaux): A finite tableau is a binary tree, labeled with signed
Propositions called entries, that satisfies the following inductive definition:
,. 1b ,. n,
T{o-Ajj)
TA FA
I F{OIAP)
T.
I F.
/\ Fp
Tp
.. " •• <b
F(OI v P)
F(Q_f,l)
T(Q .... (1) F(Q .... fJ)
T(Q ~ (1) I /\ /\
/\ T. T. F. T. F.
F. Tp
PO
I
Tp
I I
Fp Fp
I
TP
I
FIGURE 9.
4 Tableau Proofs in Propositional Calculus 29
If TO,T1,"" Ttl,··· is a (finite or infinite) sequence of finite tableaux such that, for
each n ~ 0, 7tl+1 is constructed from Ttl by an application of (ii), then T ::::UTn
is a tableau.
This definition describes ell possible tableaux. In this section, we could get by
with finite tableaux (see Theorem 4.11) but 'WOuldnecessarily be driven to in-
finite ones in predicate logic and even in the next section where we consider
propositional logic with (infinitely many) premises.
Each tableau is a way of analyzing a proposition. The intent is that, if it is all
right to assume that all the signs on entries on a path down to some entry E
in a tableau are correct, then one of the paths of the tableau that continue on
through E to the next level of the tree is also correct.
To see that this intention is realized, it suffices to consider the atomic tableaux.
Consider, for example, (Sa). If a --+ fl is true, then so is one of the branches
through it: a is false or fJ is true. Similarly for (4a), if a V fl is true, then so is
one of Q or fl. The other atomic tableaux can be analyzed in the same way. This
intuition is developed formally in the next section as the soundness theorem for
tableaux. The other major theorem about tableaux is the completeness theorem.
It is connected with the idea that we can show that if 0 is valid, then all possible
analyses of a given signed proposition FQ lead to contradictions. This constitutes
a proof c. In order to do this, we have to develop a systematic method for
generating a tableau with a given root which includes all possible procedures.
First, however, some examples of tableaux.
~xample 4.2: We wish to begin a tableau with the signed proposition F(((a --+
fJ) V (,,/ V 6)) A (0 V fJ)). There is only one atomic tableau that has this entry as
its root - the appropriate instance of the atomic tableau of type (2b) given in
Figure 10.
F«('-P)V(7v,)j F(. V Pl
FIGURE 10.
Now this tableau has two entries other than its root either of which could be
chosen for use in the induction clause to build a bigger tableau. (We could
legally use the root entry again but that would not be very interesting.) The
two POSSibilities are given in Figure 11 A and B.
We could also do each of these steps in turn to get the tableau given in Figure
11 c.
30 I. Propositional Logic
""
(0) F(((<r .......0) v h v 6») ,,(O' v,O))
F(("
I
-Pl v h v 6))
I
F(Ot ..... Pl
I
Fhv6)
(,)
""
F(({o- _ (1) v b v 6» II (a v,O))
/ P(a V (J)
F(c.
I V /3)
I
F.
I
FP
(0)
""
F{((a ..... ,8) V h V 6)) 1\ (0 V .0))
F((o-p)V{-,V6)j
/ F(a v,O)
F((o-P)Vhv6))
I I
I
F( ....... .0)
F(o
I
V p)
F.
I
I
FIGURE 11.
4 'Thbleau Proofs in Propositional Calculus 31
In this last tableau we could (ignoring duplications) choose either F(o. --+ {3} or
F(..., V 6} as the entry to develop. F(..., V 6} is the end of the only path in the
tableau that contains either of these entries. Thus, in either case the appropriate
atomic tableau would be appended to that path. Choosing F(a --+ {3} would give
the tableau of Figure 12.
I
F(. V IJ)
I
F.
I
FIJ
FIGURE 12.
As the reader must have noticed, each time we select an entry it gets repeated at
the end of the chosen path as part of the atomic tableau that we affix to the end
of the path. As a notational convenience we often omit this second occurrence
when we draw tableaux although it remains part of the lonna! definition. (They
actually are needed when we consider the predicate calculus and so we included
them in our formal definition.)
We now wish to describe those tableaux that will constitute proem and a sys-
tematic procedure for generating them from given signed propositions. We need
a number of auxiliary notions:
(i) E has been reduced on P if all the entries on one path through the atomic
32 I. Propositional Logic
(ii) P is contradictory if, for some proposition 0, To. and Fa are both entries
on P. P is finished if it is contradictory or every entry on P is reduced on
P.
Example 4.4: Figure 13shows a finished tableau with three paths. The leftmost path
is contradictory; the other two are not.
We can now define tableau proofs of o as ones that show that the assumption
that Q is false always leads to a contradiction.
~A~ / "'"
~BV~A~
1/""
I
TA
TB T(C A D)
T('A) I
I TC
FA I
I TD
PIGURE 13.
4 'nt.bJeauProofs in Propositional Calculus 33
Example 4.6: Peirce's law. Figure 14 gives a tableau proof of an instance of Peirce's
law. Remember that we don't actually recopy the entries that we are reducing.
We put <81 at the end of a path to denote that it is contradictory.
F«(A - B) _ A) _ A)
I
T«A _ Bj _ A)
I
FA
~~
F(A _ B) TA
TA
I I
IFB
~
I
FIGURE 14.
In much of what follows, for every definition or theorem dealing with a tableau
proof or a logical truth (or both), there is a dual definition or theorem dealing
with a tableau refutation and a logical falsehood, respectively. It is left to the
reader to provide these dual propositions. ..
The next step in producing proofs is to see that there is a finished tableau starting
with any given signed proposition as root entry. We describe a simple systematic
procedure for producing such a tableau. Theorem 4.11 shows that the tableaux
produced by this procedure are always finite.
at its root. Assume that Tm has been defined. Let n be the smallest l~vel of T'd
containing an entry that is unreduced on some noncontradictory path m Tm an
let E be the leftmost such entry of level n. We now let Tm+l be the tableau
gotten by adjoining the unique atomic tableau with root E to the end of every
noncontradictory path of Tm on which E is unreduced. The union of the sequence
Tm is our desired complete systematic tableau.
Proof: Consider any entry E that OCcurs at some level 11 of the CST T an d rna res 0
noncontradictory path PinT. There are at most finitely many entries on T at
or above level n. Thus, all the entries at level n or above on T must be III
. p lace
by some point of the construction. That is, there is an mo such that for every
m ~ mo, Tm through level n is the same as T through level n. Now, for m ~ 17l(J,
the restriction of P to Tm is a path in Tm containing E. At each step m 2': 171\1
in the construction of the CST we reduce the entry on the lexicographically le~t
node labeled with an unreduced entry that is on some noncontradictory path m
the tableau Tm. U E is not already reduced on P by stage mo, we can proceed
for at most finitely many steps in this construction before E would become the
lexicographically least unreduced entry. At this point in the construction we
would reduce E. 0
Proof: T is a finitely branching tree. Consider the subset of all nodes of T with no
contradiction above them. If this.set is infinite, It has an infinite path by Konig's
lemma. As this contradicts the assumption that every path in T is contradictory,
there are only finitely many such nodes. They must all appear by some level 110 of
T. Thus, every node at level n + 1 of T has a contradiction above it. Once again,
as T throUgh level n + 1 is finite, there is an m such that ~ is the same as 1
through level n + 1. Now every path P in Tm is either a path in T (ending with
a l~ of level :5 n) or a path containing a node of level n + 1. In the first case,
~ 18 contr.adlCtory by our assUIIiption that T is contradictory. In the second, P
~~~~Ictory by our choice of n and m. Thus, T... Is the desired contradictory
In the next section, we consider the import of this argument for the semantic 85
well as syntactic versions of the compactness theorem.
We conclude this section with a proof that each CST is actually finite. The proof
involves an induction based on a measure of the complexity of propositions that
we call the degree of tI propositiotL
Proof: Let T = U'Tm be any CST as described in Definition 4.7. We prove that every
path on T is finite (indeed has length at most the degree of the root of T) and so,
by Konig's lemma., T itself is finite. Consider any path P on T. It is the union of
paths Pm on Tm. A change occurs between Pm and Pm+! when, according to the
Definition 4.7, we add the atomic tableau a with root E to the end of Pm for some
entry E that is unreduced on a path in 'Tm. We claim that d(Pm+1) < d(Pm}.
Of course, this immediately implies that we can add an atomic tableau to the
end of Pm at most finitely often (indeed at most d(a) many times where a is
the proposition at the root of'T). Thus, P is finite as desired. To verify the claim
first note that adding o to the end of our path reduces the entry E on P. This
subtracts d(E) from the degree of the path while adding on the degrees of the
signed propositions other than E occurring on the path of (T that is added on to
Pm to form Pm+l. Thus, it suffices to check that the sum of the degrees of the
signed formulas (excluding the root) on each path through any atomic tableau
a is less than the degree of the root of (T. This is immediate from the definition
of degree and the list of atomic tableaux in Figure 9. 0
Exercises
Give tableau proofs of each of the propositions listed in (1) - (9) below.
(a) (a V a) .....a
(h) (oAa)_o
36 I. PropositionalLogic
(e)(.AP)_ (PA.)
(d) (.VPl-(pv.).
(a) ((.APlA»_(.A(PA>})
(b) «(.vP)v»_(.v(pv>})
(e) (.V(PA>})_«.VP)A(.V>})
(d) (.A(PV>})-(aAPlV(aA»).
(a) Q ...... Q
(b) a-(P_a)
(e) (.-P)-((P-»-(a~>})
(d) (c _ (P _ >}) _ ((a _ P) _ (a _ >}).
5. De Morgan's Laws
6. Contrapositive
(.-P}-('~-'a).
7. Double Negation
01 ...... -'-0.
8. Contradiction
-'(0 A -.0-).
9. (a) (,"VPl_(._p)
(b) (o - P) _ (t-o v Pl.
4 Tableau Prool's in Propoeltlcnal CalCUIUB 31
Recall from Exercise 3.3 that a conjunctive normal form (CNF) for a proposition
a is a conjunct of disjuncts of literals (prop06ltional letters or their negations)
which is equivalent to a. Similarly, a disjunctive normal form (DNF) for 0 is a
disjunct of conjuncts of literals which is equivalent to a. For any proposition a,
we can find equivalent conjunctive and disjunctive normal forms by the following
procedure:
(i) Eliminate all uses of ......in the formation (tree) of a by replacing any step
going from f3 and l' to f3 ...... l' by one going to ({J 1') A b ......
{J). This
produces a proposition at equivalent to a in which does not occur.
(ii) Eliminate all uses of ..... in the formation of 01 by replacing any step going
to {J ..... l' by one going to -.{J V 'Y. This produces an Q:J equivalent to Q in
which the only connectives are -t, V and A.
(iv) Now use the associativity and distributivity laws above to get equivalents
of Q3 which are either conjuncts of disjuncts of literals (CNF) or disjuncts
of conjuncts of literals (DNF).
We provide an example of this procedure by finding both normal forms for the
-.c:
Proposition a = (A .....B) ......
(A _ B) _ -,0 (i)
(A _ B) _ -,Q) A (,C _ (A _ B)) (ii)
This last line is a DNF for Ct. It can. however, be simplified by using some of the
other rules proved above and simple truth table considerations. In particular I
contradictions such as C A ~ can be eliminated from disjuncts and tautologies
38 J. Propositional Logic
10. Use the procedure described above to find CNF and DNF equivalents for the
following propositions:
(a) (A - B) _ (A - C)
(b) (A - B) _ (e V D).
11. Use the laws provided in the above exercises to prove that each step of the
above procedure produces a proposition equivalent to the original propo-
sition a.
We are going to prove the equivalence of the semantic notion of validity (1=)
and the syntactic notion of provability (f-). Thus, we show that all tableau pro~· I
able propositions are valid (soundness of the proof method) and that all valid
propo!'litions are tableau provable (completeness of the method).
If V is a valuation that agrees with the root entry of a given tableau r given as
in Definition 4.1 8.8 Urn, then T bas a path P every entry of which agrees with
v.
Lemma 5.2: If V is 11 vlllulltion thIlt Ilgrees with th£ TOOt entTlf of 11 given tllblealJ
T given ~ in Definition 4·1 as Urn, then r has 11 path P every entry of which
ll,9fUs with V.
ove
Proof;. We pr. ~y indUction that there is a sequence (P,,) such that, for every fI, P..
15 contamed m P"+l and Pro is a path through rn such that V agrees with every
entry on p... The desired path P thrQugh r will then simply be the union of the
p... The base case of the induction is easily seen to be true by the eseumpuce
5 Soundness and Completeness or Tableau ProolS 39
that V agrees with the root of T. As an example, consider (6a) with root entry
J'(o - Pl. If V(a - P) ~ T. then either V(a) = T and V(P) ~ T cr V(a) ~ F
and V(fJ) = F by the truth table definition for .......We leave the verifications for
the other atomic tableaux as Exercise I.
For the induction step, suppose that we have constructed a path p.. in Tn every
entry of which agrees with V. If Tn+l is gotten from Tn without extending Pn,
then we let Pn+l = p... If Pn is extended in T.. +1J then it is extended by adding
on to its end an atomic tableau with root E for some entry E appearing on Pn.
As we know by induction that V agrees with E, the same analysis as used in the
base case shows that V agrees with one of the extensions of Pn to a path Pn+1
in Tn+l. 0
The crucial idea in the proof of the completeness theorem is embodied in Lemma
5.4: We can always define a valuation that agrees with all entries on any non-
contradictory path of any finished tableau.
(li) Suppose T(a 1\ fJ) occurs on the noncontradictory path P. Since T is a fin-
ished tableau, both T(a) and T{P) occur on P. By the induction hypothesis
Via) ~ T ~ ViP) and eo V(a AP) ~ T es required.
(iii) Suppose F(al\{3) occurs on the noncontradictory path P. Again by the def-
inition of a finished tableau, either Fa or FfJ must occur on P. Whichever
it is, the induction hypothesis tells us that it agrees with V and so either
V(a) = F or V(P) = F. In either case V(a 1\ fJ) = F as required.
The remaining connectives are treated like one of these two cases depending on
whether or not the corresponding atomic tableau branches. The deta.ils are left
as EJr:ercise 2. 0
40 I. Propositional Logic
Proof (of Theorem 5.3): Suppose that (J is valid and so V(o) = T for every valuation V,
Consider any finished tableau T with root Fa. (The CST with root Fa is one by
Theorem 4.8.) If T had a noncontradictory path P, there would be, by Lemma
5.2, a valuation V that agrees with all its entries and so in particular with Fa.
This would give us a valuation with V(o:) = F contradicting the validity of a,
Thus, every path on T is contradictory and T is a tableau proof of a. 0
It is clear from the proof of the completeness theorem (in fact from Lemma 5.4)
that if you try to construct a tableau proof for 0: {i.e., one starting with Fa)
and you do your best by constructing a finished tableau with root Fa but fail to
produce a proof of Q [i.e., the finished tableau has at least one noncontradictory
path), then the valuation defined by this noncontradictory path as in Lemma
5.4 gives us a counterexample to the assertion that 0: is valid. As we can always
produce a finished tableau with any given root, we must, for every proposition,
be able to get either a tableau proof or a counterexample to its validity!
It is this dichotomy (albeit expressed at the level of more complicated fragments
of predicate logic) that forms the basis for constructive solutions to many prob-
lems. It is also the underlying rationale of PROLOGand of the implementation of
other constructive theorem provers as programming languages. One starts witb
~ assumption such as "there is no x such that P(x)" and one either proves
It true or finds a counterexample, that is, one actually produces an :r such that
P(x). We consider these matters in II.S and, in more detail, in Chapter III.
Exercises
Refor~ulate and ~rove the analogs of the results or this section for tableau
refutatlOns and satlSfiability:
3. IfhQis ~leau ~futable, i.e., there is a contradictory tableau with root Ta,
t en Q 18 unsl1ti.!J;:able I ,L_ •. T
~. ,.e., nere IS no valuatlOn V such that V(a):::: .
4. If Q is unsatisfiable, then there is a tableau refutation of 0:.
6
Deductions from Premises and Compactness
Recall the treatment at the end f §3
(which we called pre~) A 0 ro of~~econsequencesorasetEofpropositiO~
every valuation that is a ~et ~t1on (1 is a consequence of E (I: 1= a)if
of E IS also one of a, i.e., every valuation that
6 Deductiona from Premises and Compactness 41
makes all the elements of E true also makes o true. (See Definitions 3.2 and 3.8.)
This notion of consequence and the associated one of a proof from given premises
(which we are about to define) reflect common usage in mathematical arguments.
A theorem is typically stated as an implication of'the form a --+ p. The proof of
the theorem, however, is generally presented in a format that begins by assuming
that the hypotheses (0) are true and then argues that the conclusion (jJ) must be
true. Viewed syntactically in terms of proofs, we might describe this procedure
as "assuming" a and then "deducing" fl. The semantic notion of consequence
captures the first view of such an argument. We now want to capture the syntactic
or proof-theoretic version by defining what it means to prove a proposition from
a set of premises. Once we have developed the appropriate notions, a formal
version of the informal mathematical method of argument described above is
(easily) provided by the deduction theorem (Exercise 6). We now turn to the
abstract formulation of the notions needed to express this result.
We begin our analysis with the definition of tableaux with premises from a set of
sentences. It differs from the basic definition only in that we are allowed to add
on entries of the form To for premises a. This variation reflects the intuition
that working from a set of premises means that we are assuming them to be
true.
Definition 6.1 (Tableaux from premises): Let E be a (possibly infinite) set of propo-
sitions. We define the finite tableau:t' with premisu from E (or just from E for
short) by induction:
Oeo.nltion 6.2: A tableau proof of a propo.!ition 0 from E (or with premisu from E) Is
a tableau from E with root entry Fo that is contradictory', that is, one in which
every path Is contradictory. If there is such a proof we say that 0 iJ provable
fmm I: and write it as E r o.
42 I. Propollitional Logic
Examp 1e 6 .•3· .." .... 15 gives a tableau proof of A from a set consisting
Ft-0-- of two
prem tsee , {~B, (A VBn.
FA
I
T(~B)
I
T(A V B)
/
TA """ TB
I
o
I
FB
I
FIGURE 15.
Similarly we must take steps in the construction of the CST from E to guaran;
the appearance of these premises. We list the elements of E as am, m E J!.'
of
revise the definition of the CSTby aitnply adding on one step to the defimtlo~ u
'm+!. If our new construction has produced T... we let T + be the next tab ~
m 1
that would be defined by the standard CST procedure. (If that procedure wo nt
now terminate because every path is contradictory, we also terminate the curre th
construction.) We now add on Tam to the end of every noncontradictory pa
in T:n+l that does not already contain To to form OUf new 7"",+1,
Theorem 6.4: Every CST from a set 0/ premise" is finished.
Proof: Exercise 1.
a
The proofs of the soundness and completeness theorems can now be carried ()Ill
as before with the caveat that we must alwa.ys see to it tha.t the propositiolJS
6 Deducucne fr(lffi Premises and Compactness 43
in E are true in the relevant valuations. We state the appropriate lemmas and
theorems and leave most of their proofs in this setting as exercises.
Lemma 6.51 If a valuation V make" every Q E E true and agrees with the root of a
tableau 'T from E, then there it a path in 'T every entry of which agrees with V.
Proof: Exercise 2. o
Proof: If not, there is e. valuation that makes /3 true for every {3 E E but makes 0
false. Continue now as in the proof of Theorem 5.1. 0
Lemma 6.7: Let p be a noncontrodictory path in a finished tableau 'T from E. Define
a valuation V as in Lemma 5.4. V then 4fPUS with all entries on P and so in
particular makes every proposition fJ E E true (as TfJ must appear on P for
every /3 E E by chfinition oj a finished tableau from E ).
Proof: Exercise 3. o
Proof: If E F 0, every valuation V that makes every proposition in E true also makes
a true. Consider the CST from E with root Fa. It is finished by Theorem 6.4.
Now apply Lemma 6.7. 0
Theorem 6.9: If T = UTn is a contnulictory tableau from E, then, Jor some m, Ton it
a finite controdictory tableau from .E. In ptJrticular, if a CST from E i.! a p'TJOJ,
it i.! finite.
Proof: Exercise 4. o
Thus, we know that if 0 is provable from E, then there is a finite tableau proof of
it. This can be viewed as a syntactic version of the compactness theorem. Using
the completeness and soundness theorems it can be converted into a semantic
one.
44 I. PropOflitionaiLogic
Proof: Exercise 5. o
We have left the indirect proof, via completeness and soundness, of the semantic
version of the compactness theorem as an exercise. However, a direct proof of
this result is also available. The compactness theorem is genuinely deeper than
the others we have proven and deserves two proofs. An advantage of the direct
approach is that the completeness theorem can be proved from the compactness
theorem and without recourse to infinite tableaux. The direct approach also
shows that compactness is simply a consequence of Konig's lemma.
Example 6.12:
(i) {All A2, (AI A A2), A3, (AI/\ A3), A4, (AI/\ A,,), ... } is a satisfiable
infinite set of propositions.
(ii) {AI, A2, (AI ..... A3), (-,A3)} is a finite set of propositions that is not
satisfiable nor is any set containing it.
I
Theorem. 6.13. (Compactness): Let E = {0.1 i E w} be an infinde IIat of propo"itiOnll.
t Lt IIati!fiable if and only if ellery finite subset I' of E is IIatisfiable.
Proof: Note that the "only if" direction of the theorem is trivially true; the other
direction is not (not trivially that is). The problem is that finding different
valuation.s which satisfy longer and longer initial segments does not necessarily
mean that there is a single valuation satisfying the whole sequence. Building
such a valuation is essentially an application of Konig's lemma.
Let (eil i E w) be a list of all the Propositional letters. We define a tree T whose
nodes are binary sequences ordered by extension. We use tth(u) to denote the
~ength of a sequence a and set T = [e] there is a valuation V such that, for
1 $ lth(I1), V(Qj) = T and V(C,) = T iff l1(i) = I}. What this definition says is
that we put ".o.n the tree unless interpreting it as an assignment of truth values
to the proPOSItional letters C. (i :5 lth(l1)) already forces one of the Q' to be •
false for i ~lth(I1). •
The connection between this version of the compactness theorem for proposi-
tionallogic and the compactness theorem of topology is considered in Exercises
9 and 10. Other applications of the compactness theorem can be found in Exer-
cises 7 and 8.
~Xercises
(a) E"o.
(b) "/lE~o.
(o)El-o.
(d) I-/IE-o.
46 I. Propositional Logic
Appllc::atioD8 of Compac::tness
For Problems 7 and 8, use the compactness theorem for propositional logi~or
Konig's lemma. The key point in each case is to faithfully translate the given
problem into an appropriate set of propositions (or an appropriate tree). One
then applies compactness or Konig's lemma, Finally, one must translate the
result of this application back into the terms of the problem. These problems are
treated in predicate logic in Exercises 11.7.5.
8. A graph G is a set of elements {no, a}, ... } called nodes and a. set of pa.iIs
of nodes {(I.;, Qj} called edges. We say that G is n-colomble jf we can label
its nodes with n colors CI, •.• , en so that no two nodes in a single edge of
G have the same color. Suppose every finite subgraph of G (a finite subset
?f the nodes and the edges between them) is four-colorable. Prove that G
IS four--colorable.
Conn t' .h
ee IOns Wit topological compactness and Konig's lemma
~~e :r:;c~~e;.
the Open ts be
~rem fo~ propositional lOgic can be connected to the to~I'
all POSSibletruth valuations that is determined by letting
set I; of p:posi~:~rated by tboae of the form {V: (30 E E) (V ~ o)} for anY
7 An Axiomatic Approach- 47
10. Deduce the nontrivial direction of the semantic version of the compact-
ness theorem (6.13). Hint: Prove the contrapositive from the open cover
property.
See also Exercises 1.10 and 1.11 for other connections between Konig's lemma
and topological compactness.
12. Suppose E is a finite set of propositions. Show that every CST from E is
finite.
7 An Axiomatic Approach"
Propositional calculus (as well as other mathematkal systems) are often rormu-
lated as a collection ofaxionu and ndu of in/erenu. The axioms of propositional
logic are certain valid propositions. A rule of Inference, R, in general. "Infers" a
proposition Q from certain n-tuples al •...• a" of propositions in a way that is
expected to preserve validity. Thus. for R to be an acceptable rule ef Inference,
it must be true that. if one can use R to jnCer a from the valid propositions
or, .. '. an. then a must be valid as well.
We now give a brief description o( one such classical formulation based on the
adequate set o( connectives {..." -t}. (For simplicity we view the other connee-
tives as defined from..., and ......This cOJUllderablyreduces the number o( axioms
needed.]
7'.1 Axiom5: The axioms of our system are aU proposittons of the (ollowing
(orms:
(;) (0 _ (p _ 0»
(il) ((0 _ (p _ ,)) _ «(0 _ p) _ (0 _ ,)))
S stems beeed on axioms and rules in the style of the one pre5een~::.~~y ~~
~nerally ca.lled Hilbert-style proof systems. We therefore denot p
this ')'IItem by ~ H.
(i) A proof from E is a finite sequence 01,02, ... , o n such that for each i :5 n
either:
(I) 0, is a member of Ej
(2) OJ is an axiom;
or
Example 7.4: p
Here is a proof o((( .... ---0 0) ---0 P) from E = [e-o]:
from E
(~- ('P - '.») axiom (i)
(,p-~) modus ponena
({'P -~) - ({,P _.) - P» axiom (iv)
('P -.) - P) modus ponens.
We should note here, as we did for tableau deductions, that, although the set of
premises E may be infinite, if 0 is provable from E, then Q is provable from a
finite subeet. of E. Proo& life always finite!
We omit the proofs of soundness and completeness for this particular system
(they can be found in Mendelson [1979, 3.2J but in the next section we consider
another rule-based syatem and Ill1Pply the prcofa of such results. For now, 'We
simply state the theorems for the system presented here.
Theorem T.3 (Soundnesl:l and completeness from premises): Q U protlab~ from a $e!
o/~ E I/and onll/ i/ Q Ua comequrnce of E, i.e., E I- Q *lo E F cr.
H
8 Rescjutlon 49
Remarks 7.7:
(i) On modus ptmens: If Q has a tableau proof and Q ..... {3 has a tableau proof,
then Q and Q ..... {3 are both valid by the soundness theorem. As modus ponens
preserves validity, {3 is also valid. Thus, by the completeness theorem for tableau
proofs, {3 has a tableau proof. There is actually an algorithm for getting a tableau
proof for fJ from such proofs for a and a .....{3. This is known as the Gentzen
Hauptsatz (principle theorem) and is too long to prove here. Modus ponena is also
called the cut rule and this theorem is therefore referred to as a cut elimination
theorem.
(ii) On theorem.t: A theorem is any proposition that is provable. So any proposi-
tion that occurs as an element in a proof is a theorem. We usually think of the
conclwion as being the last element of a proof but, any initial segment of a proof
is also a proof.
(iii) Choice of o.:r;iom.t:The corollary says that the axioms are complete in the
sense that we can prove any valid proposition from them by repeated applications
of modus ponens. On the other hand, since the axioms are valid and modus pcnens
preserves validity, every theorem (i.e., every proposition provable in this system)
has a tableau proof. Thus, tableau proofs are sufficient and so are the axioms and
rules of inference listed above. One could have more axioms (or fewer) or more
(or other) rules of inference or both. Scmenmee it is a matter of taste, other
times a matter of expediency (e.g., what makes various proofs easier). The key
point is that whatever the proof system, there is really only one set of theorems,
the valid propositions.
(iv) EfficienclI: Proving theorems efficiently from such a system of axioms and
rules may be somewhat tricky since you often have to guess which axiom to use
rather than having a systematic procedure as is the case for the tableaux. The
source of tmll problem is having a plethora of axiom II from which to choose. The
Hilbert-style proof system presented here has many axioms and few rules. Other
systems that reverse the emphasis are Gentzen lIystems and natural deduction
systems. These are much more relevant to automatic theorem proving and, in
their intuitionistic or constructivist forms, to producing systems that have the
property of always being able to produce a proof or counterexample for any given
proposition (as discussed at the end of §5).
I Resolution
The proof method underlying PROLOG and most automatic theorem provers is
a particularly simple and efficient system of axioms and rules called 1Uolution.
Like the system presented in §7, resolution has only one rule. It reduces the large
amount of the guesswork involved in producing a proof by essentially eliminating
all axioms. {Actually it incorporates them automatically via various formatting
rules but as far as the work of producing the proof is concerned, this almost
50 I. Propos.itionalLogic
amounts to their elimination.) The resolution method, like our version of the
tableau method, ill a refutation procedure. That is, it tries to show that the
given formula is unsatisfiable. It begins by assuming that the formula of interest
is in conjunctive normal form (see Exercises 3.3 and 4.10-11). In typical computer
science treatments this fonn is called clawal form and the associated terminology
is as follows:
Definition 8.1:
(il) A clawe C is a finite set of literals (which you should think of as the
disjunction of its elements). As we think of C as being true iff one of
its elements is true, the empty clawe 0 is always false ~ it has no true
element.
(iii) A formula S is a (not necessarily finite) set of clauses (which you should
think of as the conjunction of its elements). Ai> we think of a formula S
as being true if every one of its elements is true, the empty fonnula 0 is
always true - it has no false element.
(v) .A ilatUjie., S, A ~ s,
iffVC E S(C n A # 0), i.e., the valuation induced by
A makes every clause in S true.
(vi) ~ formula S i3 (un)satisfiahle ifthere is an (no) assignment A that satisfie'l
it,
Examples 8.2:
·PROLOGNotation:
Another way of thinking of clausal or conjunctive normal form ill in terms of im-
plications. SUPP05e we have a cleuee C whose pontive li~ral$ (the propositional
letters contained in 0) are AI, ... , Am and whose negative litera~(the propoai-
tionalletters p eueh that p (i.e., (-.p)) is an element of 0) are B1, •.• , Bn• The
clause 0 ill then equivalent to AI V A2 V ... V A v..,81 V ... V ..,Bn• This in
tum is equivalent to BI " B2 ••• "Bn --0 Al V V Am. U there ill at most one
positive literal [i.e., at most one A.) in 0, then 0 is called a Horn clawe (or a
program clawe if it has exactly one positive literal). If the Hom clause contains
some negative literals it is a role, otherwise a fact. A goal claWt is one with no
positive literals. It is the logic and proof theory ofthese c1aUBeS (which we analyze
in Section 10) that is the heart oE PROLOG. (PROLOG is, however, not limited to
propositional letters. It also allows for variables in its literals. We elaborate on
this when we deal with predicate logic in Chapter II.)
The standard notations in PROLOG reverse the order used in --0 and instead use
either _ or :~ which are read "if". Occurrences of the "symbol are replaced by
commas. Thus, At :- BI,~ •... , Bn or AI +- BI, ... , Bn is read (and means)
Al if (BI and B2 and ... and Bn). In terms of generating deductions or writing
programs one thinks of the assertion of a clause 0 such BB AI :- 81, ••• , Bn,
as specifying conditions under which AI is true. We are usually Interested in
I'$tablishing BODIe result. Thus, AI is called the goal of the clause 0 (or at umee
the head of 0) and Bt, ...• B« the subgoals (or body and with this terminology
the symbol" :- .. is called the nul) of O. The idea is that 0 telIa us that to
establish A we should first erItablish each of B1, ••• ,Bn• Along with the goal -
subgoal terminology, come the terms succeed and fail. One says a goal A succeeds
if it is true, or more preciBely from the programming point of view. if we have
a proof of A. Otherwise we aay the goal fails. Be warned, however, that this
terminology of success and failure.is (at I_t for now) somewhat imprecise.
It is worth noting what these views imply for the meaning of the degenerate cases
of the notation :_ ,i.e., when n = 0 or m = O. If m = 0, then :- BI, ... , B..
(or +- BI, ... , Bn). called a goal claw!!', is t:quivalent to ....BI V ••• V ....8.., i.e., it
asserts that one of the Bi fails (ill false).lfn = 0, then AI:- (or Al _), caI1ed
a unit daWt, is equivalent to simply AI; thus this notation simply say.a that AI
succeeds (is true).
The resolution rule is much like a version of modus pcnens called cut. Modus
pcnens (see §1) says that from a and a _ fJ one can infer /3. In this format, the
cut rule says that from a V.., and --.a V fJ infer .., V [3. Thus, cut is somewhat
more general than modus ponens in that it allows one to carry along the extra
proposition ..,. Resolution is & restricted version of cut in which a must be a
literal while fJ and "y must be clauses.
le6nition 8.3 (Resolution): In our current terminology. we say that, from clauses
eland 02 ofthe form {t} u c;:
and {l}u C&, infer 0 = c;:
u 0& which is called
a feSoll1ent of 01 and O2, (Here t is any literal and U means that we are taking
a union of disjoint eeee.) We may also cell 01 and 02 the parent and 0 their
child and say that we rt.folved on (the literal) t.
�2 I. Propcsitional Logic
(Note that, compared to the classical form of the cut rule, the ~Iution rule
abo eliminates redundancies, l.e., letters common to Ct and C2. This takes the
place of certain axioms in 11 classical proof system such as the Hilbert-style one
of §7.)
Resolution is, of course, 11 sound rule, that is, it preserves satisfiability for evel)'
truth assignment. If some assignment satisfies both Ct and ell, whatever it does
for I, the literal on which one resolves, it must satisfy one of C: or q and
hence the resolvent qU~ . (This argument is formalized in Lemma 8.12.) The
resolution rule can thus be used as the basis of a sound proof procedure.
(i) From {P, r} and i-s , -rr} conclude {p, __q} by resolution (on r).
(ti) From {P, q, __r, s] and (__p, q, r , t] we could ooncludeeither{q, --.r, s,
r, t} or {p, q, s , --p, t} by resolution (on p or r), respectively. Of course,
both of these c:Iauses are valid and are equivalent to the empty formula.
Definition 8.6: A re.!olution tree proof of C from S is a labeled binary tree T with
the following Properties:
FIGURE 16.
Lemma 8.8: C has a reBolution tree proof from S if and only if there is a resolution
deduction of e from S.
Proof: (=» List all the labels of the nodes (T of the tree proof of e
from.s in any
order that reverses the < ordering of the tree (so leaves are listed first and the
root last). This sequence can be seen to be a resolution deduction of e
from S
by simply checking the definitions.
(<=) We proceed by induction on the length of the resolution deduction of e
from S. Suppose we can get tree proofs for any deduction of length < n and
C1, •••,en is one of length n from S. If Cn E S, there is nothing to prove. If not,
then Cn is the resolvent of Ci and Cj for some i and j less than n. By induction,
we have tree proofs T. and Tj of C. and CJ. Let Tn be the tree whose root is
labeled e and to whose Immediate successors we attach T, and Tj• Again, by
definition, this is the desired tree proof. 0
Definition 8.9: R(S) is the closure of Sunder reBolution, Le., the set determined by
the following inductive definition:
1. If C E S, C E 'R(S).
The first observation to be made is that no matter how the resolution method
is described, It gives a sound proof procedure.
We first prove a lemma which is needed for the inductive step in the proof of the
~rem. I
Lemma 8.12: If the formula (i.e., set of clawes) 5 = {C1, C2} is satisfi~ble and ~
is a ~"olvent 0/ 01 and O2, then C i3 sati3fiable. Indeed, any asSIgnment
JotUfJliny S satiJ}ies C.
Proof: A$ C is a resolvent ofCI and C2, there are t, Cl and C2 such that CI = {l}~0'
C2 = {il u q and C = Cl u C~.As A satisfies {CI, C2}, it sa.tisfi~ (that 1S,~
contains an element of) each of CI and C'l' As A is an 8SSignmen~, It cannot C!,
the case that both I E A and lEA. Say 1'1. A. As A F C'l an~ l fI- A, AF 0
and so A Fe. The proof for I 'I- A just replaces C'l by Cl and l by t.
1
Proof (of Theorem 8.11): If CI, ... ,C.. is a resolution deduction from 5, then the
lemmashows by induction (on n) that any assignment satisfying S satisfies every
0•. If the deduction is in fact a refutation of S, then en
= D. As no 8S5ignme~
can satisfy 0, S is unsatisfiable. F
Remark 8.13: The soundness theorem and its proof could just as well have ~n
phrased direetly in terms of Definitions 8,6 or 8.9. We leave these formulations
85 Exercises 2 and 3.
Our next major goal is to prove that the resolution method is complete, i.e., if S is
unsatisfiable, then there is a resolution refutation of S. We then want to consider
ways of Implementing a search for a refutation of S. We first consider using the
resolution method as originally presented. We then introduce more and more
restricUve versions of resolution which are designed to make the search more
efficient without rendering the method either unsound or incomplete. Following
this line of development, we first present a simple direct proof of the completeness
of the general form of resolution given in Definition 8.3. This proof, however,
relies on the (semantic form of the) compactness theorem. We then introduce
~d analyze a somewhat abstract description of umatisfiability. It supplies us
With a proof of the completeness theorem for resolution deduction that does not
rely on the compactness theorem and a new proof of the compactness theorem.
That. proof of .completeness is the paradigm for the completeness proofs of the
restncted version of resolution presented in §9.
8 Resolution 55
We begin our first path to completeness with a lemma that allows us to eliminate
literals in clauses which are resolution deducible from an unsatisfiable formula
S. Repeated applications of the lemma show that 0, the clause with no literals,
is deducible from S,
.emma 8.14: For any formula T and any literali, let T(i} = {C E :R.(T}I i, I fI. C}.
If T is unsatisfiable, then &0 is T(l}.
)roof: Assume T is unsatisfiable and suppose, for the sake of a contradiction, that
A is any assignment that satisfies T(l} and is defined on all the literals (of T)
other than t. Let At = =
Au {l} and A:z A u {i}. Ai;, T is unsatisfiable, there
are clauses Ct and C:z in T such that Al JI! CI and A:z JI! C:z. Now as lEAl and
At JI! CI, l fI. Ot. If I is also not in CI, then 01 E T(l} by definition. Ai;, this
would contradict our assumption that A 1= T(l}, IE Ot. Similarly, l E O:z. Thus,
we may resolve 01 and C:z on l to get a clause D not containing l and hence in
T(l). (As a resolvent of two clauses in T, D is certainly in :R.(T». Then, by our
choice of A, A 1= D. If .A satisfies the resolvent D, however, it must satisfy one
of the parents 01 or 02. Thus, we have the desired contradiction. 0
'roof: By the compactness theorem (Theorem 6.13), there is a finite subset 8' of 8
that is unsatisfieble. As any refutation deduction from 8' is one from 8, we may
assume that 8 is finite, i.e., it contains only finitely many clauses. If there are
only finitely many clauses in S and each clause is finite, there are only finitely
many literals, say l1,l2,'" ,l .. which are in any c:lause in S. For the rest of the
proof we consider only clauses and formulas based on these n literals.
We wish to consider the set of clauses 0 E :R.(5) and prove that it contains 0. We
proceed by eliminating each literal in turn by applying Lemma 8.14. We begin
with S.. = 8(l ..) = {C e 'R.(S)ll .. .i; ¢ O}. By definition, it is a collecuca of
resolution consequences of 5 none of which contain l,. or l... By Lemma 8.14 it
is unsatis6able. Next we let 8 .. _1 = 5..(l.._I). It is an unsatisfiable collection of
resolution consequences of 8 .. (and hence of S) none of which contain l .. _I, 1.._1.
l..or l...ContinuIng in this way we define 8"_2,' .. ,80• By repeated applications
of the definitions and Lemma 8.14, we see that 80 is an unsatisfiable set of
resolution consequences of 5 containing no literals at all. Ai;, the only formulas
with no literals are 0 and {D} and 0 is satisfiable, 0 E 50. Thus, 0 is a resolution
consequence of 5 as required. 0
We now turn to a more abstract formulation of the notions and lemmas inherent
in the proof of the completeness of resolution deduction. They are needed to deal
with the refinements of resolution in §9 and §10.
56 I. PropaaitionaJ Logic
!f l is false, then l is true and the same analysis applies to 51. As one of I s.n~
l must be true, we can argue (as we do in Lemma 8.19) that $ is satisfiable If
and only if one of st and 51 is satis6able. Thus, we can reduce the satisfiability
problem for 5 to two similar problems for formulas Sl and Sl with one less
propositional letter. We can then continue this procedure by considering each of
the two new formulllS st and sf. In this way, we could produce a binary tree of
formulllS in which we would successively eliminate one literal at each level of the
tree. E~ ~h through this tree corresponds to an assignment. The branch
through S 1lI the one that tnakes l true. The one through l is the one that
makEs 1false. If every path through the tree ends with a formula containing the
empty clause 0, we can conclude that the original formula S was uusatlsfiable.
On the other hand, if Dot all patl1lllead to 0, then, if we successively eliminate
all the literals appearing in $, either there is an infinite path along which we
have ~inated ~ry li~eral or at least one path ends with the empty formula
0. In el~her case S ~ satisfiable. Indeed, the appropriate path (infinite or leading
to it) directly supplies an assignment satisfying S.
8 Resolution 57
Seen in this way, the plan of the analysis is similar to that of tableau proem
beginning with Fa for some proposition a. There too, we attempted to analyze
all ways of making a false, i.e., of verifying Fa. If they all lead to contradictions
(18), we conclude that Fa is unsatisfiable and 0 is valid. Here, if all paths lead
to a formula containing the unsatisfiable clause 0, we conclude that the formula
S is unsatisfiable. On the other hand, if the tableau analysis was finished and
produced a noncontradictory path, we could use that path (Lemma 5.4) to define
a valuation satisfying a. In the analysis here, when we eliminate all the literals
(corresponding to finishing the tableau) and are left witb an infinite path or one
ending with the empty formula 0, this path itself directly supplies the assignment
satisfying S.
We illustrate the construction of Sl from S and the general form of this analysis
by considering two examples.
~mple 8.11: Let S == {{P}, {-.q}, {-.p,...,q}}. The analysis in which we eliminate
first p and then q can be represented by the tree in Figure 17:
13" = {O}
FIGURE 17.
Assuming p is true, we eliminate the clause {P} from S and the literal-.p from the
clause {""p, -.q} to get sP on the left side of the first level of the tree. Assuming
that p is false;
the right side (Si') reduces to {D, {-.q}} since S asserts that p is
true by haYing {p} as one of its clauses. At the next level, we consider q. On the
left, when q is assumed true, we again get 0 as $P asserts that -.q is true. On
the right, where we assume that q is false, we eliminate all clauses containing
""q to get the empty formula. Thus, we have a path ending in 0. It supplies the
esslgnment satisfying S: Make p true and q false.
FIGURE 18.
The path of the analysis through $fill terminates at this point since ~t eon-
tains 0 and so is unsatisfiable. The other paths displayed, however, continue- If
continued, every path would eventually terminate with an unsatisfiable formula
containing 0 as a clause. This is the analog of the proof that 5 I-n O. We leave
the completion of this analysis as Exercise 4.
We now formulate and prove the results that say that the analysis discussed
above correctly captures the notion of satisfiability.
Lemma 8.19: S i.!J 3awfiable if and only if either S' or 51 is satisfiable. (Warning:
In the "if" direction the assignments are not necessarily the seme.)
Proof: (=?) Suppose that A F S.U A were a complete assignment, we could conclude
that it must make one of l, 1true, say i. We could then show that A l= st. Ifwe
do not wish to make this assumption on A, we instead start with the fact that,
by definition, one of l or 1 does not belong to A. For the sake of definitenESS
assume that 1 ¢ A. We DOW also claim that A F st. We must show that ).
satis:6.~ every clause in s, Consider My C E st. By the definition of 51, eithet
C U {l} e S or C e S (depending on whether or not l is in the clause of 5
which "puts" C into st). Thus, by hypothesis, A ): C or A t= C u {l}. As &II
assignment satisfies a clause only if it contains one of its literals, there is a literal
It such that either k E Cn A or k e (CU {l})nA. As l f1. A by our assumptioll,
in either case we must have k e C n A, l.e., A t= C as required. The case that
l f1. .A is handled similarly.
('¢::) Suppose for definiteness that A t= S'. Now neither l nor l appear in anY
clause of Sl and so we may adjust A on l as we choose without disturbing the
satisfiability of s'. More precisely, if we let A' = (A ~ it}) U {l}, then A' F s'
ss well. We claim that A' Fe S. Consider any C E S. If lee then A' t= C as
~ e A'. If t 't G th~n C - {t} E Sl by definition of st. As A Fe 'st, there is some
llterel It E (C - (l}) n.A. Now A and A' differ at most at 1 and t. As k '" l OT
l, we see that k e A' n C as required. [J
and
Proof: As 0 is unsatisfiable, UNSAT satisfies [i). By Corollary 8.20 it also satisfies [Il].
Thus, U \:; UNSAT. We must show that UNSAT \:; U. We prove the contrapositive
by showing that if S ¢. U, then S is satisfiable. Let {Pi} list the propositional
letters such that Pi or Pi occurs in a clause of S. Define by induction the sequence
{li} such that li = Pi or Pi and Sll,...,t, ¢. U. (Property (ii) guarantees that we
can always find such an ld Now let A = {lil i E JI}. We claim that A satisfies
S. Suppose C E 5. We must show that en A # 0. As C is finite, there is an
n such that for all propositionallettefS Pi occurring in C, i < n, If C n A = 0,
then Vi < n (li ¢ C) and so a clause corresponding to C is passed on to each
st" ....e, for i < n. At each such transfer,. say to 51\,....e, we remove Ii from the
clause. As all literals in C are among the Ii, the clause deriving from C becomes
Din st......e... By our choice of the ii' Stl,...,t.. ¢. U. On the other hand, any S
containing 0 is in U by Clause {l] and we have our desired contradiction. 0
This result is the analog of Lemma. 5.4. The choice of the sequence li corresponds
to the definition of the assignment in Lemma 5.4 from the signed propositional
letters appearing on the noncontradictory path on the finished tableau. As there,
we are building an assignment that satisfies every entry on the path being con-
structed. Since we eventually reach the unsatisfiable clause 0 in this construction,
we have the desired contradiction. As for tableau proofs, this characterization
of unsatisfiabillty is really the heart of the completeness proof of the resolution
method.
that is above a leaf labeled with a clause not in S to C U {l}. We claim that
~ Is a tree proof of {l} from S. Clearly, by the definition of st, every leaf of
~ is in S. We must now check that every nonlear node of T~ is labeled with a
resolvent C' of its immediate successors q and er.
Suppose they correspond to
clauses C, CO and CI, respectively, on To. As To is a resolution tree proof, C is a
resolvent of Co and CI• Note first that no resolution in To is on l or l as neither
appear in any label on To (by the definition of st). Next, consider the possible
forroso! clauses Co, q and C' on 10. If, for example, both Co and C1 (and hence
certainly C) are above leaves labeled with clauses not in 5, then C' = C U {l}
is the resolvent ofq = Cou{l} and C; = C1 U{l}, as is required forT~to be
a resolution tree proof. The other cases to consider either keep all three clauses
the same in 10 as they were in To or change C and precisely one of Co and C1
by adding on {l}. In all these cases C' is still clearly the resolvent of C~ and c:
and we again verify that 'I6 is a tree proof. Similarly, if we replace every label
C on a node of T1 above a leaf labeled with a clause not in S by C U { t },we
get r:, a tree proof of {I} from S (or, if ell leaves were in S, one of 0). We
can now define a tree proof T of 0 from S by simply attaching 70 and T{ to the
immediate successors of the root node of T which we label with O. As 0 is a
resolvent of {l} and {i}, the resulting tree T is a proof of 0 from S. 0
·Compactness revisited
Proof; T Let
aatisfi {SI3Sd1 (")
T ~ (') ~ SISt is finite 1\ SI ts UlISatisfiabl.jl ~a" show that
, If we ~.
·'1 ~ t an formulllll.
... uliSahsfiable U of Theorem 8.21. then we are done for it will then contain
~ ~:PPQle~'~
- IIlI teqUh .....
~ercises
6. Which of the following clause sets are satisfiable? Give assignments satis-
fying them if they are. If they are not, explain why not.
10. Use resolution to show that each of the following is not satisfiable by any
assignment.
62 I. Propositional Logic
12. Do the same for the Proposition {3 = (--.r V (p 1\ q)) ...... ((r --+ p) 1\ (r ......q)).
13. Provt! that if S I-'R, C, then S 1= C.
(i) {O)ET D
(il) Sl,SIET~SET.
Prove that for every finite S E UNSAT, SET but that not every S E UNS: L.
is in T. (Thus, the characterization of UNSAT in Theorem 8.21 cann~t.
changed by replacing the base step assumption that all formulas cont~n~ng
o are included by the plausible alternative that just the formula COnslStLDg
of 0 alone be included.) PI
9 Refining Resolution
$, we need only arrange to check the application of this one rule to elements
of S and Previously deduced clauses. Even so, the search space can quickly be-
come quite large. In fact, it is known that, for a certain class of theorems, the
standard resolution method takes exponential time. A major concern is then
developing ways to limit the search space (preferably without giving up sound-
ness or completeness although in actual applications both are often sacrificed;
more on this POint later). In all honesty, we should point out that restricting
the search space for proofs means that we will miss some proofs. Thus, although
we search through a. smaller space, the proofs we find may well be longer than
9 Refining Resolution 63
those found by a wider search. Nonetheless, pruning the search tree does seem
to be more efficient. (Of course we are using efficiency in a heuristic sense. SAT
= {SI S is satisfiable} is NP-Complete in the sense of complexity theory (see
Garey and Johnson 11979, 5.3]) and no system can avoid this theoreticallimita-
tion. Nonetheless, in practice smaller search spaces tend to correspond to faster
run times.) We consider just a few of the many possible strategies for directing
the search for a resolution refutation.
We can consider directing the search from two viewpoints. The first is to ter-
minate the search along paths that are unpromising. The second is to direct it
by specifying the order in which we should try to go down alternative paths.
Perhaps the most obvious branches to prune are those with tautologies on them:
If C is a tautology, then it can't be of any use in showing that S is unsatisfiable.
As it is easy to cheek if a clause C is a tautology (just in case it contains both p
and fi for some propositional letter p), this is an inexpensive and useful pruning.
(The cost of checking for tautologies has been absorbed by the requirement that
we consider only clausal forms. Putting an arbitrary proposition into CNF can
be expensive.)
~finition 9.1: T-resolutions are resolutions in which neither of the parent clauses
is a tautology. 'RT(S) is the closure of 5 under T-resolutions.
emma 9.2: Any restriction of a sound method, ce., one that allows fewer deductions
than the sound method, is itself ,found. In particular, as resolution is sound, so
is 'R.T, ce., if 0 E 'RT(5), 5 is un.!atisfiable.
roof: AB any deduction in the restricted system is one in the original system and
by soundness there is no deduction of 0 in the original one, there is none in the
restricted system. 0
oaf: The proof of the completeness of resolution given in Theorem 8.22 remains
correct for 'RT. The only remark needed is that if To and TI heve no tautologies on
them, then neither do the trees 70 and 7i gotten by adding l and t, respectively,
to the appropriate clauses. The point here is that no clause on To (TI) contains
1 (1) by assumption as To (Til is a proof from 5' (5i). 0
Tautologies are true in every assignment and so can surely be ignored. We can
Considerably strengthen this semantic approach to refining resolution by fixing
one assignment A and requiring that in every resolution one of the clauses be
false in .A. (Again, if both are true in A, so is the resolvent and we cannot hope
to get unsolvabillty without resorting to clauses that fail in A. Of course, this is
far from a proof that we can simply ignore all such resolutions.)
64 I. Propolitional Logic
Proof: Fix an assignment A and let TA = {SIDE :RA(S}}. We mu~t show th:
UNSAT ~ TA. By the characterization of UNSAT of Theorem 8.211t suffices
prove that
(I) OES~SETAand
(i)t is immediate. For (ti) consider the A-resolution proofs To and T1 of 0 from
5 and st, respectively. We can fonn 1ri (Tn as in the proof of Theorem 9.3
before by adding 1(i) to the approp!iate clauses of To (Td. The resulting trees)
1
are, of course, resolution proofs of { l} and { z}, respectively (or perhaps of 0 '
They may not, however, be A-resolutions since one of 1, l may be true in A. On
To
the other hand, as at most one of i, l is true in .4, at least one of and 11 is.au
A-resolution proof. For definiteness say that i fI- A and so T: is an A-resolution
proof of {i} or 0 from 5. In the latter case we are done. In the former, we csn
combine this proof of {l} with To to get the desired A-resolution proof ~f 0 as
follows: To each leaf C of To that is not In 5 attach as children C U { i} and
{l}. As i;' A, this is an A-resolution. Since C ¢ S, C u {l} is in S. Th.U5,
except for the fact that { l} may not be in S we have the desired A-resolution
proof of 0 from S. We finish the construction'of the required proof by attaching
a copy of the tree 11 below each leaf labeled with { z}. The resulting tree is nOW
easily seen to represent an A-resolution deduction of 0 from S. Other than the E
resolutions of {i} and nodes of the form C U {i} that we have just consid~,
all the resolutions appearing in this new proof appear in one of the A-resolution
deduction trees To or 11· Thus, every resolution appearing on the tree is an
A-resolution. 0
Theorem 9.1: UNSAT i.! equal to the chis., of formulw U< ckfined inductively by the
following clauses:
(ii<) If no propositional letter with index stricUy smaller tMn that of p occurs
in S, 8" e us and S' eU<, then S «u«.
Proof: As the inductive clause (il<) is weaker than (il) of 8.21, U< is surely contained
in U = UNSAT. On the other hand, if we list the {Pi} occurring in S in ascending
order of their indices, then the original proof of the characterization of UNSAT
(Theorem 8.21) actually shows that any S ¢ U< is satisfiable and so UNSAT is
also contained in U<. 0
The proof of completeness of resolution in Theorem 8.22 with 'R. replaced by n<
and (ii) by (ii<) now proves the completeness of ordered resolution.
xercises
the child it has the smaller of the two possible indices. (We use superscripts
to indicate the tndextng.)
Example:
C1 = {pi, q2, r3}
C1"" {""p4, q5}
C, = {",'J
S = {CI, C1, C3}.
Here we can lock resolve C1 and C2 to get {q1, rJ} "" C4. C4 can then
be lock resolved against CJ to get {r3}. We cannot, however, lock r~~
C1 and C3 as we would have to resolve on q and the occurrence of q In . 1
does not have the lowest index of any literal in C2. (It has index 5 while
""p has index 4.)
Prove that lock resolution is complete, i.e., if Sis unsatisfiable, then there
is a lock resolution deduction of 0 from S. (Hint: Proceed by induct~on:
the euus literal parameter"" the total number of occurrences of liter
in S minus the number of clauses in S.)
4. Show that lock resolution cannot be combined with the omission of tau-
tologies to get a complete resolution system.
The usual convention is to write linear resolutions with the starting point at
the top and the conclusion at the bottom (as opposed to the picture of tree
resolutions which put the node. labeled by the conclusion, at the top). Thus, we
picture a linear resolution as follows in Figure 19:
Co Bo
1/
Ct B1
1/
FIGURE 19.
= = =
:xample 10.2: Let S {AI, A2• A3, A..J. AI {p, q}. A2 {P, ~}, A3 = {-.p, q}.
At. {"'p, ~}. Figure 20 gives a linear refutation of S:
0::
FIGURE 20.
68 I. Propoaitiooal Logic
Definition 10.3: In the context of linear resolution, the elements of the set S from
which we are making our deductions are frequently celled input clawes. The C,
are called unter clawe.! and the B; side clowes. Co is called the starting dame
of the deduction.
Linear resolution is clearly a refinement of resolution; that is, every linear res-
olution proof is an ordinary resolution proof, As resolution is sound (Theorem
8.11), so then is linear resolution. In Chapter II, Section 14 we prove that linear L.
resolution is complete. For now, we wish to consider only the case of Horn clauses
and PROLOG programs.
DefInItion 10.4: P,
(i) A Hom claUJe is a clause that contains at most one positive literal.
(il) A progrom clalUe is one that contains exactly one positive literal. (In PRO-
LOG notation It looks like A;- Bl, B~" .. , B .)
n
(ill) If a program clause contains some negative literals it is called a rule (n > 0
in the notation of (li)).
(Iv) A fact (or unit clause) is one that consists of exactly one positive literal
(Notation: A. or A:- .).
(v) ~ goo1 claWie is one that contains no positive literals. (Thus, in PROLOG it
18entered as a question with the symbol 1_ .)
Noti~e that Horn clauses are either program or goal clauses while program clauses
are mther rules or facts. An important point is that an inconsistency can arise
only. from the combination of a goal clause and a fact. The contradiction may be
mediated by rules but rules (and facts) alone cannot produce a contradiction.
Lemma 10.5: If a .Jet of Horn clatl.,le.JS it uruQtisfiable, then S mwt contain at least
one fact and one goal el4tl.,1e.
The general view of a PROLOG program is that we are given a collection of facts
and rules and wish to deduce COnsequences from them. Typically, we may want to
know if the conjunction of some facts ql, q2, ... , q" follows from our program P.
We enter this as a question 1- ql,lh, ... ,q" at the PROLOG prompt and receive
an answer telling us if the qi are consequences of the program. The general idea
implemented by PROLOG Is to add on a goal clause 0 = {"'qt. -ea, ... , -,q',.}
to the given program and ask if the resulting set P u {O} of Horn clauses Is
unsatisfiable. The simple but crucial point here is that the conjunction of facts
qlllh,· .. ,q,. is a consequence of our assumptions P just in case Pu {G} is
unsatisfiable. We isolate this basic semantic transformation as a lemma. It is
implicitly employed every time we ask a question in PROLOG.
emma 10.6: If P is a PROLOG progmm and 0 = {-,q'lt ~2, ... , -.q,.} a goal clause,
then all of the q. are consequence.! of P if and only if P U {O} is unsatis/iable.
~of: The proof simply consists of tracing through the definitions. First note that
Pu {G} is unsatisfiable if and only if any assignment satisfying P makes 0 false.
Next note that the goal clause 0 is faJse iff none of the -.qi are true, i.e., Gis
false iff all the qi are true. Thus, our desired conjunction of facts is a consequence
of our assumptions P just In case Pu {G} is unsettsdeble. 0
Our goal now is to translate this semantic condition into a proof-theoretic one
that we can verify by resolution methods. In fact, we show that linear resolution
suffices to decide unsatisfiability for sets of Horn clauses.
lOt:. By the compactness theorem (Theorem 6.13 or 8.23) we may assume that S
IS finite. We proceed by induction on the number of literals in S. By Lemma
10.5 we know that there is at least one positive literal p occurring as a fact {p}
in S. Consider the formula Sf' as described in Definition 8.16. Each clause in
sP is a subset of one in S and 50 ia Horn by definition. We claim that sP is
Unsatisfiable. The point here Is that, if .A F S1', then .A U {p} to< S contradicting
the Unsatisfiability of S. As sP contains fewer literals than S (we omit any clause
containing p and remove p from every other clause), we may apply the induction
~ypothesis to sP to get a linear resolution deduction of 0 from sP. As in the
Inductive step of the proof of the completeness theorem for the general resolution
method given for Theorem 8.22, either this is already a linear proof of 0 from
S or we can convert it into one of {P} from S by adding P to every clause below
One Dot in S. We can now extend this proof one step by adding on {p} E S as
8 ne", side clause and resolving against the last: center clause {p} to get 0 as
l'tQuired. 0
70 l. PWJlOllItional Logie
The advantage of linear resolution is obvious. We are now looking for a lin-
ear sequence to demonstrate uIlllatisfiability rather than a whole tree. The tree
structure of the searching in PROLOG is generated by the different possibilities
for side clauses. Each path in the tree of possible deductions by PROLOG repre-
sents a linear resolution. In the actual setting of a PROLOG program and a giWll
goal clause (question to the interpreter) we can be more precise in specifying the
order of clauses in the linear resolutions for which we are searching. By Lemma
10.4, we know that the goal clause must be used in the deduction. In fact, 'lie
can require our deduction of 0 to start with the goal clause and thereafter 00
use only clauses from the PROLOG program as side clauses. As these clauses are
called input clauses, this restriction of resolution is called linear input resolution.
Definition 10.8: Let P be a set of program clauses and G a goal clause. A linear inp!il
(L1) 1'e801utionrefutation of S = p U {G} is a linear resolution refutation of S
that starts with G and in which all the side clauses are from P (input clauses).
The method of LI-resalution is not complete in general as may be seen from the
following example.
Example 10.9: Recall the clauses of Example 10.2: S = {At. A2, A , A.}, At = {p,q/,
3
2
A .= {p, -,q}, A.l =
{"'p, q}, At = {"'p, -.q}. The only goal clause here is~
which we set equal to G. The remaining clauses are, however, not ail progralll
=
clauses. If we set P {AI, A2,~} and try. to produce a linear input resolutilJll
r:futation of S = Pu {G} beginning with G, we are always thwarted. Figure 21
grves one attempt.
The problem here is that, DO matter how we start the resolution when we gel
to a center clause that contains exactly one literal, any resolution' with a clause
~rn P produces another such clause as resolvent. Thus, 'We can never deduce
I
Linear input resolution does, however, suffice for the cases of interest in PROLOG
programming.
1/
bl {p"l
1/
{pI {~p,,1
1/
{,I {p, ~,I
1/
{pI {~p,,1
FIGURE 21.
-emma 10.11: If T is a set of Horn clauses, G a goal clawe such that T U {G} E
UNSAT but T E SAT, then there is a lineor resolution deduction of 0 /rom TU{ G}
starting with G.
As any set of program clauses is satisfiable by Lemma 10.5, this lemma suffices
to prove Theorem 10.10. 0
72 I. Propoeltlonal Logic
We now know the general format of the resolution proofs for PROLOG: linear
input resolution. There are two points left to consider before we have the precise
mechanism used by the PROLOG implementation. The most important one is that
PROLOG is not restricted to propositional logic; it uses predicates and variables
I
as well. This is the topic of the next chapter. The other point is more technical;
it concerns ordering considerations which come in two varieties. The first deals
with the actual representation of clauses in the implementation of resolution and
the choice of literal on which to resolve. The second deals with the ordering of
the search for linear proofs: searching and backtracking.
We begin with the representation of clauses. Our abstract presentation of res--
olution deals with clauses viewed as sets of literals. As sets, the clauses are in-
trinsically unordered. A machine, however, typically stores clauses as sequences
of literals. Moreover, it manipulates them as sequences and not as sets. Thus,
set-theoretic operations such as union must be replaced by some sort of merg-
ing procedure on sequences. In particular, when G = {...,Ao,...,Al>" .,...,A .. } and
H = {B, .... 80, ... , ....Brn} (viewed as ordered clauses) are resolved, sayan A; '" D
....
8, the interpreter simply replaces Ai by ....Bo, ... , ...,B.... The resolvent is then
(as an ordered clause) {....Ao • ...,A1, ... , ....A;_h ....Bo, ... ,...,B ... ,...,A;+1, ........ An}.
In addition to the ordering itself. one should note that as a result of this view of
clauses, duplications may arise if, for example, one of the B· is the same as some
At (I: ¥ i). The implementation of PROLOG does not check Jfor such duplication;
It merely carries along all copies of literals in the appropriate location in the
TI
ordered clause. (Ordered clauses are sometimes referred to as definite clauses,
hence the notation in the next definition using LD for llneer-definite.) This
ordering of clauses does not cause any serious changes. We embody it in the
following definition and lemma. P,
We continue to use T to denote a set of Horn clauses P a set of program clauses
and G a goal clause. '
(i) ~
n(t) +G;,
1.
i S n, is an ordered goal clause {~A
I"
0 •••
,
..,A. (.)} of length
I," •
)roor: This is left as Exercise 1. Proceed by induction on the length of the t.r-resolution
refutation of P U {G}. (Note that we can only resolve a program clause and a
goal clause at each step of the resolution. Each center clause must be a goal
clause and each side one a program cleuse.) 0
C '= Ao,o,
{ .... , ....,Ao.,t-I , ...Bj,o, ... ,-.Bj,mU) ,-..4o,,t+1 , .•. , -.Ao,n{o)}·
resolution after resolving with Cj• We can then continue the resolution deduction
exactly as in the original resolution with Cj+1 ••.•• C.... This procedure produces
an t.e-resoluncn refutation of length n-l beginning with C. By induction, it can
be replaced by an sm-reecluucn refutation via R. Adding this SLD-resolution
via R onto the single step resolution of Go with Cj described above produces the
desired SLD-resolution refutation from P U {G} via R starting with G = Go. 0
We now know what the PROLOG interpreter does when a question is entered
as in "1- AI •...• An. ". It searches for an SLD-resolution proof of 0 from the
current program P and the goal clause G = {...,A1,...• -.An} starting with G.
The remaining uncertainty in our description of its action is just bow it organizes
this search. At each step i of the SLD--resolution, the only choice to be made is
which clause in P to use to resolve on the leftmost term in our current goal
clause Gi. We can thus display the Space of all possible sLo-derivations as a
labeled tree T. The root ofT is labeled G. If any node of T is labeled G', then
its immediate successors are labeled with the results of resolving on the leftmart
literal of G' with the various possible choices of clauses in P. We call such trees
SLD-tTuJ for P and G.
Example 10.16 (SLD--Trees): Ai:. a simple example, consider the program Po:
Program Po
=::
S.~~ we ~ave. G = {""p} as our goal clause. The corresponding stu-tree is
gr low. In Figure 22. Along each branching we indicate the clause of Po
resolved agamst. The convention is that the successors are listed in Ii left to right
:enV;th ~he order in w~chth.e clauses used appear in Po. S~
such that ..1._ mg lD D. A path 18 a failure path if it ends with a clause G'
._
Uj cnere ~ no clause in P "h L'_L [ll
of G' In this WI wrucn we can resolve on the leftmost ter
example there are five POSSible paths. Two end in failure and three
end with su ccess.
The PROLOG theorem provernL_~ th
trying the left eeercnes e SLD--tree for a SUCCe5S path by always
first clause in ~;: first: That is, .it tries to resolve the current G with the
(I) (3) (5) to et the POSSIble.In FIgUre 22 it would simply follow the path
• g COrrect !llISWer "yes". If the theorem prover hits a failure
10 Linear Resolution, Hom Clauses and PROLOG 15
~p
~~
r 1(') .....
q, .....
r .....
8
(6)1~
.....
r s, ...r
..... .....
t 0
o
r r ~ .....
t, .....
r .....
r
I
failure
I I IS)
failure 0
FIGURE 22.
POint (te., DOt 0 and no resolution is possible) it backtracks, that is, it goes
back up the tree until it returns to a node N that has a path leading out of it to
the right of the one the theorem prover has followed upward. The prover then
exits from N along the path immediately to the right of the one it just returned
on (i.e., it tries the leftmost successor of N not yet attempted). This process is
repeated until a success path is found.
mple 10.17 (Backtracking): If we omit clause (3) from the above program Po to
produce Pl, we get a new st.e-eree as pictured in Figure 23 .
.....
q, .....
r
1')1 (6)/ ~)
.....
s, .....
r ,t 0
.....
r~
t, .....
r
I
failure
I
failure
FIGURE 23.
mt~ case, . It then
the theorem prover first tries the path (1), (4), (6), failure.
backtracks to .....
8, -'r and tries (7), (5), success, to give the answer yes.
76 I. Propositional Logic
Suppose tbe PROLOGinterpreter has searched the tree until it has found ~
answer and we then enter a semicolon '";" at the prompt. The interpreter will
resume backtracking to look for another resolution refutation in the part of the
tree that it has not yet searched. A "no" answer now means that there are no
more proofs. A "yes" answer indicates another one has been found. In this case,
we may once more enter ";" to start the search for yet another proof. In the
last example after finding the proof along the path (1), (4), (7), (5) the theore~
prover answered "yes". If we asked for another proof by entering a semicolon, It
would backtrack all the way up to the top node and try the path (2), It then
would proceed down (6) to a failure, backtrack to "'8 and follow (7) to another
success and "yes" answer. One more request for a proof via entering a semicolon
would finally produce a "no" answer.
If PROLOGsearches through the entire SLD--tree without finding a path leading
to 0, it gives the answer "no" the first time we ask our question. By our general
completeness theorem, we then know that in this case P U {G} is satisfiable and
so (by Theorem 10.6) the question asked ill not a logical consequence of P.
This type of search procedure ill called a depth-first search procedure 8.'1 it tries
to go as deeply as POSSiblein the tree by running down to the end of a path before
searching sideways along any other branches. In contrast, one that searches the
tree in Figure 23 in the order -e: -e. -or; -.s;"""'I1'; -'8, ..,r; ..,t; 0; 0; ..,t
j
-'r; ..,r; failure; failure; 0 is called a breadth-first search. Clearly many mixed
strategies are also possible. In our case, the depth-first search was much faster
than breadth-first (3 versus 6 steps). Indeed, this is a quite general phenomenon.
Depth-first is usually much faster than breadth-first. That, of course, is why the
implementations use depth-first searches. The cost of this strategy can, however,
~ quite high. In a breadth-first search, it is clear that, if there is a path ending
~n0, we must eventually find it. In contrast, the procedure of depth-first search
15 not complete: There may he a path leading to 0 but we may search the tree
forever without finding it.
q,- r . (1)
'0- q. (2)
q. (3)
~~h =arch Procedure applied to the starting clause -e will loop back llJId
n -.q and "'T. It will never find the contradiction supplied by (3).
This example seems ..,,"" to fix d ..•~
in the ~~ an to depend purely on the order of the cia""",
tennin~rogram. Unfortunately, rearranging clauses will not always produce II
of III 2 fI ng Program even when a correct proof does exist. (See program fi
. or an example.) The full impact of these problems cannot, however,
-- -----
10 Linear Resolution, Horn Clauses and PROLOG 77
be felt until we deal with full PROLOG rather than restricting our attention to
the propositional case. Indeed, it is only with the introduction of predicates and
variables that one sees the true power of PROLOG. We now turn to these matters,
first in the general setting of full predicate logic and then in just PROLOG.
ercases
(a) Represent these rules and the assumptions that we have some MgO,
H2, O2 and C by propositional logic formulas in which assertions say
that we have a particular chemical and implications are understood
to mean that, if we have the hypotheses, we can get the conclusion.
(Thus, (1) Is MgO A H, _ Mg A H,O.)
78 I. Propositional Logic
(b) Describe the state of affairs in clausal form and as a PROLOG Program.
(c) Give a resolution proof (in tree or linear form) that we can get some
H2C03·
If Jones is ill or Smith is away. then the directors will meet and declare a
dividend if Robinson comes to his senses and takes matters into his own
hands. If Patterson comes, he will force Robinson back to his senses but,
of course, he wUlcome only if Jones is ill. On the other hand, if Townsend,
who is inseparable from Smith. stays away, Robinson will have to take
matters into his own hands.
Give a resolution proof from your program and the added hypotheses from
above that shows that the directors will declare a dividend.
If Congress enacts a line item veto and the President acts responsibly, there
will be a decrease in both the budget and trade deficits if there is no maJor
lobbying campaign by both the protectionists and the advocates of high
interest rates. A strong public outcry will get the Congress to enact the line
item veto and force the President to act responsibly. The protectionists can
be kept quiet if productivity increases and the dollar is further devalued.
(It may help to start with a formulation in propositional logic and convert
it appropriately.)
How would you add on PROLOGclauses to reflect the fact that the public
is vocally outraged about the deficits, the dollar is continuing to fallon
world markets and productivity is on the increase?
How do you now ask the PROLOGprogram if the trade deficit will decrease?
(6) r,
(7) a.
(8) ,,- •.
In what order will the PROLOG interpreter search this tree and what output
will it give if we enter a semicolon at each yes answer?
For the general set-theoretic background needed for our treatment of orders and
trees see Chapter VI. For more about orderings, partial orderings and trees,
consult Bickhoff {I973, 3.8]. or elmoet any of the logic and computer science
texts listed in the bibliography [5.21.
For early propositional logic. read Boole (1952, 2.3] and Post [1921, 2.3].
For various alternate formalisms for logic, read the propositional part of the
following;
Tableaux: Beth {1962, 3.21, Smullyan (1968, 3.2], and Fitting [1981, 4.2].
Axioms and Rules of Inference: Hilbert and Ackermann {1950, 3.21, Mendelson
[1964, 3.21 and Enderton {1972, 3.2]. For an approach at a more advanced level,
see Kleene {1971, 3.2J, Monk {1976, 3.2J or Shoenfield 11967, 3.2].
Resolution: Chang and Lee (1973, 5.7], J. A. Robinson [1979, 5.21, Lewis and
Papadimitriou [1981, 5.2], Maier and Warren {198B, 5.4].
Natural Deduction: Prawitz [1965, 3.5], or at a more advanced level, Girard
[1987, 3.51 and Girard et aI. [1989, 3.5J.
Sequents: Gallier 11986, 5.2], Manaster [1975, 3.2) or Girard f1987, 3.5] and Girard
et el. [1989, 3.5}.
For a problem-oriented text based on resolution and Hom logic, see Kowalski
11979, 5.4J.
For Boolean algebra and its relations to propoeitlonel logtc, see Halmos [1914,
3.81, Sikorski [1969, 3.8} or Resicwe and Sikorski 11963, 3.8].
Interest in Propositional logic has recently revived primarily because of work on
~he complexity of proofs in different proof systems. A good survey of this work
III Urquhart [1995, 3.5].
I
F
1
I
'redicate Logic
as functions of ality O. They are objects that have no dependence on any inputs;
they simply denote elements of the domain of discourse. More generally, we call
all the symbols generated by the function symbols, constants and variables such
as !(x,9(y,II)), ternu. We think of them also as ranging over our domain of
discourse (or possibly just some subset of the domain, what is usually called tilt
range of the function).
Ai> with propositions, the truth-functional connectives can be used to build COlli-
po~d P:ed~cates from simpler ones. For example, if <p(x, y) still denotes the
relation x IS less than y" and .p(x,y) denotes the relation "x divides y" theD
(~{x, y) A ,p(x, V)) is a new binary predicate with the obvious meaning. In addi-
tion to the truth functional connectives, predicate logic uses two other predicate
constructors:
2
(i) the universal quantifier, "'If' , with the intended meaning 'for all"
""d
(ii) the e::ci.ftential quanti}U:r, "3" with the intended meaning "there existsn •
Example 1.1:
:ten
ur number less than it. It is equivalent to "II is not zero". 'fhe
t ({'o'x)({3J,!)<p(x, II)}} is a true one (predicate of enty 0) say~
foce
r any natural nwnbe
greater than x,
L. hie ,
r x, tuere lli a natural number y w leu
2 The Language: Terms and Formulas 83
(ll) Let the domain of discourse consist of all rational numbers Q. Again tp(x,y)
denotes x < y, f(x.lI) represents addition (x + 11),g(x, y) division (x + y)
and a, b, c are constants representing 0, 1 and 2.
(a) The ternary predicate (rp(:z:,y) A tp(y,z» says that x < y and y < z.
(b) The binary predicate «3y)(tp(x, y) A rp(y, z))) says that there is a ra-
tional number between x and z, The unary predicate «('Ix)(rp(%,z)---
«3y)('I'(x, y) A 'I'(y, z))) expreeeee • property of z which says thl,
for any x, if x is less than z then there is a rational number between
them.
(0) «('txJ«Vy)('I'(x, y) ~ ('I'(x,g(/(x, y), oj) A 'I'(g(/(x, y), oJ,y))))) Is •
sentence saying that for every x and y, if x < 11 then x < ~ < y.
(d) tp(y,/(y, y)) is again a unary predicate saying that y < y + y. Note.
however, that in this domain this predicate is equivalent to y being
positive.
!f1.nition 2.1: A language J:. consists of the following disjoint sets of distinct primitive
symbols:
(i) Variables: :z:, y, z, v,xo, Xl, ••• ,Yo, 111, ••.•.•. (an infinite set)
(v) Predicate symbols: P,Q, R, Pt,P2,'" (some set of them for each erity n =
1,2, .... There must be at least one predicate symbol in the language but
otherwise there are no restrictions on the number of them for each arity).
84 II. Predlcate Logic
{vi} Function symbols: t.s.x.t«ft, ...• !Jo, ... (any set of them for each ~lj'
n = 1,2, .... The o-ary function symbols are simply the constants listed
by convention separately in (ii). The set of constant symbols may also b!:
empty. finite or infinite).
Note that we no longer have propositional letters (which would be D-ary pred-
Icates). They are simply unnecessary in the context of predicate logic. A true
{false} proposition can be replaced by any sentence that is always true (false)
such lIS one of the form Q V -o (0 A -'0). (See Theorem 4.8 for an embedding 01
propositional logic in predicate Jogic.)
(iii) If f is an n-ary function symbol (n = 1,2, ... ) and tl, ... , t.. are terms,
then f(tl, ...• t..) is also a term.
0.,
The ground terms are the ODesyOUshould think of as naming particular elements
of the dOmain of diacoume. They are the constants and the terms built up horn
the constants by applications of function symbols as in (iii) above.
(ii) If a, f3 are formulas, then so are (a 1\ /1), (a --+ f3), (a - IJ), (-.0) and
(a V Pl.
(ill) If v is a variable and a is a formula, then «3v)a) and «Vv)a) are also
formulas.
ifinition 2.6:
(iii) A variable v is said to oa:ur fru in rp if it has at least one free occurrence
there.
To see that the definition of a sentence corresponds to the idea of a formula with
a si?gle fixed meaning and truth value, notice that all references to variables
(which are the only way of moving up to predicates of arity greater than 0)
oc~ur in the context of a quantifier. That is, they occur only in the form "there
exists an x such that ... " or "for all x it is true that ... n . The idea. of replacing
8. variable by BOrneother term to produce predicates of perhaps smaller arity (as
we did in Section 1) is captured by the following definition:
lnition 2.1 Sub.stitution (or Instantiation): If II' is a formula and v a variable,
we Write !p(u) to denote the fact that v occurs free in 'fJ. If t is a term, then
i(t), o~ ~ we wish to be more explicit, rp(ujt), is the result of su~tituting (or
~tlatlng) t for aU free occurrences of v in 11'. We call tp(t) an snstance of cp.
r,o(t) contains no free variables, we call it a ground in.Jtance of!p.
There is one important caveat that must be heeded when doing substitutions.
:oition 28.: If the term t contains an occurrence of some variab Ie:r (hiw c b l18
~ly free in t ) we say that t is lJubnituto.bk for the free variable v in 'fJ(v)
all occurrences of % in t remain free in cp(ujt).
86 II. Predicate Logic
Note that ground terms are always substitutable for any free variable. The prob- 1
lems with substituting a term t (with variables) which is not substitutable in r;
become clearer when we define the semantics of formulas. For now, we consider
two examples.
Example 2.9: P
(i) Consider first a unary predicate 1/;(y) = «3x)rp(x, y)) where our notatioo
is as in Example l.l(i). There is no problem substituting z or 2 or eWll
I(w,w) fo' y to get (3x),(x,,)), «3oo),(x,2» and «3xJ.(x,l(w,wlll,
respectively These formulas simply say that e, 2 and w + w are not zero &l
we would want and expect. However, if we try to substitute /(x,x) f~r.,
we get «3x)tp(x, f(x,x))). This formula says nothing about x or x+x; It II P
simply the true sentence assertiD8 that there is some x such that x < x+t-
(il) Next consider a language for the integers Z with constants 0 and, I, ,a P
unary function symbol 8 for successor and a predicate A(x, y, z) which ~
interpreted. as :r + y =
z. Let rp be the sentence V'x3yA(x, LI,O) which e
true in Z. As a true universal sentence, Ip should be true of any objed,
Indeed, any permissible substitution results in a formula valid in Z. On
the other hand, if we violate sUbstitutability and substitute s{y) for x we
get V:r3yA{s(y), 11,0) which is false in Z. TI
Example 2.10:
(i) «(\f:r)R(x,y)) is a formula in which y occurs free but x does not. The
formula «3Y){(\fx)R(x,y») has no free variables; it is a sentence.
(ii) A variable may have both a free and a bound Occurrence in a single formula
esdo both x and y in «(Vx)R(x, y)) V «3y)R(x,y))). P,
[iii] If ~(x) is (((3y)R(x,y)) A ((Vx)~(x,x»)) and r Is I(w u), then ~(t),
~(xlt) ls «(3y)R(f(w, u), y)) A «(V'l'Q(/(w, u}, ,))). The term g(y, ,(I}I
would, however, not be substitutable for x in tp{x).
ini:
ant
must be of the fa a !,ODJ;t symbol, then the proposition is clear. OtherWtse
s is a proper Sl,. ", .lin) and 80 of length at least two. Now if s '" t, t~
of parenth __ ' ~_ segment of t, Set, and we would contradict the properliti
-= III ...,rms proved in Exercise 6. p
2 The Language: Terms and Formulas 87
'heorem 2.12 (Unique readability for terms): Every term S is either (l; variable or
constant symbol or of the form f(st, ... , sn) in which case f, n and ~ Si for
1 :::;i :::;
n an! all uniquely determined.
'roof: Us is neither a variable nor constant symbol, then it is of the form J(81, ... , 8n)
by the definition ofterms. If it is also of the form 9(t1>"" tm). then clearly f = 9
and so n = m. Moreover, it is then obvious that either 81 £: tl or t1 £: 81. In
either case, S = t by Proposition 2.11. We can now argue in the same way for
each i in turn to get that 8.: = t.: for each i ~n as required for uniqueness. 0
roof: Clearly every formula is of length at least 2 and so if 0 were a proper ini-
tial segment of "t we would contradict the properties of parentheses in formulas
established in Exercise 9. 0
~eorem 2.14 (Unique readability for formulas): Each formula 1/J is of precisely one
of the following forms: an atomic formula (ie., of the form R(t1,'" ,tn) for
an n-ary predicate symbol R and terms tlo ... , t«), (0 A P), (0 -+ P), (0: +-> P),
(-.0:), (aV{3), (3tI)0) or «(Vv)a) (where 0 and /3 are formulas and v a tJariable).
Moreover, the relevant "components" of ¢ 43 di.!played in Mch of theae forms are
uniquely determined {i.e., R, n and tne t.: f01' 1 $ i :::;
n for an atomic formula ¢
and the formulatJ 0:, /3 and variobie tJ 43 appropriate to the other po.!sible forms
f" 'I».
'OOf: It is clear from the definition of formulas that ¢ must be of one of these
forms. If it is atomic it cannot be of any other form as all the others start with
a left parenthesis and DO atomic formula does. To establish uniqueness in this
case suppose 't/J is both R(tl, ••. ,tn) and else P(SI, .. ' ,8m), It is then clear that
R = P and so n = m. We then have that tl ~ SI or S1 ~ t1 whence h '-'"-81
by Proposition 2.11. Again we can show in this way that ti = .!i for each i ~n
as required for uniqueness. If t/J is not atomic, it is of one of the other forms.
Suppose, for example, that T/J is of the form (0 A fJ). If it were also of the fonn
b'.-> 6), h .....6) or (-yV6). then Q C "'/or -y C 0 contradicting Proposition 2.13.
If Instead 't/J were also of the form (4), ((3tJh) or((vvh), 'We would contradJct
Exercise 7. To establish uniqueness of the "components" of T/J in this case suppose
that T/J is also (-y A 6). It is now clear that Q ~ "t or -y £: 0 and so 0 = "t by
Proposition 2.13. We then argue in the same way that /3 = 6 as required.
The arguments for the other possible forms for T/J are similar and are left as
Exercise 10. 0
88 II. Predicate Logic:
&ercises
3
For each of Exercises 1-5 let the language be specified by the list of symbols
given in Definition 2.1.
6. p"", 'hat ""'Y term hao the sam numbe, af I'ft and ,igh' per enth~
Mo'"","", ""'Y prop" loitla! ",m'a' of a term t h es a'
1,as , es many e t
P&"entheses as right parentheses while if the initial segment is of length a
least 2, it has OlOre left than right parentheses.
8. Prove that every formula has the same nUmber of left and right parentheses.
9. p,,,,,, that ''''Y proper ioitial "'gmon, of a fo'mula h es at I, es t as mao~
left parentheses as right parentheses and that if the initial segment is 0
length at least 2, it has more left than right parentheses.
10. Verify the remaining case of Theorem 2.14.
3 Formation 'frees, Structures and Lists 89
As with the definition of propositions, we can make the formation rules for
formulas more explicit and the definition of such terms 8B "occurrence" more
precise by reformulating everything in terms of formation trees. This is also
the preferred presentation in most texts on PROLOG programming. Our starting
point is again the terms.
e8nition 3.1:
(i) Term formation tnu are ordered, finitely branching trees T labeled with
terms satisfying the following conditions:
(il) A term formation tree is tlUociatd with the term with which its root node
is labeled .
... ple 3.2: (i) Aseocieted with /(C,9(%,9)) and h(J(d"),9(c,a),w) we have the
term formation trees of Figure 24.
/(C,9(%,g)) root
and
.>
/(d,.)
I
,(c,a)
~ w
d
/ \ c
/ \ a
FIGURE 24.
90 II. Predicate Logtc
Proposition 3.3: Every urm t ha! a uniqut: formati.on tree associated with iL
t
Proof: The proof of this proPOSition, like those of the other results of this section, is
a simple exercise in induction like that of Theorem 1.2.4. We leave them aIIlL\
exercises. This one is Exercise 4. 0
Proposition 3.4: The ground terms are those terms whose formation trees have M
variables on their leaves.
Proof: Exercise 5.
o
The atomic formulas are handled as follows:
DefInition 3.5:
(i) The atomic formul4 auxiliary formation trees are the labeled, ordered,
finitely branching trees of depth one whose root node is labeled with au
atomic formula. If the root node of such a tree is labeled with an n-at}'
relation R(t], ... , t,d, then it has 1'1 immediate successors which are labeled
in order with the terms tl, .•• ,tn.
(ii) The atomic fonnula fOrmation trees are the finitely branching, labele:!, &
ordered trees gotten from the auxiliary trees by attaching at each Jeaf
labeled with a term t the rest of the formation tree associated with t. Sud!
a tree is associated with the atomic formula with which its root is labeled.
Example 3.6: Figure 25 shows the atomic fOnnation trees associated with the formula
R(o,f(.,y),g(a,z, w»).
y
a z w
FIGURE 25.
Proposition 3.1: E
ve1"y atomic formula is associated with a unique formation tret. Pf(
Proof: Exercise 6. 0
3 Formation Trees, Structures and Lists 91
le8nition 3.8:
(i) The formula auxiliary /orrnt1tion trees are the labeled, ordered, binary
branching trees T such that
(ii) The formuhJ jormo,tion trees are the ordered, labeled trees gotten from the
auxiliary ones by attaching to each leaf labeled with an atomic formula
the rest of its associated formation tree. Each such tree is again associated
with the formula with which its root is labeled.
(iii) The depth of 4 formula is the depth of the associated auxiliary formation
tree.
taJnple 3.9: Figure 26 shows the formula formation tree associated with the formula
3xR(c, f(x, y), g(a, %, w)) A VyR(c,f(x, y), g(a, z, w)).
""
3xR(c, f(x, y), g(a", w)) A VyR(c, f(x, y),g(a, z, w))
3zR(c, l(z, y), g(a, z, / tu» VyR(c, f(z, y), g(a, z, tu»
R(" f(x, y),g(a,
/ %, w))
\
R(,,!(x,y),g(a, z , w))
c
/1 -.
f(.r,y) g(a,z,w) c
~ J(z,y)
I
g(a,z,w)
/ \/1\
x y a % w
/
x
\/1\
v a % w
FIGURE 26.
. . nn t'ivale •ts
F"mally, we contln ue tn treat the ,.m.mmg boutf the
formulas,
notionssubformu!&l
d.fi,~'
and oocun.n,,, of vanebles as the proven "QUO en ~I h. replaced wl'h"
the last section. Those definitions could, however, eceu y
ones we present here.
P,opo.IUon 3.12, Ex
Notice th." ·'''.pt fo, the distlo,tlon we h.ve made In ou, alphahet
function _bob and pl.,ll,,,,, _bob,
he:::
the fommtion t .. " fo, term. and. "",.
fonnul", "e in""tl'_·!shahle. Each baa Ie.ves l.beled with oonstants 01 ••
.bI .. and eve." other-"6"nod. ~ labeled by 'PpI,,;ng one nf the 'ppwpn. . te n-"'J
nt>-
_hob tn the Iabeb of Its immooiate 'u"' .... "'. Th •• tand",d Implem~
tlo.. 01 PRol.O<l,and an the """" .... prog'''''''''lng text., In fact do not h"
tbl. alPhabetl, distinction. T.nn. and atoml, fOnnul", are all lumped tog.t oc
and <alled 'lruaurc... One <an the"'fo", he.... yut""tically ac"ptable ~RO~'"
d .... like "<eadlngUohn, "'adlngOacl<,HatI))". Thi. PRoLOG cI.u .. _h ",
rendered intn Engheh '" follawa, John ~ readlog Jacl<', fi,st "'adlng list. d
-"'ading' b thought 01 both ... P'OOI,,,,, desol!bing who ~ reading wh.t R an
3 Fonnation Trees, Structures and Lists 93
a function giving people's items for reading. In general, however, it seems very
difficult to make consistent sense out of such combined usages. The semantics
we present in the next section, which is the standard one for predicate logic,
makes no sense unless we maintain the distinction between function and predl-
cate symbols. As it is the basis for the theoretical analysis of PROLOG (in terms
of soundness and completeness, for example) and we know of no reason that
it might ever be necessary to exploit such a confusion, we simply assume that
separate alphabets are maintained for function and predicate symbols (at least
within any particular program or application).
a
/ \
.(6, .(0, .(d, I])))
6
/ \ ~~~~[l))
e
/ \ I])
.(d,
d
/ \I J
FIGURE 21.
T~e list la, b, c. dJ is also written [e lIb, c, d]J. The notation with the vertical bar,
I. 18 another version of the function symbol. for combining lists. [X I Y] denotes
94 II. Predicate Logic
the list whose first element is X and whose succeeding elements are those of the
list Y in order. The terminology that accompanies this notation is that X, t~
first element of the new list, is called the head of the list IX I YJ and the listY
consisting of the remaining elements is celled its tail.
Exmises
12. Prove that the length of every term t in a language I:. for predicate logic is
greater than or equal to the depth of the associated formation tree.
13. Prove that the length of every formula r,p of predicate logic is strictly greater
than the depth of the associated formation tree.
In terms of the examples considered above, we can specify structures for the
language with one binary predicate by letting the domain be N, Q or Z, re-
Spectively. The interpretations p.A of the binary predicate are then <, < and >,
resPectively. When we add the binary function symbol f we must specify in each
case a binary function fA on the domain to interpret it. In each of our exam-
ples, the function would be the one specified above: multiplication, subtraction
or max,
We begin the task of interpreting the fonnulas of I:. in the structure.A by saying,
fo~each. ground term of the language 1:., which element of the domain of discourse
A It names.
96 II. Predicate Logie
8ly function symbol of E, then the term tl, ... , n h fA's an n-8IJ
f(
• )A - IA(~ tA) of A. (Remember t at t A ~I
t .. ···'n - 1:.t"'"A
function on A and that t1 "'" tn are e Iemen ts 0 fAsothatj.A(t" ... ,.
is in fact an element of A.)
1) (I«,d))A = 0; (f(d,f(d,d))y' = 1.
2) (I«,d))A = 1/3; (I(d,/(d,d)))A = 8/27.
3) (I«,d))A = 0; (I(d,f(d,d)))A = -8.
It " oon_oot to deal wnb structures .A for langu ages £ that have a g=~
term -u,g e""ry element 0 of A. If we ere given a ,tmctu".A for alangu ~
In whi<h not.".ry element of the domain is named by a ground term, we£A oDd
£ by adding a new <o"'tan, '" to £ un
_h 0 E A to get a language h~o.
edend .A to a '''u<ture Co, £A by int",preting th ese oonstants m the 0""",
c:
WRy, = o. Thus in £A ""ry element of the domain A is named hy a rod "'"
Notice that every structure.A for t. becomes one for £..A in tbis wayan
structure for {;.4 becomes one for C by simply ignoring the constants Ca.
(i) For an atomic sentence R(tr. ... ,tn), A l= R(t}, ... , tn) iff RA,(tf, ... , t:),
i.e., the relation R"" on An assigned to R holds of the elements named by
the terms t... ,., tn' Note that, 88 R(h, ... , tn) is a sentence, the ti are all
ground terms and so name particular elements of A.
(ii) A l= -,tp <=> it is not the case that A l= tp. (We also write this as A)t' tp.)
Note that truth (or $ati!jactioR, as F is often called) for longer sentences is always
defined in (ii)-(viii) in terms of truth for shorter sentences. It is for clauses (vii)
and (viii) that the assumption that all elements of our structure are named by
ground terms is crucial.
(Ii) Given a set of sentences E = {al •... }, we say that a is a logical consequence
of E, E l= a, if a is true in every structure in which all of the members of
E are true.
Note that we have defined truth only for sentences, that is, formulas with no
~ee variables. The point here is that if Ip(v) has u free, then the formula has no
single fixed meaning in a structure A. It rather represents an n-ary predicate on
A for n > 0 and so we do not say that it is true or false. The notion for formulas
with free variables that is anaJogous to truth for sentences is that of validity.
6.nitio
. n .5·
.: A formula 'P of a language 4. with free varlab I·
es VI ••.• ,Vn is t1G '·d
I
In a .ttM1ctun: A for £ (also written A 1= cp) if the universal of tp, i.e.,
clo.fUTe
the. sentence 'Vv1'Vt/2, .. , VVn'P gotten by putting 'V'Il1in front of tp for every free
Vllriable Vi in 'P, is true in ..4.. The formula tp of 4. is valid if it is valid in every
structure for 4..
98 II. Predicate Logic
(I) Let the domain A consist of the natural numbers, let RA be the ustllll
relation <, and crt
= 0, cf = 1,.... The sentence (Yx)(3y)R(x,~) sa~
E:
that for every natural number there is a larger one, so it is true m t
structure.
(··)'-h· }.M
u ~ t e domain ofA "''''''' of th"";onal numbers Q ~ {qo, q" ... , I
ItA again be <, and let et = =
qo, cf ql, .... The sentence (Vz)(Vy)(R(x,."
.....(3z)(R(x, z) A R(z, y») is true in this structure. (It says that the rat:r
naJs
(i) forarethedense.) It is not, however valid as it is false in the structure
natural numbers. I
Warning: We have not included any special or reserved predicate symbol for
equality in either our syntax or sernllbtics for predicate logic. In other words,
we. have made no Provisions in our definitions that could be used to force US
to ~teCJ>re.t SOme ~ieular predicate, such as "=", as true equality. We have
avo,dad tim - ..
n of on, d.ftn;t;"n of • lang .... in 2.1 and the com.pond
~ restnet~ IJ1 the definition of truth in 4.3 because it does not mesh "IVe U
with resolutIOn theorem proving, logic prl:lgranuWng and PROLOG. Some of the
perhaps. uneJtpected consequences of this choice can be seen In Exercises 2-3 of
§7. A VIew of Predicate logic with such a distinguished equality predicate (as
:en as.an &PProa.ch to equality without it) is Presented in ]11.5. The syntaX 3l1d
mantics ~resented there can be read now. The proofs of soundness and ecm-
plete.ru~ss
ones discUssed
we Present in there
§7. for logic With equality are simple modifications of the
4 Semantics: Meaning and Truth 99
Now that we have defined the semantics for predicate logic we can make precise
the claim that we do not need propositions. Indeed there is a faithful embedding
of propositional logic in predicate logic.
otation: We often use vector notation as in X, ; and eto denote sequences of variables,
terms and constants, respectively.
tercises
6. P""" that. for any sen ten ce ,p, A F (,p ~ 3x,,(x» .. A F 3x(,p - ,,(x».
What happens if t/J is a fonout. in which :r is free1
7. Prove that for aoy .. 0eence ,p. A F (3x,,(x) ~ ,p) .. A F Vx(,,(x) ~ ,pl·
What happens if t/J is a fottnula in which x is free?
100 II. Predicate Logic
9. Prove Theorem 4.8 for formulas with no free variables. (Hint: Convert
between models for <p or ""1{) to assignments making !pI or .....
!p' true.)
In this section we want to specialize the ideas and definitions of the last section
to explain the semantiC! of clausal form and Horn formulas with free variables
and so begin the study of the semantics of full PROLOG programs.
The syntax for clausal form and PROLOG format is the same as in the proposi-
tional case (Definition 1.10.4) except that liternls can now be any a.tomic formula:;
or their negations. Note, however, that implementations of PROLOG uniformly
use (initial) capital letters for (names of) variables and lower case ones for (names
of) predicates, constants and functions.
(i) Literals are atomic formulas or their negations. The atomic formulas are
called po..titiveliural$ and their negations, negative liternls.
(il) A clawe is a. finite set of literals.
(iv) A progrnm clawe is a clause with exactly one positive literal. If a program
clause contains SOme negative literals it Is a rule; otherwise, it is a Joel.
(v) A goal clowe is a clause with no positive literals.
The PROLOG notation for rules and facts is as in the propositional case as well.
(i) In PROL?G, the fact {P(X)} consisting of the single positive literal P(X)
appears in PROLOG programs as follows:
P(X).
5 Interpretations of PROLOG Programs 101
(iii) For a rule C as in (U), we call p(X) the 900l or Mad of C. We cell the
qt(.X.y), ...• q..(X.y) the subgoals or body of C. When the head-body
terminology is used, the symbol :- which connects the head and body of
o is called the neck.
2 3
FIGURE 28.
ktrnolle(I, 1,2,3).
ktmove{l, 1,3,2).
Th, Jot .. ho.. ver, ""''' Ion. (336 foe,,). Mo",,",,,, In"
. is, h uon
itua , else wi>h
quicldy be-
oom~ Intobbk wh" .. eek '0'
only. Uttk bl' ,"0". Suppcee we . ht cen
to ba", 0UU>th~2 p"di"" 2IdUn'",(X"X,.X" X.) whicl> My•• bat. k... lon,
get fmrn
list of (X\,X ) to (X3,X4) in two moves. Here too we could enter 8 very
facbl:
The next steps are to apply the equivalence of -.3zrp to VZ-.I.p established in
Exercise 4.5 and then De Morgan's laws from Exercise 1.3.2 to get
One apprQ6Ch is to introduce symmetry type rules that would enable us to deri~
every bight's move from a small list of basic moves. One obvious such rule IS
symmetry iteelf:
Remember that dtis rule lIllys that (for any XI, Xi, X3, X4) if a knight can move
from (X3,X4) to (XI,X2), it can move from (Xl,X~) to (X3,X4). Introducing
this rule woukl allow lIS to cut our database in half. Other possible such rules
include the following:
(Check that these are in fac:t coned rules about a knight's behavior in chess.]
We could then list just a few basic moves which, together with these program
clauses, 1VOuidcorrectly define the predicate ktmove. (It is correct in the sense
that any structure lIlltisIying all these facts and rules would give exactly the legal
knight's moves all the quadruples of COnstants {I, ... ,8} of which the predicate
"ktmove" hokb. The correctness of the program in terms of execution, which
employs rell(llution-type theorem Proving, is dealt with later.)
(We must abo make sure that the two positions are different. This is taken care
of by the way we define the appropriate arithmetic operations. In particular 0 is
not an allowed value for IXI - X"J.) Now PROLOG hll8 many arithmetic operations
end ~redicates built in but a precise unde1'lltanding o( how they are used req~
knOWing more about how PfOgr8lJl8 are implemented. So for now, we wish to aVOid
using the built-in predicates. We can, however, put into our program definitions
of our own fOl'as much arithmetic as we need. (Be careful not to use the names
reserved for built-in predicates (or the ones you define.]
To begin with, we might define the "succeeded byn predicate on the set of numbers
{I, ... , 8} by a database:
suc(I,2).
suc(2,3).
sUC(1, 8).
(These rules do what we want because we are only interested in truncated opera-
tions, i.e., only on what happens on {I, ... ,S}. They do not define the operwo'18
correctly on all the integers. We say more about intended structures for a program
later.]
As in the ProPOSitional case, PROLOG implements the search for such witnesses
p(X1>X2), "'Q(X2,Xa)} to the
lIl, 42 and 4a by adding the goal clause G = {.....
cur~nt program P and then deciding if the result is an unsatisfiable formula. u:t
Us list varioWj semantic equivalenta of the resulting formula to help see bow t~
search produces an answer to our question. First, the meaning of the clause G IS
IIXI'VX2'VX3[-.p(X t , X2) V -.q(X2,X3)]. U adding it to the program P produces
~ UDsatisfiable formula P U {G}, then its negation is a logical consequence of
(check through the definitions 88 we did in Lemma 1.10.6). Thus
P F 3X.3X,3X,[p(X.,X,) Aq(X"X,)].
The implementation of PROLOG tries to establish this consequence relation by
;foduCing a resolution refutation of PUC G}. (We define resolution refutations ~r
t~ate caJculUSln §13 and Cbapter III.) A by-product afthe proof procedure 15
at It actually produces witnesses, °1,42.°3 in this case, that show that PU{G}
is unsatisfiable by providing a proof from P that p(al,a~} 1\ q(a~.a3}' From the
vifnvpolnt of resolution theorem proving, these witnesses are a mere by-product
of the proof. From the programming point of view, they are the essentiaJ result.
They are the output of our program; the answers to our questions.
Because of the way PROLOG represents data via logic, there is an unusual sym-
metry between input and output. We can put the variables anywhere in our
predicate when we ask questions. Thus the simple predicate add (X, Y, Z) not
only supplies a+b when we enter "?- add (a, b, Z)." it also supplies b-a when
we enter Y?- add (a, Z,o)." (at least if b > a). A single PROWG program can
thus be used to answer quite fancy questions that might be difficult to extract
from a simple database. Compare asking if one can get from (a, b) to (c,d). in
three knight's moves given one of the above PROLOG programs to explicitly writ-
ing such a program in some other language given only the database listing the
knight's moves. The arrangement of, and orders for, searching are all done auto-
matically. Again we return to these points of reversibility and searching later.
Exercises
1. Verify that the symmetry rules (SI)~(S4) are legitimate. (You can do this
by applying the arithmetic definition of ktmove (AD).)
2. ExpJa.in (in EngJish) the meaning of the rules (AI}-(A2) and why they
correctly represent addition on the structure {I, ... , 8}.
3. Explain (in English) the meaning of the rules (A3)-(A4) and why they
correctly represent absolute difference on the structure {I, ... ,8}.
4. Suppose that suc(X, Y) were correctly defined in some wayan all the nat-
ural numbers, t.e., suc(n, m) is true iff n + 1 = m.
Suppcse now that suc(X, Y} defines "succeeded by" on the integers. What
relatlODSdo
gers? the clauses (AI)-(A2) and (A3)-(A4) now define on the inte-
The fdilowing problems (and others later on) were designed to be used with a
database which we supplied online. This database consists of the genealogy given
in the first few chapters of Chronicles (the last book of the Hebrew Bible). The
information there is in terms of male descent only. (Actua1ly there are bits and
pieces of information on women and their children but so fragmentary as to make
inclusion fairly useless. The information was recorded in the database in terms
of the predicate "fatherof(a,b)lt. Thus the file consisted purely of (ma.ny) facts
entered as follows:
fatherof(adam, seth).
fatherof(abraham, isaac).
fatherof(isaae, jacob).
fatherof(isaac, esau).
In Problems 7 and 8 assume that this is the only type of information avail-
able (e.g., in defining grandfather, there is no need to consider ancestry on the
mother's side as this sort of information is not available).
We.Provide a printout of the database as-Appendix B.1f the reader does not have
online access to this database or a similar one, the following problems should be
lUlswered by just writing down a PROLOG program which is sema.ntically correct
~rding to the interpretations of facts and rules described in this section. Sim-
1~ly, descriptions of how to get the requested information from the programs
will suffice.
7. Ancestors:
8. Uncles:
Note that for this exercise you should allow yourself to use the PROLOG
version of inequality X F Y.
binary) trees as tableaux (the so-called atomic tableaux) and then givmg
development rule defining more complex tableaux from simpler ones. T be III he
' ten'
of the proof procedure is to start with SOmesigned sentence such as Fa as t
root of our tree and to analyze it into its components in such a way as to sh~
that any anal)1iis leads to a contradiction. We then conclude that we have refu
the original assumption that o is false and so have a proof of a.
The analysis of the connectives is the same as in propositional logic and the pIan
of the analysis is again that if some sentence is correctly signed (T or F) t~~~t
least one of its immediate euccessces in the tree analysis is also correctly S1!l"<'~'
The new problem is how to deal with quantifiers, If we consider, for example,
T3rrp(x), the obvious analysis ofthe assertion that there is an x such that. r,o(r)
is simply to supply such an x, Supplying such a witness means specify~:
ground term t and 88Serting that rp(t) is true. Thus, our first concern ebc we
be that there are as many ground terms available as we might ever need, If
therefore begin with any language l. we immediately expand it to one [,C by
adding on a set of constant symbols ',.~ c..... not ..__.J in £. Let A be anY
, '1,t,l ....
~,... ~ four
atomic sentence of l.c and Q, fJ be any sentences of l.c. The bese case 0
6 Proofs: Complete Systematic Tableaux 109
iition 6.1: We define tableaux as binary trees labeled with signed sentences (of
£C) called entries by induction:
(i) AU atomic tableaux are tableaux. The requirement that c be new in Cases
7b and 8a here simply means that c is one of the constants ct added on to
f. to get £c (which therefore does not appear in !p).
(ill) If 70 is a finite tableau and TO.'1, ...• Tn •..•. is a sequence of tableaux such
tbat, for every n ~ 0, Tn+! is constructed hom 'Tn by an application of (il),
then T" = lJ7"nis also a tableau.
~:ed
analogous to the ones presented in 1.6 for propositional logic. The modifications
are like thQ6e incorporated In the definitions of 1.6 for propositional logic.
key change is In the definition of & tableau from a set of sentences S. The
110 II. Predicate Logic
I. Ib ,. 2b
T(a" P)
TA FA
I F(a"p)
T.
I F.
/\ FP
Tp
'" 3b
•• .b
F(aVPI
Tf"r),.,(r} F('t'r)<jl(r)
T(3r)<p(r} F(3r).p(r)
I
T<p(t)
I I I
F<p(c) T<jl(c) FIl'(t)
fot"&l>y POund
fot" .. ne"
term t of £c for .. D ...... (or any sround
- ..... 0 constant e term t of cc
FIGURE 29.
6 Proofs: Complete Systematic Tableaux 111
underlying idea is that we are assuming that every sentence in S is true. Thus,
in addition to the formation rules for ordinary tableaux, we may assert at any
time that any sentence in S is true. We accomplish this by adding on one new
formation rule for tableaux from S.
For the remainder of this section we let S be a set of sentences in the language
C. We often refer to the elements of S as premises.
(ii') 1f'T is a finite tableau from 5, !p a sentence from S, P a path on 'T and 'T'
is obtained from 'T by adjoining T!p to the end of the path P, then r' is
also a tableau from 5.
From now on we define our notions for tableaux from 5 simultaneously with the
ones for ordinary tableaux. The additional clauses pertaining to tableaux from
S are parenthesized, as in the following important observation.
Note: It is clear from the definition that every tableau 'T (from S) is the union
?f a finite or infinite
sequence TO, Tit .•. , Tn' ... of tableaux (from S) in which 1"0
~.~ atomic tableau and each Tn+l is gotten from Tn by an application of [ii] (or
(ll)). From now on, we always assume that every tableau (from S) is presented
as such a union.
Lition6.2: Tableau proof~ (from 5): Let 'T be a tableau and P a path in 'T.
(i) P is controdictory if, for some sentence a, To. and Fa both appear as
labels of nodes of P.
Note that, if there is any contradictory tableau (from S) with root node Fa,
then there is one which is finite, t.e .• a proof of a (from S). Just terminate each
~ .when it becomes contradictory. ~ each path is now finite, the whole t~
tabfinite by Konig's lemma. Thus, the added requirement that proofs be finite
o lea? has no effect on the existence of proofs for any sentence. Anot~er way
f looking at this is that we could have required the path P in Clause (li) of the
112 II. Predicate Logic
Before describing the appropriate version of finished tableaux and the construt.
tion of complete systematic tableaux, it is instructive to look at some examples of
proofs by tableaux in predicate logic. Note that we again abbreviate the tableaux
by not repeating the entry being analyzed (or developed) unless we are dealing
with either Case 7a or 8b of the atomic tableaux.
Example 6.3: Suppose we want to check the validity of the formula ((Vx)rp(z) ....
(3.z)'P(x)). We form the tableau in Figure 30.
F[(Vz)~(z) - (3z)~(z)J
I
T(VzJ-(z)
I
F(3z)~(z)
I
F~(,)
I
T(Vz)~(z)
I
T~(,)
I
o
FIGURE 30.
For the last entrv we ftk __ ~ to h ' j'_
as to use t e same constant c as in the previous Inc .
ge:
.J. '''~
T(Vr)(P(r)
I _ Q(r»
F«Vr)P(r)
I
_ (Vr)Q(r»
T(Vr)P(r)
I
F(Vr)Q(r)
I
FQ(c)
I a "new" c
I
T(Vr)P(r)
TP(,)
I
T(Vr)(P(r)
I _ Q(r»
I
T(P(,) _ Q('»
/
FP(,)
~
TQ(,)
I I
FIGURE 31.
114 II. Predicate Logic
T(( ....r)(~(r)
/
....,;(z)))
\
F(( ....x)(..,,(.r) II "'(z)))
I
F(( ....z)~(x) ....(....
r)vi(r))
I
T(( ....
r)~(Z)1I (....X)-to(Z))
/
F('+'r)\<I(r)
\ I
F('+'r)vi(r) T( ....
r)..,,(r)
IWU F~(e)
I I I
Fvi(d) nn d T( ....
r)"'(r)
I
T(('+'r)(~(r)" vi(r»))
I I
T(("'r)(<p(r)" -to(x))) F(..,,(c)" "'(e)) ntt.1
T(~(e)"
I
vile))
I
T(~(d)"""(d»)
/ \
F<p(e) F,,(c)
I
TIII(e)
I I I
TIII(d) T( ....x)<p(r) T( ....r)"(r)
I
H(e)
I I I
T"(d) T<p(e) T,,(c)
I I I I
•
FIGURE 32.
The atomic tableaux for T{'Vx)~(x) and F(3x)!p(x) tell us that we can d",Jare
d the
Sl'(t) true or false, respeetively, for any ground term t. On the other han the f
atomic tableau for T(33;)!p(z) allows us to declare !pet) true only fo~ on~pJe
constants Cj which have not appeared so far in the tableau. The followmg
shows how we can get into trouble if we do not obey this proviso.
Example 6.6: Reverse the implication in Example 6.3 to get the sentence «3r);P(x~; I'\_~
(Vx)lp(x») which is not valid. H, however, we violate the provisions for using "llIl
constants, we can produce a "proof" of this sentence, as in Figure 33.
6 Proofs: Complete Systematic Tableaux 115
F«3.M.) - (v.M.»
I
T(3·M·)
I
F(V.)~(.)
I
T~(,)
I
F~(,)
Heft we have developed the enuy
F (V~),,(~), illegally wJing the lame
e u in a p",vioUi entry.
I
o
FIGURE 33.
It is easy to see that tableaux in predicate logic need never terminate if no con-
tradiction arises. Thus, there is some question as to when we should say that
an entry has been reduced and when a tableau is finished. To motivate these
definitions, we first consider the role of the atomic tableaux for the quantifiers
and how we use them in building tableaux. When we deal with T(3x)rp(x) (or
F(\r'z)tp(z)), we analyze it simply by listing Ttp(e) (or Frp(e)) (or some con-
stant c not yet appearing along the path being extended. The original sentence
(3%lfP(z) contains no more information than the new one !p(e) and so we may
r~nably claim to have finished with it. On the other hand, if we are dealing
wtth T(ltx)r.p(z) (or F(3x)r.p(x)) the situation is quite diJferent. Here we may
add Ttp(t) (or F!p(t)) to our tableau for any ground term t. This, however, far
~om exhausts the information in the original sentence. It merely gives us one
tnstance cf the universal fact asserted by T(\"x)rp(x). Thus, we cannot say that
: have as yet finished with T(Vx)rp(x). With this distinction in mind we can
he the notion of when an entry of a tableau has been reduced and when a
ta~leau is finished. M. in the propositional case, our goal is to describe a system-
at~cProcedure to produce a tableau proof (from S) of a given sentence rp. That
~ ~matic procedure will always succeed if r.p is valid (a logical consequence
S) 18the content of the Completeness Theorem (Theorem 1.1).
Let tr, ... ,t .., ... be a list of all the ground terms of our language £c which, we
""ll "._.
, mctudee the new constants Cj.
Oil"
IOn8.7: Let T = UT.. be a tableau (from S), P a path in T, E an entry on P
and tIi the ith occurrence of E on P {l.e., the itb node on P labeled with E).
116 It Predicate Logic
(1) E is neither of the form T(Vx)tp(x) nor F(3x)lf'(x) and.' .for some j, TJ+)
is gotten from Tj by an application of Rule (ii) of :O:fimtlon 6.1 to E and
a path on Tj which is an initial segment of P. (In this case we say that E
occurs on P Il.S the root entry of an atomic tableau.)
0'
The idea here is that signed sentences such as T(\fx)rp(x) must be instanti~
for each term t; in our language before we can say that we have finished WI
them. We can now show that there is a finished tableau (from S) with ~.
given entry on its root node by constructing the appropriate complete systematIC
tableau (from 8). The plan is to devise an ordering procedure so that we .c~
reduce each entry in turn to produce the finished tableau. We employ a vaflatl
on the lexicographic ordering on the nodes of the tableau.
Definition 6.8: Suppose T is a tree with a left-right ordering on the nodes at each of
Its levels. Reca1I (from lI) that ifT is, for example, a tree of binary sequences,
the left-right ordering is given by the usual lexicographic ordering. We define
the ltvel-lexicographic oTdeTifl9 SLL on the nodes v, J.l of T as follows:
Definition 6.9: We COnstruct the CST, the CDmplete systematic tableau, with anY
~..
Proa
given signed sentence as the label of its root, by induction.
(i) We begin with TO an atomic tableau with root the given signed senten~
This atomic tableau is uniquely specified by requiring that in Cases 7a an
8b we use the term tl and that in Cases 7b and 8a we use c, for the least
allowable i.
E E
I I
F~(';)
T~(';)
The CST from a set of premises S with a given root is defined like the ordinary CST
above with one change to introduce the elements of S. At even stages (n = 2k)
we proceedas in (i), (Il) and (iii) above. At odd stages (n = 2k+l) we adjoin Ta"
for Q", the kth element of S to every noncontradictory path in 'Tn to get Tn+1'
Wedo not terminate the construction of the CST from S unless all elements of S
have been put on every noncontradictory path in this way and every occurrence
of every entry is reduced on every path containing it.
Note that, in general a CST will be an infinite tableau (even if S is finite). The
cru'al '. '
C1 pomt IS that it is always a finished tableau.
entry'
The 18 reduced on every path.• (It..-..... h
just takes twice as many steps to get t ere.
)
Example 6.11: Figure 34 above gives an example of a tableau that is finished except
for one unreduced entry. Exercise 15 asks for the unreduced entry.
Exercises
In Exercises I-Il, let 'P and T/J be any formulas either with no free varia?les or
with only % free as appropriate. Give tableau proofs of each of the following:
15. Find the umeduced entry in Figure 34 and give a finished tableau with the
same root as the one there.
6 Proofs:Complete SystematicTableaux 119
T(3y)(~R(y,y)
I V P(y,y»
I
T(V.)R(.,.)
T(~R(,o,'o)
I V P(",.,,))
I
T(V.)R(.,,)
I
TR(co, co)
(suppose to = co)
.> ~ TP(co,eo)
I
T(V.)R(.,.)
I
TR('" t,)
I
T(V.)R(.,.)
I
TR('".,)
FIGURE 34.
120 II. Predicate Logic
Proof: The only expansion of .A that is necessary to make it a structure for all ~e
sentences appearing in r is to define et
for the constants Co in [;c _ t. appe~
on P. (Remember, these are the constants used in, as the "new" constants LD
instantiations.)
We define P and
A
et
by an induction on the .......uence T. giving the construction of
--, n (.th
T. t each step n we have a path p.. through T.. and an extension .An of A WI.
the same dOmain) which interprets all the c, on p.. and agrees with p... T.hlS
clearly suffices to prove the lemma. When r...+1 Is gotten from T.. byextendiD&
some path. other than p.. we need make no changes in p.. or .An. Suppose t~en
that '''+1 IS gotten by adding on to the end of P. either an atomic tableau WIth
E
root nan entry on Pn or an element Ok of S. In the latter case we extend p,.. ln
the only way possible by attaching OJ: to its end. No extension of .An is necessarY
and it a,g~ with OJ: (and hence Pn+ll by hypothesis. We consider then the case
of extendlDg T.. by adding on an atomic tableau T' with root E. By induction we
may assume that A.. agrees with E. We wish to extend.A to .An+land find II
~th ~nH extending p.. through TnH agreeing with A,,+l' (The base case ofo~r
induction ~ the atomic tableau TO wh06e root r« agrees with A by hypothe51S.
The analysIS of the base case is then exactly as in the inductive step: We wish to
extend .A to An and find a path Po through TO agreeing with ..40.) We consider
each type of atomic tablea.u T'.
(i) The situation for the prOpositional connectives is the same as in the proof of 1'Ite
soundness for propositional logic (Lemma 1.5.4). In particular, no extension of
7 Soundness and Completeness or Tableau Proofs 121
T(. V P)
T.
/ ~
(iil If we added on
T(Vr)~(r) F(3r)~(r)
T~(t)
I 0' I
F~(')
•.... 1.2 (Soundness): IJ tht~ u a tableau proof T' of a from 5, then 51=0:·
122 If. Predicate Logic
Proof: If not, then there is a structure A ~ -.a in which every a:/< in S is true. Lemma
1,1 then tells us that there is a path P through T and an expansion A' of A that.
agrees with every node on P. As P is contradictory by assumption, we have our
desired contradiction. 0
We now turn to the completeness of the tableau method of proof for predicate
logic. As in the propositional case (Theorem 1.5.3 and especially Lemma 1.5.4)
the plan is to use a noncontradictory path in a CST to build a structure for
tc that agrees with every entry on P. The underlying idea here is to build the
desired structure out of the only available materials _ the syntactic objects, in
particular, the ground terms appearing on the path. This idea and its application
in the proof of the completeness theorem are crucial ingredients in the proofs
of many other important results including Herbrand's theorem (Theorem 10.4)
and the Skclem-Lowenhetm theorem (Theorem 1.1).
Proof: Let the domain of this structure be the set A of ground terms tj on the master
list of ground terms of our expanded language Le. We define the functions fA
associated with the n-ary function symbols f of our language in the natural way
corresponding to the syntax of £..c:
Remember that the elements of our structure are the ground terms and so the
t; appearing On the left-hand side of this equation are being viewed as elements
of our structure to which we apply the function fA. On the right-hand side:
have another term, and so an element of our structure which we declare to
the value of this function. If R is an n-ary predicate' letter we define R). es
dictated by the path P: '
We ~
ductlon.
prove the theorem by establishing a slightly stronger assertion by in'
0
"",
Lemma 7.4: Let the not4tion be as _L_
uwtle.
(i) If F{3 OCCUrson P, then /3 is false in A.
(ii) If T/3 OCCurson P, then {3 is tnu in A.
Proof: First recall that bv P
't' 6 p,
roposllOn .10, every Occurrence of every entry on.
' J
'Ye have thus proven an effective version of the completeness theorem. For any
~ sentence Q and any set of sentences S we can produce either a proof that
'. '!ogi--'
'4l consequence of S or a model of• S in which Q fails.
Iary 7.6: For evuy eeaeence Q and set 0/ sentences S of L., either
Proof: Consider the CST from S that starts with a contradiction 01\-'0 at its root. By
the soundness theorem (Theorem 7.2) it cannot be a tableau proof of aA-.a from
S. Thus, it must have a noncontradictory path P. As there are only countabJ.Y
many ground terms in £c, the structure defined in the proof of Theorem 7.4 ~
the desired countable model of S.
The analogous theorem can also be proved for arbitrary cardinalities. Also note
that we use countable in the sense of at most countable, that Is, the model ro.a:Y
be finite. In our setting, however, one can always guarantee that the model.IS ~
infinite (Exercise 3). One can guarantee that a set of sentences has only finite
models only by the special treatment of equality which we consider in III.~'
POint. the rernacks on PROLOG,this treatment of equality can be read at this
Ig~
We can refonnulate Corollary 7.6, in analogy with the completeness and sound-
ness theorems for Propositional celculus, in terms of the equivalences ~
P~bllity and logical consequence. The point to keep in mind is that, if a IS
false 11) SOmemodel for S, then it cannot be a logical consequence of S.
Theorem 7.8: (Completeness and Soundness):
Proof: :Theonly if direction Is immediate. For the if direction consider the CST ~~ S
WIth root entry F(o A --0). If the CST is contradictory, it is finite by ProposltjoD.
7 Soundness and Completeness of Tableau Proofs 125
We should point out one important difference between the completeness proofs
for predicate and propositional logic. The finished tableaux for propositional
logicwere always finite and so for every proposition 0: we can effectively decide
if it is valid or actually produce a counterexample. For predicate logic, if a given
sentence 'fI is valid, we eventuaUy find a proof. On the other hand. if it is Dot
valid, the finished tableau and the path providing a counterexample may well
be infinite. Thus we may never in the course of our construction actually know
that rp is not valid. This phenomenon is unavoidable. Church's theorem states
that there is no effective method for deciding if a given sentence in the predicate
calculus is valid. We prove this result in Corollary III.B.IO as a corollary to a
result on termination of PROLOG programs. A proof suitable for insertion at this
POintcan, however. be based on the semantic approach indtcated in Exercise
ITI.8.3.
3. Let l. be any language for predicate logic and S be any set of sentences in
t. Prove that S is satisfiable iff it has an infinite model.
4. Let l. be a language for arithmetic on the natural numbers N (= {O.l, 2,
... }) including 0, 1. +•. and c-. Let Th(.N) be the set of all sentences of
r. true in N. Show that there is a nonstandard model of Th(.N'). Le., a
structure M for l. in which every sentence of Th(JrI) is true but in which
there is an element c greater than every n E N.
(i) EF~.
(ii) F I\I: .....!p.
(Iii) I: I- !p.
7. Complete the proof of Case (i) of Lemma 7.1 by describing the required
extensions of POI for the other propositional connectives.
•
8. Complete the proof of Case (ti) of Lemma 7.4 by handling the other propo-
sitional connectives.
9. Complete the proof or Case (iv) of Lemma 7.4 by considering the case that
p;, 3v<p(v).
10. Let C be a language with no function symbols. Describe a procedure that,
given any sentence !/Jof the form 'v'XI •.• Vx .. 31h ... 3Ymlp, with Ip quantifier
free, decides if!/J is valid. ( Hint: First use Exercise 6.13 to reduce the va-
lidity of 1/J to that of 3YI'" 3Ym!p(cJ,... , c"" Yl, ... ,Ym) for new cons~t5
cr, ... , c... If this problem is still too difficult now, reconsider it as ExercISe
10.6.)
AnAxiomatic Approach"
~ for the propositional logic we give a brief sketch of a classical approach to
predit:ate logic via axioms and rules. For the sake of brevity, we use as propo-
sitional connectives only ... and -+ as we did In 1.7. In the same vein we view
the existential quantifier 3 88 a defined symbol as well: We replace 3xip(x) by
-,VX"">ip(z). (They are equivalent by Exercise 4.5.) We also fix some list of con-
stants, function symbols and predicate symbols to complete our language £.. The
axioms include the schemes (1.7.1) for propoBitionallogic but now the variablp.s
CII, f3 and 'Y range over all formulas of £.. In addition we Include two schemes thlt.t
express the meaning of the universal quantifier. Note that we are considering all
formulas, not just sentences and remember that validity for a formula with free
variables is the same as for Its universal closure .
.1 Axiorna: Let 0, P and 'Y be any formulas of £.. The axioms of our system are all
formulas of £. of the following forms:
0) (o-IP_o»)
(ti) ((0_IP _ ,)) _ ((0 _ P) - (a - ,m
(m) II".) _ 10 _ P))
It is easy to check that all instances of these axiom schemes are valid. The re-
striction in (iv) Is necessary as we explained when we defined sub6titutability
(Definition 2.8). Recall that we considered in Example 2.9 (ii) the structure Z
~ the integers with constants for 0 and I, a function s for successor and a pred-
ICate A(:t,y,~) which is Interpreted as z + II = ~.In particular, we oonsidered
the true sentence If' = Vx3yA(z, II, 0). AB a true universal sentence, If' should be
~rue of any object. Indeed (iv) a88eJ'ts that any permleslble substitution result!!
~n &. formula valid in Z. On the other hand, If we substitute S(II) for z. we get
:t3yA(,(y),y,O), which is false in Z. As for the restriction in (v), collllider the
true .(i~ Z) sentence If' = Vx(\/yA(X.II,Y) -0 A(s, 1,1)). If we could ignore. the
;:nction in (v) we could conclude from rp (via the rule of modus ponens given
:n low) that 'oJyA(X,II, II) -0 VxA(s, I, 1). This formula. is not valid in Z as can be
~y setting the free occurrence of s to O. (This substitution only affects. the
. SIde of the implication by making it the true sentence VIIA(O,y,y). Tbe nght
Bide olthe implication is, however, false.)
~r system has two rules of inference. The fiI'llt rule is modus ponens applied to
~ fo~~ of 1:.. The aecond captures one direction of the equivalence between
h validity of a formula with free val"iables and that of its universal dOllure. (The
at ee direction is included in axiom scheme (Iv). Just take t to be s.)
l2 The rulell f'
o lIl(enlocel
Ii) Modu POTlenlll: From 01 and 0: _ fJ we can infer IJ for any formulas a and {j.
(iI) Ge ..•..."...Uq ~n: From V:o infer o.
_I· " '
128 II. Predicate Logic
As in propolll\ionalIOlic, such axiom and rule based systems are generally eall~
Hilbert. ....tyle proof systems. The definition of a proof £rom a set of formulas E IS
the same as for prDpositionailogi<: except that we have more axioms and rules.
(il) 0 is provable (a theorem) from E if there is a proof 01, ... ,On from E with
On =0.
(iii) A proof of 0 is simply a proof from 0. 0 is provable if it is pro1HJble from t.
We would. like to show that, in a certain sense, predicate logic CIlIl alm06t be
reduced to propositional logic. Roughly speaking, we want to eliminate the quan-
"",
tifiers by introducing new function symbols and terms. The basic idea is that a
formula such as:
r.p = 'r/Xl •.. 'v'Xn3Yl ... 3ymR(xl>'" ,Xn, YI> .•. ,tim)
will be replaced by one
fjJ == VXI ... Vx..R(xlt ... 'XI'l' ft(XIt ... ,XI'l)' !2(Xl,'" ,x ..),
.. " .. (XI, ... ,xn))·
(la) I- j$ .....
Vyrp +-+ ~3Jrrp
(lb) l- Q;~3W _ Q;Vy~~
(,.) f- Q;rvy~ V,p) _ Q;Vz(~(Ylz) V,p)
I U) ~
l- Qz(~ ~
VVy,p) _ QzVz(~ V ,p(ylz))
I'b) f- Q;(3y~ V,p) _ Q;3z(~(Ylz) V,p)
I'~)f- Q;(~ V 3y,p) _ Q;3z(~ V ,p(ylz)).
1ltlere% is a variable not occurring in rp or t/J or among the Xi·
f: Tableaux proofs of such equivalences are fairly simple and are left as exercises.
(Samplesof (la), (2a) and (2b') were given in Exercise 6.12 (a), (b) and (c),
resPectively.)Alternatively one can argue semantically for the equivalences and
then apply the completeness theorem. (Exercise 4.5 essentially gives (la) and
(lb),)A general approach to these equivalences is outlined In Exercises 1-3, 0
We can no '__ 1_ t
w prove that every formula rp has a prenex. equiv __ n .
reID.
fi 9 . 2 (P renex normal form): ,
For etIe'1l formtJia rp the~ 1.8 an equu'. ale n t
::;:~ rI with the "amt: free tlariahtu in which all quantifiers appear ce the
nnlng. Such an equivalmt of rp is called a prena normal fonn (PNF) of rp.
f: By ind
9aurne ucticn on the depth of rp. Remember that, by Corollary 1.2.11, we may
'P ' that the only propositional connectives occurring in q; are .....and V. If
IS atoOlic, there is nothing to prove. If rp is 'tI1I¢ or 3yt/J and '1/1 is a PNF of
ISO U. Predicate Logic
lJ, then 'I'lJVIor 3y1fI is one for t{J. (This fact is the base case for the inductioo
In Exercise l.) If t{J "'" ..,,p and 1/1 is a PNF of,p, then repeated applications d
the clauses (la) and (lb) of the lemma will produce the desired PNF for fI.lf
t{J= tP V 9, then repeated applications of the clauses (2a), (2a'), (2b) and (2b'j
will give the result for tp. 0
Note: One can easily introduce prenexing rules that deal directly with the other
connectives. The following equivalences may be used to put formulas in PNF
without first eliminating any of the connectives except _:
~ ~
(30)"Qx('lY.A~)_QxVz(.(Y/Z)A~)
~ ~
(Ja') "QX(.AVY~)_QxV'(.A~(y/z))
~ ~
(3b) " Qx(3y. A~) _ Qx3,(.(y/,) A~)
~ ~
(3b') "QX(.A3Y~)_Qx3'(.A~(y/,))
~ ~
('0) " Qx('ly. _ ~) _ Qx3z(.(y/z) _~)
('0') "Q";(. _ VW) _ Q";V,(. _ ~(y/,»)
('b) "Q";(~ _~) _ Q";Vz(.(y/,) _~)
('b') "Q";(. _~) _ Q";3'(. _ ~(y/,)).
VuVw3u[P(u,u) V ~VyQ(w,y)1
VuVw3u(P(u, v) V 3y~(w, y)1
'1u'lw3tl3z{P(u, tI) V -.(J(w, z)}.
We can now reduce the problem of giving refutation proofs of arbitrary sentences
of the predicate calculus to that for universal ones.
Iheorem 9.4 (Skolemization): For every sentence I{J in a given language t:. there is a
uniuersal formula I{J' in an expanded language t: goUen by the addition of new
junction symbols such that I{J and rp' are equisatisjiable.
(Note that we do not claim that the formulas are equivalent. The procedure will
always produce a ~ such that rI -0 rp is valid but I{J -0 ~ need not always hold.
See Exercise 9.4 for an example.)
>roof: By Theorem 9.2 we may assume that 'P is in prenex normal form. Let YI, ... , Yn
be the existentially quantified variables of 'P in the order in which they appear
in rp from left to right and, for each i 5 n, let XI,··· ,Xn; be all the universally
quantified variables preceding 1/•. We expand £, to £" by adding new n;-ary
function symbols Ii for each i :5 n. We now form ~ by first deleting each 311;
and then replacing each remaining occurrence of y. by /;(XI. ... , xnJ. We claim
that ~ is the desired sentence equisatisfiable with rp. To verify this claim it
suffices to apply the following lemma n times. 0
-emma 9.5: For any sentence I{J = VXI .. , '1x.. 3y1JJ of a language £" If) and cp' =
'1XI ... Vxnw{lIl J(Xt, ... ,xn » are equisatisfiab~ when f is a function symbol
not in C.
)roof: Let J:.' be the language obtained from £, by adding the function symbol l-
It is clear that if A' is a structure for £', A is the structure obtained from A'
by omitting the function interpreting f and A' F rp', then A F cpo On the other
band, if A is a structure for £ and A F cp, we can extend A to a structure A' by
defining rA.' so that for every ai> ... ,tIn E A:=: A', A F w(ylf(a1> ... ,a ..)). Of
course, A' F rp'. Note that n may be 0; that is, f may be a constant symbol. 0
~oroUary 9.6: For any set S of sentenceS' of a language t:. we can construct a set
9' of universal sentences of a language C which if an expansion of C. gotten by
adding on new /undion .symbols such that 5 and 5' an: equisatisjiable.
,, roof: Apply the construction supplied by Theorem 9.4 to each sentence !fJ of S
separately to introduce new function symbols f'# for each sentence lp of S and
form the corresponding universal sentence Ip'. Let S' be the collection of ell of
these sentences vi and C the corresponding expansion of £. As in the proof of
the theorem it is clear that, if a structure A' for C' is a model of 5', then it
132 II, Predicate Logic
is one of S. The proof also shows how to extend any model of ~ to one of BI I
by defining each new function symbol IV' independently of what IS done for the
others. 0
and
Example 9.8: There are many familiar examples of Skolemization in the constru~tion
of axiom systems for standard mathematical structures such as groups or negs-
In these situations, axioms of the form Vx3yrp(x,y) can be replaced by ~pen
formulas of the form <p(z,f(x)) by introducing the appropriate Skolem functiOns.
As a particular example let us reconsider the structure of Example 2.9 for the
integers Z and the sentence 'tIx3yA(x,y,O) which says that every integer has
an additive inverse. The Skolemization of this sentence is YxA(x, f(x), 0). T~e
interpretation of f should be the unary function taking every integer z to Its
additive Inverse -x. The Skolemized sentence then simply says that, for all x,
x+(-x) =0.
Harking back to the clausal forms for predicate calculus introdUced in §5, we
now see that every set of sentences has an equisatisfiable clausal form. 1
Corollary 9.9: For any set S of sentences o{ £, then U (in the terminology 0/ §5)
. , . new
a formula, that '-9, a set T of clauses in a language I:/ gotten by add'lIg
function symbols to £, such that Sand T are equisatisfiable.
Proof: Consider the set 5' of Universal sentences Vrtp'(X) equisatisfiable with S given
by Corollary 9.6. Let T consist of the equivaJent open formulas !p'(£) gotten by
dropping the initial universal quantifiers from the elements of S. (lp and If/' ace
equivalent by Exercise 4,8 or 6.13.) If we view each atomic formula of £' as~
propositional letter and fonn the CNF ""'uivalent,.J, = 1\.1. ,of each formu
.- T' ..... 'f'1lI 'f'1lI, th one
Of" E • we get a set of formulas T" each in CNF and each equivalent to e"
ofT: ATPIlI,i = f/Jrp;: vi:=:: cp for eech cp E S. (For each V', 1/I is equivalent to set
1lI
by Theorem 4.8.) The desired set T of clauses then consists precisely of the 0 I
of all ccnjuncts from all of the formulas cp in Tit : T = {"pili •• IV' E S}.
10 Herbrand'sTheorem 133
~
L Let 1(Jand 1/J be any formulas (with free variables) and let Qx represent
any string of quantifiers QIXIQ~X2'" QnXn- Prove that if 1(Jand 'if! are
equivalent then so are ~ 8J1d q;",. (Hint: Proceed by induction on
the length n of q;.) Thus in proving the equivalences (la)-(4b')
~
we may
assume that the formulas have free variables but the strings Qx of initial
quantifiers are empty.
2. Use the theorem on constants (Exercise 4.8) to show that we may also
assume that there are no free variables in formulas in the equivalences
(la)-(4b').
3. Now argue for the validity of each equivalence (la)-(4b') either semanti-
cally or by giving a tableau proof. (Use Exercises 1 and 2 to assume that
the Q; are empty and that there are no free variables present.)
o Herbrand's Theorem
The introduction of Skolem functions and the reduction of any set of sentences
~ universal ones gives us a more concrete approach to the dichotomy of unset-
lSfiability and model building implicit in the completeness theorem ~r tab~eau
proofs. Consider any set S of universal sentences in a language £, WIth venous
Skolem functions already included. We also assume that £, contains at least one
conetam c. We claim that either S is inconsistent [l.e., unsatisfiable) or there
IS a model A of S whose elements are simply the ground terms of the language
t.. A1i all such terms must be interpreted in any structure for £', this is in some
sense a minimal structure for £.
~ftn·.
ItlOU 10.1: The set of ground (Le., variable-free) terms of a langu.age £, is ~l~
the HeTbrand unitJef'$e of l,. A structure .A for £, is an Herbrand structun! If Its
134 tt. Predicate Logic
Example 10.3: If our language C contains the constants a and c. a unary function
symbol J and a binary one g and predicates P, Q, R, then the Herbrand universe
Hfor£is
{a, e, f(a), fIe), ,(a, c), f f(a), f fIe), f(g(a, e)l, g(a, f(a)), g(a, f(e)),
... g(a,g(a, e)), ... ,g(f(a), f(e)), ... ,f f f(a), ... ).
We claim not only that there is an Herbrand model for any consistent set of uni·
versal sentences (or open formulas) S but also that, if S is inconsistent, then its
unsatisfiability is demonstrable at the truth-functional level via ground instanCES
of the formulas (that is, instances of substitutions of terms from the Herbrand
structure for the universally quantified (free) variables in S).
Theorem 10.4 (Herbrand's theorem): Let S = (\O.(X1, ... ,xn,)} be a set oj opeTl
JonnuJ4! oj a language l. Either
(if) ;:ere are !i'!dely. ma.ny ~und instances oj the negations oj formulas :
~se disJlmction 15 valid. (As we may view these ground tnstances
~ilt J:otn
propositional ktters, the disjunction being valid is equivalent to
114 being a truth-functional tautolDgy.)
10 Herbrand's Theorem 135
Proof: Let 5' consist of aU ground instances from £, of formulas from 5. Consider the
CST from 5' (in the language £, alone, t.e., with no additional constant symbols
added on) starting with F(o: A -.o:} for any sentence 0:. There are two possible
outcomes. First, there might be a (possibly infinite) noncontradictory path in
the tableau. In this case, the proof of Theorem 7.3 supplies us with a model A
of 5' whose elements are the ground terms of £., l.e., an Herbrand model for S'.
By definition of 5' and of tableau proofs from 5', lp(tlt··., t..} is true in A for
every cp E 5 and every tl,"" t.. in the Herbrand universe. Thus the structure
A defined on the Herbrand universe by the path is a model for S.
The other possibility is that the tableau is finite and contradictory. In this case,
the tableau is, by definition, a proof of the unsatisfiability of the set of elements
of 5' appearing in the tableau and so we have the unsatisfiable conjunction
required in (ii). Moreover, S cannot be satisfiable: A model for S is one in
which r,oi{XlJ _.• ,x ..;} is valid, l.e., true for every instance of the free variables
Xl,. _. ,X"" for every lpi E S. Any example of (il), however, directly exhibits a
set of such instances that cannot be simultaneously satisfied in any model.
Finally, by Theorem 4.8 we may manipulate the variable-free formulas as propo-
sitional letters. The unsatisfiability of the conjunction as required in (ii) is then
equivalent by propositional rules to the disjunction of their negations being valid
or a. tautology. Thus, (ii) and (ii') are equivalent. 0
Note that if S is unsatisfiable (and so (i) fails), then (ii) directly exhibits the
unsatisfia.bility of S. Thus we have a method for producing either an Herbrand
model for 5 or a particular finite counterexample to the existence of any model
of 5.
We can now give some variations on Herbrand's theorem that are particularly
useful in our study of resolution theorem proving and PROLOG. We can also
phrase our results positively to give a direct reduction of provability or validity
In predicate logic to provability or validity in propositional logic. We begin with
the special case of an existential formula.
Translating these results into the terminology of clauses of §5, we have what will
be the key to resolution theorem proving in the predicate calculus.
Theorem 10.6: A set S of clauses is umatisfiable if and only if the set S' of all
ground instances from the Herbrnnd universe of the clauses in S is unsatisfiable.
136 11. Pftdieate Logic
Proof: If some set of instances of elements of S (instantiated with terms from the Her-
brand universe) is unsatWiable, then 5, which asserts the validity of its member
clauses, is surely unsatisfiable. In the other direction, if 5 is unsetlsfiable, then,
by Herbrand's theorem [il], there is, in fact, a finite set of instances of cleuse
of 5 that is unsatisfiable. 0
The restriction in our version of Herbrand's theorem that S contain only univer-
sal formulas (or equivalently that we consider only sets of clauses) is necessary
as can be seen from the example in Exercise 1. On the other hand, further re-
stricting S to consist of only program clauses allows us to establish the existence
of minimal and Indeed least Herbrand models. (See Exercise 3.) Moreover, in the
case of a deduction from a set of program clauses, which is the case of interest
for PROLOG, we can eliminate the disjunction in the analog of Corollary 10.5 in
favor of a single valid instance. That is, if P is a set of program clauses and 8(i)
is an atomic formula, then P Fe 3:f8(i) # there are Herhrand terms f such that
p" e(fj (Ex,,,,,,, 5).
Finally, although it is not directly relevant to resolution theorem proving, we can
use Skolemization to get a generalization of Corollary 10.5 to arbitrary sentences.
This result provides a propositional equivalent for validity in predicate logic.
Proof: By Corollary 10.5, it suffices to prove that !{) is valid if and only if 3X...,8(i} is
valid. Now Ip is valid iff .....rp is not satisfiable. On the other hand, Theorem 9.4
says that --.y; is satisfiable if and only if 9(i) is satisfiable. Thus, !{) is valid iff 6(il
is not satisfiable. Finally, note that 6(i) (or, equivalently V:EO) is not satisfiable
iff 3X.....8(i) is valid. t 0
Exercises
2. Let C. consist of the constant c, the function f and the unary predicate R.
11 Unification 137
3. Prove that every set P of program clauses has a minimal (indeed least)
Herbrand model. (Hint: Prove that the intersection of all Herbrand models
for P is itself an Herbrand model for P.)
4. Let Mp be the minimal Herbrand model for a set P of program clauses in
a language 1:.. Prove that for each atomic sentence lp of L, Mp F lp iff lp is
a logical consequence of P.
5. Let P be a set of program clauses and G = --.9(£) be a goal clause. Prove
that, if P F 3X6(£) (or equivalently, P U {G} is unsatisfiable), then there
are Herbrand terms f such that P F 6(t). (Hint: If P F 3i6(X), look at the
minimal model Mp and apply Exercise 4.)
6 Let L be a language with no function symbols. Describe a procedure that,
given any secteoce e of the form '<Ix I ..• '1x .. 31/1 .. , 311mlp, with lp quantifier
free, decides if 1/J is valid. These sentences are called the 'v'3-sentenees of
the language 1:.. ( Hint: First use Exercise 6.13 to reduce the validity of 1/J
to that of 3yl ... 3ymV'(Cl'''' ,Cn,lI1t.··, Ym) for new constants Cl,···' en·
Then apply Corollary 10.5.)
Unification
We saw in Theorem 9.4 that, for fN8ry formula lp of predicate logic, there is
another one 1/J which is open, in conjunctive normal form and equisatisfiable with
'P. Thus if we are interested in the satisfiability of (sets of) formulas in predicate
logic, it suffices to consider open formulas in clausal form. The only difference
~m the propositional case is that literals are now atomic formulas (possiblY
WIth free variables and the added Skolem function symbols) rather than simply
propositional letters. Of course, a clause with free variables is understood to
be eqUivalent to its universal closure. From the viewpoint of resolution theorem
proving, the only difference between predicate and propositional logic in deducing
o from S is the problem of how to instantiate the free variables {l.e., make
substitutions) in the available clauses so that we may then apply the reduction
rule.
Of course. we could, as in the tableau proof of Herbrand's theorem, simply list
all ground term substitutions in the Herbrand structure and start running our
resolution machine with all of them as inputs. Needless to say, this is not an
efficient procedure. We need a better guide.
For example, if we have two clauses Cl = {P(!(%),y), -Q(a.b.x)} and C'l =
{"'P(f(g(c»,g(d)} we should be able to resolve Cl and C2 by directly substi*
tutlng g(c) (or:r and g(d) for y to get {~(a,b,g(c»)}. (Remember that C, is
equivalent to its universal closure 't/z'r/1J(P(f(z),y) v ...,q(a, b,z» from which we
can deduce any substitution lnstance.) The general approach to the problem of
which substitutions to make when doing resolution proofs is called unifiro!ion
(or matching). We describe it before giving the resolution algorithm for predicate
calculus. First, we need some notation for substitutions.
De8nltion 11.1: A .tub.ditution 9 is a finite set ofthe form {Xl/tt.X'J/t'J' ... ,xn/t ..}
where the X; are distinct variables and each t; is a term other than x;. If the
t, are all ground terms, we call 8 a ground substitution. If the t; are distinct
variables, we call 8 a f1!:naming substitution.
Example 11.3:
6Q
Composition is. a ~atural operation on substitutions, i.e., we want to define.
to be the substltuticn that when applied to any expression E to get E(80') gl\o~
the same result as applying a to E9, i.e., (E8)a-.
Example 11.4: Let E = P(x,1J, W, u) and consider the two substitutions 8:= {x/I(')'
yI9('), wlv} and a = {xla,Ylb,'1 f(y), vlw,.lc}. Then EO = P(!(y),g(')' "~,I
11 Unification 139
and (E8)u = P{f(b), g(1(y», w.c). What then should 8u be? Well. x is replaced
first by fey). We then replace 11 by b. The result is x/feb). y is replaced by g(z)
and then z by ley) and so we get y/g([(y)). w gets replaced by v which is in
turn replaced by tv. The result might be written w/w but this is omitted from
the description as it causes no changes. The substitution x/a in o also h-s no
bearing on the final outcome since there are no e'e left after applying 6. The
final substitution in u, ute,
however, acts unimpeded as there is no substitution
Ior a mad, by O. Thus eo ~
I_I f(b), Y/9(1(y», ale, '/ flY), vlw).
Guided by this example we can write out the formal definition of composition of
substitutions.
>eflnition 11.5:
(i) If 6 = {xt!t), ...• x"./t",} and a = {yl/Sl .... ,ym/Sm}. then Ou is the
substitution {Xdtla, ...• x"Jt"a, lidsit' .. ,11m/Sm} with any Xi/ti(J for
which Xi = t.u and any l/;/Sj for which l/j E {Xl,'" ,x,,} removed.
We now check that we have defined composition correctly and that it is associa·
tive.
n
Proof: Let 0 and o be as in the definitionaf composition and let 1/J={zl/rl"'" Zk/ }.
As the result of a substitution consists simply of replacing each variable in an
expression by some term. it suffices to consider the case in which E is a variable,
say v, in (i) and the result of applying (,,8)a and ,,(Ou) to tJ in (il).
Example 11.8: (i) Neither {P(x,a),P(b,c)} nor {P(f(x), z), P(a,w)} is unifiable.
(Exercise 2).
(;;) S, = {P(z,,), P(b,,)) end S, = {P(f(z),y),P(f(a),w)) are. however,
both unifiable. The first can be unified by {x/b} and only by this substitution.
The situation for 52 is a bit different. 9 = {x/a,Ylw} unifies 52 but so do
a = {x/a, II/a, w/a} and t/J = {x/a, y/b,w/b} as well as many others. Here 8
has a certain advantage over the other substitutions in that it allows more scope
for future substitutions. If we first applied 9 to unify S'J we could then unify
the resulting set with the expression P(f(a), c) by applying {w/c}. Had we used
either of o or T/J, however, we would be stuck. On the other hand, we can always
go from (J to o or '" by applying the substitution {m/a} or {w/b}, respectively.
We capture this property of 8 in the following definition.
Definition 11.9: A unifier 8 for 5 is a most genern.lunijier (mgu) for S if, for ever)' 12
unifier a for S, there is a substitution>. such that 9>' = <7.
Theorem 11.10: If 8 and T/J ere both mgu'" for S, then there are renaming ,,~titu-
troM a and>' {i.e., one.! that con.riJt 5Qlely of replaul'ltent.! of distinct 1J4nab/e3
by other distinct variables) such that S9(j = 5,p and 58 = S,p>..
Proof: By the definition of an mgu there are a and >. such that S8<7 = St/J and 5T/J). ~
S9. Clearly, we may assume that o and >. make substitutions only for variables
occurring in 58 and 51jJ, respectively. (They consist of the single terms EO and
12 The Unification Algorithm 141
E'iJ, respectively, as 9 and T/J both unify S.) Suppose o makes some substitution
t;lt; where t; is not a variable or a constant. In this case the complexity [e.g.,
length) or the expression E9q in S9q = {E9q} must be strictly larger than that
of Ee in S9. As DO substitutions of terms for variables [e.g .• >') can decrease the
length of an expression we could not then have ST/J>" = 89(1)'' = 89 as required.
If there were in a a substitution x.le, for some constant c, then no further
substitution (e.g., >") could return the resulting instances of c in an expression
EOa in S8(1 back to instances of the variable x, in E8 E 89. Thus. once again,
we could not have S8(1 >. = Sf} for any>.. We now know that a can contain only
substitutions of one variable by another. If o identified distinct variables by such
a substitution, then>' could not distinguish them again. Thus (1 (and similarly
A) is simply a renaming substitution. 0
Definition 12.1: Let S be a finite nonempty set of expressions. To define the disagn'l'
rrn:nt.,-et S find the first (l.e., leftmost) position at which not all elements E
of
of 5 have the same symbol. The set of subexpressions of each E E S that begin
at this position is the disagreement set D(S) of S. (In terms of formation tr~,
we find the lexicographically least node of the formation trees associated vntb
each expression such that not all the labels of these nodes begin with the same
symbol. D(S) is then the set of labels of these nodee.)
....
12 The Unifice.tionAlgorithm 143
Stop 2. D(S,) ~ {w,b},a, ~ {wjb} [so we get to (yjh(b)) alter 011).Then S,"
(P(f(h(b), g(z», h(b)), P(J(h(b), g(a», t), P(J(h(b), g(z», h(b))}.
Note that before announcing (11 we had to check that Xl was not either of the
twO occurrences of variables in /(xo,xo). For 0'2 there were four occurrences to
chock. In general D(SHtl will have twice 11.5 many occurrences of variables lIS
D(S.) and so the "occurs check" takes exponential time.
More efficient (even linear time) procedures for unification are now available
(Martelli and Montannari [1982, 5.4]). Unfortunately, all current PROLOG imple-
mentations simply omit the -cccurs check". They simply take the first variable
x in D(S..) and substitute for it the first term t other than x in D(Sk) in the
expressions contributing x to D(Sk)' Thus, the implementations believe that
S = [z, [(x)} is unifiable. (They cannot actually carry out the substitution.
They would try to replace x by [(x) and then return to x which would again
be replaced by [(x) and so on Iorever.) Needless to say, this type of unification
destroys the soundness of the resolution method. Some protections against such
incorrect deductions can be put into programs. We discuss one in 1II.2 after we
have more fully described the actual deduction procedure of PROLOG. Unfortu·
nately, almost nothing the programmer can do can fully compensate for omitting
the occurs check. We do, however, prove (Corollary 11.8.7) that certain programs
sufficient to calculate all effective functions do in fact run correctly even without
the occurs check.
Exercises
1. Apply the unification algorithm to each of the following sets to find an
mgu or show that none exists.
2. Apply the unification algorithm to each of the following sets to find rngu's
or show that they are not unifiable.
Resolution
We DOW describe how to combine unification with the resolution method for
propositional logic to give a proof scheme for full predicate logic. As before,
we consider formulas in clausal form. Remember. however, that literals are now
atomic formulas or their negations with free variables allowed. The results of
S9and §10 show that, as long as we are willing to add function symbols to our
language, every sentence has an equisatisfiab\e version in clausal form. Note that
all the variablesin a sentence S are local. that is, each clause is understood as its
universal closure. S is then the conjunction of the universally quantified clauses.
Thus, there are no connections between the variables of distinct clauses. To
reflect this syntactically, we generally rename variables when using two clauses
together so that they have no variables in common. (This procedure is called
standardizing the variables apart.)
A1> in the propositional case, clauses with at most. one positive literal are called
Horn clauses. The rest of the terminology from Definition 1.10.4 (or 11.5.1) de--
scribing progrom etcwes, rules, facts and goals, is also carried over intact from
the propositional case. Thus, for example, 80 (PROLOG) program is a formula that
contains only program clauses, that is, ones with exactly one positive literal. We
continue to use PROWG notation.
Zwnple 13.1: Consider the following list of clauses: (1)
parent (X,Y):- mother (X,y). (2)
parent (X,Y):- father (X,Y). (3)
daughter (X,Y);- mother (Y,x), female (X). (4)
son (X,V);- mother (V,X), male (X). (5)
child (X,Y)o- son (X,Y). (6)
child (X,Y);- dBughter (X,V). (1)
daughter (X,V);- father (V,x), female(X). (8)
son (X,Y):- father (Y,X), male (X). (9)
male (jim). (10)
male (tim). (11)
female(jane) . (12)
female (pam). (13)
father (jim, tim). (14)
{ather (jim, pam). (15)
mother (jane, tim). (16)
mother (jane, pam).
These clauses are the PROLOG versions of
{{parent(:r:,y), ....,mother(.:r:,y)},
{parent(:I:, y), ....,father(:r:,y)}.
{mother(jane, pam)} }.
146 II. Predkate Logic
... 11
mother(jane, pam).
De8nition 13.2: Suppose that we can rename the variables of C..! and C2}O that ~ey
have _no variabl~ in comm~n and ar~ of the form q ~{Ptt. -.::' P:n} ~~h.},
{",PsI.. '" ....,Psrn}, respectively. If (TiS an mgu for {Ptl> ... , Ptn, PSI,.' , chiiJ
then q tr U qu is a resolvent of C1 and C2_ (qo U C~17is also called the
of the parents CI and C2.)
to get
(ii) From the clauses corresponding to (3) and (16) in Example 13.1 above, we
can form the resolvent {daughter(pam,jane),...,female(pam)} by the sub-
stitution {X/pam, Yfjane}.
Example 13.4:
and
c, = l'P(x,y)"P(.,y),P(x,.)).
We exhibit a resolution tree proof with the substitutions used in the reso-
lution displayed on the branches. For clarity, we also underline the literal
on which we resolve.
------~ ;l'lu'z."z}
( ....P(z,v), ....P(v, %). P(-e.:)} {....P(v.t1),P(t1, un = C2
\ ;I'{.'.,uM
C2 ""( ....P(v,t1).P(v,u)) ( ....P(z.v), .. P(lI.%),P(;J,z))
{U,.,.,,'l\ ;I'
( ....P(z.lI) ....P(%,v),P(z,%)} = C3
FIGURE 35.
II. Predicate Logic
\/
{son(tim,jim)}.
FIGURE 36.
One can ask for the results gotten by resolution in the above examples ~
PROLOG. If one has the c1aU8e5of Example 13.1 in the database, one ent;;; the
desired result at the "1_ " prompt as "?- son(tim, jim).". One then( ~ jim)
answer yes. PROLOG interprets the question as a request to prove son tun'tered
from the database. More precisely, if positive literals OJ, O2, ••• , 0 .. a:t~n goa!
at the "7" prompt, PROLOG tri~ ~ deduce.D from the database S an(Recal~thaI
clauseG== {"'C1, •• ' ,"'C..} which 18 also written :- 01.02, •••• 0... A,.
a goal clause is one without positive literals, Le., one of th~ form :~ Ar::;.
';uch
where the Ai are positive. The reason for this terminology 18 apparent m
examples.)
If the C. are ground, then we would expect a successful deduction . ofhis' plio
0 from
SU{..,q,.", -.e..} to imply that all of the C, are Consequences of S, (T ~36
cation follows from the soundness of resolution for predicate logic, Theo~e~. are
below, With some syntactic effort it can also be viewed, in the case that tale I~:;".I
ground, lIS a consequence of the soundness of resolution for proposmulon ~- 'ables
Consider, however, the meaning of entering an atomic formula with free ": as ~
sud> es "maIe(X),lemale(Y)" at the -r- prompt, Again PROLOG takes~«YJl.
request to Prove 0 from S and the added goal clause {-,male(X),..,fe el (Xl V
Suo_ he,e nnly meens that from S we 'an conclude ,YXWI,m e(X) V
,lemale(Y)1 as the clause {'maIe(X)"lemaJe(Y)) mean, YX\lYI,m~:oLOG
,lemale(Y)]. That ts, we rond~de 3X3Y(male(X) A lemale(Y)], What dam'"
actually does IS return a substitutIOn, say X = jim, Y = Jane which on the
strates the truth of the conclusion 3X3Yfmale(X) A female(Y)j b~ S Of
infonna~ionin S - i.e. {"'maleOirn), "'Cemale(ja.ne)} is inconsistent. wl~h ~b8t
COurse, In applications it is almost always this correct answer substitution
we reaUy want, not the mere 8B8ertion that 3X3Y(male(X) 1\ female(Y)J.
DeDn;tion 13,5, Up;,. P'<>gnun and G ~ {,A" ... "An} e goal do"",,:::
~at the substitution 9 (for the variables of G ) is a correct amwer $UbJ~ rs&l
2
If (AI A A A ... A .4,.)8 is a logical consequence of P (that is, of its uJUVt!
closure),
13 Resolution 149
Proof: Suppose, for the sake of a contradiction, that A F S. Let the notation for a
resolution be as in Definition 13.2. It suffices to show that if A F C1> C2 and C
is a resolvent of 01> O2 then A F 0, l.e., A F CT for every ground substitution
T. (If so, we could show by induction that A 1= C for every 0 E 'R.(S). As 1<.(8)
contains 0, we would have the desired contradiction.) The only point to notice
here is that if A F Oit then A F Cin; for any t7i as the 0; are open. For every
ground instantiation". of the variables of C :;:Cia U C~uwe can argue as in
the propositional case. (See Lemma 1.8.12 and Theorem 1.8.11.) As, for each
ground instantiation"., either Ci/1". or C~t7".is true in A (depending on whether
the literal resolved on is true in A or not and in which of the C;". it appears
positively), then so is their union C".. 0
We now want to prove the completeness of the resolution method for predicate
logic by reducing it to the case of propositional logic. We begin with two lemmas.
The first (Lemma 13.7) relates single resolutions in propositional and predicate
lcgte. The second (Lemma 13.8) extends the correspondence to resolution proofs.
This lemma (which is often called the lifting lemma as it "lifts" proofs in propo-
sitionallogic to ones in predicate logic) is quite useful in the analysis of restricted
versions of resolution in §14 and Hl.I. The special case of proofs of 0 is especially
useful and is singled out as Corollary 13.9.
Lemma 13.7: If Ci and q are ground instancu (trio. the substitutions 81 and 82)
of C1 and C2, respectively, and 0 is a resolvent of and c: c~,
then there is a
resolvent C of Ct and C2 .wch that C' is a ground in.!tarn:e of C (via 8182 if
C1 and C2 have no variablu in common).
Proof: A1; the resolution rule allows us to rename the variables in C1 and C2 as part
of the resolution, we may as well assume that they (and so also fh and 82) have
no variables in common. As Ci "'"Ct81 and ~ "'" C282 are resolvable, say on the
ground literal P(tl, ... ,tn), there are sets of literals
and
150 II. Predicate Logic
which become unified to {P(th"" tn)} and {-.P(t" ... ,tn)} by fh and 82, re-
spectively. A8 the sets of variables in 81 and 92 are disjoint, 9192 unifies both
sets of literals Al and A2 simultaneously. Thus, by the definition of resolution
for the predicate calculus (Definition 13.2), C = ((Cl - AI) U (C2 - A2))17 is a
resolvent of Ct and C2 where a is the mgu for
given by the unification algorithm. The only point left to verify is that C' is lID
instance of C. We claim that C' = C9.92. Note that as 9192 unifies -.A1 UA2, the
special property of the mgu given by our algorithm (Theorem 12.5) guarantees
that 17919<J = 9192. Thus
c
C9192 = ((CI - Ad U (C2 - A2))l79192
= ((C1 - Ad U (C2 - A2))9t92
= (C191 - A19t} U (C292 - A292) (by disjointness of variables)
~ (C; - (P(t" ... , tn))) U (C; - {_P(t" ... , tn))) P
= C' (by definition). 0
o
T
Lemma 13.8 (Lifting lemma): Let 8 be a formula in a language £:. and let 5' be
tM .Jet of all ground instance.JI of clawes in 8 in the Herbrand universe for l. P
If T is a resolution tree proof of C' from 8', then there is a clause C of L,
a ruolution tree proof T of C from S and a substitution 9 such that T8 =' r
(i.e., T and T' are fabeling" of the same tree and Co9 = for Ci, c:
~e c;
rupective labels of each node of the common tree underlying T and T'. Thus, III
particular, C' "" C8). Moreover, if the leaves of T' are labeled R; and each R.
i.J an instance of an 5i in 5, then we may arrange it so that the corruponding
lea1Je3of T aN! labeled with f'entlmings of the appropriate 5i•
Proof: We proceed by induction on the depth of resolution tree proofs from 8'. F~r
the base case of elements 14 of 51, the lemma is immediate as each such R; IS E
a substitution instance of an element of S. Consider now a proof of C' from S'
of depth n + 1. It consists of two proofs T' and X' (of depth < n) of ground
c1a"c~C'
--= l' C'fr2 om
S' and a final resolution
'1
of C' 2and C' to get
-, C. SUPr-
-
that P(tlo"" tn) E Gi, ",P(h"" ,t'l) E q and th1at we r:SOlved on this literal
to get
C' ~ C; U C; - {P(,,, ... , 'n), _P("' ... ' tn)).
By induction, we have predicate clauses CI and C2 proof trees T1 and T2 of Cl
and OJ and su~tutions 91 and 82 such that Tj8i =' r:.
(The leaves of Ti ~ also
~abeled appropnately by induction.) At the cost perhaps of renaming vanables
In T1 and T2, we may assume that 91 and 82 have no variables in common. {As
13 Resolution 151
the resolution rule allows for arbitrary renamings of the parents, the T; re'llain
resolution proofs. As our lemma only calls for the leaves to be labeled with some
renamings of the given clauses from S, this renaming does not alter the fact that
we have the leaves appropriately Iebeled.) We now apply Lemma 13.7 to get a
resolvent C of C1 and C2 with C' = C8182' We can now form a resolution tree
proof T from S of C by combining T1 and T2. As 81 and 82 are disjoint, 1'8182
restricted to T and T, simply gives us back T181 and T,8,. Of course, on the
1
remaining node C of T we have C818, = C'. Thus T is the required predicate
logic resolution proof from S' of C and 8182 is the substitution required in our
lemma. 0
orollary 13.9: If T' is a resolution tree proof of 0 each of whose leaves L; is labeled
with a ground instance ~ of the clause Sit then there is a relabeling T of the
underlying tree of T' that gitJe8 a resolution proof of 0 each of whose leave$ L;
is labeled with (a renaming) of Si.
roof: This is simply the special case of the theorem with C' = O. The only point to
notice is that the only clause C that can have 0 as a substitution instance is 0
itself. 0
roof: Let $' be the set of all ground instances of claw>es in S in the Herbrand
universe for the language J:. of $. By one of the consequences (Theorem 10.6) of
Herbrand's theorem, S and S' are equisatisfiable. Thus if we assume that $ is
unsatisfiable, then so is 8'. By the completeness of resolution for propositional
logic (Theorem 1.8.15 or 1.8.22) we then know that 0 E R.,,(S') where we use 'R.p
to represent the resolution procedure in propositional logic. (As usual we consider
the atomic formulas as propositional letters in this situation.) The completeness
?f resolution for predicate logic [Le., 0 E 'Ro(S) if S is unsatisfiable) is now
munediate from Corollary' 13.9. 0
:xercises
2. Translate the following sentences into predicate logic, put them in clausal
form and prove the stated conclusion by resolution:
II. Predicate Logic
a) Suppose all barbers shave everyone who does not shave himself. More-
over, no barber shaves anyone who shaves himself. Conclude that there
are no barbers.
b) Suppose John likes anyone who doesn't like himself. Conclude that it
is not the case that John likes no one who likes himself.
Translate (i)-(iv) into predicate logic. Use resolution to answer the follow-
ing questions:
(i) All the stockholders who will have real estate partners will vote againSt
the proposal but no others.
14 Refining Resolution: Linear Resolution 153
(ii) john and jim (and similarly mary and jane) will form real estate part-
nerships if some bank will give them a loan unless none of the lawyers
can get them the needed zoning variance.
(iii) No banker will give a loan to form a real estate partnership without a
lawyer's getting the needed zoning variances. With such an assurance
they require only a good appraisal to agree to the loan.
(iv) john and jane are stockholders.
(v) joyce is a lawyer who can get zoning approval for anyone with enough
money.
(vi) john is immensely wealthy and his and jim's land has been given a
good appraisal.
Translate these sentences into predicate logic, put them in clausal form
and use resolution to deduce that someone will vote against the proposal.
Who is it?
FIGURE 31.
The linear resolution for the following familiar example (1.10.2) is illustrated in
Figure 38.
{p(x), ~q(x))
.:
o
FIGURE 38 .
DeHmtIoD
• '. 14.2: In thIS context, the elements of S are frequently cal J-->'
t:U mpu t dauses.
C
If we extend the Pillent---child terminology by defining the ancestors of 8. clau; we
in a resolution proof of C from S to be the clauses above it in the tree proo ,
14 Refining Resolution: Linear Resolution 155
can rephrase the definition of linear deduction by saying that each Cj is resolved
against an input clause or one of its own ancestors to produce CHI.
The intuition here is that we consider a formula S e UNSAT. In this case the
"cause" of the unsatisfiability has been isolated in U (which "supports" the fact
that S E UNSAT).
IOtem 14.4: IJ S E UNSAT and U is a set of support for S, then there is a linear
refutation oj S with support U.
OUt first step is to reduce the proof of Theorem 14.4 to the case in which every
nonempty subset of S is a set of support for 8.
of (of Theorem 14.4): Our plan nOWis once again to reduce the p~ to the case
or Pro . 10 • bel w) As In the case of
POSit nal Iogie. (We supply a proof for this case o· . bl d has
::neral resoiution, we apply Herbrand's theorem. If S is unsat;lS;; :n':it has
s pport U, so is 8', the set of all ground instances of elements 0 ~ to show
uPport U', the set of all ground instances of elements of U. We wish I
that . . rt U' lifts to one rom
S . any hnear reeoluncn proof 1" of 0 from S' With suppo the lifting lemma.
'!'helrithliffsupPOrt U. This' IS immediate from Coronary
_~ __ 1 •
13.9 to .'
tree and so lifts linear
mg lemma preserves the shape of the retlUIutlOD th leaves of the
proofsto linear proofs. It also lifts instances Rt of c1aUSeJSo on e
156 11. Predicate Logic
tree to (renamings of) Si. Thus if the clause CO of the proof T is in V' and ill
'
is an instance of a clause C in U, then it lifts to a (renaming of) the same
clause C. 0
We now turn to the proof of the strengthened completeness theorem for linear
resolution in the propositional calculus. The proof here is more difficult than for
semantic or ordered resolution but is connected with the set of support and Joel:
resolution methods considered in the exercises for 1.9.
Prool (of the Propositional version of Theorem 14.4): By Lemma 14.6, it suffi~
to consider only those S that are minimally uDSatis6able. (Any linear resolutkm
refutation of 8' ~ S with support Uns' is one of 8 with support U by definition.)
We proceed by induction on E(8) = the excess literal number 0/ 5, that is, the
number of occurrences of literals in all clauses of 8 minus the number of clauses
in S. (Note that we need S to be finite to even define the excess literal number.)
We in fact prove by induction that, for any C E S, there is a linear refutation of
8 that begins with C, i.e. C = Co in the proof tree. At the bottom, if E(S) = -1,
DES and there is nothing to prove. Suppose now that E(8) ~ O.
Case 1. C is a unit clause, t.e., it contains exactly one Iiterall. There must be a
clause C' E 5 with L E C' as otherwise any assignment satisfying S _ C
(which is satisfiable by the minimality of 5 ) could be extended to one
satisfying S by adding on t: Note that t ~ C' for if it did, C' would be
a tautology and 5 would not be minimally unsatisfiahle contrary to.
~ur
assumption. Thus C' - {i} is in st by the definition of SL (Defimtlon
1.8.16). If C' = {I}, we are done as we can simply resolve C and C' to
get D. Su~pose then that c: = {i, ...} has more than one literal. As S,E
UNSAT, S t E UNSAT by Lemma 1.8.19. Each clause removed from S ~
forming 8 has at least one literal (i) (again by definition). Thus the!1
removal cannot increase the excess literal number. On the other hand, at
least C' loses one literal (l) in its transition to st. Thus E(SL) < E(S).
E,
We next claim that st is also minimally unsatisfiable: Suppose D E gt
but st - {D} is unsatisfie.ble. Now, by the definition of SL, DES or
D U {l} E S and in either case ilf. D. Let D' represent whichever clause
~Ion.gsto S. We know, by the minimal unsatisfiability of S, that S_ {D'}
IS satisfiable. Let A be an assignment satisfying it. As C = {t} E S _ {D'},
AFt. Consider now any F E 5t - {D} and the associated F' E S _ {~!'
As A F i and A Fe F', A F F in either case of the definition of P. (F IS
defined from F as D' was defined from D.) Thus A F st _ {D} contrarY
to our assumption.
Our induction
t hypothesis now gives us a linear resolution deduction of 0
from 5 5~gWithC'_{i}: (Q1,B1 }, .•. ,(C .., B.. ) with Co = C'-{ll
Each B. IS a member of st or is Cj for some j < i and C.., B.. resolve
14 Refining Resolution: Linear Resolution 157
Case 2. C = {f •... } has more than one literal. Now consider Si. As above, it
is minimally unsatis6able and has lower excess literal number than 5, We
thus have, by induction, a linear resolution deduction of 0 from SI starting
with C - {f~.If we add on t to every center clause and to any side clause
which is in S but not 5. we get aUnear proof of {f} from 5 starting with C.
Consider now 5' = S-{C}u{ {t}}. It too is unsatis6able. (Any assignment
satisfying it satisfies S.) As C bas more than one literal, E(5') < E(8).
Now as 0 ~ S', for any 5/1 ~ 5', E(5"):5 E(5/).1( we take 5" ~ 5' to be
rninimaJly unsatis6able we have, by induction, a linear resolution proof of
o from S" ~ Su {{til beginning with {t}. (Note that S' - {t} ~ S - {e}
is satisfiable by the minimal unsatisfiability of 5. Thus, any unsatisfiable
subset 8" of 5' must contain {f}.) Attaching this proof to the end of the
ODeof {f} from 5 gives the desired linear refutation of S starting with C8
:ercises
5. Give the definitions and prove the soundness and completeness theorems I
for the predicate version of lock resolution (Exercise 1.9.1).
F
Suggestions for FUrther Reading
To see how predicate logic got its start, read Frege [18791 in van Heijenoort [1967,
2.1J.
For more on the predicate logic versions of tableaux, axioms and rules of in.
Ierecce, resolution, natural deduction and sequents, see the references to these
topics at the end of Chapter I.
The basic development of model theory (beyond the few theorems given, he~) J
can be found in Chang and Keisler 11990, 3.41 or any of the other texts ~ l~
3.4 of the bibliography. A wide-ranging current view of much of the subject IS
given in Hodges [1993, 3.4J.
To see where Herbrand universes and unification come from, read the first few
pages of Herbrand [1930J in van Heijenoon [1967, 2.1J or Herbrand {1971. 2.31.
To see Herbrand's theorem used as a basis for the exposition oflogic, see Chang
and Lee [1973, 5,7J, Many varieties of resolution can be found there; see also
Loveland [1978, 5.7J and Bibel {1987, 5.71.
The standard text on the theory of PROLOG is Lloyd {19B7, 5.41 which also has
an extensive bibliography. Other Suggestions for reading about PROLOG can be
found at the end of Chapter Ill.
II
lROLOG
8LD-Resolution
In this chapter we consider the full PROLOG language for logic programming in
~redicate logic. Much of the basic terminology is simply the predicate logic ver-
sicn of that introduced in 1.10. We, nonetheless, restate the basic definitions in a
form suitable for resolution theorem proving in the predicate calculus. PROLOG
~mploysa refinement of linear resolution but we have made the presentation
independent of the (ratber difficult) completeness theorem for linear resolution
(:theorem 11.14.4). We do, however, assume familiarity with the definitions for
linear resolution in Definitions 11.14.1-3. Thus our proofs are based on the anal-
ysis of the propositional version of PROLOG discussed in 1.10, together with Her-
bra:nd's theorem (11.10.4) and the reduction of predicate logic to propositional
logic that it entails. At times when a knowledge of II.l4 would illuminate certain
Ideas or simplify proofs, we mark such alternate results or proofs with an *.
~I from 11.5.1 that a PROLOG program P is 8 set of program clauses, Le., ones
:-"~thprecisely one positive literal. We ask questions by entering a sequence of p0s-
Itive literals A ..... , A", at the II 1- "prompt. The PROLOGinterpreter answers
the question by convecting our entry into a goal clause G = {...,Al, .. ·,...,An}
and asking if P U {G} is UDSatisfiable. We now describe the way in which PRO-
~ discovers if P U {G} is unsatisfiable. Our starting point is the method of
linear resolution introduced in 1.10 for propositional logic and proved complete
for predicate logic in U.14. We next restrict ourselves to an input version of lin-
ear resolution. Although this is not in general a complete version of resolution
(as can be seen from the example following Definition 11.14.1), it turns out to
~ complete in the setting of PROLOG. For the remainder of this section P is a
LOG program and G a goal clause.
We now know the general format of resolution proofs for PROLOG: linear input
resolution. Before continuing to examine the additional refinements implemented
in PROLOG, we should note (and this is usually true of implementations of all res-
olution methods) that when G = {"Ao, ... ,.,An} and C = {8, .,80,' .. , ...,Bm}
are resolved, say on Ai = B via mgu 9, the interpreter does not check to see
if perhaps some resulting duplications should be eliminated (e.g., A 9 = k9
j
or Aj9 = Bt9 or B,,9 = Bt9) . It simply replaces .,Ai by .,Bo, ... , -.Bm and
then applies 9 to each term. It does no further simplification. To understand ~he
actual implementations, we should therefore think of clauses (as the machine
does) not 8S sets of literals but as ordered clauses, te., sequences of literals. A
resolution 8S above then inserts the literals -.Bo, ... , -.B". in place of -.A, and
applies 9 to each literal in the sequence to get the next (ordered) goal c1~~.
This ordering of clauses does not cause any serious changes. We embody It iD
the foUowing definition and lemma.
Deflnition 1.3:
(i) U G "" {-'Ao, ... ,-.A..} and C "" {B, -,Bo, ... , -.B } are ordered c1a~
m
and 9 is an mgu for A; and B, then we can perform an ordered resolu!l~n
of G and C on the literal A,. The (ordered) resolvent of this resolution 15
the ordered clause {"".Au, ... , .,Ai_h .,Bo, ... ,-.8 , .,A + ... , -.A,,}8,
m i lt
Note that this ~ethod does not employ the strategy of collapsing literals. We
resolve on one literal from each clause and remove only these two literals from
the resolvent.
Proof: Consider all (ordered) ground instances pi U G' of the (ordered) clauses in
PU{G} in the appropriate Herbrand universe. By Herbrand's theorem (Theorem
11.10.6)PuG' is unsatisfiable. By the compactness theorem (11.7.9), some finite
subset of P' u G' is unsatisfiable. M all sets of program clauses are satisfiable
(Exercise 11.5.6), any such subset must include elements of G', Le., instances
of G. Let pi' u Gn be an unsatis6able subset of pi u G' of minimal size. By
minimality there is a G" E Gil such that pIt U Gil - {Gg} is satisfiable. By
Lemma 1.10.11, there is then an LD-resolution refutation of P" U Gil starting
with 0'6' By Lemma. 1.5 below this can be lifted to the desired LD--refutation of
PUG. 0
'Proof: Let P' and {G'} be the sets of unordered clauses corresponding to P and {O},
respectively. The proof proceeds by a simple induction on the length of the L1-
refutation of P'u{G'}. Note, however. that one u-eeectcncn may be replaced by
~ sequence of LD-resolutiona to compenaate for the collapsing of literal.!lallowed
In u-resolution. We leavethe details as Exercises 1-2. 0
Lemma 1.5: The lifting lemma holth for LD---f'eSolution proofs. More preci3ely 11.13.7
/wld.! for ordered resolutiofl.!l; 11.13.8 holds for LD---f'eSolutionproofs; and 11.13.9
holds for LO-resolution rejutatiofl.!l.
Proof: The proofs are essentially the same as in 11.13.The lifting of a single resolution
(11.13.7) is, however, somewhat simpler in that no collapsing of literals occurs
here (and so the parameters n1 and n:J are both equal to 1 in the proof). In the
proof of the lifting lemma itself, we note that. for linear resolutions, an induction
on the depth of the tree is the same as one on the length of the proof. The leaves
of the tree are the starting clause and the side clauses. We leave the details of
rewriting the proofs of 11.13 in this setting as Exercises 3-5. 0
Definition 1.7: A selection rule R is intlanant if. for every (ordered) clause C and
every substitution 8. R(C8) := (R(C»8.
Proof (for invariant selection rules): We argue exactly as in the proof of Lemma 1.4
except that we apply Theorem 1.10.13 in place of Lemma 1.10.9. We then apply
the lifting lemma for SLD-resolutions with an invariant selection rule (Exercise
6). 0
We could now supply a direct but fairly complicated proof of Theorem 1.8 for
arbitrary selection rules. It is somewhat simpler to instead prove a lemma. as-
serting an independence result: given an Lo-refutation starting from O. we can
find an SLDone via any selection rule R. The general form of Theorem 1.8 woul.d
then foUow directly from Lemma. 1.4. The proof of this independence result IS
itself somewhat technical and we postpone it to Lemma 1.12.
roof: We proceed by induction on the length of the sLD-refutation. For the base
case of a refutation of length one, G ::=: Go = {...... =
A} and Co {B} are singletons
with 6 an mgu for {A} and {B}. As B E P. it is a logical consequence of P as
is its substitution instance B6. As 6 is a unifier. 86 = A6 which is then also
n
a logical consequence of P as required. Suppose now that G = {...,~,... , ...,A }
and Pu{G} has an sLo-refutation of length n+1 starting with Go = G and Co =
{B, .....B , ,...,B } and a resolution on ...,Ai with mgu 60' The resolvent Gt =
o m
{...,~, , Ai_ll BO Bm, Ai+l' ' ...,~}60 has an SLD-refutation from
P of length n with mgu 6' = 6t ••• 6n. Thus, by the induction hypothesis, G1606'
is a logical consequence of P. Let 6 = 606'. As Co E P, C06 is also a logical
consequence of P. Now C 6 is equivalent to (B06 A A 8,.,.6) -> 86. So by
0
propositional logic, {.....
~6, ... , ...... B6, ......
Ai_16, ...... AH16' An6} is then also a
, ......
consequence of P. As 6 = 606', 6 also unifies Ai and B, t.e., Ai6 = B6. Thus G6
is a logical consequence of P as required. 0
The answers supplied by sco-reeotoucoe are, in a sense, all the correct ones
there are.
Theorem 1.10 (Completeness of implementation): Let R be a selection rule. If P F
(AlA ... A An)u and G =
{Al""'A,.}, then there is an SLD-refutation T =
({ G , C )1 i $. n) of P U {G} via R with answer substitution 6 and also a
i i
substitution t/J such that GO" = G61/!.
Proof (for invariant selection rules): We prove by induction on the length n of an SLD-
refutation of PU {Gu} via R that there is a refutation with answer substitution
(J and a t/J such that 0 = 6t/J on the variables of G. Choose a substitution "'f
instantiating all the Vlloriablesof Go to new constants (Le., ones not appearing
in PU{G}). As PF (At A ... A An)O' it is clear that PU{GO''''f} E UNSAT.Let
T = «(Gi.Oi)l i < n) be aground SLo-refutation of PU {Ga;} via R. By the
invariance of R, reversing the substitution I (i.e., replacing the constants by the
original variables) gives an SLo-refutation T' = ( ~.C:)l i < n) of PU {Gu}
via R In which the unifiers tPi restricted to the variables in GO' are the identity.
The ground refutation can also be lifted, by Exercise 6, to one
T'=((G':.~')li<n)
of p U {O} with mgu's 60,... ,6n. Suppose that R selects the literal Ai from G.
We can now apply the induction hypothesis to
and
c; = { .....
Ao6 •... , ...... Bo.I90,·.·,
Ai_tBo, ...... ...,Bo,mo60,.....Ai+160'···, ....,An60}
0
as Gi = G'tatPo = G','t/JoO' (remember that GutPo = GO' and, as O't/JO unifies
An end B • 6 O'1/Jo=~t/Jo). Thus, we have an sLD-refutation of P U {ott} via
o 0
164 III. PROLOG
R with mgu's ~ ... /Y., and a >" such that 8i ... e:.>.' = 0" on the variables in
G't. If x occurs in G = Go. but x80 does not appear in G1, then x80 does not
appear in OJ,, ... ,/Y.,. Since 90fT = 0 on the variables in Ao, we can extend ).,'to
)" by setting >.(x) "" o(x) for each variable x in Ao such that x80 is not in 0';.
Then 90~ ... ~>."" CT on aU the variables of G, as required. (Keep in mind that
p
¢OCT = IICT for II occurring in G.) 0
1b provide proofs for Theorems 1.8 and 1.10 for arbitrary selection rules, we now
prove the independence lemma, as promised. We begin with a basic procedure
to change a single choice of literal in an LD-refutation.
Lemma 1.11 (Switching lemma): Le! G = Go = {.... Ao, ... , ....An} and let (Go,Co),
... , (G., C.) ~ an Lo-rejutation of P U {Go} with answer substitution !/J =
VJo ... t/J.- Suppose that AjtPo ... ..p~-l is the liteml resolved on at step s > O.
There u then an LD-rejutation (Go, Cb),"" (GI., C~) of PU {Go} with answer
.tub.dilution 9 = 90", 6J: in which we resolve on Aj90" . (J._2 = AjtPo··· !/J.-2 nt
slap .t - 1 such that G9 is a renaming of G1/J .
Proof: Let C, = {B, •.....B"o, ... , ....,Bt,ma for i $; k. Let G~_l = {.... Au, ....,A~.... , -,AD
where AjtPo ... tP~-2 =0 Aj, and Suppose we resolved on A~ at stage s - 1. Thus
G~={....,AO,....,Ai,... , ....A~_h ....B._t,D, ... , ....B~-1,m._l •.....A~+l' ... , ....AaW~-1and
?~+l is ,p. applied to the result of replacing ....A; = ..,Aj, by ..,B.,o•... , .... 8"...,
ill G._ (Recall that by the definition of LD refutations, ..,B.,o, ... , ....B~,m, haw
no variables acted on by W.-to) We know that Aj,tP~_lW~= B.W. = B~,p.-l,p.
and so we can unify Aj, and B.. Let W;_l be the corresponding rngu ~d.let
A be liuch that W~-lt/J.= ¢;-l>'. We now replace step s - 1 of the Original
refutation by this resolution. We want to show that we can resolve with C,_l on
the literal A~1/J~_lat step s with mgu '1/1.. If we can also show that the result
of this resolution is a renaming of G.+I, ;e can continue the refutation, modulo
renamings, to get the desired result.
'!'e ~t note t~at. from oU,roriginal refutation, A~¢._l= 8._1 W.-l' combin~
109 t~ fact with the relation for>. above we can get the following sequence .
iualltles: A~?/J;_l)" = .A:.?/J.-ITP, = B'_l¢~_lt/J. = B .._1"'~_1A. Thus A;
es A~!/I._l and B~_l = B'-1t/J~_1 (by convention, B,_1 has no variables .
on by 1/1.-.). We may therefore resolve on ti' .IJ with rngu Wi as required.
W; also >" ~'II~-l' h va
e get a sU~hthat A = "':>'" _ Combining the equations for )", ~ a,
"'~-11/J. = V'.-1W:>'. If we can now prove the existence of a substitutiOn ~
s.uch that t/J;,I'ltt. ~ 1Ji.-IW.rp', then, by Exercise II.H.4, we will have est &7
hshed that 1/J~_1 t/I" 18a renaming of W.-I1/J. as required to complete the proe ~
T~e argument for the existence of !.p' is similar to that of A'. We knoW thai
A .. 'tI,_I¢; = B~-I¥t:_l!Jl, while in the original proof 1/J~-1 is an mgu for ~
and B._I, Thus there is a!.p such that .,.' .,J = .1, ,n We next note tha+
At. IJi - At 1/1' !JI, 'i-'I_l'll. 'i-'~-lr' and
8" ~-1!P - j' .-1 ~ = B~¥I,1/J~_1= B~1/J~_IIp. Thus 'P unifies Aj,1/J~-l ..1
~¢~-l' As 1/J~in the original proof is an mgu for tbis unification, there is a If
such that Ip - 1/JqI Co b' . see that
.1,1 .IJ -.. m uung this with the first equation for 'P, we 0
'i-'~-t''II~"" W.-l1/J.rp'as required.
1 SLD-Resolution 165
selectionrules 0
Exercises
1. Pro", ebe following lerom" If G Is an o,dered goal
program 010_, G' .. d C' tbe uno,d,red 010_ "",.,ponding
01._. C an o,dered
onte to G .. d
C, reepecetvely (t.e., th' union of the ele .... nts of the "",u ) and th'
goal clause D' Is an u-eeso lvant of G' and C'. then th,re Is a "",uente
of LD-,esolutions ,tortlng with G and C and ,ndlng with an ordered goal
1.4.
3. Prove Lemma 11.13.7 for ordered cla.uses and Lo-resolution.
4. Prove Lemma 11.13.8 for ordered clauses and Lo-resolution.
test ,- p(X,X).
P(X,J(X)).
~d the question "?- test." PROLOGwill answer "yes.". What has happened here
ISthat the theorem prover says that to verify "test", we must verify p(X,X~.
As p(X, f(X)) is given, it suffices to see if p(X, X) and p(X,/(X)) can be un~
Jied. The unifier answers that they can. As no further information is needed (
inst·t .............e ..._"to
anne e 1oC)~, lor example) the theorem prover gives the answer r-:
our question. Thus, it gives an answer that is not a logical consequence of the
program - a violation of soundness.
A key point in the above implementation is that the theorem prover did no~ have
to. car? out the .substitution {XI f(X)} implicit in the unifier's answer. If It b~
tried, It ~uI~have ~all~n in~ the endless loop of trying to output the results
the substitution, This SituatIOn is illustrated by the program:
If we now ask "7- test1(X).", tbe result oftbe looping is displayed as PROLOG
tries to give the "correct" answer substitution of X = f(J(J( .... (Hit control-
break to stop the dlspley.) This type of failure can also occur undisplayed in the
search.for an SLD-resolution. Consider the program:
In this case, the only indication that something has gone wrong is that no answer
is forthcoming.
Unfortunately, these problems may well occur in natural programs as well. Of
course, both of these problems could be eliminated by implementing the uni-
fication algorithm correctly. As there are now reasonably efficient (i.e., linear)
unification algorithms, this is not an unreasonable expectation. For now, how-
ever, one can fairly easily eliminate the first type of problem in favor of the
second. One simply writes programs in which any variable appearing in the head
of a clause also appears in the body. This can be done by simply adding X = X
to the body (or any variable X in the head not already in the body. The first
program would then become
Now, when the theorem prover tries to resolve on p(X,X} and P(X, f(X)) and
~e unifier says they are unifiable, the prover asks for the substitution so that
It can put the expression resulting from X = X into the goal clause in place
ofP(X,X). As the substitution is circular, it never gets to complete the proof.
Thus, this simple programming trick will restore the soundness of the PROLOG
theorem prover (at the expense, of course, of taking longer to run). Completeness,
however, is another matter.
The SOurceof the incompleteness of the PROLOG implementation is the method
employed to search for an sLD-refutation. Suppose we are given a program P
and a goal clause G. We wish to find an sLD-resolution refutation of P U {G}
~inning with G. At each step i of the sLD-reso1ution, the only choice to make
18which clause in P to use to resolve on the leftmost term in our current goal
claUseGi. We can thus display the space of all possible SLo--derivations as a
!ree: the root node is labeled G and if a node is labeled G' then the labels of
It successors are the results of all possible choices of clauses of P for the next
resolution on the leftmost term of G'. We call such trees SLD-treu for P and G.
As a simple example, consider the program Pi below:
168 Ill. PROLOG
The SLD-tree for PI starting with the goal clause G = {-,p(X, X)} is displayed
in Figure 39. Along each branching we indicate the clause of Pi resolved against.
The convention is that the successors are listed in a. left to right order that
agrees with the order in which the clauses used appear in Pl' Sueass patJu,
corresponding to yes answers, are those ending in D. At the end of each such
suc:cesspath we put the answer substitution given by the proof (of 0) represented
by the path. A path is a failure path if it ends with a cleuse G' such that there
is no clause in P with which we can resolve on the leftmost term of 0'.
~p(X,X)
Y
",(X, Y), ",(X, Z)
~ ~,(X)
(3y' I(4) \(~) \(1)
o
{X/b)
failure failure 0
{X/b)
0
{X/a} I
-,r(a,a)
failure
FIGURE 39.
We see here that, of the six possible paths, three end in failure, two end with
the correct substitution {X/b} and one with the correct substitution {X/a}.
T~ PROLOGtheorem prover searches the SUr-tree for a success path by al~YS
trymg the leftmost path first. That is, it tries to resolve the current G WIth
the first clause in P that is possible. In Figure 39 it would simply follow the
path (1), (3), (6) to get the correct answer substitution {Xjb}. If the theorem
prover hi~a failure point [l.e., not 0 and no resolution is possible) it backtrack'·
:=:
Baclrtre:cking means retracing the path one has just followed until one finds li-
With a branch to the right of the path being retraced. If there is DlO:e
one .such path, take the leftmost one. The theorem prover repeats this
backtrackmg procedure until a success path is found.
2 Implementations: Searching and Backtracking 169
Copiesof printouts for runs of the programs Pi (and other programs listed in this
section) are included at the end of the section. We also include printouts of the
runs with "tracing". (Tracing is a facility supplied with most implementations
of PROLOG that displays the actual steps of the search of the sue-tree. It is
an important tool for understanding the flow of control in a program and for
debugging. Note that items of the form .._Oonn" are just names for variables.)
If, for example. we omit clause (3) from the above program Pi to produce P2,
we get a new SLD-tree as pictured in Figure 40.
r
~p(X,X)
~J
~q(X, Y), ~r(X,Z) ~,(X)
(i ~) ~J
'r(a,Z) ~r(a,Y),~r(X,Z) ~q(X,a)
I I (i ~'J
-.r(a,a)
failure 0
failure (Xla)
I
failure
FIGURE 40.
In this case. the theorem prover first tries the path (I), (4). failure. It then
backtracks to --.q(X. Y). --.r(X. Z) and tries (5), failure. It then backtracks all the
;~~ . ...,p(X.X) and tries (2), (7), (4), success to give the answer substitution
~p(X,X)
;Y ~
~q(X,Y), ~,(X,Z) ~.(X)
I'y' (.)[ \(5) \(1)
,,(b,Z) ~,(a,Z) ~,(a, Y),~,(X,Z) ~q(X,a)
(6')1 I I I'y' 1,)1 ~')
...,r(a, a)
""r(6, Z) failure failure 0 0
(6')1 {Xlb) {Xla}
1
failure
FIGURE 41.
~ises 7-8 we use a unary function symbol s (with the intended meaning
r of") to define a counter beginning with the constant O. Thus 0 cor-
:tio~
~~ to 0, s{O) to 1, 8(8(0» to 2, and in general sft(O) (= 8 ... 8(0) with n
of the. function tl) corresponds to n. Do not try to use the built-in
rnetlCoperations supplied with PROLOG.
1. :rite a program to calculate the length of 8 list using this counter. Try
on a couple of inputs: [e, b,e], (a,b,e, [b,el, [d,e, eJJ. What happens when
you try to find a list of length three?
9. Recall the procedure in II.5 for defining a knight's move on the chess hoard.
Do not use any built-in predicates (Le., no arithmetic, no cut, no "not")
in writing the programs for (a)-(c).
10. Write a program for the function FLATTEN that strips off all brackets from
a list except the outermost, i.e., it returns a list of atoms in the order in
which they would appear on the page when the input list is written out,
ThegoaJ
?- tc(a,b).
",,:ill SUCCeed. exactly when the pair (a, b) is in the transitive closure of t~e
hl,nary relatIOn T as defined in Exercise 11 of II. 7. How do you reconcile~
with the result of that exercise? (This problem is also relevant to gxercse
1.8.)
e) Can you lind more than one such ancestor? Should you be able to do 50 if
all were well with the database?
d) Use this program to find four of levi's great-great-great-grandchUdren.
removed of Y.
f} Find seven second cousins once removed of libnl. Can you tell or guess and
verify what relation they are to the people listed in (d)?
g) Find three third cousins twice removed of libni. Can you predict from your
program how they are likely to be related to libni {i.e., what routing is
taken to find these instances)?
14. Various anomalies may creep into your results when implemented with an
actual genealogical database. Consider bow the following typical problems
with such databases might affect your programs.
a) The same data may be recorded twice. For example, the fact fa-
therof(abraham,isaaC) appears twice in the database. Will this cause
any wrong answers to be reported? What effect if any will it have on
running a program such 85 the one for ancestor or for nth cousins m
times removed?
b) Different people may have the same Dame and not be distingUished in
the database. (Try to see who is the father of enoeh-] How will this
affect the ancestor and cousin programs? Can you devise B method for
identifying people in the datab~ tha.t might be used to eliminate or
reduce the impact of this problem? (Hint: Consider using a counter.)
Try the father of enoch again. Also see if you have eliminated all
solutions to ancestor(X,X).
116 m. PROLOG
c) The same person may appear under more than one name, We know,
for example, from other Biblical passages that eseu is seir. How will
this affect the ancestor and cousin programs? What could you do
(short of editing the data file) to correct for such a situation? Can
you add rules to the database that would take care of this problem
without editing the database? (Examples in the database used for
trying your solution out are finding the grandfather of lotan and the
cousins of bori.)
Runs of Programs Pi - P4
PROGRAM Pl.
?- IbtiaS·
(2) FAIL: r(b,..ll261n>
ph ..U :-
q(J.,B) , (1) IEDO: q(b •• )?>
dJ.,cl. (0 EXIT; q(", ..n>
p(J..J.) ;_
(3) C1LL: r( ... ..ll261l?>
.(U.
(3) FAIL: d .. ,..o26D?>
q(b, .. ) .
q(a,"). (D aEDO: q( ..... )?>
q(l.B) :- (4) C1LL' r( ..,..ll255n>
r(...B) .
(4) FAIL: r< ... ..o265)!>
r(b,A),
(1) FUL; q<"0085 •..o255)?>
.(A) :-
..
(5) CALL, .Cooa5)!>
'l(l.a) .
,
?~ p(I.I),
(6) CALL: q(.1lO85 ...
(6) £IIT: qu.... n>
rr >
I ... _;
•• (D) 1EDll; p(b,b)?
,.. (Ii)
(6) UDQ,
IliDD: .(b)?>
'l(b •• )?>
,..
1- I... b(fall), (6) JUIT: 'l("''')?>
,..
(&) IUT: .(.)?>
1- .py(p/2).
•• (0) EXIT: p( ..... )?;>
X ... _;
1- pLt,IL
•• (0) REDO; p(.... )? >
•• (0) CALL, P(..llOll& •.ooa5)'l'>
(Iii) l£lIO: .(a)?>
c» CALL, 'l(..D085 •..ll25Sl?>
(6) aEOO, 'l( ••• )'!'>
(1) ElIY; q(b, .. )?>
(7) C1LL: r(a.a)?:>
(2) CALL: r(b •..D26t)1>
('I') FAIL, r(a.a)?>
(2) £lIT, r(b •..ll261)?>
•• (0) DIT: p(b.b)1>
(6) FUL: q(..ooes.a)?>
X • b ..... ; (5) FUL, .C.D08S)?>
•• (0) FJ.Jt., pLOO8S• ..D06S)'!'>
•• (0) 1£00: p(b,b)?>
,..
'1.(1,.) .
(4) un, I(.>?'>
.. (0)snr p<-,.>?'>
,.
1- p(l.I:).
.. I • I ......
••
;
(0) JKIHl: p(.,,)?>
,..
!- tnt •. (4) lEllO: s<&)?>
(6) UDO, q(I •• H>
1- althS'
P(l,l) :_ ,..
q(.1.I) •
r(l.C) . ..
1_
,r-
leub(full).
,..
P(l,l) :_ sPJ(p/2)·
1(1) .
q(I>,.) . !_ p<I.I),
q(I,I>' •• (0) CALL: p(..oo511•..oo611)?>
q(l,l) ,..
(1) caLL' q(.0060,..o220)1>
r(l.ll.
r(l,l) :_
(1) un, q(I>,aH>
(2) CALL; r(l ••..D239H>
r(b .1).
1(1) ;_ (3) CAU' r(I>•..o239)?>
,..
'1(1,.) . (4) ClLL: r(b,..D239H>
(5) CALL' r(b •..D239)?>
!- p{I.X>.
178 m. PROLOG
PROGRAM Pi.
? 1htbS·
p(A,A) :_ ?- p<x,X>.
ICA) . .. (0) CALL: p(-OOSD• ..oo5D)'l')
pCA,A) :- (1) CALL: a(_005D)?>
qCA,B),
(2) CALL: q(-OOSD,a)?)
rCA,C).
(2) £lIT: q(b,a)?>
q(b,a).
q(a,a) . CD ElIT: ICb)?>
q(A,8) ,_ •• (0) EIIT: pCb,b)!>
rCa,l).
I· b _;
reA,8) ,_
.. (0) lEIlO: p(b.b)!>
r(b,8) •
(1) lEIla: I(b)? >
I(A) :_
q(A.I) . (2) lEDO: q(b,a)!>
,.. (2)
(1) EIIT:
ElIT: q(I,I)?>
I(a)?>
?- p(I,X>.
I • b _, •• (0) £lIT: p(a,a)?>
I • a _;
,..
•• (0) Jt.EJlO: p(a.a)!>
,..
?- laaah(:f\llI). (2) UDO: q(a,a)?>
,.,
?- ·P,(p/2). (4) CALL: r(b,a)?>
We have seen that the success of an execution of even a semen tlIC ally correct 'on
PROLOG program depends in many ways on the specifics of the implementatlth~
So far, the only control we have had over the path of execution has been case
ordering of clauses in the program. We know, for example, that :h~ base facts
of a recursion should always Precede the inductive case (why?). SllntlarJ~, ~"n
trol
about a Predicate should generally precede the asserted rules. Such heurts. tICS .......'
however, go only so far. At times we might wish to exercise more ~etailed sly" fer
over implementing the searching of the SLD-tree. Sometimes this IS "mere of
the sake of efficiency. At other times there just seems to be no other way cb
getting a program that will run at all. In this section we consider one su
built-in control facility _ cut.
Syntactically
write: cut, written "!", appears to be simply another literal. Thus we
3 Controlling the Implementation: Cut 179
It does not, however, have any (declarative) semantics. Instead, it alters the
implementation of the program. When the above clause is called in a search of
the SLD-tree, the subgoals ql. Ib, I, lJ3 , q4 are inserted at the beginning of our
currentgoal clause as usual. We try to satisfy ql end Ib in turn, as before. If we
succeed, we skip over the cut and attempt to satisfy qa and q4 . If we succeed
in satisfying qa and qc all continues as if there were no cut. Should we, however,
fail and so by backtracking be returned to the cut, we act as if p has failed and
~ are returned by "deep backtrocking" to the node of the st.n-tree immediately
above that for p, called the parent goal, and try the next branch to the right out
ofthat node. (H none exists, the current search fails as usuel.]
t,-p.r. (1)
t,-.. (2)
p:- Qllq:z,I,qa,q4. (3)
p:- U, tI. (4)
q,. (5)
q,. (6)
•. (7)
u. (8)
:g
lI'orse t. 1...-
ru . ye, It could prune all the success pat..... n
down an Infinite path - demonstrating the
I this case we lUI
~com:~
bothIII much as in the analysis of depth-firfit searclJin:g· I
1 ness of the sea.rch
it might prune
Y ill answer sno"
aUSuccess paths and all infinite paths. In this case PROLOGod an O",·u-·
"he n . . t can intr uce ..... ~
unse I.D fact P U {G} is unsatisfiable. In this way cu hat P U {G} Is satisfiable.
undness into programs, as a "no" answer means t
180 III. PROLOG
~,
~~
~p,~r ~s
-e..
>
(3) ~
~q2,I, -vs,~q",~r
~
<.
(.) "- «77')
<.
o
(5)1 success
~q2,!,~q3,~q4,-,r
(6))
', ~q3,~q",~r
(~<ll failure
failure
FIGURE 42.
Nonetheless, cut can be very useful if extreme care is taken w h en USlI~ . it Some i
en-
implementations of PROLOG have other facilities for controlli~g the unp ef~ut.
tation of searching. One such is called .!nip. It acts as a restricted form 0 ch
For example, when a clause 11:- 01, q:l:, [!q3, q,,!}, qs is encountered, the:en
progresses normally through the snip (q,,), that is, through the c~uses d . f the
the exclamation POints. Should backtracking return you to the right en .0. at
snip, however, it instead skips over the snip to return to /l2:. Although th15l~
times a convenient tool, we see in the exercises that a snip can always be rep an
by a use of cut. In general, we simply warn the reader- be very careful, cut the
have unexpected consequences. At the very least, uses of cut that subvert. fly
declarative selDantics of the Program should be avoided. We do, however, bne e
consider one important use of cut- defining negation-as a lead-in to sam
other topics.
We see here that if not(A) is called, PROLOG turns to the first clause defining it
and cells A. If A succeeds, we pass over the cut and hit "fail". "fail" is a built-in
predicate that always fails (and so could be replaced with any other clause that
always fails). Thus, if A succeeds, not(A) fails. On the other hand, if A fails, we
try the second clause defining not(A) and it succeeds.
In fact, the tables can often be tumed. Many uses of cut can and should be
replaced by uses of "not" • We say "should" because "not" can have some declar-
ative sense in PROLOG programs (even though not the classical one) while cut is
much more problematic. We explore the theoretical semantic underpinnings of
PROLOG's use of "not" in §6. In order to do that, however, we first make a start
on dealing with equality in §5.
1. In Exercise 2.4 what would be the effect of inserting a cut, !, between the
two literals in the body of clause (2) on your answer to (b)7
Recall the list notation introduced in Example 11.3.15. Consider the fol-
lowing program APPEND for appending one list to another:
(al) a(lI,Y,Y).
(02) a(lX I y],Z,IX I WI) ,- a(Y,Z,W).
For the rest of this section P is a PROLOG program and G a goal in a languag~
t: All clauses and resolutions are ordered. We let P' and G' be the set of gro~
instances of P and G, respectively. SLo--proofs mean ones using the stand.
selection rule. The basic property of the program P that we wish to cherecteree
is given in the following definition:
(;) A I I . . (nfiQitil'C
eve mapptng for P IS a function f from the atomic sentences r-:-teral
ground literals) of r.. to N. We denote the value of this function on ~ lieleer
A by [All, called the level of A with respect to f. If the function / IS
from the context, we Omit the subscript.
(iii) Pis aceeptabk with respect to a level mapping / and a model M 0/ P if for
every B:- A in P, i.e.• every ground instance of a clause in P, IBI > IAil
for each i :5 M (A). P is acceptable if it is acceptable with respect to some
level mapping and model.
To grasp the idea behind this definition. consider first a level mapping without
any mention of a model. It is then clear that. if P is acceptable, every ground
resolution of a goal clause G = {.....
Al •... , .....An} with a clause in P gives a resol-
vent of lower level than G. This modified notion of acceptability corresponds to
the condition that all LD-proofs from P starting with G are finite. (See Exercises
1-2.) The restriction to sr.n-proofa will be captured by the restriction to literals
A; for i :5 M(G) by the right choice of the model M. The basic idea is that, if
A.}. then no st.n-refuteuon starting with G can
there is no SLD-refutatlon of {.....
get beyond Ai. Thus there is no need to consider later literals in an analysis of
the SLD--treefrom G. On the other hand, if there is no SLD-refutation of {..... ~},
there is a model M in which Ai is false. Thus the right choice of model will cut
off the level function precisely at the point at which one need not consider any
moreliterals.
To begin our analysis we define. from a given level mapping / and model M of
P, the required well ordering of clauses. We must consider first the ground goal
clauses and then certain nonground ones.
lefInition4.3:
Proof: The "only if" direction is immediate. Suppose then that there is a T as described
in the lemma. Let t be a number larger than any element of 'T. If C- E G1, then
there are at most n elements in the sequence IC-I. By the choice of T and t, each
of these elements is less than t. Thus there are only finitely many sequences of
the form IC-I for G- E G'. As every finite set has a maximum in any ordering
we are done. 0
Our next task is to prove that any acceptable program that starts with a bounded
goal must terminate. As the ordering induced on the goal clauses is a well or-
dering, it suffices to show that resolutions with clauses in P decrease the levelof
the goal cleuse. We begin with ground resolutions.
Proof: We proceed by cases. First, suppose that M(G) = 1, t.e., M;! AI and so by
definition ICj "" (IAII). As we resolved G and C, B = At and it is false in M by
assumption. As C E P', it must be true in the model M of P. Thus, Bi must be
false in M for some i ~m and so by definition M(H) ~ m. As IB.I < IAII.for
every i :S m by acceptability, [HI < IGI = IAI) by the definition of the ordenng·
Next suppose that M(G) > 1. In this case H and G succeed in M for the first
time at the same literal, i.e., M(H) = M(G) + m _ 1. Thus the sequence IHI
has the same elements aslGI except that tAtl is replaced by the set of elements
IB;I for 1:S t S m. As jB.1 < IA[ for each i it is clear from the definition oftbe
extension of the level mapping to clauses and the ordering on these sequences
that IH) < IGI as required. 0
Lemma 4.6: Let P be acceptable lUith respect to a level mappi.ng / and a mod~
M. liG = {-,AIt ... ,-,An} is a bounded (lUith 1'e.fpect to f and M) goalll_
H == {-,Bt, ... ,-,B"., ....A2, •••• -,An}8 an SLD-resolvent of G with J011le » c
{B, -,B\, ... , -,Bm} in P, then H is bounded and IHI < IGI.
Proot: Consider any sLD-proof from P U {G} starting with G = Go. Each successive
resolution produces a new goal clause Gn. By Lemma 4.6, the sequence IGnl
is strictly decreasing. As the ordering on goal clauses is 8 well ordering, the
sequenceof resolutions must be finite. 0
Proo!: The corollary follows from the theorem 88 every ground goal is by definition
bounded. 0
leanition 4.9: If the stu-tree from P U {G} beginning with G is finite, N(G) is the
DUmberof its nodes; otherwise, N(G) is undefined.
(ti) for every goal clause G G if bounded with re.spet:tto f and M if and only
if every SLD---proof fro':'
P U {G} beginning with G is finite.
~f; Wedefine the required level mapping I and model M by setting IAI = N({:-,A})
for each atomic sentence A of £. and requiring that .M ~ A ~ the~ IS an
SLO--refutationof P U {...,A}. Note that, as we are assuming that IS left- 1'.
terminating,l is well defined. Also by the completeness of SLD--resolutlOD,each
atomic sentence A is true in M if'and only if It is a logical consequence of P.
Wenow prove that I and M have the desired properties.
[Ii] Let G be a bounded goal clause. Suppose, for the sake of a contradic~,
that there is a nonterminating SLD-proof (Go, Co), (Gl,Cd, ... starting
with G = Go. For any n, we can (starting with (Gn, e..))find a substitution
othat grounds all theclaWleS of (Go, Co), (CI• C1) •••• , (o...e ..). Thisgive;
an SLD-proof beginning with the ground instance GO of G of length n. As
n was arbitrary, this contradicts the assumption that G is bounded.
Finally, suppose that every SLD-proof beginning with G terminates. Notice that
the sun-tree from My goal clause is finitely branching: Each immediate su~
of a fixed node corresponds to a clause in the finite program P. Thus, by Komgs
lemma (Theorem 1.1.4) the SLD-tree for G is finite. Suppose it has n nod~.
Again, as every SLD-tree has branchings of at most the number of clauses III
P, there can be st.o-teeee from ground instances of G with arbitrarily ~
numbers of nodes only if there are ones of arbitrarily large depth. Thus, if G IS
not bounded, there is an SLD-proof beginning with a ground instance of G of
length n + 1. The lifting lemma for SLD-proofs (Exercise 1.6) then lifts such a
proof to one of l~~ n ~ 1 beginning with G. &. this proo.f ~ust be a patb o~
the SLD-tree begmmng WIth G we have the desired contradiction.
As an example we show that the program PERM for deciding if one list is 8. ~r.
mutation of another is left-terminating. The language of our program ~o~
of a constant r] for the empty list and the binary list combining functi~ .
of Example 11.3.15. We also use the alternate notations and abbreviations mtro-
duced th~e 8~ch 88 [a] llb,c,d] for [a,b,c,d]. The set of ground terms ~j
language, r.e., Its Herbrand universe H, consists of the closure of the coast !
under the 1i5t combining operation. The program for PERM includes a progralll
APPEND (consisting of (a1) and (82) below) for appending one list to another as
well as two clauses (pI) and (p2) defining PERM from APPEND:
(a1) a(l], Y, Y).
(a2) a(lXIYj,Z,IXIW)) r-. aWZ W).
(PI) P([I, Ii). ' ,
(p2) p(X, /Y, ZJ) ,- .(w, !YIV),X),.(w, V,U),p(U, Z).
Now not all LD-proofs from PERM starting with a ground goal are finite (.Exe::;
3) but we show that PERM is acceptable and so all stu-proofs startiJl.g
ground goals terminate.
createan artificial model that embodies just enough to cut off the resolutions
when needed. We define M with universe H by saying that p(x,y) holds for
every x, 31 E H and that 0.(3:,31, e} holds iff Ixl + Iyl = [e]. It is obvious from the
definitions that M is a model of PERM. We prove that, with this choice of level
mapping and model, PERM is acceptable.
We only have to check ground instances of Clauses (&2) and (p2). For (82) just
notethat,for any x, 31 E H, 1311 < Hxlyll by definition. Thus for any x,y, z, wE H,
I»(x, (., xl)l ~ Ixl + 1I.lxll + I> la(w, 1.lvl,x)1 ~ min{lwl, Ixl)·
If Iwl + 1[3111111'" lxi, then we are done by our choice of M and the definition
of acceptability. Suppose then that Iwl + 111I1vll = Ixl and so Iwl :::; Ixl· Thus
Ip(x, (.,x})1 = Ixl + 1I.lxll + I > iwl ~ la(w, v, 0)1. Once again we are done anIess
Iwl+ial = lal .. well.ln this , ... , 101< [e] and ec i»(x, [.,,})I ~ Ixl+II.lxll+1 >
luI + l[ylzll + 1 = ]p(u,z)1 as required to complete the proof of acceptability. 0
As acceptability implies left-termination, we have shown that PERM running with
the standard implementation of PROLOG will terminate on any ground clause.
As the logical consequences of PERM are the intended ones by Exercise 5, PERM
will terminate with a correct answer on any ground goal. Thus we have a proven
method for checking if one list is a permutation of another. More interestingly,
we can use the characterization of termination In terms of boundedness to prove
that it can do much more. For example, by starting with a goal of the form
'! = {""p(x, X)} we would hope to be able to find all the permutations of a given
list x. To see this, it suffices to prove that G is bounded. We prove much more.
Theorem. 4.13: For all ternu t, tI, ... tn of r., l!!tIl!!ryyoal G {-.p([tl
I tnl,t)} is
l •• ·'
bounded (with respect to the ~vd mopping and model oj the proof oj Theorem
'.12).
Proof: For any ground instance 0'1 of G, 10'11 = n + m + 1 where m = It"}'l· As the
length of t")' is constant for any ground substitution rt, G is bounded. 0
Many other types of goal clauses can be proven bounded for PERM. See, for
example, Exercise 7.
188 III. PROLOG
Exercises
Deftnition :
(i) P is terminating for a goal 0 if all t.n-procfs from P U {O} starting with
G are finite. P is terminating jf it is terminating for every ground goal G.
(ii) P is recummt with respect to a level mapping f if, for every da~
A:- Ab.·.,An. in P, IAI > IAil for each 1:5 i:5 n. Pis recumntif
it is recurrent with respect to some level mapping.
5. Prove that the logical consequences of PERM of the form p(x,y) for :t,Y E B
are the intended ones.
7. Suppose G 0::: { ..... A1, .•• , .....A,.,}. Prove that, if each A. is bounded (with
respect to some level mapping and model), then so is G.
5 Equality
Until. now, we ha,:: ignored the whole question of mathematical equ~ity. (~~
that in PROLOG, t1 = ta" is used to mean that t1 and t~can be umfied.)
t'
une l._~ • • tedeed 8
uc.:l come to at least face the problem of "true" equality for It IS 1
The basic Propenies of equality (in a language C) are captured by the follo~
Definition 5.1: The equality axiom$ for c.
5 Equality 189
(1) x ~ x.
(2) Xl = Yl A ... 1\ Xn == !In ...... f(%1>'" .Xn) ::=:f(Yl •. ··• Yn) for each n-ary
function symbol f of I:.. •
(3) Xl =YlA ... AXn::=:!ln ......(P(Xl •... 'Xn) ......P(Yl, ... ,Yn» for each n-ary
predicate symbol P of 1:, (including the binary one "=").
We can now think of these axioms as being added to any set of sentences we
are dealing with under any proof system. Thus. by a tableau refutation proof of
a sentence S with "=" in its language. we mean one from the set of sentences
S. where S· is S plus the universal closures of (1)-(3) for all the function and
predicate symbols of S. Similarly. a resolution refutation of S is one from S·.
Unfortunately, simply adding in these clauses makes for a very inefficient proce-
dure. We return to this point shortly when we consider more specialized methods
such as paramodule.tion.
The next step is to decide on the intended semantics for equality. Here there
are two choices. We can treat equality as we did all other predicates and simply
require that the interpretation of "=" be a two-place relation that satisfies all the
~uality axioms. From the proof-theoretic. and so the PRoLOG point of view, this
18 the only approach on which we have any real handle, and within the confines of
a fixed language, it is all we can say about equality. On the other hand. from an
abstract mathematical point of view we would like to require that "=" always
be interpreted as true equality. •
We can. in fact. require this of our interpretations and still prove all the basic
theorems of 11.7 as before: soundness. completeness. compactness. etc. The only
problem arises in the proof of the completeness theorem. In the proof of Theorem
I~.7.3. our construction via the CST gives us a structure in which the interpreta-
tion of "=" satisfies all the above axioms but this does not guarantee that it is
true equality. The solution is to divide out by the equivalence relation induced
by "=" . To be precise, let A be the structure determined by a noncontradictory
path on the CST for a given set of sentence S. The elements of A. we recall.
are the ground terms t of a language £; . We define a relation E on them by:
t1 :: t ¢> A 1= tl ::=:t2. Using the equality axioms. it is easy to see that E is an
2
equivalence relation [i.e., t E t for every t; if h E ta, then h E tl and if tl E t2
and t2 =: ea, then tl := t3)' We then define a structure B for 1:, on the equivalence
classes of :=. That is the elements of 8 are the sets of the form [t 11 = {e] t E t I}
for each h E A. The functions and relations are defined on B by choosing rep-
resentatives and referring to .A : 8 1= p([th [tnD # A F P(h,· .. ,4.) (for P
I' •••
other than u=") and f8([th •... , (tnJ) == If.A(tb'·· .tn)}· Of course "=" is ~ter·
preted as true equality in B. At this point, one must check: that these delinitlOllS
190 Ill. PROLOG
are independent of the choice of representatives (that is, the elements ti chooen
from the sets {til). The final step is to show by induction, as we did for A, thai
B agrees with every signed statement on the path used to construct A. Thus B
is the required model for 5 in which "=" is interpreted as true equality.
Definition 5.3: An equality structure ior a language £ with "=" is any structure
for C that satisfies the equality axioms. Similarly, an equality model of a $et 1)/
sentencu S of £ is an equality structure for £ in which all sentences of S are
true. An equality resolution (or tableau) proof from S is then one from SpillS
the equality axioms.
The soundness, completeness and compactness theorems for resolution (or teb-
leaux) are then by definition true for equality interpretations and proofs. In terDlS
of actually carrying out equality resolutions with any sort of efficiency, however,
we are considerably worse off than in the original case. There are simply too
many new rules. At this point we give one revised resolution rule to handle
equ&lity that goes a long way towards alleviating the problem.
!he inference scheme (paramodulation) we want will take the place of the equal-
Ity ~ioms ~2) and (3). That is, we want a rule (like resolution) which, whe~
combined With resolution, will be complete for equality interpretations: If {~
e} E S and S has no equality model, then 0 is derivable from S using resolut~
and paramodulation. (The point here is that S may mention "=:" but cont8Ul
no eqUali~ axio~ other than x = x.) The basic idea is that if we have a e'::,
fr:
1
0 COntaining a hteral L(t, ... ) in which a term t occurs and a clause C2 (
no V&l'iablesin common with Cd containing t = s, then we can conclud~
1 2
and O not only C) U C2 but also the modification of GI U C2 in whIch .
0 ep1ace
Lr t by s in L(t, ... ). Of course we need not replace t by s everywhe~ L"
. Thus we want to co id ._--. r'bysln .
. ' llSJ er replaCement of a single occurrence 0 he
(O~v)IO~IY, multiple replacements can then be generated by repeated uses of t of
t'"b' ysmL.. e use L[t/sJ to represent the result of replacing some one occurrence
As with resolution, we may also collapse literals via unification before applying
the substitution. Here it is necessary to separate these operations.
Ileflni.tion5.1: Suppose we can rename the variables of C1 and C:l so that they have
no variables in common and Ct is of the form {L(h), ... , L(tn)} ue{ and C2 is
of the form {rt = 8), ...• rm = 8m}UC~.IfO'"t is an mgu for {L(tt), ... ,L(tn)},
/12one for {rl = 81>"" rm = 8m} and o one for {ttO'J, rt0'2}, then any clause of
the form
{L O'tO'[tIO'"lO'" / 8l0'20'"]}U Cf (/10' U C20'"20'"
is a parnmodtdant of Cl and C2•
The proof is very much like that for resolution alone and we omit it. The general
P~lem of dealing with just equality is quite complicated. It. is a we~-develo~
subject on its own that of rewrite rules. The problems of mtegrating equa.h~
~th PROLOGor more general theorem provers is an as yet underdeveloped toprc
of current research that lies beyond the scope of this book.
6 Negation as Failure
The CWA arises naturally in the context of databases. If we are given a data~
of grades for students in the math department, we may have reason to bebeYe
that it is a correct and complete list. Thus if the fact that Jones got an A
· M a th ...,."
In
'00 d "
oes not appear. we may reasonably . 1~'
assume that It IS ':"l~", The
extension of this principle to a setting such as PROLOG with rules as well as data
leads to the CWA for a program P: If a ground atomic formula (positive literal)
A is not a logical consequence of P, then we may infer .....
A.
The .lirst thing to note here is that the CWA deals with the abstract notion of log-
'a\. ~
IC consequence or, eqUJvalently, provability in some complete proof systems
predicate logic. By the undecidability of provability in predicate logic (Coronae:
8.10), however, we Cannot hope to implement such a rule even in theory· Th
closest we can expect to COmeis to conclude ..... A when we have a proof that A
· t I '--'
IS no a cgrcar consequence of P. For a PROLOG-like system such a prOO rrug
f 101M
reasonably cons~ of a finite si-n-tree starting with the goal .....A in which even:
branch
· ends a failure. In this case we know that there is no sLD-refutation stefl
·hthe·' _
mg Wit gwen goal. The completeness theorem for sr.n-rerutenons (Thellr
6 Negation as Failure 193
1.8) then tells us that A Is not a logical consequence of P. Such a tree is called
a finitely failed SLD-tree for P U {A}.
The usual Implementations of PROLOG only check for a finitely failed SLD--tree
via the standard selection rule. For theoretical analyses, however, we are better
olf considering a more general definition which has a clearer semantic content.
To this end, we have to consider refutation search procedures that do not follow
the standard rule or even any selection rule that always chooses the same literal
from a given goal. (See Exercise 2.)
We begin with a generalized notion of a selection rule that makes its choice of
literal at any step based on the entire history of the proof up to that point rather
than on just the current goal clause.
lellnition 6.1:
We now give the formal definition of the sun-tree associated with a given goal,
program and generalized selection rule.
),llnit'Ion 6.2: Let P be PROLOG program, G a gcel clause and R a generalized
selection rule. The associated sr.o-eee (from P starting with G via R) is a
finitely branching tree T labeled with goal clauses such that each path of T is
associated with an SLD proof via R. We define T by induction. The root node
of T is labeled with G. If any node a of T is labeled with a goal clause G'
and the generalized selection rule R chooses the literal ...,A from G' given the
proof associated with the path through T leading to G', then the Immediate
successors of o correspond to the clauses Ci of P which can be resolved with G'
on ..,A. These nodes are labeled with the results of resolving G' on ....A with the
corresponding clause Ci of P. (The proof associated with the path to a successor
of G' is the one associated with the path to G' followed by the appropriate
resolutjcn.]
Note that, in general the stu-tree associated with some P, G and R may be in-
finite. Some paths m;y succeed, t.e., end with 0 (success) and so be (necessarily)
finite refutations of G from P. Others may be failed, Le., there is no clause of
P with which the final goal can be resolved on the selected literal. Other paths,
however, may never terminate.
We can now approximate the set of literals A that are not logical co~uences
of a program P by considering those for which the search for a refutation of A
fails in a finite and hence observable way.
194 III. PROLOG
Definition 6.3:
(i) The sun-tree associated with P, G and R is finitely failed if it is finite and
every path ends because of a failure to find a clause of P with which the
selected literal can be resolved. (In particular no path ends with success,
i.e., D.)
(ii) The SLD finite failure set of a PROLOG program P is the set of ground
atoms A such that there is a generalized selection rule R such tha.t the
SLD-tree associated with P, {..,A} and R is finitely failed.
Definition 6.4: An si.o-prcot (via R) is fair if it is either finite (and so either failed
or a successful refutation) or, for every occurrence of a literal Q in the proof (say
in Gi), either R selects Q at step i or there is a stage j > i at which Q8i ... 8j_1
is selected by R, where 8" is the mgu used at step k of the proof. A generalized
selection rule R is fair if every SLD-proof via R is fair.
Theore~ 6.5: For a progrom P and ground atomic formula A, A is in the SLD-fi~itf
failun: set of P iff the SLD-tree for A via R is failed for every fair gene~ed
selution rule R. Thus, there is a finitely failed SLD-tree for A wing any seledWfl
role if and only if the SLD-tree fOT A is finitely failed for any fair generatizd
"elution rule.
Proof: The "if" direction is immediate from the definition of the finite failure ~.
Suppose, therefore, that A is in the finite failure set of P and R is allY fll1f
g~eralized selection rule. We wish to prove that the suo-tree via R starling
With {.,A} is finitely failed. We prove a stronger lemma by induction. 0
Lemma 6.6: Let P be a PROLOG program and R a fair generalized seledion nJe·
II'!.agooJ.clause .G = {..,At, ... , ...,Am} haJ a finitely failed SLO-trU of depth ~
": any ~enertW:ed selection role) and (Go, Co), ... , (On, Cn) is an SLD~
fro P tIIa R with Gn = G, then every path on the SLD-tree via R that h
(Go, Co), ... , (Gn, Cn) a.s an initial "egrnent is finitely failed.
fair there is a node on Q at which R chooses A.9 for some substitution 9. By our
assumption about A., no clause of P has a head that can be unified with A.9.
Thus the path Q terminates with a failure at this point. As Q was an arbitrary
path on T with the specified initial segment, T is finitely failed below this point.
For the induction step, let A. be the literal chosen at the first level of the given
finitely failed sun-tree S of depth k + 1. The first level of S then consists of all
the resolvents of all re;olutions on A. with clauses in P, Each node at this level
then has the form
where 9 is the mgu associated with the appropriate resolution and clause C of
P. Note that H has a finitely £ailed stn-eree of depth k.
Now let Q be any path on the sto-eree T via H starting with (Go, Co},·'"
{Gn.,C } with Gn. = G. Again, by the fairness of H, there is some level, say
m -1, n of Q at which we first select a literal of the form A.t/J coming from A. in
G. Let (Go, Co}, ... , (Gm,Cm) be the path up to the point at which we have
performed the resolution on A.t/J. The last resolution on this path was with some
C E P whose head unified with A.t/J and so with A •. The proof of the switching
lemma (Lemma 1.11) shows that Gm is a renaming of the clause H on the
first level of S that corresponds to Cm-I' As starting a finitely failed sco-eee
is obviously invariant under renamings, Om starts a finitely failed sr.n-cree mof
depth k and we can apply the induction hypothesis to (Go, Co},··" (G" .. C )
to conclude that Q is finitely £ailed. 0
In. view of Theorem 6.5, we may assume that we have specified any fair gener-
alized selection rule R to define our SLo-trees. It is now reasonably clear how
a PROLOG-type system equipped with an implementation of a. fair R should
a~taek a question 6Sking for negative as well 6S positive conclusions. We start
With a clause G oontaining both positive and negative literals. We then carry
out an sto-proot via R except that when we select a positive literal A we try
to COnstruct a finitely failed SLD-tree via R starting with A. If we succeed, we
eliminate the literal A and continue. If we fail, the attempt a.t refutation of G
f~ls as well. We formali2e this procedure as SLDNF-re£utations (SLo-refutations
With negation 6S failure).
Deftnition 6.7:
this ease, there must be a finitely failed sun-tree (via R) starting with the
goal ...,A. We then have G'+i equal to G. with A deleted, C. plays no role
and (}i is the identity.
Before describing the relationship between negation as failure and the CWA, we
introduce a more general. approach in terms of "compkted databases" (CO.B).
The idea here is that, when one specifies the conditions under which sometbmg
occurs, one specifies them all. In terms of a particular program P, suppose we
consider one n-ary predicate r and all the clauses of P with r in their heads:
To deal with equality, we include in Comp(P) the basic equality axioms (1)-(3)
of§5 for the language of P. In addition, the database point of view dictates that
distinct terms (names) represent distinct objects. We incorporate this point of
view (to the extent possible in first order logic) by including the following axioms
in Comp(P) as well:
(4) I(X1o ... , x,,) 1:- 9(Y1o ... , y",,) for each distinct pair of function symbols 1
and 9 of arities n • m ~ O. respectively.
(5) t(x) f x for each term t(x) (other than x itself) in which x occurs.
(6) l(xlt ... ,x,,) = I(Yl •... , y,,) -t Xl = til 1\ ••• 1\ x" = 11" for each n-ary
function symbol I-
This completes the construction of Comp(P) from P. Every clause in P is clearly
a consequence of Comp(P) and so Comp(P) 1= P. Moreover, if P is a PROLOG
~rogram, Comp(P) is consistent. (Again, the Herbrend structure in which "="
15 interpreted as true equality and every other ground atomic formula is true is
a model.) We can now use Comp(P) to prove soundness and completeness the-
orems "justifying" the negation as failure rule. We begin with a lemma relating
unification and the equality axioms (1)-{6).
Proof: (i) We proceed by induction on the depth of the finitely failed SLONF-tree
starting with G. We begin with the case that the tree is finitely failed at its first
level.
Now consider the inductive step. Suppose that G has a finitely failed SLDNF-t~ee
of depth k + 1. If R(G) is a positive ground literal L, then the sr.o-eree starting
with -.L is finitely failed and Gt is G _ {L}. It has a finitely failed SLONF-tree of
depth k and so by induction, Comp(P) F Gt• AB G contains G), Comp(P) F G
as well.
Finally, s~ppoae R(G) is a negative literal L = -,r( St. ... ,sn). (Again we adopt
the notation of the definition of Comp(P).) Each immediate successor Hi ~fG
on level 1 of th~ given failed SLONF-tree is the result of applying the approp~3te
mgu 8,: to G with L replaced. by -eo. ... ,-.q':,n; (for i ~k). Each has 3.failed
SLDNF-tree of depth 5: k and so, by induction, Comp(P) F Hi for each 1 -= ~.
It thus suffices to prove that Comp(P) F AH,: -4 vxc. To see this, it suffices m
turn to prove that
Now by the definition of Comp(P). -.r(sl, ... , sn) can fail to hold only if 3YI' S·
3~p,
(.tl = ti,1A ... /\ sn = t,:,n A qi,t/\ . " 1\ q':,n;) for some i ~k. By LeU:i11136.,
this can happen only if there is a Y that unifies Sj and t.,; for each j ~n as well
6 Negation as Failure 199
as witness q;,1A ... A qi,n;' As 9; is the mgu for this unification, the assumption
that (~i,1 V ... V --.qi,nJ9; implies that there are no such Y as required. 0
As the first step in defining the set of atomic formulas true in M, we declare
r([tl}, ... , (t,,]) true if there are Si E (til such that .....
r(sl •...• Sn) appears as a
literal in one of the goal clauses G.... Note that this immediately makes M I:
3X(A1 A ... A A.) (as the (classes of the) terms in G provide the witnesses).
Our next, and most critical, claim is that the set S of atomic facts declared
true so far satisfies the "only if" direction of the axioms for predicate letters
in Comp(P}. Suppose ....r(,flJ ... , ,f,,) first appears as a literal in the goal cla~
Gm. By the fairness of R. there is au> m at which ....r(sl,.", s")8,,,.,. 8~IS
selected, Note that ....r(sl •... , s")8 ... ,,. (Ju = ..... r(s),., . ,9n)80'" 8" by the usual
convention on the choice of variables and mgu'a. At that step it is replaced by the
literals (....qi,l, ...• "q;, .. ;}8u+1 (= (.....
qi,t. ... , -,qi,n;}(JO ' , ,6,,+d from the body of
the appropriate clause of P. As 8"+1 is an mgu for this resolution, each q..lb+1
is in S. So by Lemma 6.8(i) we have the desired. witnesses for the disjunct qi of
the instance of the axiom of Comp(P) associated with r(fs1]"'" [s"D.
We now have to extend 8 so as to make M a model of the "if" direction of the
axioms, i.e., of P, without losing the "only if" direction. Let P' be the set of
ground substitution instances of clauses of P by elements of M and let S'.~
the set of resolution consequences of 8 UP', Let M be such that 8' is the set
atomic facts true in M. We claim that M is the desired model of Comp(P). As
it is obVi~u.s1ya model of P, we only have to check that the "only if",direc.tiO~
~fthe ,a:ooms for each predicate r have been preserved 85 well, This ~laim
Imme(hate by induction on the length of the resolution deduction puttmg any
r(tl •... , tOll into 8'; It can be deduced only if some appropriate instances of the
qi,t.· .. ,qi,,,; in one of the clauses of P with T in its head have already ~
deduced.
The definition of Comp(P) formalizes the intuition behind the COB approach·
Analogously, CWA{P) is the set of all sentences that should be associated with P
~rding to the CWA (closed world assumption), The basic intuition of the c~
is that, for any positive ground literal L, if P Y L then we should infer .,L. e
can thus view it as adjoining to P the fOllowing clauses:
(0) {...,L} for each ground positive literal L such that Pit L.
While the CWA shares with cos the view that the domain of discourse is correctly
caPt~ b~ the ground terms, the CWA takes it even further. In addition to ~he
eqU~ty 8.XIOms (1)-(6) described above, it asserts that the universe co~
PI"eC1Sely of the ground te:rms. This assertion cannot however, be guaranteed
a formula of Predicate I.....: [Exer -) , . aI nsaquence
... ra ther t han
(") &UJ!>'C
bili e-xercise 6 . If we consider only logiC co '.m""
- Jini-'
I prova ty. we can express this requirement by an ID
cause, DCA, the domain closure lUiom:
We now write CWA(P) to denote the extension of P by (0)-(7). Note that any
modelfor CWA(P) is an Herbrand model for P. AB the adjunction of (0) gueran-
teestbat the truth of every ground literal is determined by CWA(P), there can be
a.tmost one such model. Indeed for any PROLOG program P, CWA(P) is always
satisfiable and its only model is the minimal Herbrand model for P (Exercise 7).
As this model is also one of Comp(P) (Exercise 8), the soundness results (The--
orem 6.9) proved for negation as failure and Comp(P) hold automatically for
CWA(P) as well. There can, however, be no completeness theorem comparable to
Theorem 6.10 for CWA(P). Indeed, no effective procedure (such as searching for
an sLDNF-refutation) can list all the logical consequences of CWA(P) for every
p (Exercise 8.6).
In addition to sometimes wanting to derive negative information, the PROLOG
programmer might lib to use such expressions in the program as well. This leads
ution
to the notion of general programs and general SLDNy-resol .
loftnir~on 6.11: A geneml program cl411Je is one that contains at least one positive
teral (but perhaps more). A general progmm is a set of general program clauses.
~ any given general program clause {R,Lt. ... ,L,,} we single out one posi-
tive literal, R, as the head and consider all others as the body of the clause.
We then write the clause in PROLOG notation (with ...) as R:- Lt. .. ·, L".
(Unf?rtuna.tely, the interpretation and analysis depend on which positive lit-
~ralIS chosen as the beed.) In the 68JDe vein, we write general goal clauses
In the form {...Ll,"" -.L,,}; however, as before the hope here is to show that
p ~ 3X .•. X",(L A ... A L,,)9 by deriving 0 (via some form of resolution)
1 1
from P U {G} with mgu's 90" .9. = 8 .
~e cannow extend the definition of SLDNF-refutations to general prograll18 by
mtroducfng a recursion at the point at which we search for a finitely failed tree.
~e now look for a finitely failed SLDNF-tree. The extensions of a general program
to CWA(P) and Comp(P) are defined as before. Soundness results such as
those of Theorems 6.8, 6.9 can be proved in this general setting as well. The
~pleteness result of Theorem 6.10 no longer holds. Indeed. the completeness
heorem cannot be extended to general goal clauses even for all pROLOGprograms
(Exercise 9). Weaker forms that deal only with the cases in which every branch
of the SLDNF-tree ends in success or failure do hold. Under these conditions, it is
pceeible to show that the SLDNF-tree gives, in some sense, "all" the answen that
are consequences of CWA(P) or Comp{P). We refer the reader to Shepher~
[1992, 5.4J for a treatment of CWA(P) and to Chapter 3 of Lloyd [1987, 5.4J for
a thorough discussion of the COB approach and Comp(P),
The crucial caveat in the setting of general programs P is that it may t~rn out
that CWA(P) or Comp{P) or both are unsatisfiab1e even though P is satisfiable
202 III. PROLOG
Exercises
1. Show that no selection rule that always chooses the same literal from each
goal clause can be fair,
(Hint; Consider the program P with three clauses;
(Hint; Always choose the first literal to appear in the proof so far that bas
not yet been chosen.)
4. Verify that the relation == defined in the proof of Theorem 6.10 is an equfv-
alence relation.
5. Verify that the equality axioms (1)-(6) are satisfied in the set M defined
in the proof of Tbeorem 6.10 when "=" is interpreted as true equality of
equivalence classes.
6. Prove that no set of sentences of predicate logic can imply axiom (7) of
CWA. (Hint: Use the compactness theorem.)
7. Prove that the unique model for CWA(P) for a PROLOG program P is the
minimal Herbrand model for P.
8. Prove tbat the minimal Herbrand model for a PROLOG program P is alSO
a model of Camp(?).
10. Give an example of a general program P such that Camp(P) (and hence
P) is satisfiable but CWA(P) is not.
11. ~ive ~ example of a general program P such that CWA(P) (and hence P)
IS satISfiable but Comp(p) is not.
(a_(p_a)) .
The crucial extension of such a system to nonmonotonic logic is to add restraints
to the deduction. In addition to knowing each proposition in the set of hypothe-
ses, it may be necessary to not know (believe, have a proof of, have already
established, etc.] each of some other collection of propositions in order to draw
the conclusion permitted by a given rule. The notation for this situation is to list
the usual kind of premises first and then, separated by a colon, follow them with
the list of restraints. The restraints are the propositions that the rule requires
us not to know (believe, etc.]. Thus we read the rule
,
01"·',O'n:131,···,13m
as saying that if 01," ., On are known (proven, established) and 131,' .. , 13mare
not, then we may conclude that we know (can prove or establish) 'Y'
(iv) A subset S of U is deductively clo.!ed in the system (U, N) if, for each ~~
r oftv. such that all the premises QI, ••. ,On of T are in S and none of I
restraints 131,... ,13m are in S, the conclusion rp of r is in S.
7 Negation and Nonmonotonic Logic 205
Tl=-
a
a:{3
r2=--
p
(I) Let Nt = {TItT2}' There is only one minimal deductively closed set for
(U, Nl) : S = {a,P}. S is then the set of secured consequences of (U, N1)·
(ii) Let N2 = {rl,Ta,r ..}. There are two minimal deductively closed. sets for
(U,N2) : 81 = {a,p} and ~ = {o,1}. S = {a} is then the set ofsc<:ured
COnsequences of (U, N'J). In this case the set of secured consequences is
not deductively closed.
DeOnit'IOn 7.3: Let (U,N) be a nonmonotonic formal system and let 8,1 ~ U. An
S-deduction oj rp from 1 in (U,N) is a finite sequence rplt···,rpl< such that
'P :: rpl<and, for ell i :5 k, rpi is either in 1, an axiom of ( U, N) or the conclusion
of a rule r E N all of whose premises are included among rpl,···,rp;-I and
all of whose restraints are contained in U - S. In this situation rp is called an
S-comequence oj I and we denote by Cs(1) the set of all s--consequences,:.,f 1.
Note that the role of S in the above definitklDS is to prevent applications of rules
with any restraint in S' it does not contribute any members of U directly to
Cs(I). Indeed, Cs(I) m~y not contaln S and may not be deductively closed.
206 III. PROLOG
Example 1.4: With the notation as in Example 7.2, define a system ( U, N) by setting:
N = {rr, T3}. If S = {O}, then Cs(0) = {o] is not deductively closed as it does
not contain..., in violation of rule T3·
Proof: Suppose all the premises of a rule T with conclusion lP are in Cs(!) and all
of r's restraints are outside it. By the definition of Cs(I), we can produce an
S-deduction containing all the premises of r . All of the restraints in r are outside
S by hypothesis. We can thus extend the S-deduction to one of 'P by applying
r to get 'P E Cs(I) as desired. 0
The extensions S of I are the analogs for nonmonotonic systems of the logical
consequences of I. Every member of an extension is deducible from I and all the
S--consequences of I are in fact in S. We give some basic properties of extensions
in Exercises 3--5.
It turns out that extensions capture many procedures in mathematics and com-
puter science. We give some mathematical examples in Exercises 8-9. Nowwe
return to PROLOG programs with negation and their connection to extensions
through the notion of stable models.
From our current point of view, it is natural to try to consider the negation lIS
failure as a nonmonotonic system. The underlying idea of negation as failurelIS
presented in the last section is that we may assert ...,p when we do not knoW
(cannot deduce) p. This suggests a natural translation of a general PROLOG
program into a nonmonotonic formal system.
Recall from Definition 6.11 that a general program clause has the form p:- qt,
... ,q",""sl,···,,,,,sm wherep,q; and Sj are atoms.
Remember also that we are in the propositional case. Thus, if a prograD1of
interest .has variables, we consider instead all ground instances of the progcllll1
clauses ID the Herbrand universe. We can now easily translate a general ~
gram P containing only ground atoms into a nonmonotonic formal systelJl III a
natural way. We consider each ground atom as a propositional letter. TheSe
atoms constitute our universe U. Each program clause C of P of the (oflll
p:- qt,···, q", --';51,··., ""Sm is translated into a rule tr(C) :
The n~nmonotonic system is then specified by letting its set of rules N be the
COllection {"(C) .. C E P} 0 f translatlons
. of clauses of P.
Definition 7.7:
l .
Let P be a general program with only ground cleusee- tr(P),settheof
fran" anon oj P, is the nonmonotonic system (U, N) where U is the
7 Negation and Nonmonotonic Logic 207
Example 7.10: Let Q be the £ollowing general program of Gelfand and Lifschitz
{1988, 5.41'
p(1,2).
q(x) ,- p(x,y),-v,(y).
p(I,2).
,(1) ,- p(l, 1), -,(1).
,(1) ,- p(l, 2), -q(2).
,(2) ,- p(2, I), -q(I).
,(2) ,- p(2, 2), -,(2).
p(I,2).
,(1) ,- p(I,2).
,(2) ,- p(2,2).
p(I,2).
,(1) ,- p(I,2).
,(2) ,- p(2,2).
p(I,2).
,(1) ,- p(l, I).
,(2) ,- p(2, 1).
Its minimal model is {p(l,2)} "I M2• Thus M'J is not stable.
In fact, M1 is the only stable model of P (Exercise 7) and so the stable model
is the "right" one from the viewpoint of negation as failure.
definition then, p:_ ql,'" .qn is one of the clauses of PM' As M' is a model of
PM, p E M' as required. 0
For the converse, suppose that M is a minimal Herbrand model of PM' We first
~ote that, by Lemma 7.11, M:2 C",(0). By the minlmality assumption on M,
It sUf6.~ to prove that CM(0) is a model of PM to conclude that M = CM(0)
~ required. Consider, therefore, any clause p:- ql,"" qn in PM with all the q.
ill CM(0). There is then an M-deduction !Ph'" ,!pI< containing all of the qt· By
definltlion of PM, there is a clause C = p:- qh ... 'qn'-.Slt .. ·, ..... ' P With
Sm m '
none of the s; in M and so a rule tree) in tr(P) with all its premises in CM(0).
We may thus form an M-dedue:tion with p as the consequence. So P E Cu(0) as
required. 0
Ge1fond and Lifschitz show that certain classes of programs with properties such
as those considered in §4 have unique stable models and propose the term stable
~odel semantics for such programs. The special case of a unique stable model
18 certainly of particular interest. From the viewpoint of nonmonotonic logic,
however, all the extensions of tT(P) are equally good candidates for models of
the system.
Exercises
1. Let $1 :2 $2 :2 ... be a. nested sequence of deductively closed sets for a
nonmonotonic system (U,N). Prove that nS. is deductively closed.
2. A version of Zorn's lemma (see Theorem VI.10.2 and Exercise VI.10.2)
states that any nonempty family of sets dosed under the intersection of
downwardly nested sequences has a minimal element. Use it and Exercise 1
to prove that every nonmonotonic formal system has a minimal deductively
closed subset.
3. Prove that the operation Cs(l) is monotonic in I and antimonotonic in 5,
that is if I s J, then Cs(l) ~ Cs(J) and if s~
T. then Cs(l):2 GT(I).
(Hint: To begin the analysis note that any candidate must contain P(1,2)to
be a model of P but will not contain any other instance of P by minimalilJ'
ccnelderencns.)
Refer to Exercises 1.6.7-8 for the basic terminology about graphs and partial
orderings used below.
Cxi,Cyi
~
Pr~ that S £; U(G) is an extension for (U(G), N(G») if
colonng each node x of G with color i iff Cxi e S produces 8Jl
ofG.
8Jl::~
11
J