INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances...

77
INFERENCE IN FIRST ORDER LOGIC

Transcript of INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances...

Page 1: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

INFERENCE IN FIRST ORDER LOGIC

Page 2: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

SUBST()

• SUBST() is a method of substituting particular instances for variables (or vice versa).

• The syntax is as follows:

SUBST({v/g}, )

v is some variable, or unknowng is a ground term, a term that contains no variables (i.e. a

constant symbol such as e or pi)

is a sentence in First-Order logic

Thus, the purpose of using the SUBST for a sentence , is to replace a variable v with some ground term g.

Page 3: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Universal Elimination

• The purpose of Universal Elimination is to remove all occurrences of the variable v, and replace them with the more specific ground term g.

• Which can be written:

For any sentence , variable v, and ground term g:

v, ---------------------

SUBST({v/g}, )

Page 4: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

An example of Universal Elimination could be:

: v, Loves(v, A.I.)

• Now substitute the ground term ‘Rose’ for v:

• SUBST({v/Rose}, )

• And you’re left with:

• Loves(Rose, A.I.)

Page 5: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Why does this work?

• Think of Universal Elimination as And-Elimination (a^b^c |- a)

• Thus, Loves(v, A.I.) represents all instances of people who love A.I.

• If the knowledge base consisting of people who love A.I. was comprised of Rose, James, Maggie, and Neil we would have (Rose ^ James ^ Maggie ^ Neil).

• Using And-Elimination, we can eliminate James, Maggie, and Neil, and then conclude that Rose does in fact love A.I.

Page 6: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Existential Elimination

• The purpose of Existential Elimination, is to give a specific instance a name or symbol that does not already appear in our knowledge base.

• The definition is as follows:

For any sentence , variable v, and constant symbol k that does not appear elsewhere in the knowledge base:

v, ---------------------- SUBST({v/k}, )

Page 7: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

An example of Existential Elimination could be:

: There exists a number that is equal to the circumference of a circle divided by its diameter.

• Thus, v, Satisfies(v, ) means: there exists some number v which satisfies the equation specified by .

• Now, we would like to give v a more specific name, so we might choose the symbol .

• So, SUBST({v/ }, )• And we’re left with:• Satisfies(, ), which reads: is a number which is

equal to the circumference of a circle divided by its diameter.

Page 8: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Existential Elimination

• It is very important that does not already appear in our knowledge base.

• As it would be a large mistake to have two different numbers which can be represented by the symbol .

Page 9: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Existential Introduction:

• Existential Introduction is the exact opposite of Existential Elimination.

• Its purpose is to replace some symbol or ground term, with a variable.

• The definition is as follows: 

For any sentence , variable v that does not occur in , and ground term g that does occur in :

--------------------------- v, SUBST({g/v}, )

Page 10: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

An example of Existential Introduction could be:

is a number that is equal to the circumference of a circle divided by its diameter.

• Satisfies(, )• Now, we want to remove from this sentence, and

make it more general.• So, we apply our SUBST

• SUBST({ /v}, )• And we’re left with: v, Satisfies(v, ) which reads: There exists some

number that is equal to the circumference of a circle divided by its diameter.

Page 11: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

An example of Existential Introduction could be(1):

is a number that is equal to the circumference of a circle divided by its diameter.

• Satisfies(, )• Now, we want to remove from this sentence, and

make it more general.• So, we apply our SUBST

• SUBST({ /v}, )• And we’re left with: v, Satisfies(v, ) which reads: There exists some

number that is equal to the circumference of a circle divided by its diameter.

Page 12: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Existential Introduction(1):

• Similarly to Existential Elimination, it is important that v does not already occur in the sentence .

• And likewise, our ground term () must be in the knowledge base to begin with.

Page 13: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

An example of Existential Introduction could be(crime):

1 - The law says that is a crime for American

2 - to sell weapons to hostile nations .

3 - The country Nono,an enemy of America,

4 - has some missiles, and all of its missiles

5 - were sold to it by Colonel West,who is American

Page 14: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

"…it is a crime for an American to sell weapons to hostile nations ."

