37
CS 416 Artificial Intelligence Lecture 12 Lecture 12 First-Order Logic First-Order Logic Chapter 9 Chapter 9

CS 416 Artificial Intelligence

  • Upload
    gwidon

  • View
    18

  • Download
    0

Embed Size (px)

DESCRIPTION

CS 416 Artificial Intelligence. Lecture 12 First-Order Logic Chapter 9. Midterm. October 25 th Up through chapter 9 (excluding chapter 5). Review. Inference in First-Order Logic Could convert first-order logic (FOL) to propositional logic (PL) and use PL inference - PowerPoint PPT Presentation

Citation preview

Page 1: CS 416 Artificial Intelligence

CS 416Artificial Intelligence

Lecture 12Lecture 12

First-Order LogicFirst-Order Logic

Chapter 9Chapter 9

Lecture 12Lecture 12

First-Order LogicFirst-Order Logic

Chapter 9Chapter 9

Page 2: CS 416 Artificial Intelligence

Midterm

October 25October 25thth

Up through chapter 9 (excluding chapter 5)Up through chapter 9 (excluding chapter 5)

October 25October 25thth

Up through chapter 9 (excluding chapter 5)Up through chapter 9 (excluding chapter 5)

Page 3: CS 416 Artificial Intelligence

Review

Inference in First-Order LogicInference in First-Order Logic

• Could convert first-order logic (FOL) to propositional logic Could convert first-order logic (FOL) to propositional logic (PL) and use PL inference(PL) and use PL inference

– Must convert (reduce) Universal and Existential Must convert (reduce) Universal and Existential Quantifiers into PLQuantifiers into PL

– Potential problem with infinite number of substitutionsPotential problem with infinite number of substitutions

• Could lift Modus Ponens to FOLCould lift Modus Ponens to FOL

– Unification required to make expressions look identicalUnification required to make expressions look identical

Inference in First-Order LogicInference in First-Order Logic

• Could convert first-order logic (FOL) to propositional logic Could convert first-order logic (FOL) to propositional logic (PL) and use PL inference(PL) and use PL inference

– Must convert (reduce) Universal and Existential Must convert (reduce) Universal and Existential Quantifiers into PLQuantifiers into PL

– Potential problem with infinite number of substitutionsPotential problem with infinite number of substitutions

• Could lift Modus Ponens to FOLCould lift Modus Ponens to FOL

– Unification required to make expressions look identicalUnification required to make expressions look identical

Page 4: CS 416 Artificial Intelligence

How to perform inference in FOL

Use a knowledge baseUse a knowledge base

• Insert data with “STORE”Insert data with “STORE”

• Retrieve “unified” sentences using “FETCH”Retrieve “unified” sentences using “FETCH”

– Search for substitutions that unite query with every Search for substitutions that unite query with every sentence in KBsentence in KB

How can se make FETCH fast?How can se make FETCH fast?

• Only attempt unifications if they have a chance of succeedingOnly attempt unifications if they have a chance of succeeding

Use a knowledge baseUse a knowledge base

• Insert data with “STORE”Insert data with “STORE”

• Retrieve “unified” sentences using “FETCH”Retrieve “unified” sentences using “FETCH”

– Search for substitutions that unite query with every Search for substitutions that unite query with every sentence in KBsentence in KB

How can se make FETCH fast?How can se make FETCH fast?

• Only attempt unifications if they have a chance of succeedingOnly attempt unifications if they have a chance of succeeding

Page 5: CS 416 Artificial Intelligence

Predicate Indexing

Index the facts in the KBIndex the facts in the KB

• Example: unify Knows (John, x) with KB:Example: unify Knows (John, x) with KB:

– Knows (John, Jane)Knows (John, Jane)

– Knows (y, Bill)Knows (y, Bill)

– Brother (Richard, John)Brother (Richard, John)

– Knows (y, Mother(y))Knows (y, Mother(y))

