Docsity

Interference in First Order Logic - Lecture Slides | CS 440, Study notes of Computer Science

Partial preview of the text

Download Interference in First Order Logic - Lecture Slides | CS 440 and more Study notes Computer Science in PDF only on Docsity!

Inference in First Order LogicInference in First Order Logic

Introduction to Artificial Intelligence

CS440/ECE

Lecture 12

New homework out today, due March 2

Last lectureLast lecture

-^

Examples of sentences

-^

Simple inference rules

-^

Inference with quantifiers

This lecture^ This lecture

-^

Substitutions and unification

-^

Generalized Modus Ponens

-^

Resolution and refutation

Reading^ Reading

-^

Chapter 9

Universal Elimination (UE):Universal Elimination (UE):

x

Subst(

{x/

[τ

must be a ground term (i.e., no variables).] Example

Imagine Universe of Discourse is

{Rodrigo, Sharon, David, Jonathan}

x At (x, UIUC)

OK(x)

At(Rodrigo, UIUC)

OK(Rodrigo)

Inference with Universal Quantifiers^ Inference with Universal Quantifiers

substitution list^ substitution list

Inference with Existential QuantifiersInference with Existential Quantifiers

Existential Elimination:

∃ν α Subst({

ν/k},

α

where

k

is a

new (Skolem) constant.

Example

From

∃x Teaches(x, CS348)

we can infer that

Teaches(PorkyPig, CS348)

if the symbol

PorkyPig

has

not

appeared before.

Search with primitive inference rulesSearch with primitive inference rules

•^

Operators are inference rules.

-^

States are sets of sentences.

-^

Goal test checks state to see if itcontains query sentence..

-^

Problem: branching factor huge, esp. for UE.

-^

AI, UE, MP is a common inference pattern.

-^

Idea:

find a substitution that makes the rule premise match

some known facts.

A single, more powerful inference rule.

UnificationUnification

A substitution

σ

unifies

atomic sentences p and q if

Subst

(σ

, p)=

Subst

(σ

, q)

(also denoted

p

σ

=q

σ

p^ p

qq

Knows(John,x)

Knows(John, Jane)

Knows(John,x)

Knows(y, Amy)

Knows(John,x)

Knows(y, Mother(y))

{ x/Jane }{ y/John, x/Amy }{ y/John, x/Mother(John) }

Idea:

Unify rule premises with known facts, apply unifier to conclusion. E.g., if we know both

q

and

Knows(John,x)

⇒

Likes(John,x)

then we conclude:

Likes(John,Jane)Likes(John,Amy)Likes(John,Mother(John))

Most General UnifierMost General Unifier

•^

A substitution

σ

is more general than

τ

iff there is a substitution

δ^

such that

σδ

τ.

  • e.g.

σ

= { z/ F(w) } is more general than

τ

= { z/F(C) } since

δ^

= { w/C }

•^

A most general unifier

ρ

of

φ

and

ψ

is such that, for any unifier

κ^

of

φ

and

ψ

, there exists a substitution

φκ

ψκ

φρ

)κ

•^

Informally, the most general unifier (MGU) imposes the fewestconstraints on the terms (contains the most variables).

-^

MGU’s are unique up to variable reordering and changes ofnaming of variables in terms.

-^

The unification procedure on p. 278 gives the MGU.

Generalized ModusGeneralized Modus

PonensPonens

(GMP)(GMP)

p

’, p 1

’,…, p 2

’, (pn

p

pn

q)

where

p

’σσσσi

= p

σσσσi

q

σ

for all

i

For example, let

p

’ = Faster (Bob, Pat) 1 p

’ = Faster (Pat, Steve) 2 Faster (x, y)

Faster (y, z)

Faster (x, z)

Unify

p

and

p

with the premise

σ

= { x/Bob, y/Pat, z/Steve }

Apply substitution to the conclusion

q

σ

= Faster(Bob, Steve)

p

andi

q

atomic sentences

Universally quantified variables

Forward chainingForward chaining

When a new fact

P

is added to the KB:

For each rule such that

P

unifies with a premise,

if the other premises are knownthen add the conclusion to the KB and continue chaining.

Forward chaining is

data-driven

e.g., inferring properties and categories from percepts.

Forward Chaining ExampleForward Chaining Example

-^

White: Facts added in turn

-^

Yellow:

The result of implication of rules.

  1. Buffalo(x)

∧

Pig(y)

⇒

Faster(x, y)

  1. Pig(y)

∧

Slug(z)

⇒

Faster(y, z)

  1. Faster(x, y)

∧

Faster(y, z)

⇒

Faster(x, z)

  1. Buffalo(Bob)

[ Unifies with 1-a ]

  1. Pig(Pat)

[ Unifies with 1-b, GMP Fires ][ Unifies with 2-a ]

  1. Faster(Bob,Pat)

[ Unifies with 3-a, 3-b ]

  1. Slug(Steve)

[ Unifies with 2-b, GMP Fires ]

  1. Faster(Pat, Steve)

[ Unifies with 3-b and with 6,GMP Fires ]

  1. Faster (Bob, Steve) 10. …

Backward Chaining ExampleBackward Chaining Example

  1. Pig(y)

Slug(z)

Faster (y, z)

  1. Slimy(a)

Creeps(a)

Slug(a)

  1. Pig(Pat)4. Slimy(Steve)5. Creeps(Steve)

Soundness & CompletenessSoundness & Completeness

•^

An inference procedure is sound if the conclusion is true in allcases where the premises are true.

-^

Easy to show the

Generalized ModusGeneralized Modus

PonensPonens

(GMP) is sound.(GMP) is sound.

•^

Completeness:

If KB entails

α

, can GMP be used to infer

α

PhD(x)

HighlyQualified(x)

PhD(x)

EarlyEarnings(x)

HighlyQualified(x)

Rich(x)

EarlyEarnings(x)

Rich(x)

Should be able to infer

Rich(Me)

[or

Rich(Kiki)

for that matter],

but can’t since

PhD(x)

EarlyEarnings(x)

is not a Horn

sentence.

•^

Therefore,

GMP is NOT complete!GMP is NOT complete!

Resolution Inference RuleResolution Inference Rule

•^

Idea:

If

β

is true or

α

is true

and

β

is false or

γ

is true

then

α

or

γ

must be true

•^

Basic resolution rule from propositional logic:

α ∨ β,

¬β ∨ γ

α ∨ γ

•^

Can be expressed in terms of implications

¬α ⇒ β

,^

β ⇒ γ

¬α ⇒ γ

•^

Note that Resolution rule is a generalization of Modus Ponens

β,

β ⇒ γ

is equivalent to

TRUE

⇒ β

,^ β ⇒ γ

γ^

TRUE

⇒ γ

Generalized ResolutionGeneralized Resolution

Generalized resolution rule for first order logic (with variables)If

p

can be unified withj

¬

qk

, then we can apply the resolution rule: p^1

∨ …

∨

p

∨j …

∨

p

m

q^1

∨ …

∨

q

∨k …

∨

q

n

Subst(

θ, (p

∨ 1 …

∨

p

j-

∨ p

j+

∨ …

∨

p

m^

∨q

∨ 1 …

∨

q

k-

∨ q

k+

∨ …

∨

q

))n

where

θ

= Unify (

pj

,^ ¬

qk

)

•^

Example:^ KB:

¬

Rich(x)

∨

Unhappy(x)

Rich(Me)

Substitution:

θ^

= {

x/Me

}

Conclusion:

Unhappy(Me)