0% found this document useful (0 votes)
36 views68 pages

9-Predicate Logic v2

The document discusses the limitations of propositional logic and introduces First Order Logic (FOL) as a more expressive framework for knowledge representation in artificial intelligence. It covers the syntax, semantics, and inference rules of FOL, highlighting the use of quantifiers and the representation of objects, relations, and functions. Additionally, it provides examples and transformations to illustrate how FOL can represent complex statements and relationships in various domains.

Uploaded by

nihar.dhurde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views68 pages

9-Predicate Logic v2

The document discusses the limitations of propositional logic and introduces First Order Logic (FOL) as a more expressive framework for knowledge representation in artificial intelligence. It covers the syntax, semantics, and inference rules of FOL, highlighting the use of quantifiers and the representation of objects, relations, and functions. Additionally, it provides examples and transformations to illustrate how FOL can represent complex statements and relationships in various domains.

Uploaded by

nihar.dhurde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Artificial Intelligence

First Order Predicate Logic


unknown

RL

known
deterministic stochastic
atomic
SEARCH MDPs

factored Bayes
LOGIC
nets

structured First-order
logic
Outline
▪ Limitation of Propositional Logic
▪ Introduction to First Order Logic (FOL)
▪ Knowledge Representation in FOL
▪ Syntax
▪ Semantics
▪ Logical inference in FOL
▪ Inference Rule
▪ Resolution
▪ Forward and Backward Chaining
Pros and Cons of Propositional Logic
▪ Pros:
▪ Propositional logic is declarative: pieces of syntax correspond to facts
▪ Propositional logic allows partial/disjunctive/negated information
(unlike most data structures and databases)
▪ Propositional logic is compositional:
meaning of B ∧ P is derived from meaning of B and of P
▪ Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)
▪ Cons:
▪ Propositional logic has very limited expressive power (unlike natural language)
Limitation of Propositional Logic
▪ Propositional logic has limited expressive power.
▪ We cannot represent relations like All, Some, or none with propositional
logic. Example:
▪ Statements about similar objects, relations
▪ Statements referring to groups of objects
▪ All the animals are intelligent.
▪ Some apples are sweet.
▪ We cannot describe statements in terms of their properties or logical
relationships.
Limitation of Propositional Logic
▪ Statements referring to groups of objects ▪ Statements about objects and relations
▪ Example: ▪ Example:
▪ Assume we want to express: “Every student ▪ Seniority of people domain
likes vacation” ▪ Virat is older than Rohit
▪ Require to include statements about every ▪ Rohit is older than Shubham
student ▪ To derive: Virat is older than Shubham
Rohit likes vacation ∧ Virat is older than Rohit ∧ Rohit is older than Shubham ⇒
Virat is older than Shubham
Virat likes vacation ∧
Shubham likes vacation ∧ …..
▪ Assume we add another fact:
Mahi is older than Rohit
▪ To derive:
▪ Problem: KB grows large
Mahi is older than Rohit ∧ Rohit is older than Shubham ⇒
▪ Solution: ? Mahi is older than Shubham

▪ Possible solution: ▪ Possible solution: introduce variables