– Knows (x, Elizabeth)Knows (x, Elizabeth)

Index the facts in the KBIndex the facts in the KB

• Example: unify Knows (John, x) with KB:Example: unify Knows (John, x) with KB:

– Knows (John, Jane)Knows (John, Jane)

– Knows (y, Bill)Knows (y, Bill)

– Brother (Richard, John)Brother (Richard, John)

– Knows (y, Mother(y))Knows (y, Mother(y))

– Knows (x, Elizabeth)Knows (x, Elizabeth)

No need to check

Page 6: CS 416 Artificial Intelligence

Predicate Indexing

• Predicate indexing puts all the Predicate indexing puts all the KnowsKnows facts in one bucket facts in one bucket and all the and all the Brother Brother facts in anotherfacts in another

– Might not be a win if there are lots of clauses for a Might not be a win if there are lots of clauses for a particular predicate symbolparticular predicate symbol

Consider how many people Consider how many people Know Know one anotherone another

– Instead index by predicate and first argumentInstead index by predicate and first argument

Clauses may be stored in multiple bucketsClauses may be stored in multiple buckets

• Predicate indexing puts all the Predicate indexing puts all the KnowsKnows facts in one bucket facts in one bucket and all the and all the Brother Brother facts in anotherfacts in another

– Might not be a win if there are lots of clauses for a Might not be a win if there are lots of clauses for a particular predicate symbolparticular predicate symbol

Consider how many people Consider how many people Know Know one anotherone another

– Instead index by predicate and first argumentInstead index by predicate and first argument

Clauses may be stored in multiple bucketsClauses may be stored in multiple buckets

Page 7: CS 416 Artificial Intelligence

Subsumption lattice

How to construct indices for all possible queries How to construct indices for all possible queries that unify with itthat unify with it

• Example: Employs (AIMA.org, Richard)Example: Employs (AIMA.org, Richard)

How to construct indices for all possible queries How to construct indices for all possible queries that unify with itthat unify with it

• Example: Employs (AIMA.org, Richard)Example: Employs (AIMA.org, Richard)

Page 8: CS 416 Artificial Intelligence

Subsumption Lattice

Page 9: CS 416 Artificial Intelligence

Subsumption lattice

• Each node reflects making one substitutionEach node reflects making one substitution

• The “highest” common descendent of any two nodes is the The “highest” common descendent of any two nodes is the result of applying the most general unifierresult of applying the most general unifier

• Predicate with Predicate with n n arguments will create a lattice with O(2arguments will create a lattice with O(2nn) ) nodesnodes

• Benefits of indexing may be outweighed by cost of storing Benefits of indexing may be outweighed by cost of storing and maintaining indicesand maintaining indices

• Each node reflects making one substitutionEach node reflects making one substitution

• The “highest” common descendent of any two nodes is the The “highest” common descendent of any two nodes is the result of applying the most general unifierresult of applying the most general unifier

• Predicate with Predicate with n n arguments will create a lattice with O(2arguments will create a lattice with O(2nn) ) nodesnodes

• Benefits of indexing may be outweighed by cost of storing Benefits of indexing may be outweighed by cost of storing and maintaining indicesand maintaining indices

Page 10: CS 416 Artificial Intelligence

Forward Chaining

Remember this from propositional logic?Remember this from propositional logic?

• Start with atomic sentences in KBStart with atomic sentences in KB

• Apply Modus PonensApply Modus Ponens

– add new sentences to KBadd new sentences to KB

– discontinue when no new sentencesdiscontinue when no new sentences

• Hopefully find the sentence you are looking for in the Hopefully find the sentence you are looking for in the generated sentencesgenerated sentences

Remember this from propositional logic?Remember this from propositional logic?

• Start with atomic sentences in KBStart with atomic sentences in KB

• Apply Modus PonensApply Modus Ponens

– add new sentences to KBadd new sentences to KB

