9-Predicate Logic v2
9-Predicate Logic v2
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
▪ 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 $xloves( x , tweety)
$x likes( x , broccoli ) is equivalent to "xlikes( 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) = { ( , ); ( , ); ……. }
▪ 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.
"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
▪ (OI) Or-Introduction ,
▪ (UR) Unit Resolution
,
▪ (R) General Resolution
▪ 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
▪ There is a single most general unifier (MGU) that is unique up to renaming of variables.
▪ 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
α = 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
▪ If a universal quantifier precede the existential quantifier replace the variable with a function of the
“universal” variable
(2) "x [($y p( x , y )) ($y (q ( x , y ) r ( x , y )))] Move inward the negation symbol
(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.)
y = john
x = bob
x1 = john
▪ 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 α
▪ Problems:
▪ Handling human conceptual categories, uncertainty and dynamics
▪ Next week: Planning with FOL