▪ Allow quantification in statements A is older than B ∧ B is older than C ⇒ A is older than C
▪ Universal (∀) and Existential (∃) ∀x student(x) ⇒ like_vacation(x)
First-Order Logic
▪ Another way of knowledge representation in artificial intelligence.
▪ FOL is sufficiently expressive to represent the natural language statements
▪ Propositional logic: world contains facts
▪ First-order logic: the world contains objects, relations, and functions
▪ Objects: people, houses, numbers, theories, location, colors, baseball games, wars, centuries . . .
▪ Relations: brother of, bigger than, inside, part of, has color, occurred after, owns, comes between, . . .
▪ Functions: father of, best friend, third inning of, one more than, end of . . .
▪ Introducing variables that refer to an arbitrary objects
▪ Introducing quantifiers allowing us to make statements over groups objects
Logic
▪ Logic is defined by:
▪ A set of sentences
▪ A sentence is constructed from a set of primitives according to syntax rules.
▪ A set of interpretations
▪ An interpretation gives a semantic to primitives. It associates primitives with
objects, values in the real world.
▪ The valuation (meaning) function V
▪ Assigns a truth value to a given sentence under some interpretation
▪ V : sentence × interpretation → {True , False }
First Order Logic: Syntax
▪ Term: syntactic entity for representing
objects
▪ Constant symbols: represent specific objects
Virat, India, Car
▪ Variables: represent objects of a certain type
x, y, z
▪ Functions: applied to one or more terms
father-of (Pratik), father-of(father-of(Pratik))
First Order Logic: Syntax
▪ Sentences in FOL:
▪ Atomic sentences:
▪ A predicate symbol applied to 0 or more
terms
▪ Examples:
▪ Red(Rose)
▪ Sister(Arati, Jyoti)
▪ Manager(father-of(Ritesh)
▪ t1 = t2 equivalence of terms
▪ Example:
▪ Chha. Shivaji Maharaj = father-of(Chha.
Sambhaji Maharaj)
First Order Logic: Syntax
▪ Sentences in FOL:
▪ Complex sentences:
▪ Assume P, Q are sentences in FOL. Then:
(P ∧ Q ), (P ∨ Q ), (P ⇒ Q ), (P ⇔ Q ), ¬ Q
and ∀x P ∃y Q are sentences
▪ Symbols ∃, ∀
▪ stand for the existential and the
universal quantifier
First Order Logic: Syntax
▪ All birds fly.
▪ The predicate is "fly(bird).“
▪ ∀x bird(x)  fly(x)
▪ Every man respects his parent.
▪ The predicate is "respect(x, y)," where
x=man, and y= parent.
▪ ∀x man(x)  respects(x, parent)
▪ Some boys play cricket.
▪ In this sentence, the predicate is "play(x, y),"
where x= boys, and y= game.
▪ ∃x boys(x)  play(x, cricket)
Dealing with Quantifiers
▪ " can be thought of as “conjunction” over all objects in domain:
▪ e.g., "x bird ( x )
can be interpreted as bird (tweety )  bird ( sam)  bird ( fred ) 

▪ $ can be thought of as “disjunction” over all objects in domain:


▪ e.g., $x bird ( x )
can be interpreted as bird (tweety )  bird ( sam)  bird ( fred ) 

▪ Quantifier Duality
▪ Each can be expressed using the other
▪ This is an application of DeMorgan’s laws
▪ examples:
"x loves( x , tweety) is equivalent to $xloves( x , tweety)
$x likes( x , broccoli ) is equivalent to "xlikes( x , broccoli )
Dealing with Quantifiers
▪ Usually use  with ":
▪ e.g., "x human( x)  mortal ( x ) says, all humans are mortal
but, "x human( x )  mortal ( x ) say, everything is human and mortal
▪ Usually use  with $:
▪ e.g., $x bird ( x)  flies( x) says, there is a bird that does not fly
but, $x bird ( x )  flies( x ) is also true for anything that is not a bird
▪ "x$y is not the same as $y"x :
▪ e.g., $x"y loves( x , y ) says, there is someone who loves everyone
but, "y$x loves( x , y ) says, everyone is loved by at least one person
Semantic: Interpretation
▪ An interpretation I is defined by a mapping to the domain of
discourse D or relations on D
▪ Domain of discourse: a set of objects in the world we represent and
refer to;
▪ An interpretation I maps:
▪ Constant symbols to objects in D
▪ I(Sachin) =
▪ Predicate symbols to relations, properties on D
▪ I(brother) = { ( , ); ( , ); ……. }
▪ Function symbols to functional relations on D
▪ I(father-of) = {( → ); {( → ); ……….}
Semantics of Sentences
▪ Meaning (evaluation) function:
▪ V : sentence × interpretation → {True , False}
▪ A predicate: predicate(term-1, term-2, term-3, term-n) is true for the interpretation I ,
iff the objects referred to by term-1, term-2, term-3, term-n are in the relation referred
to by predicate

▪ I(Rohit) = I(Kunal) =

▪ I(brother) = { ( , ); ( , ); ……. }

▪ brother(Rohit, Kunal) = ( , ) in I(brother)

▪ V(brother(Rohit, Kunal), I) = True


Semantics of Sentences with quantifiers
▪ Universal quantification ▪ Existential quantification

▪ V(∀x ∅, I) = True substitution of x with d


▪ V(∃x ∅, I) = True
▪ Iff for all d ∈ D, V(∅, I[x/d]) = True ▪ Iff for all d ∈ D, s.t. V(∅, I[x/d]) = True
Semantics of Sentences with quantifiers
▪ Universal quantification ▪ Existential quantification
▪ All COEP students are smart ▪ Someone at COEP is smart
▪ Assume the universe of discourse of ▪ Assume the universe of discourse
x are COEP students of x are COEP affiliates
▪ ∀x at(x, COEP) ⇒ smart(x) ▪ ∃x smart(x)
▪ Assume the universe of discourse of ▪ Assume the universe of discourse
x are students of x are people
▪ ∀x smart(x) ▪ ∃x at(x, COEP) ∧ student(x)
▪ Assume the universe of discourse of
x are people
▪ ∀x student(x) ∧ at(x, COEP) ⇒ smart(x)
Semantics of Sentences with quantifiers
Assume two predicates S(x) and P(x)

▪ Universal quantification ▪ Existential quantification

▪ Typically, the ∀ connects with ▪ Typically, the ∃ connects with a


implication conjunction

▪ All S(x) is P(x) ▪ Some S(x) is P(x)


▪ ∀x ( S(x) ⇒ P(x) ) ▪ ∃x (S(x) ∧ P(x) )
▪ No S(x) is P(x) ▪ Some S(x) is not P(x)
▪ ∀x ( S(x) ⇒ ¬P(x) ) ▪ ∃x (S(x) ∧ ¬P(x) )
Connection Between Quantifiers
▪ Everyone likes ice cream
▪ ∀x likes(x, IceCream)

▪ Is it possible to convey the same meaning using an existential quantifier ?


▪ There is no one who does not like ice cream
▪ ¬∃x ¬likes(x, IceCream)

▪ A universal quantifier in the sentence can be expressed using an existential


quantifier !!!
Connection Between Quantifiers
▪ Someone likes ice cream
▪ ∃x likes(x, IceCream)

▪ Is it possible to convey the same meaning using an Universal quantifier ?


▪ Not everyone does not like ice cream
▪ ¬∀x ¬likes(x, IceCream)

▪ A existential quantifier in the sentence can be expressed using an universal


quantifier !!!
Nested quantifiers
▪ More than one quantifier may be necessary to capture the
meaning of a statement in the predicate logic.
▪ Order of quantifiers of the same type does not matter
▪ For all x and y, if x is a parent of y then y is a child of x
▪ ∀x,y parent(x, y) ⇒ child(y, x)
▪ ∀y,x parent (x, y) ⇒ child(y, x)
▪ Order of different quantifiers changes the meaning
▪ ∀x∃y loves(x, y) : Everybody loves somebody
▪ ∃y∀x loves(x, y) : There is someone who is loved by everyone
Examples
▪ Suppose:
▪ Variables x, y denote people
▪ Loves(x, y) denotes “x loves y”

▪ Translate:
▪ Everybody loves Virat. ▪ ∀x Loves(x, Virat)
▪ Everybody loves somebody. ▪ ∀x ∃y Loves(x, y)
▪ There is somebody whom everybody loves. ▪ ∃y ∀x Loves(x, y)
▪ There is somebody who Virat doesn't love. ▪ ∃y ¬Loves(Virat, y)
▪ There is somebody whom no one loves. ▪ ∃y ∀x ¬Loves(x, y)
Some examples of FOL sentences
▪ Every gardener likes the sun. "x gardener(x)  likes (x, Sun)

▪ You can fool some of the people all of the $x (person(x) ∧ " t (time(t)  can-fool(x, t)))
time

▪ You can fool all of the people some of the "x (person(x)  $ t (time(t) ∧ can-fool(x, t)))
time.

▪ No purple mushroom is poisonous. ¬$x purple(x) ∧ mushroom(x) ∧ poisonous(x)


or, equivalently,
"x (mushroom(x) ∧ purple(x))  ¬poisonous(x)
Transformation to FOPC
goodgrade(mary , cs101)  goodgrade(mary , cs102) Mary got good grades in courses CS101 and CS102

pass( john, cs102) John passed CS102

"x , y[ student ( x )  course( y )  goodgrade( x , y )  pass( x , y )] Student who gets good grades in a course
passes that course

"x[ student ( x )  $y[course( y )  pass( x , y )]  happy ( x )] Students who pass a course are happy

"x[ student ( x )  happy ( x )  $y[course( y )  pass( x , y )]] A student who is not happy hasn’t passed all
his/her courses

$x[ student ( x )  "y[course( y )  pass( x , y )]


Only one student failed all the courses
"z[( student ( z )  ( x = z ))  $y[ course( y )  pass( z , y )]]
Representing knowledge in FOL
Example: Kinship domain
▪ Objects: people
Jyoti, Arti, Dipak, …
▪ Properties: gender
Male(x), Female(x)
▪ Relations: parenthood, brotherhood,
marriage
Parent ( x, y ), Brother ( x, y), Spouse ( x, y )
▪ Functions: mother-of (one for each
person x)
MotherOf (x)
Representing knowledge in FOL
• Family • Extended family • Relation change
• Spouse • Grandparent • Marriage
• Grandfather
• Husband • Adoption
• Grandmother
• Wife • Relation end
• Grandson
• Parent • Granddaughter • Breakup
• Father • Uncle • Divorced
• Mother • Aunt • Disownment
• Step-father • Cousin • Emancipation
• Step-mother • Nephew • Widowhood
• Niece
• Legal guardian
• Family-in-law
• Child
• Father-in-law
• Son • Mother-in-law
• Daughter • Brother-in-law
• Step-son • Sister-in-law
• Step-daughter
• Sibling
• Brother
• Sister
Representing knowledge in FOL
Relations between predicates and functions: write down what we know
about them; how relate to each other.
▪ Male and female are disjoint categories
∀x Male ( x) ⇔ ¬Female ( x)
▪ Parent and child relations are inverse
∀x, y Parent ( x, y ) ⇔ Child ( y, x)
▪ A grandparent is a parent of parent
∀g, c Grandparent(g, c) ⇔ ∃p Parent(g, p) ∧ Parent( p, c)
▪ A sibling is another child of one’s parents
∀x, y Sibling ( x, y) ⇔ ( x ≠ y) ∧ ∃p Parent ( p, x) ∧ Parent ( p, y)
▪ And so on …
Knowledge Representation
INFERENCE IN FIRST ORDER LOGIC
Logical inference in FOL
Logical inference problem:
▪ Given a knowledge base KB (a set of sentences) and α (a sentence) , does
the KB semantically entail α?
KB ╞ α ?
▪ In other words: In all interpretations in which sentences in the KB are true,
is also α true ?

▪ Logical inference problem in the first-order logic is undecidable !!!.


▪ No procedure that can decide the entailment for all possible input
sentences in a finite number of steps.
Logical inference in FOL
▪ Logical Inference in PL ▪ Truth-table approach a viable ▪ Inference rule approach a
KB ╞ α ? for the FOL? viable for the FOL?
▪ Three approaches: ▪ NO! ▪ Yes.
▪ Truth-table approach ▪ It would require us to ▪ The inference rules
▪ Inference rules enumerate and list all represent sound inference
▪ Resolution-refutation possible interpretations I patterns one can apply to
▪ I = (assignments of symbols to sentences in the KB
objects, predicates to ▪ What is derived follows from
relations and functions to the KB
relational mappings) ▪ Caveat: Need to add rules for
▪ Simply there are too many handling quantifiers
interpretations ▪ Must involve variable
substitutions
Theorem Proving: Inference Rule
▪ (MP) Modes Ponens
  ,  ▪ (AE) And-Elimination

▪ (AI) And-Introduction 


▪ (NE) Negation-Elimination

▪ (OI) Or-Introduction    , 
▪ (UR) Unit Resolution

   ,   
▪ (R) General Resolution
 

▪ Additional inference rules are needed


▪ For sentences with quantifiers and variables
▪ Must involve variable substitutions
Variable Substitutions
▪ Variables in the sentences can be substituted with terms.
(terms = constants, variables, functions)
▪ Substitution: Is a mapping from variables to terms
{x1/t1, x2/t2, …..}

▪ Application of the substitution to sentences


SUBST({x/Ram, y/Sham}, Likes(x, y)) = Likes(Ram, Sham)

SUBST({ x/Ram , y/fatherof(Ram)}, Likes(x, y)) = Likes(Ram, fatherof(Ram))


Inference Rules for Quantifiers
Universal Instantiation/elimination Existential Instantiation/elimination
∀𝑥 ∅ 𝑥 ∃𝑥 ∅ 𝑥
a is constant ∅ 𝑎
∅ 𝑎

▪ Substitutes a variable with a constant ▪ Substitutes a variable with a constant


symbol symbol
▪ that symbol does not appear elsewhere
in the KB
▪ Example: Special constant called a Skolem constant
▪ Example:
"x Likes(x, IceCream) → Likes(Virat, IceCream)
$x Kill(x, Victim) → Kill(Murderer, Victim)
$y"x(likes(x, y)) → "x likes(x, a)
Special function called a Skolem function

"x $y (likes(x, y)) → "x likes(x, f(x))


Example of Derivation
▪ Let KB = { parent(john ,mary), parent(john, joe), "x"y [$z ( parent ( z, x)  parent ( z, y)  sibling ( x, y) ) ]}
KB╞ sibling (mary , joe)

1. "x"y [$z ( parent ( z, x )  parent ( z, y )  sibling ( x , y ) ) ] (from KB)


2. "y [$z ( parent ( z, mary)  parent ( z, y )  sibling (mary , y ) ) ] (1, UI)
3. $z ( parent ( z, mary)  parent ( z, joe)  sibling (mary, joe) ) (2, UI)
4. parent ( john, mary )  parent ( john, joe)  sibling (mary , joe) (3, EI)
5. parent ( john, mary) (from KB)
6. parent ( john, joe) (from KB)
7. parent ( john, mary)  parent ( john, joe) (5, 6, AI)
8. sibling (mary , joe) (4, 7, MP)

▪ This derivation shows that KB╞ sibling (mary , joe)


Reduction to Propositional Inference
▪ Suppose the KB contains just the following:
∀x King(x) ∧ Greedy(x) ⇒ Evil(x)
King(John)
Greedy(John)
Brother(Richard, John)
▪ Instantiating the universal sentence in all possible ways, we have:
King(John) ∧ Greedy(John) ⇒ Evil(John)
King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard)
King(John)
Greedy(John)
Brother(Richard, John)
▪ The new KB is propositionalized: proposition symbols are
King(John), Greedy(John), Evil(John), King(Richard), etc.
Problems with Propositionalization
▪ Propositionalization seems to generate lots of irrelevant sentences
▪ E.g., from:
∀x King(x) ∧ Greedy(x) ⇒ Evil(x)
King(John)
∀y Greedy(y)
Brother(Richard, John)

▪ It seems obvious that Evil(John), but propositionalization produces lots of facts such as
Greedy(Richard) that are irrelevant
Unification (alignment)
▪ Problem in inference: Universal elimination gives many opportunities for
substituting variables with ground terms
∀𝑥 ∅ 𝑥
▪ a is constant
∅ 𝑎
▪ Solution: Try substitutions that help us to make progress
▪ Use substitutions of “similar” sentences in KB
▪ Example:
▪ ∀x King(x) ∧ Greedy(x) ⇒ Evil(x)
▪ King(John)
▪ ∀y Greedy(y)
▪ If we use a substitution σ = {x/John, y/John}
▪ we can use modus ponens to infer Evil(John) in one step
Unification
▪ Takes two similar sentences and computes the substitution that makes them look the
same, if it exists
▪ Use substitutions of “similar” sentences in KB
UNIFY ( p, q) = σ such that SUBST( σ, p) = SUBST (σ , q)

▪ Examples:
UNIFY (Knows(John, x), Knows(John, Jane)) = {x/Jane}
UNIFY(Knows(John, x),Knows(y, Ann)) = {x/Ann, y/John}
UNIFY(Knows(John, x),Knows(y, Motherof(y))) = {x/Motherof(John), y/John}
UNIFY(Knows(John, x), Knows(x, Elizabeth)) = fail
Unification

▪ To unify Knows(John,x) and Knows(y,z),

σ = {y/John, x/z } or σ = {y/John, x/John, z/John}

▪ The first unifier is more general than the second.

▪ There is a single most general unifier (MGU) that is unique up to renaming of variables.

MGU = { y/John, x/z }


Generalized Inference Rules
▪ Use substitutions that let us make inferences
▪ Example: Modus Ponens
▪ If there exists a substitution σ such that
SUBST( σ, A𝑖 ) = SUBST (σ , A𝑖 ) For all i = 1, 2, 3, …, n

(𝐴1 ∧ 𝐴2 ∧ . . . . 𝐴𝑛 ⇒ 𝐵, 𝐴1′ , 𝐴′2 , . . . 𝐴′𝑛 )


𝑆𝑈𝐵𝑆𝑇(𝜎, 𝐵)
▪ Substitution that satisfies the generalized inference rule can be build via unification
process
Resolution inference rule
▪ Recall: Resolution inference rule is sound and complete (refutation-complete) for the
propositional logic and CNF

▪ Generalized resolution rule is sound and refutation complete for the first-order logic
and CNF w/o equalities (if unsatisfiable the resolution will find the contradiction)

▪ Example
Resolution Rule
▪ Proof by refutation:
▪ To prove that KB ╞ , show that KB   is unsatisfiable
▪ KB and , must be in CNF (conjunction of clauses)
▪ Resolution is refutation-complete

▪ Refutation procedure
▪ Each step in the refutation procedure involves applying C1 C2
resolution to two clauses, in order to get a new clause
▪ Inference continues until the empty clause {Ø} is derived {Ø}
(a contradiction)
Recall the Refutation Procedure - Example
1. A  B  C
2. D  B
Given KB = 3. E  A Prove KB╞ C
4. E
5. D

C A  B  C (clause 1)

A  B E  A (clause 3)

E  B E (clause 4)

B D  B (clause 2)

D D (clause 5)
Resolution Rule of Inference
▪ Basic Propositional Version:
   ,       ,   
or equivalently
    

▪ Full First-Order Version:

provided that pj and qk are unifiable via a substitution s


▪ Example: rich( x )  unhappy ( x ) rich(bob)

with substitution s = {x/bob}


unhappy (bob)
Resolution Example
KB = {¬P(w) ∨ Q(w)
¬Q(y) ∨ S (y)
P(x) ∨ R x)
¬R(z) ∨ S (z) }

α = S(A)
Resolution Example
KB ¬α
¬P(w) ∨ Q(w) ¬Q(y) ∨ S (y) P(x) ∨ R x) ¬R(z) ∨ S (z), ¬S(A)

{y / w}

¬P(w) ∨ S (w)
{x / w}

S(w) ∨ R(w)
{z / w}

S (w)
{w / A}

{}
KB ╞ α Contradiction
Conversion to CNF
1. Eliminate implications, equivalences

2. Move negations inside (DeMorgan’s Laws, double negation)

3. Standardise variables (Rename duplicate variables)

4. Move all quantifiers left (no invalid capture possible )


Conversion to CNF
5. Skolemization (removal of existential quantifiers through elimination)
▪ If no universal quantifier occurs before the existential quantifier, replace the variable with a new
constant symbol

▪ If a universal quantifier precede the existential quantifier replace the variable with a function of the
“universal” variable

F(x) - a Skolem function

6. Drop universal quantifiers (all variables are universally quantified)

7. Convert to CNF using the distributive laws


Conversion to CNF - Example
Convert: "x [("y p( x , y ))  ("y (q ( x, y )  r ( x , y)))]

(1) "x [ ("y p( x , y ))  ("y ( q ( x , y )  r ( x , y )))] Replace P  Q with P  Q

(2) "x [($y p( x , y ))  ($y (q ( x , y )  r ( x , y )))] Move inward the negation symbol

(3) "x [($y p( x , y ))  ($z (q ( x , z)  r ( x , z)))] Standardize variables apart

(4) "x$y$z [ p( x , y )  ( q ( x , z)  r ( x , z))] Move quantifiers left in order

(5) "x [p( x, sk1 ( x))  ( q( x, sk2 ( x))  r ( x, sk2 ( x)))] Eliminate $ by Skolemization

(6) p( x, sk1 ( x))  ( q( x, sk2 ( x))  r ( x, sk2 ( x))) Drop universal quantifiers

(7) [p( x, sk1 ( x))  q( x, sk2 ( x))]  [p( x, sk1 ( x))  r ( x, sk2 ( x))] Distribute  over 

(8) { p( x, sk1 ( x))  q( x, sk2 ( x)), p( w, sk1 ( w))  r ( w, sk 2 ( w)) } Split conjunctions (into a set of
clauses) and rename variables
Refutation Procedure - Example
1. father ( john, mary )
2. mother ( sue, john)
KB = 3. father (bob, john)
4. "x"y[( father ( x, y)  mother ( x, y ))  parent ( x , y )]
5. "x"y[$z( parent ( x , z)  parent ( z, y ))  grand ( x , y )]

KB ╞ $x parent ( x, john)
KB ╞ grand ( sue, mary )
Refutation Procedure - Example
1. father ( john, mary )
2. mother ( sue, john)
KB = 3. father (bob, john)
4. "x"y[( father ( x, y)  mother ( x, y ))  parent ( x , y )]
5. "x"y[$z( parent ( x , z)  parent ( z, y ))  grand ( x , y )]

Converting 4 to CNF:
4. ( father ( x , y )  parent ( x , y ))  ( mother ( x , y )  parent ( x , y ))

Converting 5 to CNF:
5. "x"y[ $z( parent ( x , z)  parent ( z, y ))  grand ( x , y )]
 "x"y"z [ ( parent ( x , z)  parent ( z, y ))  grand ( x , y )]
 parent ( x , z )  parent ( z , y )  grand ( x , y )
Refutation Procedure - Example (cont.)

1. father ( john, mary )


2. mother ( sue, john)
3. father (bob, john) Here is the
KB = final KB in
4. father ( x , y)  parent ( x, y) clausal form:
5. mother ( x , y )  parent ( x , y )
6. parent ( x , z)  parent ( z, y)  grand ( x , y )

Next we want to prove the following using resolution refutation:

$x parent ( x , john) (there is someone who is john’s parent)


Refutation Procedure - Example (cont.)
To prove, we must first negate the goal and transform into clausal form:

$x parent ( x , john) "x parent ( x , john) parent ( x , john)

The refutation (proof by contradiction):

parent ( x , john) father ( x , y )  parent ( x , y ) (clause 4)

y = john

father ( x , john) father (bob, john) (clause 3)

x = bob

Note that the proof is constructive: we end up with an answer x = bob


Refutation Procedure - Example (cont.)

1. father ( john, mary )


2. mother ( sue, john)
3. father (bob, john) Here is the
KB = final KB in
4. father ( x , y)  parent ( x, y) clausal form:
5. mother ( x , y )  parent ( x , y )
6. parent ( x , z)  parent ( z, y)  grand ( x , y )

Next we want to prove the following using resolution refutation:

grand ( sue, mary ) (sue is a grandparent of mary)


Refutation Procedure - Example (cont.)
Now, let’s prove that sue is the grandparent of mary:

grand ( sue, mary ) parent ( x , z )  parent ( z , y )  grand ( x , y ) (clause 6)


x = sue
y = mary
parent ( sue, z )  parent ( z , mary ) father ( x1 , y1 )  parent ( x1 , y1 ) (clause 4)
z = x1
y1 = mary
parent ( sue, x1 )  father ( x1 , mary ) father ( john, mary ) (clause 1)

x1 = john

parent ( sue, john) mother ( x2 , y2 )  parent ( x2 , y2 ) (clause 5)


x2 = sue
y2 = john
mother ( sue, john) mother ( sue, john) (clause 2)
KB in Restricted Forms
▪ The sentences in the KB are restricted to some special forms
▪ Horn form (Horn normal form)
(A ∨ ¬B) ∧ (¬ A ∨ ¬C ∨ D) Also be written as: (A ⇒ B) ∧ ( A ∧ C) ⇒ D)

