40
Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2009 Adina Magda Florea http://turing.cs.pub.ro/krr_10 curs.cs.pub.ro r of Science in Artificial Intelligence, 2010-2012

Knowledge Representation and Reasoning

  • Upload
    avidan

  • View
    30

  • Download
    0

Embed Size (px)

DESCRIPTION

Master of Science in Artificial Intelligence, 2010-2012. Knowledge Representation and Reasoning. University "Politehnica" of Bucharest Department of Computer Science Fall 2009 Adina Magda Florea http://turing.cs.pub.ro/krr_10 curs.cs.pub.ro. Lecture 6. Modal Logic Lecture outline - PowerPoint PPT Presentation

Citation preview

Page 1: Knowledge Representation and Reasoning

Knowledge Representation and Reasoning

University "Politehnica" of BucharestDepartment of Computer Science

Fall 2009

Adina Magda Floreahttp://turing.cs.pub.ro/krr_10

curs.cs.pub.ro

Master of Science in Artificial Intelligence, 2010-2012

Page 2: Knowledge Representation and Reasoning

2

Lecture 6

Modal Logic

Lecture outline Introduction Modal logic in CS Syntax of modal logic Semantics of modal logic Logics of knowledge and belief Temporal logics

Page 3: Knowledge Representation and Reasoning

3

1. Introduction

In first order logic a formula is either true or false in any model

In natural language, we distinguish between various “modes of truth”, e.g, “known to be true”, “believed to be true”, “necessarily true”, “true in the future”• “Barack Obama is the president of the US” is currently

true but it will not be true at some point in the future.

• “After program P is executed, A hold” is possibly true if the program performs what is intended to perform.

Page 4: Knowledge Representation and Reasoning

4

History

Classical logic is truth-functional = truth value of a formula is determined by the truth value(s) of its subformula(e) via truth tables for ,, ¬, and →.

Lewis tried to capture a non-truth-functional notion of “A Necessarily Implies B” (A → B)

We can take A → B to mean “it is impossible for A to be true and B to be false”

He chose a symbol, P, and wrote PA for “A is possible”; then:

• ¬PA is “A is impossible”

• ¬P¬A is “not-A is impossible”

Then he used the symbol N to stand for ¬P and expressed

• NA := ¬P¬A “A is necessary”

Because → is logical implication, we can transform it like this:

• A → B := N(A → B) = ¬P¬(A → B) = ¬P¬(¬A B) = ¬P(A ¬B)

Page 5: Knowledge Representation and Reasoning

5

Modal operators

P - “possibly true” N - “necessarily true” Modal logics - modes of truth: Basic modal logic: - box, and - diamond The necessity / possibility - necessary, and -

possible Logics about knowledge - what an agent

knows / believes Deontic logic - - it is obligatory that, and - it is

permissible that

Page 6: Knowledge Representation and Reasoning

6

2. Modal logic in CS

Temporal logic Dynamic logic Logic of knowledge and belief Model problems and complex reasoning

The Lady and the Tiger Puzzle There are two rooms, A and B, with the following signs on them: A: In this room there is a lady, and in the other room there is a tiger” B: “In one of these rooms there is a lady and in one of them there is

a tiger” One of the two signs is true and the other one is false.

Q: Behind which door is the lady?

Page 7: Knowledge Representation and Reasoning

7

Modeling modal reasoning

The King's Wise Men Puzzle The King called the three wisest men in the country. He painted a spot on each of their foreheads and told

them that at least one of them has a white spot on his forehead.

The first wise man said: “I do not know whether I have a white spot”

The second man then says “I also do not know whether I have a white spot”.

The third man says then “I know I have a white spot on my forehead”.

Q: How did the third wise man reason?

Page 8: Knowledge Representation and Reasoning

8

Modeling modal reasoning

Mr. S. and Mr. P Puzzle Two numbers m and n are chosen such that 2 m

n 99.

Mr. S is told their sum and Mr. P is told their product.

Mr. P: "I don't know the numbers. "

Mr. S: "I knew you didn't know. I don't know either."

Mr. P: "Now I know the numbers."

Mr  S: "Now I know them too."

Q: In view of the above dialogue, what are the numbers?

Page 9: Knowledge Representation and Reasoning

9

3. Modal logic - Syntax

Atomic formulae: p ::= p0 | p1 | p2 | q …. where pi , q are atoms in PL

Formulae: ::= p | ¬ | | | | | → where and are a wffs in PL

Examples: p → q p → q (p1 → p2) → ((p1) → (p2))