– discontinue when no new sentencesdiscontinue when no new sentences

• Hopefully find the sentence you are looking for in the Hopefully find the sentence you are looking for in the generated sentencesgenerated sentences

Page 11: CS 416 Artificial Intelligence

Lifting forward chaining

First-order First-order definitedefinite clauses clauses

– disjunction of literals with exactly one positive disjunction of literals with exactly one positive oror

– implication whose antecedent is a conjunction of positive implication whose antecedent is a conjunction of positive literals and whose consequent is a single positive literalliterals and whose consequent is a single positive literal

– all sentences are defined this way to simplify processingall sentences are defined this way to simplify processing

First-order First-order definitedefinite clauses clauses

– disjunction of literals with exactly one positive disjunction of literals with exactly one positive oror

– implication whose antecedent is a conjunction of positive implication whose antecedent is a conjunction of positive literals and whose consequent is a single positive literalliterals and whose consequent is a single positive literal

– all sentences are defined this way to simplify processingall sentences are defined this way to simplify processing

Universal quantificationassumed

Page 12: CS 416 Artificial Intelligence

Example

• The law says it is a crime for an American to sell weapons to The law says it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by has some missiles, and all of its missiles were sold to it by Colonel West, who is AmericanColonel West, who is American

• We will prove West is a criminalWe will prove West is a criminal

• The law says it is a crime for an American to sell weapons to The law says it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by has some missiles, and all of its missiles were sold to it by Colonel West, who is AmericanColonel West, who is American

• We will prove West is a criminalWe will prove West is a criminal

Page 13: CS 416 Artificial Intelligence

Example

• It is a crime for an American to sell weapons to hostile nationsIt is a crime for an American to sell weapons to hostile nations

• Nono… has some misslesNono… has some missles

– Owns (Nono, M1)Owns (Nono, M1)

– Missile (M1)Missile (M1)

• All of its missiles were sold to it by Colonel WestAll of its missiles were sold to it by Colonel West

• It is a crime for an American to sell weapons to hostile nationsIt is a crime for an American to sell weapons to hostile nations

• Nono… has some misslesNono… has some missles

– Owns (Nono, M1)Owns (Nono, M1)

– Missile (M1)Missile (M1)

• All of its missiles were sold to it by Colonel WestAll of its missiles were sold to it by Colonel West

Page 14: CS 416 Artificial Intelligence

Example

• We also need to know that missiles are weaponsWe also need to know that missiles are weapons

• and we must know that an enemy of America counts as and we must know that an enemy of America counts as “hostile”“hostile”

• ““West, who is American”West, who is American”

• The country Nono, an enemy of AmericaThe country Nono, an enemy of America

• We also need to know that missiles are weaponsWe also need to know that missiles are weapons

• and we must know that an enemy of America counts as and we must know that an enemy of America counts as “hostile”“hostile”

• ““West, who is American”West, who is American”

• The country Nono, an enemy of AmericaThe country Nono, an enemy of America

Page 15: CS 416 Artificial Intelligence

Forward-chaining

Starting from the factsStarting from the facts

• find all rules with satisfied premisesfind all rules with satisfied premises

• add their conclusions to known factsadd their conclusions to known facts

• repeat untilrepeat until

– query is answeredquery is answered

– no new facts are addedno new facts are added

Starting from the factsStarting from the facts

• find all rules with satisfied premisesfind all rules with satisfied premises

• add their conclusions to known factsadd their conclusions to known facts

• repeat untilrepeat until

– query is answeredquery is answered

– no new facts are addedno new facts are added

Page 16: CS 416 Artificial Intelligence

First iteration of forward chaining

Look at the implication sentences firstLook at the implication sentences first

• must satisfy unknown premisesmust satisfy unknown premises

• We can satisfy this ruleWe can satisfy this rule

– by substituting {x/M1} by substituting {x/M1}

