28
9 주 주주 주주주주 Agent that reason logical ly

9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Embed Size (px)

Citation preview

Page 1: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

9 주 강의

지식표현Agent that reason logically

Page 2: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Knowledge Base

• A set of representations of facts about the world• Knowledge representation language

– tell : what has been told to the knowledge base previously

– ask : a question and the answer• Inference : what follows from what the KB has been T

elled• Background knowledge : a knowledge base which may

initially contained• Sentence : individual representation of a fact

Page 3: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Knowledge base

• The knowledge level :: saying what it knows to KB “Golden Gates Bridge links San Francisco and Marin Country

• The logical level :: the knowledge is encoding into sentences Links(GGBridge, SF, Marin)

• The implementation level :: the level that runs on the agent architecture (data structures to represent knowledge or facts)

Page 4: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Knowledge

• declarative/procedural– love(john, mary).– can_fly(X) :- bird(X), not(can_fly(X)), !.

• learning : general knowledge about the environment given a series of percepts

• Commonsense knowledge

Page 5: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Specifying the environment

Figure 6.2 A typical wumpus world

Page 6: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Domain specific knowledge

• Domain specific knowledge– In the squares directly adjacent to a pit, the agent

will perceive a breeze

• Commonsense knowledge– logical reasoning – stench(1,2) & ~setnch(2,1) ~wumpus(2,2)– wumpus(1,3) stench(2,1) & stench(2,3) & stench(1,4)

Page 7: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Inference in Wumpus world(I)

4,13,12,11,1

4,23,22,21,2

4,33,32,31,3

4,43,42,41,4

OKOK

A = AgentB = BreezeG = Glitter, GoldOK = Safe squareP = PitS = StenchV = VisitedW = Wumpus

4,13,12,11,1

4,23,22,21,2

4,33,32,31,3

4,43,42,41,4

OKOK

OK

AA

BV

P ?

Figure 6.3 The first step taken by the agent in the wumpus world.(a) The initial situation, after percept [None, None, None, None, None]. (b) After one move, with percept [None, Breeze, None, None, None].

Page 8: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Inference in Wumpus world (II)

4,13,12,11,1

4,23,22,21,2

4,33,32,31,3

4,43,42,41,4

OKOK

A = AgentB = BreezeG = Glitter, GoldOK = Safe squareP = PitS = StenchV = VisitedW = Wumpus

4,13,12,11,1

4,23,22,21,2

4,33,32,31,3

4,43,42,41,4

OKOK

OK

A

VV

V

Figure 6.4 Two later stages in the progress of the agent.(a) After the third move, with percept [Stench, None, None, None, None]. (b) After the fifth move, with percept [Stench, Breeze, Glitter, None, None].

V VB

OK OK

W!

BOK

VS

P !

P ?

P ?

AW !S GB

Page 9: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Representation, Reasoning, and Logic

• Syntax : the possible configurations that constitute sentences

• Semantics : the facts in the world to which the sentences refer

Page 10: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

The logical reasoning

Aentences Sentence

Facts Fact

Sem

antics

Entails

Follows

Representation

World

Sem

antics

Figure 6.5 The connection between sentences and facts is provided by the semantics of the language. The property of one fact following from some other facts is mirrored by the property of one sentence being entailed by some other sentences. Logical inference generates new sentences that are entailed by existing sentences.

Page 11: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Inference I

• Entailment :: generation of new sentences that are necessarily true, given that the old sentences are true

• Soundness, truth-preserving :: An inference procedure that generates only entailed sentences modus ponens <-> abduction

• KB├i , is derived from KB by I

• Proof :: a sound inference procedure

Page 12: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Inference II

• Completeness :: an inference procedure that can find a proof for any sentence that is entailed

• Proof :: specifying the reasoning steps that are sound

• Valid :: if and only if all possible interpretations in all possible worlds

• Tautologies, analytic sentences :: valid sentences

• Satisfiable :: if and only if there is some interpretation in some world for which it is true

• Unsatisfiable :: a sentence that is not satisfiable

Page 13: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Logics

• Boolean logic – Symbols represent whole propositions

(facts)– Boolean connectives

• First-order logic– objects, predicates– connectives, quantifiers

Page 14: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Wrong logical reasoningFIRST VILLAGER: We have found a witch. May we burn her?ALL: A witch! Burn her!BEDEVERE: Why do you think she is a witch?SECOND VILLAGER: She turned me into a newt.BEDEVERE: A newt?SECOND VILLAGER (after looking at himself for some time): I got better.ALL: Burn her anyway.BEDEVERE: Quiet! Quiet! There are ways of telling whether she is a witch.BEDEVERE: Tell me … What do you do with witches?ALL: Burn them.BEDEVERE: And what do you burn, apart from witches?FOURTH VILLAGER: … Wood?BEDEVERE: So why do witches burn?SECOND VILLAGER: (pianissimo) Because they’re made of wood?BEDEVERE: Good.ALL: I see. Yes, of course.BEDEVERE: So how can we tell if she is made of wood?FIRST VILLAGER: Make a bridge out of her.BEDEVERE: Ah … but can you not also make bridges out of stone?ALL: Yes, of course … um … er …BEDEVERE: Does wood sink in water?ALL: No, no, it floats. Throw her in the pond.BEDEVERE: Wait. Wait … tell me, what also floats on water?ALL: Bread? No, no no. Apples … gravy … very small rocks …BEDEVERE: No, no no.KING ARTHUR: A duck!(They all turn and look at ARTHUR. BEDEVERE looks up very impressed.)BEDEVERE: Exactly. So … logically …FIRST VILLAGER (beginning to pick up the thread): If she .. Weight the same as a duck … she’s made of wood.BEDEVERE: And therefore?ALL: A witch!