Schema: → → ( → ) → ( → )

Schema Instances: Uniformly replace the formula variables with formulae (inference)

Examples: p → p is an instance of → but p → q is not

Page 10: Knowledge Representation and Reasoning

10

Deduction in modal logic

Axioms

The 3 axioms of PL

• A1. ( )

• A2. ( ( )) (( ) ( ))

• A3. ((¬) (¬)) ( )

The axiom to specify distribution of necessity

• A4. ( ) ( ) Distribution of modality

Page 11: Knowledge Representation and Reasoning

11

Deduction in modal logic

Inference rules

Substitution (uniform) ’

Modus Ponens  , ( )

The modal rule of necessity |- « for any formula , if was proved then

we can infer  »

Page 12: Knowledge Representation and Reasoning

12

4. Semantics of modal logic

Nonlinear model The semantics of modal logic is known as the Kripke

Semantics, also called the Possible World approach

Directed graph (V, E)

Vertices V = {v, v1, v2, …}

Directed edges {(s1,t1), (s2,t2),…} from source vertex si V to the target vertex tiV for i = 1,2,…

Cross product of a set V, V x V

{(v,w) | vV and wV} the set of all ordered pairs (v,w), where v and w are from V.

Directed graph

- a pair (V,E), where V = {v, v1, v2, …} and E V x V is a binary relation over V.

Page 13: Knowledge Representation and Reasoning

13

Semantics of modal logic

A Kipke frame is a directed graph <W, R>, where:

• W is a non-empty set of worlds (points, vertices) and

• R W x W is a binary relation over W, called the accessibility relation.

An interpretation of a wff in modal logic on a Kripke frame <W, R> is a function I : W x L → {t,f} which tells the truth value of every atomic formula from the language L at every point (in every word) in W.

A Kripke model M of a formula (an interpretation which makes the formula true) is

• the triple <W, R, I>, where I is an interpretation of the formula on a Kripke frame <W,R> which makes the formula true.

This is denoted by M |=W

Page 14: Knowledge Representation and Reasoning

14

Semantics of modal logic

Using the model, we can define the semantics of formulae in modal logic and can compute the truth value of formulae.

M |=W iff M |=/W (or M |=W ¬)

M |=W iff M |=W and M |=W

M |=W iff M |=W or M |=W

M |=W → iff M |=W ¬ or M |=W

(¬ is true in W)

M |=W iff w': R(w,w') M |=W'

M |=W iff w': R(w,w') M |=W'

Page 15: Knowledge Representation and Reasoning

15

W0

I(W0,p) = fI(W0,q) = fI(W0,r) = f

W1

I(W1,p) = fI(W1,q) = fI(W1,r) = a

W2

I(W2,p) = fI(W2,q) = fI(W2,r) = f

p – I am richq – I am president of Romaniar – I am holding a PhD in CS

Examples

I(W0, p) = ? I(W0, p) = ?

I(W0, r) = ? I(W0, r) = ?

Page 16: Knowledge Representation and Reasoning

16

w0

p, q, r

w1

p, q, r

w2

p, q, r

w3

p, q, r

p -Alice visits Parisq - It is spring timer - Alice is in Italy

I(W0, p) = ? I(W0, p) = ?

I(W0, q) = ? I(W0, q) = ?

I(W0, r) = ? I(W0, r) = ?

I(W1, p) = ? I(W1, p) = ?

Examples

Page 17: Knowledge Representation and Reasoning

17

Different modal logic systems

The modal logic K• A1. ( )

• A2. ( ( )) (( ) ( ))

• A3. ((¬) (¬)) ( )

• A4. ( ) ( )

X X Here is an invalidating model:

R(w0,w1), I(w0,p)=f, I(w1,p)=t

M |=W iff w': R(w,w') M |=W'

“it is impossible for A to be true and B to be false”

Page 18: Knowledge Representation and Reasoning

18

Different modal logic systems

The modal logic DAdd axiom

X X In fact, D-models are K-models that meet an

additional restriction: the accessibility relation must be serial.

A relation R on W is serial iff

• (wW: (w'W: (w,w')R))

Page 19: Knowledge Representation and Reasoning

19

Different modal logic systems

The modal logic TAdd axiom X X A T-model is a K-model whose accessibility

relation is reflexive. A relation R on W is reflexive iff

• (wW: (w,w)R).

Page 20: Knowledge Representation and Reasoning

20

Different modal logic systems

The modal logic S4Add axiom X X An S4-model is a K-model whose accessibility

