itcs 3153 artificial intelligence lecture 11 logical agents chapter 7 lecture 11 logical agents...

26
ITCS 3153 Artificial Intelligence Lecture 11 Lecture 11 Logical Agents Logical Agents Chapter 7 Chapter 7

Post on 20-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

ITCS 3153Artificial Intelligence

Lecture 11Lecture 11

Logical AgentsLogical Agents

Chapter 7Chapter 7

Lecture 11Lecture 11

Logical AgentsLogical Agents

Chapter 7Chapter 7

Page 2: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Reasoning w/ propositional logic

Remember what we’ve developed so farRemember what we’ve developed so far

• Logical sentencesLogical sentences

• And, or, not, implies (entailment), iff (equivalence)And, or, not, implies (entailment), iff (equivalence)

• Syntax vs. semanticsSyntax vs. semantics

• Truth tablesTruth tables

• Satisfiability, proof by contradictionSatisfiability, proof by contradiction

Remember what we’ve developed so farRemember what we’ve developed so far

• Logical sentencesLogical sentences

• And, or, not, implies (entailment), iff (equivalence)And, or, not, implies (entailment), iff (equivalence)

• Syntax vs. semanticsSyntax vs. semantics

• Truth tablesTruth tables

• Satisfiability, proof by contradictionSatisfiability, proof by contradiction

Page 3: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Logical Equivalences

Know these equivalencesKnow these equivalencesKnow these equivalencesKnow these equivalences

Page 4: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Reasoning w/ propositional logic

Inference RulesInference Rules

• Modus Ponens: Modus Ponens:

– Whenever sentences of form Whenever sentences of form => => and and are given are giventhe sentence the sentence can be inferred can be inferred

RR11: Green => Martian: Green => Martian

RR22: Green: Green

Inferred: MartianInferred: Martian

Inference RulesInference Rules

• Modus Ponens: Modus Ponens:

– Whenever sentences of form Whenever sentences of form => => and and are given are giventhe sentence the sentence can be inferred can be inferred

RR11: Green => Martian: Green => Martian

RR22: Green: Green

Inferred: MartianInferred: Martian

Page 5: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Reasoning w/ propositional logic

Inference RulesInference Rules• And-EliminationAnd-Elimination

– Any of conjuncts can be inferredAny of conjuncts can be inferred

RR11: Martian ^ Green: Martian ^ Green

Inferred: MartianInferred: Martian

Inferrred: GreenInferrred: Green

Use truth tables if you want to confirm inference Use truth tables if you want to confirm inference rulesrules

Inference RulesInference Rules• And-EliminationAnd-Elimination

– Any of conjuncts can be inferredAny of conjuncts can be inferred

RR11: Martian ^ Green: Martian ^ Green

Inferred: MartianInferred: Martian

Inferrred: GreenInferrred: Green

Use truth tables if you want to confirm inference Use truth tables if you want to confirm inference rulesrules

Page 6: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Example of a proof

~P ~B

BP?

P?

P?

P?

Page 7: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Example of a proof

~P ~B

B~P

P?

P?

~P

Page 8: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Constructing a proof

Proving Proving is like is like searchingsearching

• Find sequence of logical inference rules that lead to desired Find sequence of logical inference rules that lead to desired resultresult

• Note the explosion of propositionsNote the explosion of propositions

– Good proof methods ignore the countless irrelevant Good proof methods ignore the countless irrelevant propositionspropositions

Proving Proving is like is like searchingsearching

• Find sequence of logical inference rules that lead to desired Find sequence of logical inference rules that lead to desired resultresult

• Note the explosion of propositionsNote the explosion of propositions

– Good proof methods ignore the countless irrelevant Good proof methods ignore the countless irrelevant propositionspropositions

Page 9: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Monotonicity of knowledge base

Knowledge base can only get largerKnowledge base can only get larger

• Adding new sentences to knowledge base can only make it get largerAdding new sentences to knowledge base can only make it get larger

– If (KB entails If (KB entails ))

((KB ^ ((KB ^ ) entails ) entails ))

• This is important when constructing proofsThis is important when constructing proofs

– A logical conclusion drawn at one point cannot be invalidated by a A logical conclusion drawn at one point cannot be invalidated by a subsequent entailmentsubsequent entailment

Knowledge base can only get largerKnowledge base can only get larger

• Adding new sentences to knowledge base can only make it get largerAdding new sentences to knowledge base can only make it get larger

– If (KB entails If (KB entails ))

((KB ^ ((KB ^ ) entails ) entails ))

