Você está na página 1de 47

Master of Science in Artificial Intelligence, 2015-2017

Knowledge
Representation
and Reasoning
University "Politehnica" of
Bucharest
Department of Computer
Science
Fall 2015
Adina Magda Florea

Lecture 3
Modal Logic
Lecture outline

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

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.
3

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
Initially modal logic tried to capture a non truthfunctional notion of A Necessarily Implies B (A
B) or it is necessary that A B

Modal operators

P - possibly true
N - necessarily true
Modal logics - modes of truth:

Basic modal logic: - box, and - diamond


Pa
a = robots will be able to cry
Nb
b = sun will rise tomorrow

Modal operators
In a narrower sense the term modal logic refers to the
logic dealing with the notions of necessity and
possibility - - necessary, and - possible
In a broader sense:
deontic logic dealing with the notions of obligation and
permissibility - - it is obligatory that, and - it is
permissible that
temporal logic dealing with the logic of expressions like
It will be the case that, It will always be the case that
F eventually, G always
epistemic logic dealing with the notions of knowledge
and belief - knowledge - what an agent knows / believes
6

2. Modeling with modal logics


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?

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 spots can be Black or White and 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?


8

Modeling modal reasoning


Mr. S. and Mr. P Puzzle
Two numbers x and y are chosen such that

2 x <y 99

Mr. S is told their sum (x+y) and Mr. P is told their


product (x*y)
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?

Modeling modal reasoning


To simplify the problem, we can give an upper
bound of 20 for each of the two numbers
This means that the sum cannot be greater than 40
or the product greater than 400.
If you succeed in finding the unique solution, you
will see that the problem can be extended by
raising the upper bound.
Surprisingly, if the bound is raised to 100, the
answer remains the same.
A computer program checked on all numbers up to
two million without finding a second solution. It may
be possible to prove that the solution is unique
even if there is no upper bound whatsoever.
10

3. Modal logic
Saul Aaron Kripke born 1940 is
an American philosopher and logician,
currently Professor of
Philosophy, Emeritus, at Princeton
University
Kripke has made influential and
original contributions to logic,
especially modal logic Kripke
semantics
He proposed his semantics when he
was 19 years old, student at Harvard

11

3. Modal logic - Syntax

Atomic formulae: p ::= p0 | p1 | p2 . where pi are


atoms in Propositional Logic (PL)

Formulae: A ::= p | A | A | A | A B | A B | A B
where A and B are a wffs in PL
Examples:
pq,
p q

(p1 p2) (( p1) ( p2))

12

Modal logic relations among connectors


P ~ ~P

P ~~P

P = it will rain
It is possible that it will rain today if and only if it
is not necessary that it will not rain today
It is necessary that it will rain today if and only if
it is not possible that it will not rain today.

13

Deduction in modal logic


Axioms
The 3 axioms of PL

A1. A (B A)
A2. (A (B C)) ((A B) (A C))
A3. ((A) (B)) (B A)

The axiom to specify distribution of necessity

A4. (A B) ( A

B)

Distribution of modality

14

Deduction in modal logic

Inference rules

Substitution (uniform)

Modus Ponens A, (A B) B

The modal rule of necessity |- A A

A A

for any formula A, if A was proved then


we can infer A

15

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,

A pair (V,E), where V = {v, v1, v2, } and E V x V is a


binary relation over V.

16

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 A (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 A

17

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 A iff
M |=/W A
(or M |=W A)

M |=W A B iff

M |=W A and M |=W B

M |=W A B iff

M |=W A or M |=W B

M |=W A B iff

M |=W A or M |=W B
(A B is true in W)

M |=W A iff

w': R(w,w') & M |=W' A

M |=W

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

A iff

18

Examples
p I am rich
q I am president of Romania
r I am holding a PhD in CS

W1
I(W1,p) = f
I(W1,q) = f
I(W1,r) = t

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

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

I(W0, p) = ?

I(W0, p) = ?

I(W0, r) = ?

I(W0, r) = ?
19

Examples
w1
p, q, r

w0
p, q, r

w2
p, q, r

w3
p, q, r

p -Alice visits Paris


q - It is spring time
r - 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) = ?

20

Different modal logic systems


The modal logic K

A1. A (B A)
A2. (A (B C)) ((A B) (A C))
A3. ((A) (B)) (B A)
A4. (A B) ( A B)
X X

is false in K

Here is an invalidating model:


R(w0,w1), I(w0,p)=f, I(w1,p)=t
M |=W

A iff

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


21

Different modal logic systems


The modal logic T
A relation R on W is reflexive iff
(wW: (w,w)R).
A T-model is a K-model whose accessibility
relation is reflexive.
X X is then true in T
Add axiom
X X
22

Different modal logic systems


The modal logic B
A relation R on W is symmetric iff
(w1,w2W: (w1,w2)R (w2,w1)R)
A B-model is a K-model whose accessibility
relation is reflexive and symmetric.
Add axiom
X X

23

Different modal logic systems