relation is reflexive and transitive. A relation R on W is transitive iff

• (w1,w2,w3 wW:

(w1,w2)R (w2, w3)R (w1,w3)R).

Page 21: Knowledge Representation and Reasoning

21

Different modal logic systems

The modal logic BAdd axiom X X A B-model is a K-model whose accessibility

relation is reflexive and symmetric. A relation R on W is symmetric iff

• (w1,w2W: (w1,w2)R (w2,w1)R)

Page 22: Knowledge Representation and Reasoning

22

Different modal logic systems

The modal logic S5Add the axiom X X An S5-model is a K-model whose accessibility

relation is reflexive, symmetric, and transitive. That is, it is an equivalence relation

Exercise: Find an S5-model in which X X is false.S5 is the system obtained if every possible world is possible relative to every other world

Page 23: Knowledge Representation and Reasoning

23

Different modal logic systems

The modal logic S5 X X

A relation is euclidian iff (w1,w2,w3W: (w1,w2)R

(w1, w3)R (w2,w3)R)

Page 24: Knowledge Representation and Reasoning

24

Different modal logic systems

D = K + D

T = K + T

S4 = T + 4

B = T + B

S5 = S4 + B

S5

S4 B

T

K

D

serial

reflexive

transitive symmetric

symmetric transitive

reflexive

Page 25: Knowledge Representation and Reasoning

25

5. Logics of knowledge and belief

Used to model "modes of truth" of cognitive agents

Distributed modalities

Cognitive agents characterise an intelligent agent using symbolic representations and mentalistic notions:

• knowledge - John knows humans are mortal

• beliefs - John took his umbrella because he believed it was going to rain

• desires, goals - John wants to possess a PhD

• intentions - John intends to work hard in order to have a PhD

• commitments - John will not stop working until getting his PhD

Page 26: Knowledge Representation and Reasoning

26

Logics of knowledge and belief

How to represent knowledge and beliefs of agents? FOPL augmented with two modal operators K and B

K(a,) - a knows B(a,) - a believes

with LFOPL, aA, set of agents

Associate with each agent a set of possible worlds Kripke model Ma of agent a for a formula

Ma =<W, R, I>

with R A x W X W

and I - interpretation of the formula on a Kripke frame <W,R> which makes the formula true for agent a

Page 27: Knowledge Representation and Reasoning

27

Logics of knowledge and belief

An agent knows a propositions in a given world if the proposition holds in all worlds accessible to the agent from the given world

Ma |=W K iff w': R(w,w') Ma |=W' An agent believes a propositions in a given

world if the proposition holds in all worlds accessible to the agent from the given world

Ma |=W B iff w': R(w,w') Ma |=W'

The difference between B and K is given by their properties

Page 28: Knowledge Representation and Reasoning

28

Properties of knowledge

(A1) Distribution axiom:K(a, ) K(a, ) K(a, )

"The agent ought to be able to reason with its knowledge"

( ) ( ) (Axiom of distribution of modality)

K(a, ) ( K(a,) K(a,) )

(A2) Knowledge axiom: K(a, ) "The agent can not know something that is false"

(T) - satisfied if R is reflexive

K(a, )

Page 29: Knowledge Representation and Reasoning

29

Properties of knowledge

(A3) Positive introspection axiom

K(a, ) K(a, K(a, ))X X (S4) - satisfied if R is transitive

K(a, ) K(a, K(a, ))

(A4) Negative introspection axiom

K(a, ) K(a, K(a, ))X X (S5) - satisfied if R is euclidian

Page 30: Knowledge Representation and Reasoning

30

Inference rules for knowledge

(R1) Epistemic necessitation

|- K(a, )

modal rule of necessity |-

(R2) Logical omniscience

and K(a, ) K(a, )

problematic

Page 31: Knowledge Representation and Reasoning

31

Properties of belief

Distribution axiom: B(a, ) B(a, ) B(a, )

YES

Knowledge axiom: B(a, ) NO

Positive introspection axiom

B(a, ) B(a, B(a, ))

YES

Negative introspection axiom

B(a, ) B(a, B(a, )) problematic

Page 32: Knowledge Representation and Reasoning

32

Inference rules for belief

(R1) Epistemic necessitation

|- B(a, ) problematic

modal rule of necessity |-

(R2) Logical omniscience

and B(a, ) B(a, )

usually NO

Page 33: Knowledge Representation and Reasoning

33

Some more axioms for beliefs

Knowing what you believe

B(a, ) K(a, B(a, ))

Believing what you know