• This is important when constructing proofsThis is important when constructing proofs

– A logical conclusion drawn at one point cannot be invalidated by a A logical conclusion drawn at one point cannot be invalidated by a subsequent entailmentsubsequent entailment

Page 10: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

How many inferences?

Previous example relied on application of inference Previous example relied on application of inference rules to generate new sentencesrules to generate new sentences

• When have you drawn enough inferences to prove something?When have you drawn enough inferences to prove something?

– Too many make search process take longerToo many make search process take longer

– Too few halt logical progression and make proof process Too few halt logical progression and make proof process incompleteincomplete

Previous example relied on application of inference Previous example relied on application of inference rules to generate new sentencesrules to generate new sentences

• When have you drawn enough inferences to prove something?When have you drawn enough inferences to prove something?

– Too many make search process take longerToo many make search process take longer

– Too few halt logical progression and make proof process Too few halt logical progression and make proof process incompleteincomplete

Page 11: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Resolution

Unit Resolution Inference RuleUnit Resolution Inference Rule

• If If mm and and llii are are

complementarycomplementaryliteralsliterals

Unit Resolution Inference RuleUnit Resolution Inference Rule

• If If mm and and llii are are

complementarycomplementaryliteralsliterals

Page 12: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Resolution Inference Rule

Also works with clausesAlso works with clauses

But make sure each literal appears only onceBut make sure each literal appears only once

Also works with clausesAlso works with clauses

But make sure each literal appears only onceBut make sure each literal appears only once

Page 13: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Resolution and completeness

Any Any completecomplete search algorithm, applying only the search algorithm, applying only the resolution rule, can derive any conclusion resolution rule, can derive any conclusion entailed by any knowledge base in propositional entailed by any knowledge base in propositional logiclogic

• More specifically, More specifically, refutation completenessrefutation completeness

– Able to confirm or refute any sentenceAble to confirm or refute any sentence

– Unable to enumerate all true sentencesUnable to enumerate all true sentences

Any Any completecomplete search algorithm, applying only the search algorithm, applying only the resolution rule, can derive any conclusion resolution rule, can derive any conclusion entailed by any knowledge base in propositional entailed by any knowledge base in propositional logiclogic

• More specifically, More specifically, refutation completenessrefutation completeness

– Able to confirm or refute any sentenceAble to confirm or refute any sentence

– Unable to enumerate all true sentencesUnable to enumerate all true sentences

Page 14: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

What about “and” clauses?

Resolution only applies to “or” clausesResolution only applies to “or” clauses

• Every sentence of propositional logic can be transformed to a Every sentence of propositional logic can be transformed to a logically equivalent conjunction of disjunctions of literalslogically equivalent conjunction of disjunctions of literals

Conjunctive Normal Form (CNF)Conjunctive Normal Form (CNF)

• A sentence expressed as conjunction of disjunction of literalsA sentence expressed as conjunction of disjunction of literals

– k-CNF: exactly k literals per clausek-CNF: exactly k literals per clause

Resolution only applies to “or” clausesResolution only applies to “or” clauses

• Every sentence of propositional logic can be transformed to a Every sentence of propositional logic can be transformed to a logically equivalent conjunction of disjunctions of literalslogically equivalent conjunction of disjunctions of literals

Conjunctive Normal Form (CNF)Conjunctive Normal Form (CNF)

• A sentence expressed as conjunction of disjunction of literalsA sentence expressed as conjunction of disjunction of literals

– k-CNF: exactly k literals per clausek-CNF: exactly k literals per clause

Page 15: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

CNF

Page 16: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

An algorithm for resolution

We wish to prove KB entails We wish to prove KB entails • Must show (KB ^ ~Must show (KB ^ ~) is unsatisfiable) is unsatisfiable

– No possible way for KB to entail (not No possible way for KB to entail (not ))

– Proof by contradictionProof by contradiction

We wish to prove KB entails We wish to prove KB entails • Must show (KB ^ ~Must show (KB ^ ~) is unsatisfiable) is unsatisfiable

– No possible way for KB to entail (not No possible way for KB to entail (not ))

– Proof by contradictionProof by contradiction

Page 17: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

An algorithm for resolution

AlgorithmAlgorithm

• KB ^ ~KB ^ ~is put in CNFis put in CNF

• Each pair with complementary literals is resolved to produce Each pair with complementary literals is resolved to produce new clause which is added to KB (if novel)new clause which is added to KB (if novel)

– Cease if no new clauses to add (~Cease if no new clauses to add (~ is not entailed) is not entailed)

