0% found this document useful (0 votes)
12 views55 pages

Ch5: Using Predicate Logic

Predicate knowledge representation in AI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views55 pages

Ch5: Using Predicate Logic

Predicate knowledge representation in AI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

Ch5: Using Predicate Logic

Q Representing simple facts in Logic


Q Representing Instance and Isa relationships
Q Make an exception
Q Computable functions and predicates
Q Resolution
Q Natural deduction

Slide 1
Ch5: Using Predicate Logic
Logic
Logic is concerned with the truth of statements about the world.
Generally each statement is either TRUE or FALSE.
Logic includes :Syntax , Semantics and Inference Procedure.
◊ Syntax :
Specifies the symbols in the language about how they can be
combined to form sentences. The facts about the world are
represented as sentences in logic.
◊ Semantic :
Specifies how to assign a truth value to a sentence based on its
meaning in the world. It Specifies what facts a sentence refers to.
A fact is a claim about the world, and it may be TRUE or FALSE.
◊ Inference Procedure :
Specifies methods for computing new sentences from the exist-
ing sentences. Slide 2
Representing Simple Facts in Logic
Q Using propositional logic
–Real-world facts are represented as logical propositions
written as well-formed formulas (wff’s)
–Example 1:

It is raining RAINING
It is sunny SUNNY
It is Windy WINDY
If it is raining, then it is not sunny RAINING  ¬SUNNY

Slide 3
Representing Simple Facts in Logic
– Example 2:
Socrates is a man SOCRATESMAN
Plato is a man PLATOMAN
All men are mortal MORTALMAN

=> Since the assertions are separate, it is not possible to


draw any conclusion about similarities between Socrates
and Plato.

Slide 4
Representing Simple Facts in Logic
It would be much better to represent these facts as
Socrates is a man man(socrates)
Plato is a man man(plato)

All men are mortal mortalman

•This fails to capture the relationship between any individual being


a man and that individual being a mortal.
•Therefore it is necessary to move to first order predicate logic as a
way of representing knowledge because it permits representation
of things that cannot reasonably be represented in prepositional
logic.
•In predicate logic, real world facts are represented as statements
written as wff’s. Slide 5
Representing Simple Facts in Logic
Q Propositional logic vs. predicate logic
–Using propositional logic
• Theorem proving is decidable
• Cannot represent objects and quantification
–Using predicate logic
• Can represent objects and quantification
• Theorem proving is semi-decidable

Slide 6
Representing Simple Facts in Logic

Consider the following set of sentences.


1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeians were Romans.
4. Caesar was a ruler.
5. All Romans were either loyal to Caesar or hated him.
6. Every one is loyal to someone.
7. People only try to assassinate rulers they are not loyal to.
8. Marcus tried to assassinate Caesar

Slide 7
Representing Simple Facts in Logic
1. Marcus was a man.
man(Marcus)

2. Marcus was a Pompeian.


Pompeian(Marcus)

3. All Pompeians were Romans.


x: Pompeian(x) 
Roman(x)

4. Caesar was a ruler.


ruler(Caesar)
Slide 8
Representing Simple Facts in Logic
5. All Romans were either loyal to Caesar or hated him.
In English the word ‘or’ means the logical inclusive-or
and sometimes means the logical exclusive-or(XOR)

inclusive-or
x: Roman(x)  loyalto(x, Caesar)  hate(x, Caesar)

exclusive-or (XOR)
x: Roman(x)  (loyalto(x, Caesar)   hate(x, Caesar))
 ( loyalto(x, Caesar)  hate(x, Caesar))

Slide 9
Representing Simple Facts in Logic
6. Every one is loyal to someone.
x y: loyalto(x, y)
7. People only try to assassinate rulers they are not loyal
to.

x: y: person(x)  ruler(y)  tryassassinate(x, y)


 loyalto(x, y)

8. Marcus tried to assassinate Caesar.


tryassassinate(Marcus, Caesar)

Slide 10
Representing Simple Facts in Logic
To answer the question
Was Marcus loyal to Caesar?
To produce a formal proof , reasoning backward from
the desired goal
loyalto(Marcus, Cae-
sar)
To prove the goal, rules of inference are to be used to
transform into another goal that in turn be transformed
and so on, until there are no insatisfied goals remain-
ing.

Slide 11
Representing Simple Facts in Logic

•This attempt fails , since there is no way to satisfy the goal per-
son(Marcus)with the statements available.
•The problem is although its known that Marcus was a man there
is no way to conclude it.
•Therefore another representation is added namely