▪ A disjunction of literals with at most one positive, i.e. unnegated, literal.


▪ A clause with one literal, e.g. A, is also called a fact
▪ A clause representing an implication (with a conjunction of positive literals in
antecedent and one positive literal in consequent), is also called a rule
▪ Two inference rules that are sound and complete with respect to propositional symbols
for KBs in the Horn normal form:
▪ Resolution (positive unit resolution)
▪ Modus ponens
Horn normal form in FOL
▪ First-order logic (FOL)
▪ Adds variables, works with terms
▪ Generalized modus ponens rule:

▪ Generalized modus ponens:


▪ Is sound and complete for definite clauses and no functions
▪ In general it is semidecidable
▪ Not all first-order logic sentences can be expressed in the HNF form
Entailment with Horn Clause
▪ Deciding entailment with Horn clauses can be done in time that is linear in
the size of the knowledge base
▪ Forward Chaining:
▪ Idea: Whenever the premises of a rule are satisfied, infer the conclusion. Continue with rules
that became satisfied.
▪ Typical usage: If we want to infer all sentences entailed by the existing KB.

▪ Backward Chaining:
▪ Idea: To prove the fact that appears in the conclusion of a rule prove the premises of the rule.
Continue recursively
▪ Typical usage: If we want to prove that the target (goal) sentence is α entailed by the existing KB.
Forward and Backward Chaining
▪ Work forward from KB to query α: ▪ Work backwards from the query α to KB:
▪ Fire any rule whose premises are satisfied in the KB ▪ Check if α is known already, or
▪ Add its conclusion to the KB, until query α is found ▪ Prove by BC all premises of some rule concluding α