– Cease if resolution rule derives empty clause (~Cease if resolution rule derives empty clause (~ is is entailed)entailed)

AlgorithmAlgorithm

• KB ^ ~KB ^ ~is put in CNFis put in CNF

• Each pair with complementary literals is resolved to produce Each pair with complementary literals is resolved to produce new clause which is added to KB (if novel)new clause which is added to KB (if novel)

– Cease if no new clauses to add (~Cease if no new clauses to add (~ is not entailed) is not entailed)

– Cease if resolution rule derives empty clause (~Cease if resolution rule derives empty clause (~ is is entailed)entailed)

Page 18: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Example of resolution

Proof that there is not a pit in PProof that there is not a pit in P1,21,2: ~P: ~P1,21,2

• KB ^ PKB ^ P1,21,2 leads to empty clause leads to empty clause

• Therefore ~PTherefore ~P1,21,2 is true is true

Proof that there is not a pit in PProof that there is not a pit in P1,21,2: ~P: ~P1,21,2

• KB ^ PKB ^ P1,21,2 leads to empty clause leads to empty clause

• Therefore ~PTherefore ~P1,21,2 is true is true

Page 19: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Formal Algorithm

Page 20: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Horn Clauses

Horn ClauseHorn Clause

• Disjunction of literals with at most one is positiveDisjunction of literals with at most one is positive

– (~a V ~b V ~c V d)(~a V ~b V ~c V d)

– (~a V b V c V ~d) (~a V b V c V ~d) Not a Horn ClauseNot a Horn Clause

Horn ClauseHorn Clause

• Disjunction of literals with at most one is positiveDisjunction of literals with at most one is positive

– (~a V ~b V ~c V d)(~a V ~b V ~c V d)

– (~a V b V c V ~d) (~a V b V c V ~d) Not a Horn ClauseNot a Horn Clause

Page 21: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Horn Clauses

Can be written as a special implicationCan be written as a special implication

• (~a V ~b V c) (~a V ~b V c) (a ^ b) => c (a ^ b) => c

– (~a V ~b V c) == (~(a ^ b) V c) … de Morgan(~a V ~b V c) == (~(a ^ b) V c) … de Morgan

– (~(a ^ b) V c) == ((a ^ b) => c … implication elimination(~(a ^ b) V c) == ((a ^ b) => c … implication elimination

Can be written as a special implicationCan be written as a special implication

• (~a V ~b V c) (~a V ~b V c) (a ^ b) => c (a ^ b) => c

– (~a V ~b V c) == (~(a ^ b) V c) … de Morgan(~a V ~b V c) == (~(a ^ b) V c) … de Morgan

– (~(a ^ b) V c) == ((a ^ b) => c … implication elimination(~(a ^ b) V c) == ((a ^ b) => c … implication elimination

Page 22: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Horn Clauses

Permit straightforward inference determinationPermit straightforward inference determination

• Forward chainingForward chaining

• Backward chainingBackward chaining

Permit straightforward inference determinationPermit straightforward inference determination

• Forward chainingForward chaining

• Backward chainingBackward chaining

Page 23: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Horn Clauses

Permit determination of entailment in linear time Permit determination of entailment in linear time (in order of knowledge base size)(in order of knowledge base size)Permit determination of entailment in linear time Permit determination of entailment in linear time (in order of knowledge base size)(in order of knowledge base size)

Page 24: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Forward Chaining

Page 25: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Forward Chaining

PropertiesProperties

• SoundSound

• CompleteComplete

– All entailed atomic sentence will be derivedAll entailed atomic sentence will be derived

Data DrivenData Driven

• Start with what we knowStart with what we know

• Derive new info until we discover what we wantDerive new info until we discover what we want

PropertiesProperties

• SoundSound

• CompleteComplete

– All entailed atomic sentence will be derivedAll entailed atomic sentence will be derived

Data DrivenData Driven

• Start with what we knowStart with what we know

• Derive new info until we discover what we wantDerive new info until we discover what we want

Page 26: ITCS 3153 Artificial Intelligence Lecture 11 Logical Agents Chapter 7 Lecture 11 Logical Agents Chapter 7

Backward Chaining

Start with what you want to know, a query (q)Start with what you want to know, a query (q)

Look for implications that conclude qLook for implications that conclude q

Goal-Directed ReasoningGoal-Directed Reasoning

Start with what you want to know, a query (q)Start with what you want to know, a query (q)

Look for implications that conclude qLook for implications that conclude q

Goal-Directed ReasoningGoal-Directed Reasoning