Slide 12
Representing Simple Facts in Logic
9.All men are people
x:man(x)person(x)
This satisfies the last goal and produce a proof that Marcus
was not loyal to ceasar.
Three important issues to be addressed in this process
of converting English sentences to logical statements and
then using these statements to deduce new ones.
• Many English sentences are ambiguous. Choosing the cor-
rect interpretation may be difficult.
• There is often a choice of how to represent knowledge
• Obvious information may be necessary for reasoning
• We may not know in advance which statements to
•deduce (P or P). Slide 13
Representing Instance & Isa Relationships
•Attributes “ IsA ” and “ Instance ” support property inheritance
and play important role in knowledge representation.The ways
these two attributes "instance" and "isa", are logically ex-
pressed are shown in the example below :
Example : A simple sentence like "Joe is a musician"
Here "is a" (called IsA) is a way of expressing what
logically is called a class-instance relationship between the
subjects represented by the terms "Joe" and "musician".
◊ "Joe" is an instance of the class of things called "musician".
"Joe" plays the role of instance,
"musician" plays the role of class in that sentence.
◊ Note : In such a sentence, while for a human there is no
confusion, but for computers each relationship have to be de-
fined explicitly.
This is specified as: [Joe] IsA [Musician] Slide 14

i.e., [Instance] IsA [Class]


Representing Instance & Isa Relationships

Slide 15
Representing Instance & Isa Relationships
•The first part of the figure contains the representations, in
which the class membership is represented with unary predi-
cates, each corresponding to a class. Asserting that p(x) is true
is equivalent to asserting that X is an instance of p.
•The second part uses the instance predicate explicitly. It is a
binary one, whose first argument is an object and whose sec-
ond argument is a class to which the object belongs. The impli-
cation rule in statement 3 states that object is an instance of the
subclass pompeian then it is an instance of the superclass
Roman.
•The third part contains representations that use both the in-
stance and isa predicates explicitly. Use of isa simplifies the
representation of sentence 3 but requires one additional ax-
iom.It describes how an instance relation and an isa relation
combined to derive a new instance relation.
Slide 16
Computable Functions and Predicates
•All the simple facts can be expressed as combination of indi-
vidual predicates such as
tryassassinate(Marcus, Caesar)
•This is fine if the number of facts is not very large. But sup-
pose if we want to express simple facts such as greater-than
and less-than relationships:
Q Computable predi-
less-than(0, 1)
cates greater-than(1,
less-than(1, 2)
0)
less-than(2, 3)
greater-than(2, 1)
….
greater-than(3, 2)
Slide 17
….
Computable Functions and Predicates
• It is not possible to write out the representation of each of
these facts individually as they are infinitely many of them.
• But if only the finite number of them are to be represented, it
would be extremely inefficient to store explicitly a large set of
statements instead so easily compute each one as we need
it.
• Thus it becomes useful to argument the representations by
computable predicates.
• A procedure will be invoked which is specified in addition to
the regular rules, that will evaluate it and return true or false.
• It is often useful to have computable functions as well as
computable predicates.
• Eg:gt(2+3,1), the value of the plus function is computed given
the arguments 2 and 3 , and then send the arguments 5 and
Slide 18
1 to gt
Computable Functions and Predicates

Slide 19
Computable Functions and Predicates

Slide 20
Computable Functions and Predicates
Set of facts about Marcus

The numbering is changed slightly because sentence 5 has


been split into two parts.
Slide 21
Computable Functions and Predicates
The question is “Is Marcus alive?” This question can be an-
swered by proving
¬alive(Marcus,now)
The term nil at the end of each proof indicates that the lsit of
conditions remaining to be proved is empty and so the proof
has succeeded.

Slide 22
Resolution
From looking at the proofs, two things are clear.
•Even very simple conclusions can require many steps to
prove.
•A variety of processes such as matching, substitution are in-
volved in the production of a proof.
Resolution
•This reduces some of the complexity because it operates on
statements that have first been converted to a single canonical
form.
•Resolution produces proofs by refutation.
•In other words to prove a statement(i.e show that it is valid)
resolution attempts to show that the negation of the statement
produces a contradiction with the known statements.
•This approach contrasts with the technique that generate
proofs by chaining backward from the theorem to be proved to
Slide 23
the axiom.
Algorithm: Convert to Clause Form
1. Eliminate , using: a  b=  a v b.
2. Reduce the scope of each  to a single term, using:
 ( p) = p
deMorgan's laws: (a  b) =  a V  b
(a V b) =  a   b
 x P(x) = x  P(x)
 x P(x) = x  P(x)