K(a, ) B(a, )

Have confidence in the belief of another agent

B(a1, B(a2,)) B(a1, )

Page 34: Knowledge Representation and Reasoning

Two-wise men problem - Genesereth, Nilsson(1) A and B know that each can see the other's forehead. Thus, for example:

(1a) If A does not have a white spot, B will know that A does not have a white spot

(1b) A knows (1a)

(2) A and B each know that at least one of them have a white spot, and they each know that the other knows that. In particular

(2a) A knows that B knows that either A or B has a white spot

(3) B says that he does not know whether he has a white spot, and A thereby knows that B does not know

34

1. KA(WA KB( WA) (1b)2. KA(KB(WA WB)) (2a)3. KA(KB(WB)) (3)

4. WA KB(WA) 1, A2 A2: K(a, ) 5. KB(WA WB) 2, A2

6. KB(WA) KB(WB) 5, A1 A1: K(a, ) (K(a,) K(a,))

7. WA KB(WB) 4, 6

Proof

8. KB(WB) WA contrapositive of 79. KA(WA) 3, 8, R2

R2: and K(a, ) infer K(a, )

Page 35: Knowledge Representation and Reasoning

35

The time may be linear or branching; the branching can be in the past, in the future of both

Time is viewed as a set of moments with a strict partial order, <, which denotes temporal precedence.

Every moment is associated with a possible state of the world, identified by the propositions that hold at that moment

Modal operators of temporal logic (linear)

p U q - p is true until q becomes true - untilXp - p is true in the next moment - nextPp - p was true in a past moment - past

Fp - p will eventually be true in the future - eventuallyGp - p will always be true in the future – always

Fp true U p Gp F p

F – one time pointG – each time point

6. Temporal logic

Page 36: Knowledge Representation and Reasoning

36

Temporal structure with a branching time future and a single past - time tree

CTL – Computational Tree Logic In a branching logic of time, a path at a given

moment is any maximal set of moments containing the given moment and all the moments in the future along some particular branch of <

Situation - a world w at a particular time point t, wt

State formulas - evaluated at a specific time point in a time tree

Path formulas - evaluated over a specific path in a time tree

Branching time logic - CTL

Page 37: Knowledge Representation and Reasoning

37

CTL Modal operators over both state and path formulas

From Temporal logic (linear)

Fp - p will sometime be true in the future - eventually

Gp - p will always be true in the future - always

Xp - p is true in the next moment - next

p U q - p is true until q becomes true - until(p holds on a path s starting in the current moment t until q comes

true)

Modal operators over path formulas (branching)

Ap - at a particular time moment, p is true in all paths emanating from that point - inevitable p

Ep - at a particular time moment, p is true in some path emanating from that point - optional p

F – one time pointG – each time point

A – all pathE – some path

Branching time logic - CTL

Page 38: Knowledge Representation and Reasoning

LB - set of moment formula

LS - set of path-formula

SemanticsM = <W, T, <, | |, R> - every tT has associated a world wtWM |=t iff t||

is true in the set of moments for which holds

M |=t pq iff M |=t p and M |=t q

M |=t p iff M |=/t p

M |=s,t pUq iff (t': tt' and M |=s,t' q and

(t": t t" t' M |=s,t" p))p holds on a path s starting in the current moment t until q comes true

Fp true Up

Gp F p

M |=t A p iff (s: sSt M |=s,t p) Ep A p

s is a path, St - all paths starting at the present moment

M |=s,t X p iff M |=s,t+1 p) 38

Page 39: Knowledge Representation and Reasoning

s is true in each time point (G) and in all path (A) r is true in each time point (G) in some path (E) p will eventually (F) be true in some path (E) q will eventually (F) be true in all path (A)

39

rs

ssq

rs

psq

rsq

s

AGs

EGr

EFp

AFq

r - Alice is in Italy p -Alice visits Pariss – Paris is the capital of France q - It is spring time

F - eventuallyG - alwaysA - inevitableE - optional

Page 40: Knowledge Representation and Reasoning

Each situation has associated a set of accessible words - the worlds the agent believes to be possible. Each such world is a time tree.

Within these worlds, the branching future represents the choices (options) available to the agent in selecting which action to perform

Similar to a decision tree in a game of chance

40

Player 1

Player 2

Player 1

Dice

Chance nodes

Decision nodes

• Each arc emanating froma chance node correspondsto a possible world

• Each arc emanating froma decision node correspondsto a choice available in apossible world

1/36 1/18

Dice

1/36 1/18