– and adding Sells(West, M1, Nono) to KBand adding Sells(West, M1, Nono) to KB

Look at the implication sentences firstLook at the implication sentences first

• must satisfy unknown premisesmust satisfy unknown premises

• We can satisfy this ruleWe can satisfy this rule

– by substituting {x/M1} by substituting {x/M1}

– and adding Sells(West, M1, Nono) to KBand adding Sells(West, M1, Nono) to KB

Page 17: CS 416 Artificial Intelligence

First iteration of forward chaining

• We can satisfyWe can satisfy

– with {x/M1}with {x/M1}

– and Weapon (M1) is addedand Weapon (M1) is added

• We can satisfyWe can satisfy

– with {x/Nono}with {x/Nono}

– and Hostile {Nono} is addedand Hostile {Nono} is added

• We can satisfyWe can satisfy

– with {x/M1}with {x/M1}

– and Weapon (M1) is addedand Weapon (M1) is added

• We can satisfyWe can satisfy

– with {x/Nono}with {x/Nono}

– and Hostile {Nono} is addedand Hostile {Nono} is added

Page 18: CS 416 Artificial Intelligence

Second iteration of forward chaining

• We can satisfyWe can satisfy

– with {x/West, y/M1, z/Nono}with {x/West, y/M1, z/Nono}

– and Criminal (West) is addedand Criminal (West) is added

• We can satisfyWe can satisfy

– with {x/West, y/M1, z/Nono}with {x/West, y/M1, z/Nono}

– and Criminal (West) is addedand Criminal (West) is added

Page 19: CS 416 Artificial Intelligence

Analyze this algorithm

Sound?Sound?

• Does it only derive sentences that are entailed?Does it only derive sentences that are entailed?

– Yes, because only Modus Ponens is used and it is soundYes, because only Modus Ponens is used and it is sound

Complete?Complete?

• Does it answer every query whose answers are entailed by the KB?Does it answer every query whose answers are entailed by the KB?

– Yes, if the clauses are definite clauseYes, if the clauses are definite clause

Semi-decidable?Semi-decidable?

• Algorithm returns “yes” for every entailed sentence, Algorithm returns “yes” for every entailed sentence, but does not return “no” for every nonentailed sentencebut does not return “no” for every nonentailed sentence

Sound?Sound?

• Does it only derive sentences that are entailed?Does it only derive sentences that are entailed?

– Yes, because only Modus Ponens is used and it is soundYes, because only Modus Ponens is used and it is sound

Complete?Complete?

• Does it answer every query whose answers are entailed by the KB?Does it answer every query whose answers are entailed by the KB?

– Yes, if the clauses are definite clauseYes, if the clauses are definite clause

Semi-decidable?Semi-decidable?

• Algorithm returns “yes” for every entailed sentence, Algorithm returns “yes” for every entailed sentence, but does not return “no” for every nonentailed sentencebut does not return “no” for every nonentailed sentence

NatNum(0)NatNum(n) NatNum(S(n))NatNum(S(0)), NatNum(S(S(0))),…

Page 20: CS 416 Artificial Intelligence

Proving completeness

Assume KB only has sentences with no function symbolsAssume KB only has sentences with no function symbols

• What’s the most number of iterations through algorithm?What’s the most number of iterations through algorithm?

• Depends on the number of facts that can be addedDepends on the number of facts that can be added

– Let Let kk be the arity, the max number of arguments of any predicate and be the arity, the max number of arguments of any predicate and

– Let Let pp be the number of predicates be the number of predicates

– Let Let nn be the number of constant symbols be the number of constant symbols

• At most At most pnpnkk distinct ground facts distinct ground facts

• Fixed point is reached after this many iterationsFixed point is reached after this many iterations

• A proof by contradiction shows that the final KB is completeA proof by contradiction shows that the final KB is complete

Assume KB only has sentences with no function symbolsAssume KB only has sentences with no function symbols