3. Standardize variables.
4. Move all quantifiers to the left of the formula without changing their
relative order.
5. Eliminate existential quantifiers by inserting Skolem functions.
6. Drop the prefix.
7. Convert the expression into a conjunction of disjuncts, using asso-
ciativity and distributivity.
8. Create a separate clause for each conjunct.
9. Standardize apart the variables in the set of clauses generated in
step 8, using the fact that: (x: P(x)  Q(x)) = x: P(x)  x: Q(x)
Resolution

Slide 25
Resolution

Slide 26
Resolution

Slide 27
Resolution

Slide 28
Resolution

Slide 29
Resolution

Slide 30
Resolution
•After applying this entire procedure to a set of wff’s, a set of
clauses will be obtained each of which is a disjunction of literals.
•These clauses can now be exploited by the resolution procedure
to generate proofs.

Slide 31
Skolem Functions in FOL
•Objective
–Want all variables universally quantified
–Notational variant of FOL w/o existentials
–Retain implicitly full FOL expressiveness
•Skolem’s Theorem
Every existentially quantified variable can be replaced by a
unique Skolem function whose arguments are all the universally
quantified variables on which the existential depends, without
changing FOL.
•Examples
–“Everybody likes something”
(x)  (y) [Person(x) & Likes(x,y)]
(x) [Person(x) & Likes(x, S1(x))]
Where S1(x) = “that which x likes”
–“Every philosopher writes at least one book”
(x) (y)[Philosopher(x) & Book(y)) => Write(x,y)]
(x)[(Philosopher(x) & Book(S2(x))) => Write(x,S2(x))]
The Basis of Resolution
The resolution procedure is a simple iterative process
•at each step two clauses called the parent clauses are
compared(resolved) yielding a new clause that has been in-
ferred from them.
•The new clause represents ways that the two parent
clauses interact with each other.
•Given:
winter V summer
 winter V cold
We can conclude:
summer v cold
Both the clauses must be true. If winter is true, then cold
must be true to guarantee the truth of the second clause
and vice versa.
The Basis of Resolution

•This is the deduction that the resolution procedure will


make.
•Resolution operates by taking two clauses that each con-
tain the same literal, in this example winter.
•The literal must occur in positive form in one clause and in
negative form in the other.
•The resolvent is obtained by combining all the literals of the
two clauses except the ones that cancel.
•If the clause that is produced is the empty clause,then a
contradiction has been found.Example
Winter
¬Winter
•Will produce the empty clause.
Herbrand's Theorem

•Herbrand's Theorem:
To show that a set of clauses S is unsatisfiable, it is
necessary to consider only interpretations over a particu-
lar set, called the Herbrand universe of S. A set of
clauses S is unsatisfiable if and only if a finite subset of
ground instances (in which all bound variables have had
a value substituted for them) of S is unsatsifable.
Algorithm: Propositional Resolution
1. Convert all the propositions of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set
of clauses obtained in step 1.
3. Repeat until either a contradiction is found or no progress can be
made:
a) Select two clauses. Call these the parent clauses.
b) Resolve them together. The resolvent will be the disjunction of all
of the literals of both of the parent clauses with the following ex-
ception: If there are any pairs of literals L and  L such that one
of the parent clauses contains L and the other contains L, then
select one such pair and eliminate both L and L from the resol-
vent.
c) If the resolvent is the empty clause, then a contradiction has
been found. If it is not, then add it to the set of clauses available
to the procedure.
A Few Facts in Propositional Logic
•OR is allowed and AND is not allowed.
•Implications are also not allowed.
Given Axioms(wff’s) Clause Form(conjuctive
normal form)
1.P P (1)
2.(P  Q)  R P V Q V R (2)
De Morgan’s Law
1)¬(a b)= a V b
2)¬(a V b)= a  b
 (P  Q) V R= P V Q V R
A Few Facts in Propositional Logic
3.(S V T)  Q S V Q (3)

4. T V Q (4)
Ø(S V T) V Q= ( S   T) V Q
By Distributive law= ( S V Q) ( T V Q)
5.T T (5)

•To prove R. First the axioms are converted to clause form. Then we
negate R.
•Then pairs of clauses are selected to resolve together.
•Although any pairs of clauses can be resolved, only those pairs that
contain complementary literals will produce a resolvent that is likely
to lead to the goal of producing the empty clause.
Resolution in Propositional Logic
P V Q V R R

P V Q P

T V Q Q