(8_1) : x,y,z American(x) ^ Weapons(y)^ Nation(z) ^ Hostile(z) ^ Sells(x,y,z) Criminal(x)

Page 15: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

(8_2) : “ None … has some missiles “ : $x Owns (Nono,x)^Missile(x)

(8_3) : “ All of its missiles were sold to it by

Colonel West “ :

$ x Owns (Nono,x) ^ Missile(x)

Sells( West ,Nono,x)

Page 16: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

)8_4( : “ missile is a kind of weapon “ : $Missile(x) Weapon(x)

)8_5) : “ Hostile is an enemy of America “ : $Enemy (x,America)Hostile (x)

(8_6) : “ west,who is American.....“ :

$ American (West)

Page 17: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)(8_7) : ” The country Nono …":

$ Nation(Nono)

)8_8) : “ Nono ,an enemy of America…"

$ Enemy(Nono,America)

(8_9( :

$ Nation(America)

• From (8_2) and Existential Elimination :

(8_10) :

$ Owns(Nono,M1) ^ missile(M1)

Page 18: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

• From (8_10(, And , (^) Elimination :

(8_11 (:

$ Owns(Nono,M1)

• From (8_4( and Universal Elimination :

)8_13( :

$ Missile (M1)Weapon(M1)

Page 19: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

• From (8_12),(8_13 (,Modus Ponens (MP):

(8_14( :

$ Weapon(M1)

• From (8_3), Universal Elimination (UE):

(8_15) :

$ Owns(Nono,M1) ^ Missile(M1) Sells(West,Nono,M1)

Page 20: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

• From (8_15(,(8_10), MP :

(8_16) :

$ Sells(West,Nono,M1)

• From (8-1), Universal E (3th) :

(8_17) :

$ American (West) ^ Weapon(M1) ^ Nation(Nono) ^ Hostile (Nono) ^ sells(West,Nono,M1)Criminal(West)

Page 21: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

• From(8_5), Universal Elimination :

(8_18) :

$ Enemy (Nono, America)

Hostile (Nono)

• From(8_18),(8_8),MP :

(8_19) :

$ Hostile (Nono)

Page 22: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example of Existential(crime)

• From (8_6),(8_7),(8_14),(8_16),(8_19) :

(8_20) :

$ American (West) ^ Weapon(M1) ^ Nation(Nono)^ Hostile (Nono) ^ Sells(West,Nono,M1)

• From (8_17),(8_20),MP :

(8_21) :

$ Criminal(West)

Page 23: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

• Generalized modus ponens enables us to take some sentences from a knowledge base and infer a new sentence in a single step.

• The formula is:

For atomic sentences pi, pi1, and q , where there is a

substitution such that SUBST(, pi1) = SUBST(, pi),

for all i:

• p11,p2

1,...,pn1, (p1^p2^...^pn => q)

-----------------------------------------

SUBST(theta, q)

• It is an efficient improvement and is more powerful than the regular modus ponens.

Generalized modus ponens

Page 24: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

example Example of generalized modus ponens of Existential(2)

• p11,p2

1,...,pn1, (p1^p2^...^pn => q)

-----------------------------------------

SUBST(theta, q)

P1’ is Missile(M1) p1 is Missile(x)

P2’ is Owns(y,M1) p2 is Owns(Nono,x)

Theta is {x/M1 , y/Nono} q is Sells (West,Nono,x)

• SUBST ( theta,q) is Sells ( West,Nono, M1)

Page 25: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

• Canonical form for modus ponens requires that each sentence in KB be either an atomic sentence or an implication with a conjunction of atomic sentences on the left hand side and a single atom on the right.

• Sentences in the canonical form are called Horn sentences.

Canonical form

Page 26: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Horn sentences

• Sentences must be in Horn sentence form to use generalized modus ponens.

• If all the sentences are horn sentences, then the KB is in Horn Normal Form.

• We use and-elimination and existential-elimination to remove conjuncts and existential quantifiers.

• Horn sentences are a useful class of sentences for which a polynomial-time inference procedure exists.

Page 27: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

• We use the routine UNIFY to take two atomic sentences q and p and return a substitution that would make q and p look the same.

• This is how we found an appropriate substitution in the example of generalized modus ponens:

• UNIFY(p , q) = , SUBST( , P ) = SUBST( , q )

Unification

Page 28: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Efficiency:• -it takes bigger steps, combining several small inferences

into one.-In just one step it does what is required for

-an And-Introduction-a Universal Elimination- and Modus Ponens

• -it takes sensible steps - it uses substitutions that are guaranteed to help rather than randomly trying Universal Eliminators. The unification algorithm takes two sentences and returns a substitution that makes them look the same if such a substitution exists.

• -it makes use of a pre-compilation step that converts all the sentences in the knowledge base into canonical form.

Why generalized modus ponens are helpful

Page 29: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Unification Example

• “John hates everyone he knows .”• Knows(John,x) Hates(John,x)

• Knows(John,Jane)• Knows(y,Leonid)• Knows(y,Mother(y))• Knows(x,Elizabeth)•

Page 30: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Unification ExampleContinuance

1 _ UNIFY) Knows( John , x ) , Knows( John , Jane )) = { x / jane }

2_ UNIFY) Knows( John , x ) , Knows( John , Leonid )) = { x / Leonid , y / John}

3_ UNIFY) Knows( John , x ) , Knows( y , Mother (y))) = { y / John , x / Mother ( John ))}

4_ UNIFY) Knows( John , x ) , Knows( x , Leonid )) = fail [A point , in this state . We will see it, soon]

Page 31: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Renaming

Renaming: Renaming is where you switch the variable inside a predicate, with another variable. Though after the renaming, the sentences must mean the same thing.

Eg. A renaming of the sentence Watches(x, Movies) … Is: Watches(y, Movies)Though: Movies(x, x) and Movies(x, y) are not renamings of each other.

Page 32: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

That point is here

4_ UNIFY) Knows( John , x 1) , Knows( x2 , Leonid ))

={x1 / Elizabeth , x2 / John }

x2 Knows( x2 , Elizabeth ) , x Knows( x , Elizabeth ) • Have unification sense

Page 33: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Unification Example( crime )

(8_22) :

$ American (x) ^

Weapon(y) ^

Nation(z) ^

Hostile (z) ^ Sells(x,z,y) Criminal (x)

Page 34: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Unification Example( crime )

(8_23) :

$ Owns( Nono , M1)

(8_24) :

$ Missile( M1)

(8_25) :

$ Owns( Nono , x ) ^ Missile( x )

Sells( West , Nono ,x )

Page 35: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Unification Example( crime )

(8_26) : $ Missile( x ) Weapon ( x )(8_27) : $ Enemy( x , America ) Hostile( x )(8_28) : $ America ( West )(8_29) : $ Nation ( Nono )(8_30) : $ Enemy(Nono , America ) (8_31) : $ Nation (America)

Page 36: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Unification Example( crime )

• From (8_24),(8_26),MP :

(8_32) :

$ Weapon ( M1)

From (8_28),(8_32),(8_29),(8_33),(8_34),

(8_22), MP :

(8_34) :

$ Criminal ( west )

Page 37: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

We get: (4) x person(x) using Universal Introduction on 2 (5) x,y eatFruit(x,y) using Universal Introduction on 3 (6) x,y person(x) ^eatFruit(x,y)

using And Introduction on 4,5 (7) x healthy(x) using modus ponens on 1,6 (8) healthy(Bob) by Universal Elimination on

• Using regular modus ponens:

Given in the knowledge base:

(1) x,y person(x) ^ eatFruit(x,y) => healthy(x)

(2) person(Bob)

(3) eatFruit(Bob, Mango)

Comparing modus ponens with generalized modus ponens

Page 38: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

• Using generalized modus ponens:

Given in the knowledge base:

(1) x,y person(x) ^ eatFruit(x,y) => healthy(x)

(2) person(Bob)

(3) eatFruit(Bob, Mango)We get:

(4) healthy(Bob) using = {x/Bob, y/Mango}

Comparing modus ponens with generalized modus ponens

Page 39: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

CompositionComposition: Another technique we need before we begin is the

idea of acomposition of substitutions. Compose(1, 2) returns a substitution, whose effect is

identical to:Subst(Compose(1, 2), p) = Subst(2, Subst(1, p))Eg. p = Watches(x, y), 1 = {x / Don}, 2 = {y / TV}Subst(2, Subst(1, p)) = Subst(2, Watches(Don, y)) = Watches(Don, TV).Subst(Compose(1, 2), p) = Subst( {x / Don, y / TV}, p)

= Watches(Don, TV).

Page 40: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Forward Chaining Algorithm

•This algorithm is used as a reasoning program.

•And it is based upon the Generalized Modus Ponens

•The algorithm takes sentences currently in the Knowledge Base and generates new conclusions that can be used to infer even more conclusions.

Page 41: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

About Forward Chaining

• Adds inputted sentences to the Knowledge Base

• Uses Generalized Modus Ponens to attempt to infer new facts.

Page 42: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Second half of the Algorithm

Procedure Find-And-Infer(KB, premises, conclusion, )

If premises = [] then Forward-Chain(KB, Subst(, conclusion)) else for each p’ in KB s.t. Unify(p’, Subst(, First(premises))) = 2 do Find-And-Infer(KB, Rest(premises), conclusion, Compose(, 2)) end

Page 43: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Procedure Forward-Chain(KB, p) If p or a renaming of p is in KB then Return

Add p to KB

For each (p1^…^pn -> q) in KB s.t. I, Unify(pi,p) = succeeds do Find-And-Infer( KB, [p1,…, pi-1, Pi+1,…, pn], q, ) End

First half of the Algorithm

Page 44: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Forward Chaining Example(crime)

(8_36) :

$ American (x) ^

Weapon(y) ^

Nation(z) ^

Hostile (z) ^ Sells(x,z,y) Criminal (x)

Page 45: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Forward Chaining Example(crime)

(8_37) : $ Owns (Nono , x ) ^ Missile ( x ) Sells( West , Nono , x )(8_38) : $ Missle ( x ) Weapon (x)(8_39) : $ Enemy ( x , America ) Hotile( x )

Page 46: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Forward Chaining Example(crime)Addtion Atomic Sentenes To kowledge Base(1)

Step 1 :Compatiable with (8_36) defaulte1_FORWARD _ CHAIN (KB , America (West))

FC unknowns another (8_36)’s defaultes then , fc return with no new inference

Step 2 :Compatiable with (8_39) defaulte2_FORWARD _ CHAIN (KB , Nation(Nono))

There are some lose defaulte then fc return

Step 3 :Compatiable with (8_36) defaulte,and {x/Nono}3_FORWARD _ CHAIN (KB , Enemy(Nono,America))

Page 47: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Forward Chaining Example(crime)Addtion Atomic Sentenes To kowledge Base(2)

Step 4 :Compatiable with (8_36)’s default4_FORWARD _ CHAIN (KB , Hostile(Nono)) Stop processingStep 5 :Compatiable with (8_37)’s default , and {x/ M1}5_FORWARD _ CHAIN (KB , Owns(Nono,M1)) Stop processingStep 6 :Compatiable with (8_37)’s and (8_38)’s default6_FORWARD _ CHAIN (KB , Missile(M1))

Page 48: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Forward Chaining Example(crime)Addtion Atomic Sentenes To kowledge Base(3)

studing step 6

1_Step 6 :

Compatiable with (8_37)’s default

Page 49: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Backward Chaining Algorithm• The same principle that applies for forward

chaining, works in reveres for backward chaining.• How it works:1) Start with something you wish to prove.2) Find implication sentences that would allow you to

conclude it.3) From there try to establish the premise in turn.