• What’s the most number of iterations through algorithm?What’s the most number of iterations through algorithm?

• Depends on the number of facts that can be addedDepends on the number of facts that can be added

– Let Let kk be the arity, the max number of arguments of any predicate and be the arity, the max number of arguments of any predicate and

– Let Let pp be the number of predicates be the number of predicates

– Let Let nn be the number of constant symbols be the number of constant symbols

• At most At most pnpnkk distinct ground facts distinct ground facts

• Fixed point is reached after this many iterationsFixed point is reached after this many iterations

• A proof by contradiction shows that the final KB is completeA proof by contradiction shows that the final KB is complete

Page 21: CS 416 Artificial Intelligence

Complexity of this algorithm

Three sources of complexityThree sources of complexity

• inner loop requires finding all unifiers such that premise of inner loop requires finding all unifiers such that premise of rule unifies with facts of databaserule unifies with facts of database

– this this “pattern matching” “pattern matching” is expensiveis expensive

• must check every rule on every iteration to check if its must check every rule on every iteration to check if its premises are satisfiedpremises are satisfied

• many facts are generated that are irrelevant to goalmany facts are generated that are irrelevant to goal

Three sources of complexityThree sources of complexity

• inner loop requires finding all unifiers such that premise of inner loop requires finding all unifiers such that premise of rule unifies with facts of databaserule unifies with facts of database

– this this “pattern matching” “pattern matching” is expensiveis expensive

• must check every rule on every iteration to check if its must check every rule on every iteration to check if its premises are satisfiedpremises are satisfied

• many facts are generated that are irrelevant to goalmany facts are generated that are irrelevant to goal

Page 22: CS 416 Artificial Intelligence

Pattern matching

Conjunct orderingConjunct ordering

• Missile (x) ^ Owns (Nono, x) => Sells (West, x, Nono)Missile (x) ^ Owns (Nono, x) => Sells (West, x, Nono)

– Look at all items owned by Nono, call them XLook at all items owned by Nono, call them X

– for each element x in X, check if it is a missilefor each element x in X, check if it is a missile

– Look for all missiles, call them XLook for all missiles, call them X

– for each element x in X, check if it is owned by Nonofor each element x in X, check if it is owned by Nono

Optimal ordering is NP-hard, similar to matrix multOptimal ordering is NP-hard, similar to matrix mult

• Good heuristic: group first according to whichever group is smallerGood heuristic: group first according to whichever group is smaller

Conjunct orderingConjunct ordering

• Missile (x) ^ Owns (Nono, x) => Sells (West, x, Nono)Missile (x) ^ Owns (Nono, x) => Sells (West, x, Nono)

– Look at all items owned by Nono, call them XLook at all items owned by Nono, call them X

– for each element x in X, check if it is a missilefor each element x in X, check if it is a missile

– Look for all missiles, call them XLook for all missiles, call them X

– for each element x in X, check if it is owned by Nonofor each element x in X, check if it is owned by Nono

Optimal ordering is NP-hard, similar to matrix multOptimal ordering is NP-hard, similar to matrix mult

• Good heuristic: group first according to whichever group is smallerGood heuristic: group first according to whichever group is smaller

Page 23: CS 416 Artificial Intelligence

Incremental forward chaining

Pointless (redundant) repetitionPointless (redundant) repetition

• Some rules generate new informationSome rules generate new information

– this information may permit unification of existing rulesthis information may permit unification of existing rules

• some rules generate preexisting informationsome rules generate preexisting information

– we need not revisit the unification of the existing ruleswe need not revisit the unification of the existing rules

Every Every newnew fact inferred on iteration t must be derived fact inferred on iteration t must be derived from at least one from at least one newnew fact inferred on iteration t-1 fact inferred on iteration t-1

Pointless (redundant) repetitionPointless (redundant) repetition

• Some rules generate new informationSome rules generate new information

