Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

24
Reasoning with Propositional Logic automated processing of a simple knowledge base CD

description

D Goforth - COSC 4117, fall Knowledge representation  KB - knowledge base: conjunction of general knowledge and facts  model: assignment of true/false values to the propositions so KB can be determined to be true or false NOTE: term “model” is not clearly defined – sometimes, it means any assignment to propositions; usually it means an assignments so KB is true

Transcript of Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

Page 1: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

Reasoning withPropositional Logic

automated processing of a simple knowledge baseCD

Page 2: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 2

Knowledge representation propositions: set of atomic statements

that may be true or false general knowledge: set of complex

sentences describing conditions (constraints) on environment

facts: data (from perceptions) about specific state of environment

Page 3: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 3

Knowledge representation KB - knowledge base: conjunction of

general knowledge and facts model: assignment of true/false values

to the propositions so KB can be determined to be true or false

NOTE: term “model” is not clearly defined – sometimes, it means any assignment to propositions; usually it means an assignments so KB is true

Page 4: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 4

model

propositions: set of atomic statements that may be true or false general knowledge: complex sentences describing conditions on environment facts: data (from perceptions) about specific state of environment KB - knowledge base: conjunction of general knowledge and facts model: assignment of true/false values to the propositions

facts general knowledge

Agent

propositionspropositions

general knowledgeenvironment

Agent sets true/false values of propositionsto make model(s) whereKB is consistent (true)

- these models represent “understanding”

Page 5: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 5

Knowledge representationtruth table

P1 P2 P3 ...Pn R1 R2 R3 ...Rm Rm+1 Rm+2 Rm+3 ...Rk KB=ΛRi

t t t ...t t f f ...t f f f ...f f

t t t ...t t f f ...t f f f ...f ft t t ...f f f t ...t f t t ...f f

f t t ...f t t t ...t t t t ...t t

f f f ...f t f f ...f f t f ...f f

...

...

propositions general knowledge facts

a model m

aking KB true

Page 6: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 6

propositions: set of atomic statements that may be true or false general knowledge: complex sentences describing conditions on environment facts: data (from perceptions) about specific state of environment KB - knowledge base: conjunction of general knowledge and facts model: assignment of true/false values to the propositions

model

facts general knowledge

Agent

propositionspropositions

general knowledge

Is GREEN in front of RED? NO

Page 7: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 7

Facts (from perception):1. RED occludes ORANGE2. ORANGE occludes GREEN

Propositions:1. ORANGE inFrontOf RED2. ORANGE inFrontOf GREEN3. RED inFrontOf GREEN4. RED inFrontOf ORANGE5. GREEN inFrontOf RED6. GREEN inFrontOf ORANGE

General knowledge (incomplete):•if (ORANGE occludes RED) then (ORANGE inFrontOf RED)•if (RED inFrontOf ORANGE) then not(ORANGE inFrontOf RED)•if (RED inFrontOf ORANGE) and (ORANGE inFrontOf GREEN) then (RED inFrontOf GREEN)•etc…

general knowledge

Agent

propositions

general knowledgefacts

model propositions

Page 8: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 8

Knowledge representationtruth table

P1 P2 P3 ...P6 R1 R2 R3 ...Rm Rm+1 Rm+2 KB=ΛRi

t t t ...t t f f ...t t t f

f t t ...f t t t ...t t t t

f f f ...f t f f ...f t t f

...

...

propositions general knowledge facts

Combination of true/false that describesthe order of RED, GREEN, ORANGE

Page 9: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

Logical equivalences

Review the truth tables for each of these connectives:

Page 10: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

Practice applying these logical equivalence axioms

Page 11: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 11

Uses of logical equivalence axioms Rewriting sentences

Show equivalence or difference Format for reasoning Reduce number of connectives(people like variety; computers like simplicity)e.g., A B ( A B ) ( B A )

( A B ) ( B A ) (A B ) (B A )

Page 12: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 12

Properties of sentences validity: sentence is true in all models satisfiability: sentence is true in some

model• general knowledge is valid;• facts are (should be) satisfiable

Page 13: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 13

Proof strategiesA. finding models that satisfy KB

– truth table enumeration O(2n) for n propositions

B. applying inference rules

Page 14: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 14

B. Inference rules human-like reasoning from classic logic

1. and elimination2. modus ponens3. logical equivalences

Page 15: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 15

1. And elimination Spot is big and friendly

Spot is friendly A Λ B

B

Page 16: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 16

2. Modus ponens Spot is a dog

A dog is a mammal(if Spot is a dog then Spot is a mammal)

Spot is a mammal A , A=>B

B

Page 17: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 17

3. Logical equivalence (eg) logical equivalence:

~ ( A \/ B ) = ~A Λ ~B The car is not (red or green)

The car is not redand it’s not green

~ ( A \/ B ) ~A Λ ~B

Question – can we claim “car is not red”?

Page 18: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 18

Short inference sequencePropositions: A car is red

B car is greenKnowledge: ~ ( A \/ B )Inference: ~ ( A \/ B )

~A Λ ~B (logical equivalence)

~A (and elimination)Claim: car is not red

Page 19: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 19

Automated reasoning reduced variety of representation for

sentences harder to ‘read’ for humans simpler data structure to process

reduced set of inference rules less efficient for humans equally powerful simpler algorithm for implication

Page 20: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 20

Simplified representation - CNF Conjunctive Normal Form

conjunction of disjunctions (AND of OR’s)of literals (atomic propositions or negations)

(P \/ Q \/ ~R) Λ (~W \/ ~Q \/ T) Λ (W \/ P) A Knowledge base is in CNF if the

statements are disjunctions

Page 21: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

less readable?

Example sentence

Example sentence in CNF

Page 22: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 22

Restricted CNF – Horn clause CNF disjunction

At most one literal is positive (P \/ Q \/ ~R) is not Horn clause (~W \/ ~Q \/ T) is Horn clause

Basis of PROLOG – logic programming language

(~W \/ ~Q \/ T) is (W Λ Q) T

Page 23: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 23

Summary 1 Representation – facts, propositions,

general knowledge Models, validity and satisfiability Propositional logic Reasoning – by searching models

– by inference CNF, Horn clauses

Page 24: Reasoning with Propositional Logic automated processing of a simple knowledge base CD.

D Goforth - COSC 4117, fall 2006 24

Summary 2 Logical equivalence axioms Sound and complete inference Inference strategies

And elimination Modus ponens Resolution

Inference algorithms (coming next) Resolution proof by contradiction Forward chaining – data-driven Backward chaining –goal-directed