▪ Assume the KB with the following rules and facts


▪ KB: R1: Steamboat (x) ∧ Sailboat (y) ⇒ Faster (x, y) α = Faster (Titanic , PondArrow )
R2: Sailboat (y) ∧ RowBoat (z) ⇒ Faster (y, z)
R3: Faster (x, y) ∧ Faster (y, z) ⇒ Faster (x, z)
F1: Steamboat (Titanic)
F2: Sailboat (Mistral)
F3: RowBoat(PondArrow)
Forward and Backward Chaining
▪ Assume the KB with the following rules and facts
▪ KB: R1: Steamboat (x) ∧ Sailboat(y) ⇒ Faster(x, y) α = Faster(Titanic, PondArrow)
R2: Sailboat(y) ∧ RowBoat(z) ⇒ Faster(y, z)
R3: Faster(x, y) ∧ Faster(y, z) ⇒ Faster(x, z)
F1: Steamboat(Titanic)
F2: Sailboat(Mistral)
F3: RowBoat(PondArrow)
Rule R1 is satisfied: x/Titanic, y/Mistral
F4: Faster(Titanic, Mistral)
Rule R2 is satisfied: y/Mistral, z/PondArrow
F5: Faster(Mistral, PondArrow)
Rule R3 is satisfied:
Faster(Titanic, PondArrow)
Forward and Backward Chaining
▪ Assume the KB with the following rules and facts
▪ KB: R1: Steamboat (x) ∧ Sailboat ( y) ⇒ Faster (x, y) α = Faster (Titanic , PondArrow )
R2: Sailboat ( y) ∧ RowBoat (z) ⇒ Faster ( y, z)
R3: Faster (x, y) ∧ Faster ( y, z) ⇒ Faster (x, z)
F1: Steamboat (Titanic )
F2: Sailboat (Mistral )
F3: RowBoat(PondArrow)
Example
▪ Encode the following English statement into First-Order definite cluses.
"The law says that it is a crime for an American to sell weapons to hostile nations. The
country Nano, an enemy of America, has some missiles, and all of its missiles were sold
to it by Colonel West, who is American."