– this information may permit unification of existing rulesthis information may permit unification of existing rules

• some rules generate preexisting informationsome rules generate preexisting information

– we need not revisit the unification of the existing ruleswe need not revisit the unification of the existing rules

Every Every newnew fact inferred on iteration t must be derived fact inferred on iteration t must be derived from at least one from at least one newnew fact inferred on iteration t-1 fact inferred on iteration t-1

Page 24: CS 416 Artificial Intelligence

Irrelevant facts

Some facts are irrelevant and occupy computation Some facts are irrelevant and occupy computation of forward-chaining algorithmof forward-chaining algorithm

• What if Nono example included lots of facts about food What if Nono example included lots of facts about food preferences?preferences?

– Not related to conclusions drawn about sale of weaponsNot related to conclusions drawn about sale of weapons

– How can we eliminate them?How can we eliminate them?

Some facts are irrelevant and occupy computation Some facts are irrelevant and occupy computation of forward-chaining algorithmof forward-chaining algorithm

• What if Nono example included lots of facts about food What if Nono example included lots of facts about food preferences?preferences?

– Not related to conclusions drawn about sale of weaponsNot related to conclusions drawn about sale of weapons

– How can we eliminate them?How can we eliminate them?

Page 25: CS 416 Artificial Intelligence

Magic Set

Rewriting the rule setRewriting the rule set

• We have learned earlier that backward chaining limits the We have learned earlier that backward chaining limits the search spacesearch space

• We’re still using forward chaining, but we will add elements to We’re still using forward chaining, but we will add elements to premises of sentences that further restrict the forward premises of sentences that further restrict the forward inferences we will drawinferences we will draw

– added elements are based on goal (thus the backward added elements are based on goal (thus the backward influence)influence)

Rewriting the rule setRewriting the rule set

• We have learned earlier that backward chaining limits the We have learned earlier that backward chaining limits the search spacesearch space

• We’re still using forward chaining, but we will add elements to We’re still using forward chaining, but we will add elements to premises of sentences that further restrict the forward premises of sentences that further restrict the forward inferences we will drawinferences we will draw

– added elements are based on goal (thus the backward added elements are based on goal (thus the backward influence)influence)

Page 26: CS 416 Artificial Intelligence

Magic Set

Rewriting the rule setRewriting the rule set• Let goal = Criminal (West)Let goal = Criminal (West)

– American(x) ^ Weapon(y) ^ Sells(x,y,z) ^ Hostile(z) American(x) ^ Weapon(y) ^ Sells(x,y,z) ^ Hostile(z) Criminal(x) Criminal(x)

• We know we are concerned with We know we are concerned with criminalscriminals and and WestWest

• Let’s distinguish Let’s distinguish WestWest as important by placing it in a Magic set: as important by placing it in a Magic set: Magic(West)Magic(West)

• Let’s rewrite the rule to constrain our forward chaining to only include Let’s rewrite the rule to constrain our forward chaining to only include sentences related to Westsentences related to West

– Magic(x) ^ American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile(z) => Magic(x) ^ American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile(z) => Criminal (x)Criminal (x)

Rewriting the rule setRewriting the rule set• Let goal = Criminal (West)Let goal = Criminal (West)

– American(x) ^ Weapon(y) ^ Sells(x,y,z) ^ Hostile(z) American(x) ^ Weapon(y) ^ Sells(x,y,z) ^ Hostile(z) Criminal(x) Criminal(x)

• We know we are concerned with We know we are concerned with criminalscriminals and and WestWest

• Let’s distinguish Let’s distinguish WestWest as important by placing it in a Magic set: as important by placing it in a Magic set: Magic(West)Magic(West)

• Let’s rewrite the rule to constrain our forward chaining to only include Let’s rewrite the rule to constrain our forward chaining to only include sentences related to Westsentences related to West

– Magic(x) ^ American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile(z) => Magic(x) ^ American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile(z) => Criminal (x)Criminal (x)

