Predicate Logic
Predicate Logic
Introduction
• Representing Facts-the language of logic
• Logical formalism is appealing because it immediately suggests a
powerful way of deriving new knowledge from old
-mathematical deduction
a new statement is true by proving that it follows from the
statements that are already known.
Deductions as a way of deriving answers to questions & solutions
to problems
(and)
Logic symbols: (for all)
(material implication) ` : ( there exist )
(not)
(or)
Logic in general
• Logics are formal languages for representing information
such that conclusions can be drawn
• Syntax defines the sentences in the language
• Semantics define the “meaning” of sentences;
i.e., define truth of a sentence in a world
E.g., the language of arithmetic
x + 2 y is a sentence; x2 + y > is not a sentence
x + 2 y is true in the number x + 2 is no less than the number y
x + 2 y is true in a world where x=7; y =1
x + 2 y is false in a world where x=0; y =6
Entailment
• Entailment means that one thing follows from another:
• KB ╞ α
– E.g., the KB containing “the Giants won” and “the Reds won”
entails “Either the Giants won or the Reds won”
– E.g., x+y = 4 entails 4 = x+y
–
– Entailment is a relationship between sentences (i.e., syntax)
that is based on semantics
Models
• Logicians typically think in terms of models, which are formally structured
worlds with respect to which truth can be evaluated
• It is sunny: SUNNY
• It is windy: WINDY
(4, substitution)
P QR R
-There is no way for all of these
clauses to be true in a single
P Q P interpretation
-This is indicated by the empty
clause
T Q Q
T T
Unification
• In PPL, it is easy to determine that two literals
cannot both be true at the same time.
• In Predicate Logic, matching process is more
complicated since the arguments of the
predicates must be considered
man(John) and man(John) is a contradiction
While man(John) and man(Spot) is not
Unification
• In order to determine contradictions,
-need a matching procedure that compares two literals
- discovers whether there exists a set of substitutions
that makes them identical
• There is a straightforward recursive procedure,
called unification algorithm.
• Idea: first check if their initial predicate symbols are
the same
-if so, proceed. Otherwise, there is no way they can be
unified, regardless of their arguments.
Unification
• tryassassinate(Marcus, Caesar)
hate(Marcus, Caesar)
-cannot be unified
-if the predicate symbols match, then check the
arguments one pair at a time
-if the first matches, continue with the 2nd, & so on
-to test each argument pair, simply call the unification procedure
recursively
-different constants/predicates cannot match; identical ones can
-A variable can match another variable, any constant, or a predicate
expression, with the restriction that the predicate expression must not
contain any instances of the variable being match
Unification
• Complication: must find a single, consistent substitution for the
entire literal, not separate ones for each piece of it.
• To do this, we must take each substitution that we find & apply it to
remainder of the literals before we continue trying to unify them.
P(x,x)
P(y,z)
-two instances of P match, fine
-next compare x & y,
-decide that if we substitute y for x, they could match
-y/x
-z/x
-cannot substitute both y & z for x
-no consistent substitution has produce
Unification
-after first substitution
P(y,y)
P(y,z)
-attempt to unify arguments y & z, which succeeds with
substitution z/y
-entire unification process has now succeeded with a
substitution that is the composition of the two
substitutions.
(z/y)(y/x)
-(a1/a2, a3/a4,….)(b1/b2, b3/b4,……)…means to apply most
list, then take the result & apply all ones of the next list, &
so forth, until all substitutions have been applied
unification
• The object of unification is to discover at least one substitution
that causes two literals to match
• Usually, if there is one such substitution there are many
hate(x,y)
hate(Marcus, z)
Could be unified:
(Marcus/x, z/y)
(Marcus/x, y/z)
(Marcus/x, Caesar/y, Caesar/z)
(Marcus/x, Polonius/y, Polonius/z)
-first 02 are equivalent except for lexical variation
-2nd two, although they produce a match, also produce a substitution
that is more restrictive than absolutely necessary for the match
Algorithm: Unify (L1,L2)
1. If L1 or L2 are both variables or constants, then:
a) If L1 & L2 are identical, then return NIL
b) Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL},
else return (L2/L1)
c) Else if L2 is a variable then if L2 in L1 then return {FAIL}, else
return (L1/L2)
d) Else return {FAIL}
2. If the initial predicate symbols in L1 & L2 are not identical, then
return {FAIL}
3. If L1 & L2 have a different number of arguments, then return
{FAIL}
4. Set SUBST to NIL (at the end of this procedure, SUBST will
contain all the substitutions used to unify L1 & L2)
Algorithm: Unify (L1,L2)
5. For i 1 to number of arguments in L1:
a) Call Unify with the ith argument of L1 & the ith
argument of L2, putting result in S
b) If S contains FAIL then return {FAIL}
c) If S is not equal to NIL then:
i. Apply S to the remainder of both L1 & L2
ii. SUBST: = APPEND(S, SUBST)
6. Return SUBST
Resolution in Predicate Logic
• Easy way of determining that two literals are contradictory—they are if one
of them can be unified with the negation of the other
• man(x) and man(Spot) are contradictory
-since man(x) & man(Spot) can be unified
1. man(Marcus)
2. man(x1)mortal(x1)
-the literal man(Marcus) can be unified with man(x1): Marcus/x1 (for
x1=Marcus, man(Marcus) is false
-we cannot cancel out the two man literals.
-clause 2 says that for a given x1, either man(x1) or mortal (x1).
So, for it to be true, we can now conclude only that
mortal (Marcus) must be true.
hate(Marcus,Caesar) 5
Marcus/x2 1. man(Marcus)
3 Roman(Marcus) loyalto(Marcus,Caesar) 2. Pompeian(Marcus)
Marcus/x1 3. Pompeian(x1) Roman(x1)
Pompeian(Marcus) loyalto(Marcus,Caesar) 2 4. ruler(Caesar)
7 loyalto(Marcus,Caesar) 5. Roman(x2) loyalto(x2,
Marcus/x4, Ceasar/y1 Caesar) hate(x2, Caesar)
1 man(Marcus) ruler(Caesar) tryassassinate(Marcus,Ceasar)
6. loyalto(x3, f1(x3))
ruler(Caesar) tryassassinate(Marcus,Ceasar) 4
7. man(x4) ruler(y1)
tryassassinate(Marcus,Ceasar) 8
tryassassinate(x4,y1)
loyalto(x4,y1)
8. tryassassinate(Marcus,Caesar)
An Example
• hate(Maucus, Caesar)
• Did Marcus hate Caesar?
Prove: hate(Maucus, Caesar)
Add: hate(Maucus, Caesar) to the set of available clauses & begun
resolution process
-no clauses that contain a literal hate
-since the resolution process can only generate new clauses that are
composed of combinations of literals form already existing clauses,
we know that no such clause can be generated & thus we conclude
that
hate(Marcus, Caesar) will not produce a contradiction with the
known statements.
Unsuccessful attempt at Resolution
Prove: loyalto(Marcus,Caesar)
9. persecute(x5,y2)hate(y2,x5)
loyalto(Marcus,Caesar) 5 10. hate(x6,y3) persecute(y3,x6)
Marcus/x2
3 Roman(Marcus) hate(Marcus,Caesar)
Marcus/x1
Pompeian(Marcus) hate(Marcus,Caesar) 2 hate(Marcus,Caesar) 10
Marcus/x6,Caesar/y3
hate(Marcus,Caesar) persecute(Marcus,Caesar) 9
Marcus/x4, Ceasar/y1
Marcus/x5, Caesar/y2
hate(Marcus,Caesar)
-
9. persecute(x,y)hate(y,x) -
10. hate(x,y) persecute(y,x) -
An Example
• Now to detect that there is no contradiction
we must discover that the only resolvents that
can be generated have been generated before.
• In other words, although we can generate
resolvents, we can generate no new ones.
An Example
• In its pure form, resolution requires all the
knowledge it uses to be represented in the
form of clauses.
• It is more efficient to represent certain kinds
of info in the form of computable functions,
computable predicates, & equality
relationships
An Example
Prove: alive(Marcus,now)
alive(Marcus,now) 9a 1. man(Marcus)
Marcus/x4, now/t3 2. Pompeian(Marcus)
dead(Marcus,now) 10 3. born(Marcus,40)
Marcus/x6, now/t6 4. man(x1) mortal(x1)
5 dead(Marcus,t5) gt(now,t5)
5. Pompeian(x2) died(x2,79)
Marcus/x2, 79/t5
Pompeian(Marcus) gt(now,79) 6. erupted(volcano,79)
Substitute equals 7. mortal(x3) born(x3,t1)
Pompeian(Marcus) gt(2014,79) gt(t2-t1,150) dead(x3,t2)
reduce 8. now=2014
Pompeian(Marcus)
2 9a. alive(x4,t3) dead(x4,t3)
9b. dead(x5, t4) alive(x5, t4)
10. died(x6, t5) gt(t6, t5)
dead(x6,t6)
Using resolution with equality & reduce
Two ways of generating new clauses in
addition to the resolution rule
1. substitution of one value for another to which
it is equal
2. Reduction of computable predicates. If the
predicate evaluates to FALSE, it can simply be
dropped, since adding V FALSE to a disjunction
cannot change its truth value.
-If the predicates evaluates to TRUE, then the
generated clause is a tautology & cannot lead to
a contradiction
Chapter Summary
• Logic: Propositional Logic & Predicate Logic
• Facts to Predicated logic (CNF)
• Computable functions & Predicates
• Resolution
• Unification