▪ Prove the following by using the forward and backward chaining


“Colonel West is a criminal”
Terms
"The law says that it is a crime for an American to sell weapons to hostile nations. The
country Nano, an enemy of America, has some missiles, and all of its missiles were sold
to it by Colonel West, who is American."

▪ Constants: ▪ Function (propoerty): ▪ Relation:


▪ America ▪ American(x): x is an American ▪ Owns(x, y): x owns y
▪ Nano ▪ Weapon(x): x is a weapon ▪ Sells(x, y, z): x sells y to z
▪ West ▪ Hostile(x): x is a hostile nation ▪ Enemy(x, y): x is an enemy of y
▪ Criminal(x): x is a criminal
▪ Missile(x): x is a missile
Example
▪ Sentences ▪ First-Order Definite Clauses
▪ It is a crime for an American to sell ▪ Sells(x, y, z)  American(x)  Weapon(y)  Hostile(z)
weapons to hostile nations  Criminal(x)
▪ Nano ... has some missiles ▪ $x Owns(Nano, x)  Missile(x):
Owns(Nono,M1)  Missile(M1)
▪ All of its missiles were sold to it by ▪ Missile(x)  Owns(Nano, x)  Sells(West, x, Nano)
Colonel West
▪ Missiles are weapons ▪ Missile(x)  Weapon(x)
▪ An enemy of America counts as "hostile“ ▪ Enemy(x, America)  Hostile(x)
▪ West, who is American ▪ American(West)
▪ The country Nano, an enemy of America ▪ Enemy(Nano, America)
Forward Chaining
▪ First-Order Definite Clauses
▪ American(x)  Weapon(y)  Sells(x, y, z)  Hostile(z)  Criminal(x)
▪ Missile(x)  Weapon(x)
▪ Enemy(x, America)  Hostile(x)
▪ Missile(x)  Owns(Nano, x)  Sells(West, x, Nano)
▪ Owns(Nono,M1)
▪ Missile(M1)
▪ American(West)
▪ Enemy(Nano, America)
Backward Chaining
▪ First-Order Definite Clauses
▪ American(x)  Weapon(y)  Sells(x, y, z)  Hostile(z)  Criminal(x)
▪ Missile(x)  Weapon(x)
▪ Enemy(x, America)  Hostile(x)
▪ Missile(x)  Owns(Nano, x)  Sells(West, x, Nano)
▪ Owns(Nono,M1)
▪ Missile(M1)
▪ American(West)
▪ Enemy(Nano, America)
Summary
▪ First-order logic:
▪ objects and relations are semantic primitives
▪ syntax: constants, functions, predicates, equality, quantifiers
▪ Increased expressive power: sufficient to express real-world problems
▪ Resolution is complete for propositional logic
Forward, backward chaining are linear-time, complete for Horn clauses

▪ Problems:
▪ Handling human conceptual categories, uncertainty and dynamics
▪ Next week: Planning with FOL

You might also like