Page 27: CS 416 Artificial Intelligence

Backward Chaining

Start with the premises of the goalStart with the premises of the goal• Each premise must be supported by KBEach premise must be supported by KB

• Start with first premise and look for support from KBStart with first premise and look for support from KB

– looking for clauses with a head that matches premiselooking for clauses with a head that matches premise

– the head’s body (premise) must then be supported by KBthe head’s body (premise) must then be supported by KB

– Place premises on a stack with the goalPlace premises on a stack with the goal

A recursive, depth-first, algorithmA recursive, depth-first, algorithm• Suffers from repetition and incompletenessSuffers from repetition and incompleteness

Start with the premises of the goalStart with the premises of the goal• Each premise must be supported by KBEach premise must be supported by KB

• Start with first premise and look for support from KBStart with first premise and look for support from KB

– looking for clauses with a head that matches premiselooking for clauses with a head that matches premise

– the head’s body (premise) must then be supported by KBthe head’s body (premise) must then be supported by KB

– Place premises on a stack with the goalPlace premises on a stack with the goal

A recursive, depth-first, algorithmA recursive, depth-first, algorithm• Suffers from repetition and incompletenessSuffers from repetition and incompleteness

Page 28: CS 416 Artificial Intelligence

Resolution

We saw earlier that resolution is a We saw earlier that resolution is a completecomplete algorithm for refuting statementsalgorithm for refuting statements

• Must put first-order sentences into conjunctive normal formMust put first-order sentences into conjunctive normal form

– conjunction of clauses, each is a disjunction of literalsconjunction of clauses, each is a disjunction of literals

literals can contain variables (which are assumed to be literals can contain variables (which are assumed to be universally quantified)universally quantified)

We saw earlier that resolution is a We saw earlier that resolution is a completecomplete algorithm for refuting statementsalgorithm for refuting statements

• Must put first-order sentences into conjunctive normal formMust put first-order sentences into conjunctive normal form

– conjunction of clauses, each is a disjunction of literalsconjunction of clauses, each is a disjunction of literals

literals can contain variables (which are assumed to be literals can contain variables (which are assumed to be universally quantified)universally quantified)

Page 29: CS 416 Artificial Intelligence

Resolution - aside

Mathematical theorem proversMathematical theorem provers• Resolution has been used to prove mathematical theoremsResolution has been used to prove mathematical theorems

• Kurt GKurt Gödel proved ödel proved incompletenessincompleteness of logic systems of logic systems containing induction (a building block of discrete math)containing induction (a building block of discrete math)

– There are sentences entailed by a knowledge base, but no There are sentences entailed by a knowledge base, but no finite proof existsfinite proof exists

That is, generating all possible sentences, when That is, generating all possible sentences, when induction is one possible operator, will not derive all induction is one possible operator, will not derive all sentences that are entailedsentences that are entailed

Mathematical theorem proversMathematical theorem provers• Resolution has been used to prove mathematical theoremsResolution has been used to prove mathematical theorems

• Kurt GKurt Gödel proved ödel proved incompletenessincompleteness of logic systems of logic systems containing induction (a building block of discrete math)containing induction (a building block of discrete math)

– There are sentences entailed by a knowledge base, but no There are sentences entailed by a knowledge base, but no finite proof existsfinite proof exists

That is, generating all possible sentences, when That is, generating all possible sentences, when induction is one possible operator, will not derive all induction is one possible operator, will not derive all sentences that are entailedsentences that are entailed

Page 30: CS 416 Artificial Intelligence

First-order CNF

• For all x, American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile (z) => For all x, American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile (z) => Criminal(x)Criminal(x)

• ~American(x) V ~Weapon(y) V ~Sells(x, y, z) V ~Hostile(z) V Criminal(x)~American(x) V ~Weapon(y) V ~Sells(x, y, z) V ~Hostile(z) V Criminal(x)

