Professional Documents
Culture Documents
Part two
First Order Logic
Propositional logic is a weak language
• PL cannot handle even a domain with small worlds. The
problem is that there are just too many propositions to handle
• Example: Prove that “my dog Fido is Nice, given that “all dogs
are Nice.”
–This requires to get at the structure and meanings of
statements (where FOL is useful).
First Order Logic
x sentence P is true iff P is true with x being each possible object in
the given universe
–The above statement is equivalent to the conjunction
At(Selam, ASTU) Smart(Selam)
At(solomon, ASTU) Smart(solomon)
...
Universal quantifier
• A common mistake to avoid
–Typically, is the main connective with
–Common mistake: the use of as the main connective with :
x At(x, AAU) Smart(x) is true if “Everyone is at AAU & everyone
is smart”
Another example.
• Rules such as "All kings are persons,'' is written in first-
order logic as
• x King(x) => Person(x)
• where x or .x is pronounced as “ For all ..”
• Thus, the sentence says, "For all x, if x is a king, then z is a
person."
Existential quantification
•Makes statements about some objects in the universe
<variables> <sentence>
–Someone at ASTU is smart:
x At(x,ASTU) Smart(x)
–Spot has a sister who is a cat:
x sister(spot,x) cat(x)
x sentence P is true iff P is true with x being some
possible objects
–The above statement is equivalent to the disjunction
At(Selam, ASTU) Smart(Selam)
At(Rakeb, ASTU) Smart(Rakeb)
…..
•Common mistake to avoid
–Typically, is the main connective with
–Common mistake: using as the main connective with :
x At(x, ASTU) Smart(x) is true if there is anyone who is not at ASTU
Existential quantification
x y Brother(x, y) Sibling(x, y) .
"x, y Sibling(x, y) Sibling(y, z) .
x y Loves(x, y)
–There is a person who loves everyone in the given world
x y Loves(x, y)
–Everyone in the given universe is loved by at least one person
• Quantifier duality: each can be expressed using the other, using negation ()
–Everyone likes ice cream means that there is nobody who dislikes ice cream
–There is someone who likes cake means that there is no one who dislikes
cake
Sentence structure
In FOL the basic unit is a predicate (argument/terms) structure called
sentence to represent facts.
• Terms refer to objects
Example: likes(muhe, chocolate); tall(fred)
x man(x) mortal(x)
man(Aristotle)
so we can conclude that: mortal(Aristotle)
–This involves matching man(x) against man(Aristotle) and
binding the variable x to Aristotle.
Unification
• Unification is an algorithm for determining the substitutions
needed to make two expressions match
– Unification is a "pattern matching" procedure that takes two
atomic sentences as input, and returns the most general unifier,
i.e., a shortest length substitution list that makes the two literals
match.
– E.g: To make, say p(X, X) and p( Y, Z) match, subst(X/ Y) or subst(X/ Z)
•Example
Sentence 1 Sentence 2 Unifier
group(x, cat(x), dog(Bill)) group(Bill, cat(Bill), y) {x/Bill, y/dog(Bill)}
group(x, cat(x), dog(Bill)) group(Bill, cat(y), z) {x/Bill, y/Bill, z/dog(Bill)}
group(x, cat(x), dog(Jane)) group(Bill, cat(y), dog(y)) Failure
Unification
• A variable can never be replaced by a term containing that variable. For
example, x/f(x) is illegal.
• Unification and inference rules allows us to make inferences on a set of
logical assertions. To do this, the logical database must be expressed in an
appropriate form
• A substitution α unfies atomic sentences p and q if pα = qα
p q α
Knows(John,x) Knows(John,Jane) {x/Jane}
Knows(John,x) Knows(y, Abe) {y/John, x/Abe}
Knows(John,x) Knows(y,Mother(y))
{y/John, x/Mother(John)}
Knows(John,x) Knows(x,Abe)
Rule 1: IF Y is true
AND D is true
THEN Z is true
A X
Rule 2: IF X is true
AND B is true
B Y
AND E is true
Z
THEN Y is true
E D
Rule 3: IF A is true
THEN X is true
Forward chaining
A BC DE AB CD E AB CD E
? ?
Z Y X
Knowledge Base Knowledge Base Knowledge Base
Y&D Z Y&D Z Y&D Z
X&B&E Y X & B & EY X & B & EY
A X A X A X
C L C L C L
L&M N L&M N L&M N
Goal: Z Sub-Goal: Y Sub-Goal: X
AB CD E AC B DE AC B DE
X X Y X Y Z
Examples:
–Given: Rich(ken); Rich(x) v unhappy(x)
using subst {x/ken}
we can conclude that: unhappy(ken)
Generalized Resolution: proof by refutation
• Generalized Resolution inference rule provides a complete
system for proof by refutation.
–Resolution is a generalization of modus ponens
–It requires a normal form, any sentence can be put into CNF
• Conjunctive normal form (CNF)
–Each individual sentence is a disjunction of literals. This form is
CNF
–CNF is more common. For instance,
P(x) v R(x)
Q(y) v S(y)
• Conversion to CNF:
–any FOL sentence can be converted into normal form
Steps to convert a FOL sentence to CNF
• Eliminate connectives: replace (P Q) by ((P Q) ^ (Q P))
• Eliminate connectives: replace each instance (P Q) by (P v Q)
• Reduce the scope of negation:
P to P; (P v Q) to P ^ Q; (P ^ Q) to P v Q; x P(x) to x P(x), and x
P(x) to x P(x)
• Eliminate by introducing Skolem symbols/function.
x P(x) converted to P(c) where c is a brand new Skolem constant symbol
that is not used in any other sentence.
– If is within the scope of a universal quantified variable, then introduce a
Skolem function (f). Example, xyP(x,y) is converted to xP(x, f(x)).
E.g.: x y loves(x,y) converted to x loves(x,f(x)) where f(x) specifies the
person that x loves. (If everyone loved their mother, then f could be
mother_of (x) function)
• Drop x quantifiers. For example, convert x P(x) to P(x).
• Distribute "and" over "or" to get conjunctive normal form.
Convert (P ^ Q) v R to (P v R) ^ (Q v R), & (P v Q) v R to (P v Q v R).
• And Elimination: Split each conjunct into a separate clause.
(P v R) ^ (Q v R) into (P v R), (Q v R)
x (P(x) (y (P(y) P(f(x,y))) ^ y(Q(x,y) P(y)))
• Eliminate :
(x)(P(x) v ((y)(P(y) v P(f(x,y))) ^ (y)(Q(x,y) v P(y))))
• Reduce scope of :
(x)(P(x) v ((y)(P(y) v P(f(x,y))) ^ (y)(Q(x,y) ^ P(y))))
• Standardize variables:
(x)(P(x) v ((y)(P(y) v P(f(x,y))) ^ (z)(Q(x,z) ^ P(z))))
• Eliminate :
(x)(P(x) v ((y)(P(y) v P(f(x,y))) ^ (Q(x,g(x)) ^ P(g(x)))))
• Drop universal quantification
(P(x) v ((P(y) v P(f(x,y))) ^ (Q(x,g(x)) ^ P(g(x)))))
• Convert to conjunction of disjunctions
(P(x) v P(y) v P(f(x,y))) ^ (P(x) v Q(x,g(x))) ^ (P(x) v P(g(x)))
• Create separate clauses (And Elimination)
P(x) v P(y) v P(f(x,y)), P(x) v Q(x,g(x)), P(x) v P(g(x))
• Standardize variables
P(x) v P(y) v P(f(x,y)), P(z) v Q(z,g(z)), P(w) v P(g(w))
Assignment 1:
Convert the following sentence to CNF
1. x [y animal(y) loves(x,y)] [z loves(z,x)]
Note: make sure that you followed all the steps until you come up with
independent sentences
Resolution: Proof by Refutation
Example
• Jack owns a dog. Every dog owner is an animal lover. No
animal lover kills an animal. Either Jack or Curiosity killed
the cat, who is named Tuna. Did Curiosity kill the cat?
FOL representation:
A. (x) Dog(x) Owns(Jack,x)
B. (x) ((y) Dog(y) Owns(x, y)) AnimalLover(x)
C. (x) AnimalLover(x) ((y) Animal(y) Kills(x,y))
D. Kills(Jack,Tuna) Kills(Curiosity,Tuna)
E. Cat(Tuna)
F. (x) Cat(x) Animal(x)
G. Kills(Curiosity, Tuna)
Assignment
• The law sys that it is crime to for Sudanese to sell
weapons to hostile nations. The country Eritrea
an enemy of Sudan, has some bomb and all of its
bombs were sold to it by Hasan.
• Is john garang criminal ? proof