• In short it works the same as for the Generalized Modus Ponens, though in reverse.

Page 50: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

The Algorithm pt. 1

Function Back-Chain(KB, q) returns a set of substitutions Back-Chain-List(KB, [q], {})

Page 51: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

The Algorithm pt. 2

Function Back-Chain-List(KB, qlist, )Inputs: KB, a knowledge base qlist, a list of conjuncts forming a query( already applied) , the current substitutionLocal vars: answers, a set of substitutions, initially empty if qlist is empty then return {} q <- First(qlist) For each qi’ in KB s.t. <- Unify(q, qi’) succeeds do Add Compose(, i) to answers end

Page 52: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

The Algorithm pt. 3

For each (p1^…^pn -> qi’) in KB s.t. i <- Unify(q,qi’) succeeds do answers <- Back-Chain-List(KB, Subst(i, [p1...pn]),Compose(,i)) answers

End

Return the union of Back-Chain-List(KB, Rest(qlist), ) for each answers

Page 53: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

How it works

• The algorithm tries to find the inputted sentence in the KB.

• If it is not found, it then attempts to find implications in the KB, where the inputted sentence is the conclusion

• The algorithm then recursively calls itself with each premise of each implication, until something definite can be said or found.

Page 54: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Backward Chain Inference’s TreeThe resoulet is certain