Every sentence of first-order logic can be converted into Every sentence of first-order logic can be converted into an inferentially equivalent CNF sentence (they are both an inferentially equivalent CNF sentence (they are both unsatisfiable in same conditions)unsatisfiable in same conditions)

• For all x, American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile (z) => For all x, American(x) ^ Weapon(y) ^ Sells(x, y, z) ^ Hostile (z) => Criminal(x)Criminal(x)

• ~American(x) V ~Weapon(y) V ~Sells(x, y, z) V ~Hostile(z) V Criminal(x)~American(x) V ~Weapon(y) V ~Sells(x, y, z) V ~Hostile(z) V Criminal(x)

Every sentence of first-order logic can be converted into Every sentence of first-order logic can be converted into an inferentially equivalent CNF sentence (they are both an inferentially equivalent CNF sentence (they are both unsatisfiable in same conditions)unsatisfiable in same conditions)

Page 31: CS 416 Artificial Intelligence

Example

Everyone who loves all animals is loved by someoneEveryone who loves all animals is loved by someoneEveryone who loves all animals is loved by someoneEveryone who loves all animals is loved by someone

Page 32: CS 416 Artificial Intelligence

Example

Page 33: CS 416 Artificial Intelligence

Example

F and G are Skolem FunctionsF and G are Skolem Functions

• arguments of function are universally quantified variables in arguments of function are universally quantified variables in whose scope the existential quantifier appearswhose scope the existential quantifier appears

F and G are Skolem FunctionsF and G are Skolem Functions

• arguments of function are universally quantified variables in arguments of function are universally quantified variables in whose scope the existential quantifier appearswhose scope the existential quantifier appears

Page 34: CS 416 Artificial Intelligence

Example

• Two clausesTwo clauses

• F(x) refers to the animal potentially unloved by xF(x) refers to the animal potentially unloved by x

• G(x) refers to someone who might love xG(x) refers to someone who might love x

• Two clausesTwo clauses

• F(x) refers to the animal potentially unloved by xF(x) refers to the animal potentially unloved by x

• G(x) refers to someone who might love xG(x) refers to someone who might love x

Page 35: CS 416 Artificial Intelligence

Resolution inference rule

A lifted version of propositional resolution ruleA lifted version of propositional resolution rule

• two clauses must be standardized aparttwo clauses must be standardized apart

– no variables are sharedno variables are shared

• can be resolved if their literals are complementarycan be resolved if their literals are complementary

– one is the negation of the otherone is the negation of the other

– if one unifies with the negation of the otherif one unifies with the negation of the other

A lifted version of propositional resolution ruleA lifted version of propositional resolution rule

• two clauses must be standardized aparttwo clauses must be standardized apart

– no variables are sharedno variables are shared

• can be resolved if their literals are complementarycan be resolved if their literals are complementary

– one is the negation of the otherone is the negation of the other

– if one unifies with the negation of the otherif one unifies with the negation of the other

li and m are

complementaryliterals

Page 36: CS 416 Artificial Intelligence

Resolution

li and mj are

complementaryliterals

Page 37: CS 416 Artificial Intelligence

Inference in first-order logic

Our goal is to prove that KB entails a fact, Our goal is to prove that KB entails a fact, • We use logical inferenceWe use logical inference

Forward chainingForward chaining

Backward chainingBackward chaining

ResolutionResolution

All three logical inference systems rely on search All three logical inference systems rely on search to find a sequence of actions that derive the empty to find a sequence of actions that derive the empty clauseclause

Our goal is to prove that KB entails a fact, Our goal is to prove that KB entails a fact, • We use logical inferenceWe use logical inference

Forward chainingForward chaining

Backward chainingBackward chaining

ResolutionResolution

All three logical inference systems rely on search All three logical inference systems rely on search to find a sequence of actions that derive the empty to find a sequence of actions that derive the empty clauseclause