The modal logic S4
A relation R on W is transitive iff
(w1,w2,w3 wW:
(w1,w2)R & (w2, w3)R (w1,w3)R).
An S4-model is a K-model whose accessibility
relation is reflexive and transitive.
Add axiom
X X
24

Different modal logic systems

The modal logic S5


An S5-model is a K-model whose accessibility
relation is reflexive, symmetric, and transitive.
That is, it is an equivalence relation
Add the axiom
X X
S5 is the system obtained if every possible world is possible relative to every
other world

Exercise: Find an S5-model in which X X is false.


25

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)

26

Different modal logic systems


The modal logic D
A relation R on W is serial iff
(wW: (w'W: (w,w')R))
A D-model is a K-model whose accessibility
relation is serial.
Add axiom
X X

27

Different modal logic systems


T: X X
B: X X
S4: X X
D: X X
S5: X X
S5 = S4 + B

S5
symmetric

transitive

S4

transitive
reflexive

symmetric

reflexive
serial

K
28

5. Logics of knowledge and belief


In Protagoras of Plato
(dialogs)
Knowledge is justified
belief the modern
version of Platos
definition

29

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
30

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) - a knows A
B(a,A) - a believes A
with ALFOPL, aA, set of agents
Associate with each agent a set of possible worlds
Kripke model Ma of agent a for a formula A
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
31

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
w': R(w,w') Ma |=W' A
Ma |=W KA iff
An agent believes a propositions in a given
world if the proposition holds in all worlds
accessible to the agent from the given world
w': R(w,w') Ma |=W' A
Ma |=W BA iff
The difference between B and K is given by their
properties
32

Properties of knowledge
(A1) Distribution axiom:
K(a, A) K(a, A B) K(a, B)
"The agent ought to be able to reason with its
knowledge"
(A B) ( A B) (Axiom of distribution of modality)
K(a,A B) ( K(a,A) K(a,B) )

(A2) Knowledge axiom: K(a, A) A


"The agent can not know something that is false"
A A (T) - satisfied if R is reflexive
K(a, A) A
33

Properties of knowledge
(A3) Positive introspection axiom
K(a, A) K(a, K(a, A))
X X (S4) - satisfied if R is transitive
K(a, A) K(a, K(a, A))

(A4) Negative introspection axiom


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

Inference rules for knowledge


(R1) Epistemic necessitation
|- A K(a, A)
modal rule of necessity |- A A

(R2) Logical omniscience


A B and K(a, A) K(a, B)
problematic
35

Properties of belief
Distribution axiom: B(a, A) B(a, A B) B(a, B)
YES
Knowledge axiom: B(a, A) A
NO
Positive introspection axiom
B(a, A) B(a, B(a, A))
YES
Negative introspection axiom
B(a, A) B(a, B(a, A))

problematic
36

Inference rules for belief


(R1) Epistemic necessitation
|- A B(a, A)
problematic
modal rule of necessity |- A A

(R2) Logical omniscience


A B and B(a, A) B(a, B)
usually NO
37

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

1. KA(WA KB( WA))


2. KA(KB(WA W B))
3. KA(KB(W B))

(1b)
(2a)
(3)

Proof

4. WA KB(WA)
5. KB(WA W B)

1, A2
2, A2

A2: K(a, A) A

6. KB(WA) KB(W B)
7. WA KB(W B)

5, A1
4, 6

A1: K(a,A B) (K(a,A) K(a,B))

8. KB(W B) WA
9. KA(WA)

contrapositive of 7
3, 8, R2
R2: A B and K(a, A) infer K(a, B)

38

6. Temporal logic
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 S of the
world, identified by the propositions that hold at that
moment

39

Temporal logic
Modal operators of temporal logic (linear)
- Xp - p is true in the next moment next ()
M |=s,t X p iff M |=s,t+1 p

Xp

- Pp - p was true in a past moment - past


M |=s,t P p iff M |=s,t-1 p

Pp

- p U q - p is true until q becomes true until


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

pUq

40

Temporal logic
Fp - p will eventually be true in the future - eventually

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

Gp
F one time point
Gp F p

G each time point


41

Branching time logic - CTL


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
42

Branching time logic - CTL


CTL Modal operators over both state and path formulas
From Temporal logic (linear)
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)
Fp - p will sometime be true in the future - eventually
Gp - p will always be true in the future - always
F one time point
G each time point

43

Branching time logic - CTL


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
A all path
E some path

44

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
M |=t A p iff (s: sSt M |=s,t p)
s is a path, St - all paths starting at the present
moment
Ep A p

45

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)

r
s

r
s

p
s
q

r
s
q

F - eventually
G - always

AGs

A - inevitable

EGr

E - optional

EFp
AFq

r - Alice is in Italy
s Paris is the capital of France

s
q

p -Alice visits Paris


q - It is spring time
46

pie
cake

pie
cake

G - always

apple

cake pie

E cake pie

A cake pie

apple

E apple

A apple

apple

apple

F - eventually

E
E

apple
apple

A
A

A - inevitable

E - optional

apple
apple
47

Você também pode gostar