West is a criminal

American(x) Weapon(y) Nation(z) Hostile(Nono) Sells(West,Nono,M1)

Missile(y) Enemy(Nono,America)

Owns(Nono,M1) Missile(M1)

Criminal(x)

Yes,{x/west} Yes,{z/Nono}

Yes,{y/M1}Yes,{}

Yes,{}Yes,{}

Page 55: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Backward Chain Inference Tree The resoulet is not certain

American(x) Weapon(y) Nation(z) Hostile(Nono) Sells(West, America,M1)

Missile(y)

fail

Criminal(x)

Yes,{x/west} Yes,{z/America}

Yes,{y/M1}

Page 56: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

An Example

• Back-Chain(GivesFreeDrinks(Glen))

• |-> Back-Chain(Friend(Glen))

• |-> Back-Chain(Bartender(Glen))

• |-> Back-Chain(Beer(Guinness))

• |-> Back-Chain(Serves(Glen, Guinness))

In KB: x,y Bartender(x) ^ Beer(y) ^ Serves(x, y) -> Friend(x) x Friend(x) -> GivesFreeDrinks(x) -------------------------------------------------------------------------------

Page 57: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Completeness 8_5

• For a language to be complete, you must have the ability to be able to say “For any sentence which is a consequence of a language, then that sentence is deducible from that language”