Page 15: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Ontological and epistemological commitments

• Ontological commitments :: to do with the nature of reality – Propositional logic(true/false), Predicate log

ic, Temporal logic • Epistemological commitments :: to do with the

possible states of knowledge an agent can have using various types of logic – degree of belief– fuzzy logic

Page 16: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Commitments

Language Ontological Commitment(What exists in the world)

Epistemological Commitment(What an agent believes about facts)

Propositional logicFirst-order logicTemporal logicProbability theoryFuzzy logic

factsfacts, objects, relationstimesfactsdegree of truth

true/false/unknowntrue/false/unknowntrue/false/unknowndegree of belief 0…1degree of belief 0…1

Formal languages and their and ontological and epistemological commitments

Page 17: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Propositional Logic

• logical constant : true/false• propositional symbols : P, Q• parentheses : (P & Q)• logical connectives : &(conjuction), v(dis

junction), ->(implication), <->(equivalence), ~(negation)

Page 18: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Grammar

Sentence AtomicSentence | ComplexSentence

AtomicSentence True | False | P | Q | R | …

ComplexSentence ( Sentence ) | Sentence Connective Sentence | Sentence

Connective | | |

Figure 6.8 A BNF (Backus-Naur Form) grammar of sentences in propositional logic.

Page 19: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Semantics

P H PH (P H) ┐H ((P H) ┐H)P

FalseFalseTrueTrue

FalseTrueFalseTrue

FalseTrueTrueTrue

FalseFalseTrueFalse

TrueTrueTrueTrue

Truth table showing validity of a complex sentence

Page 20: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Validity and Inference

Truth tables for five logical connectives

P Q ┐P PQ PQ PQ PQ

False False True True

False True False True

True True False False

False False False True

False True True True

True True False True

True False False True

Page 21: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Models

• Any world in which a sentence is true under a particular interpretation

• Entailment :: a sentence is entailed by a knowledge base KB if the models of the KB are all models of

• The set of models of P & Q is the intersection of the models of P and the models of Q

Page 22: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Inference Rules for propositional logic

Modus Ponens or Implication-Elimination: (From an implication and the premise of the implication, you can infer the conclusion.)

And-Elimination: (From a conjunction, you can infer any of the conjuncts.)

And-Introduction: (From a list of sentences, you can infer their conjunction.)

Or-Introduction: (From a sentence, you can infer its disjunction with anything else at all.)

Double-Negation Elimination: (From a doubly negated sentence, you can infer a positive sentence.)

Unit Resolution: (From a disjunction, if one of the disjuncts is false, then you can infer the other one is true.)

Figure 6.13 Seven inference for propositional logic. The unit resolution rule is a special case of the resolution rule, which in turn is a special case of the full resolution rule for first-order logic discussed in Chapter 9.

=> ,

i

1 2 … n

1 2 … n

1, 2, …, n

1 2 … n

i

,

,

=>

=> , =>

Resolution: (This is the most difficult. Because cannot be both true and false, one of the other disjucts must be true in one of the premises. Or equivalently, implication is transitive.)

or equivalently

Page 23: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Complexity of propositional inference

• NP-complete • Monotonicity

– If KB1╞ then (KB1 ∪ KB2) ╞ • Horn clause logic

– polynomial time complexity– P1∧P2∧….∧Pn ⇒ Q

Page 24: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Wumpus world

• Initial state ~S1,1 ~B1,1 ~S2,1 B2,1 S1,2 ~B1,2

• Rule R1: ~S1,1 -> ~W1,1 & ~W1,2 & ~W2,1 R2: ~S2,1 -> ~W1,1 & ~W2,1 & ~W2,2 & ~W3,1 R3: ~S1,2 -> ~W1,1 & ~W1,2 & ~W2,2 & ~W1,3 R4: S1,2 -> W1,3 V W1,2 V W2,2 V W1,2

Page 25: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Finding the wumpus

• Inference process– Modus ponens : ~S1,1 and R1 ~W1,1 & ~W1,2 & ~W2,1– And-Elimination ~W1,1 ~W1,2 ~W2,1– Modus ponens and And-Elimination: ~W2,2 ~W2,1 ~W3,1– Modus ponens S1,2 and R4 W1,3 V W1,2 V W2,2 V W1,1

Page 26: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Inference process(cont.)

– unit resolution ~W1,1 and W1,3 V W1,2 V W2,2 V W1,1

W1,3 V W1,2 V W2,2

– unit resolution ~W2,2 and W1,3 V W1,2 V W2,2

W1,3 V W1,2

– unit resolution ~W1,2 and W1,3 V W1,2 W1,3

Page 27: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

Translating knowledge into action

• A1,1 & EastA & W2,1 -> ~Forward EastA :: facing east

• Propositional logic is not powerful enough to solve the wumpus problem easily

Page 28: 9 주 강의 지식표현 Agent that reason logically. Knowledge Base A set of representations of facts about the world Knowledge representation language – tell : what

숙제• 6.3, 6.6, 6.7, 6.9, 6.10, 6.12,

6.15, 6.16