T T
Unification Algorithm
Unification Algorithm
Unification Algorithm
Unification Algorithm
Unification Algorithm
Unification Algorithm
Algorithm: Unify(L1,L2)
1. If L1 or L2 is a variable or con- 4. Set SUBST to NIL.
stant, then:
a) If L1 and L2 are identical, then 5. For i  1 to number of arguments in
return NIL.
b) Else if L1 is a variable, then if L1:
L1 occurs in L2 then return a) Call Unify with the ith argument
FAIL, else return {(L2/L1)}. of L1 and the ith argument of
c) Else if L2 is a variable, then if L2, putting result in S.
L2 occurs in L1 then return b) If S = FAIL then return FAIL.
FAIL, else return {(L1/L2)}. c) If S is not equal to NIL then:
d) Else return FAIL. i. Apply S to the remainder of both
L1 and L2.
2. If the initial predicate symbols in ii. SUBST := APPEND(S, SUBST).
L1 and L2 are not identical, then
return FAIL. 6. Return SUBST.
3. If L1 and L2 have a different
number of arguments, then return
FAIL
Algorithm: Resolution
1. Convert all the propositions of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set
of clauses obtained in 1.
3. Repeat until either a contradiction is found, no progress can be
made, or a predetermined amount of effort has been expended.
a) Select two clauses. Call these the parent clauses.
b) Resolve them together. The resolvent will be the disjunction of all
the literals of both parent clauses with appropriate substitutions
performed and with the following exception: If there is one pair
of literals T1 and  T2 such that one of the parent clauses con-
tains T1 and the other contains  T2 and if T1 and T2 are unifi-
able, then neither T1 nor  T2 should appear in the resolvent. If
there is more than one pair of complementary literals, only one
pair should be omitted from the resolvent.
c) If the resolvent is the empty clause, then a contradiction has
been found. If it is not, then add it to the set of clauses available
to the procedure.
A Resolution Proof
• Axioms in clause form:
1. man(Marcus)
2. Pompeian(Marcus)
3.  Pompeian(x1) v Roman(x1)
4. Ruler(Caesar)
5.  Roman(x2) v loyalto(x2, Caesar) v hate(x2, Caesar)
6. loyalto(x3, f1(x3))
7.  man(x4) v  ruler(y1) v  tryassassinate(x4, y1) v
loyalto (x4, y1)
8. tryassassinate(Marcus, Caesar)
Resolution Proof cont.
Prove: hate(Marcus, Caesar) hate(Marcus, Caesar) 5

Marcus/x2
3 Roman(Marcus) V loyalto(Marcus,Caesar)

Marcus/
x1
Pompeian(Marcus) V loyalto(Marcus,Caesar) 2

7 loyalto(Marcus,Caesar)

Marcus/x4, Caesar/y1

1 man(Marcus) V  ruler(Caesar) V  tryassassinate(Marcus,


Caesar)

 ruler(Caesar) V  tryassassinate(Marcus, Caesar) 4

 tryassassinate(Marcus, Caesar) 8
An Unsuccessful Attempt at Resolution
Prove: loyalto(Marcus, Cae- loyalto(Marcus, Caesar) 5
sar)
Marcus/x2

3 Roman(Marcus) V hate(Marcus,Caesar)
Marcus/
x1
Pompeian(Marcus) V hate(Marcus,Caesar) 2

hate(Marcus,Caesar)
(a)
hate(Marcus,Caes 10
ar)
Marcus/x6, Caesar/y3
persecute(Caesar, Marcus) 9
Marcus/x5, Caesar/y2
hate(Marcus,Caesar)
:
: (b)
Question Answering
1. When did Marcus die?
2. Whom did Marcus hate?
3. Who tried to assassinate a ruler?
4. What happen in 79 A.D.?
5. Did Marcus hate everyone?

Q Answering = finding a known statement that matches


the terms given in the question

Slide 51
Question Answering

Slide 52
Question Answering
When did Marcus die?
 t: died(Marcus, t)
Resolution:
  t: died(Marcus, t) =  died(Marcus, t)
 Pompeian(x) v died(x, 79)  died(Marcus, t)

79 / t, Marcus / x
Pompeian(Marcus)  Pompeian(Marcus)

false

Slide 53
Question Answering

Slide 54
Natural Deduction
Q Problems with resolution
–The heuristic information contained in the original
statements can be lost in the transformation
x: judge(x)   crooked(x)  educated(x)
 judge(x) v crooked(x) v educated(x)
–People do not think in resolution
Q Natural deduction: A way of doing machine theorem
proving that corresponds more closely to processes
used in human theorem proving

Slide 55

You might also like