• This hear brings us to Kurt Gödel’s Completeness Theorem, which he came up with in 1930 – 1931:

• If KB |= then KB |-R

Page 58: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

More on Completeness

• There is one main problem with the completeness theorem.

• It states that if a sentence follows, then it can be proved.

• Normally we can’t tell until a proof is done that a sentence does follow; what happens when the sentence does not follow?

Page 59: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Even more on Completeness

• In First Order Logic it turns out that we can not tell if a sentence follows or not.

• The proof procedure can go on infinitely but you can never tell if it’s stuck in a loop or if the answer will pop out.

• This problem very similar to the halting problem

Page 60: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Final info on Completeness

• Finally we can say FOL is semi decidable.

• This is because we can show sentences follow from premises, though we can not always show that they do not .

Page 61: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Resolution 8.6

• Some basic rules of deduction we should all know and or recognize.

v , v |- v • Or equivalently -> , -> |- ->

• These are also the basic rules of resolution

Page 62: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Resolution

• Much like the Generalize Modus Ponens, There is a generalized form of resolution.

• It generalizes the two rules listed earlier into two forms of Generalized Resolution, one for disjunctions and one for implications.

Page 63: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Resolution Disjunction

Generalized Resolution (Disjunction)For literals pi and qi, where Unify(pj, qk) =

p1 v … pj … v pm

q1 v … qk … v qn

------------------------------------------------------------------------Subst(, (p1 v … pj-1 v … pm v q1 … qk-1 v qk+1 … v qn))

Page 64: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Resolution Implication

Generalized Resolution (Implication)For atoms pi, qi, ri, si, where Unify(pj, qj) =

p1 ^ … pj … ^ pn1 -> r1 ^ … ^ rn2

s1 ^ … ^ sn3 -> q1 v … qk … v qn4

---------------------------------------------------------------------Subst(, (p1^…^pj-1^pj+1^pn1^s1^…^sn3 -> r1v…v rn2v q v…v qk-1v qk+1 v…v qn4))

Page 65: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Resolution

• It is important to realize that resolution is a generalization of Modus Ponens.

Page 66: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Conclusion

• FOL is a tool for AI computers to interpret English from a mathematical point of view.

• The algorithms in this chapter help speed up the thought process done by a computer on FOL.

Page 67: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Resolution of S(A) from KB in (8_41)

P(w)Q(w)

True P(x) v R(x)

TrueS(A)

R(z) S(z)

Q(y)S(y)

P(w)S(w)

True S(x) v R(x)

•{y/w}

{w/x}

{x/A, z/A}

Page 68: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

P(w)Q(w)

True P(x) v R(x)

TrueS(A)

R(z) S(z)

Q(y)S(y)

P(w)S(w)

True S(x) v R(x)

S(A)False

TrueFalse

•y/w

w/x

•z/x

•x/A

Page 69: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

نرمال فرم به تبديل

شرطي _1 تركيب حذف pq = ~pvq

~ حذف _2

~(p v q ) ~p ^ ~q

~(p ^ q) ~p v ~q

~ x,p x ~p

~ x,p x ~p

~~pp

Page 70: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

نرمال فرم به تبديل

3_ سازي استانداردعمل حوزه به توجه با مشابه هاي نام تغيير

سورها كرد

4_ چپ به سورها انتقالp v x q x p v q

Page 71: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

نرمال فرم به تبديل

skolemization :skolemize _5

x Person(x) y Heart (y) ^ Has (x ,y)

x Person(x) Heart (H) ^ Has (x , H)

OR

x Person(x) Heart (f(x)) ^ Has (x , f(x))

Page 72: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

نرمال فرم به تبديل

v 6_ بر ^ توزيع(a ^ b ) v c == (a v c ) ^ (b v c )

7_ شده مسطح اي النه عطفي و فصلي تركيبات(a v b ) v c == (a v b v c )(a ^ b ) ^ c == (a ^ b ^ c )

شرطي _8 تركيبات به فصلي تركيبات تبديل( ~a v ~b v c v d ) (a ^ b) (c v d )

Page 73: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

اثبات مثال

• Jake owns a dog .

• Every dog owner is an animal lover .

• No animal lover kills an animal .

• Either Jake or Curiosity killed the cat , who is named Tuna .

• Did Curiosity kill the cat ?

Page 74: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

اثبات مثال

• A. x Dog (x) ^ Owns (Jake ,x)

• B. x [ y Dog(y) ^ Owns(x,y)Animal lover(x)]

• C. x Animallover(x)yAnimal(y)~Kills(x,y)

• D. Kills(Jake, Tuna) v Kills(Curiosity, Tuna)

• E. Cat (Tuna)

• F. x Cat(x) Animal(x)

Page 75: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

اثبات مثال

• A1. Dog(D)

• A2. Owns(Jake,D)

• B. Dog(y) ^ Owns(x,y) Animal lover(x)

• C. Animal lover(x) ^ Animal(y) ^ Kills(x,y)False

• D. Kills(Jake, Tuna) v Kills(Curiosity, Tuna)

• E. Cat(Tuna)

• F. Cat(x) Animal(x)

Page 76: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows:

Dog(D) •Dog(y)^Owns(x,y)Animallover(x)

Animallover(x)^Animal(y)^Kills(x,y)False

Owns(x,D) Animal lover(x) Owns(Jake,D)

Animallover(Jake)

Cat(Tuna) Cat(x) Animal(x)

•Kills(Jake,Tuna) v Kills(Curiosity,Tuna)

Kills(Curiosity, Tuna)False

Kills(Jake,Tuna)

•Animal(Tuna)

Animallover(x)^Kills(x,Tuna)False

~Kills(Jake, Tuna)

False

{}

{}

{x/Jake}

{y/D}

{x/Jake}{x/Tuna}

•{y/Tuna}

Page 77: INFERENCE IN FIRST ORDER LOGIC. S UBST () S UBST () is a method of substituting particular instances for variables (or vice versa). The syntax is as follows: