Master of Science in Artificial Intelligence 2009 2011








































- Slides: 40
Master of Science in Artificial Intelligence, 2009 -2011 Knowledge Representation and Reasoning University "Politehnica" of Bucharest Department of Computer Science Fall 2009 Adina Magda Florea http: //turing. cs. pub. ro/krr_09 curs. cs. pub. ro 1
Lecture 4 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 →. § 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) 4
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 5
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? 6
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? 7
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? 8
3. Modal logic - Syntax § § Atomic formulae: p : : = p 0 | p 1 | p 2 | q …. where pi , q are atoms in PL Formulae: : : = p | ¬ | � | | | | → where and are a wffs in PL Examples: § �p → q § �p → ��q § � (p 1 → p 2) → ((�p 1) → (�p 2)) Schema: • � → �� • �( → ) → (� → � ) Schema Instances: Uniformly replace the formula variables with formulae (inference) Examples: § �p → p is an instance of � → but § �p → q is not 9
Deduction in modal logic § Axioms The 3 axioms of PL • • • A 1. ( ) A 2. ( ( )) (( ) ( )) A 3. ((¬ ) (¬ )) ( ) The axiom to specify distribution of necessity • A 4. �( ) (� � ) Distribution of modality 10
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 � » 11
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, v 1, v 2, …} § Directed edges {(s 1, t 1), (s 2, t 2), …} from source vertex si V to the target vertex ti V for i = 1, 2, … Cross product of a set V, V x V § {(v, w) | v V and w V} the set of all ordered pairs (v, w), where v and w are from V. Directed graph - a pair (V, E), where V = {v, v 1, v 2, …} and E V x V is a binary relation over V. 12
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 13
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' 14
Examples p – I am rich q – I am president of Romania r – I am holding a Ph. D in CS W 1 I(W 1, p) = f I(W 1, q) = f I(W 1, r) = a W 0 I(W 0, p) = f I(W 0, q) = f I(W 0, r) = f I(W 0, p) = ? I(W 0, �p) = ? I(W 0, r) = ? I(W 0, �r) = ? W 2 I(W 2, p) = f I(W 2, q) = f I(W 2, r) = f 15
Examples w 1 p, q, r p -Alice visits Paris q - It is spring time r - Alice is in Italy w 2 w 0 p, q, r p, q, r w 3 p, q, r I(W 0, p) = ? I(W 0, �p) = ? I(W 0, q) = ? I(W 0, �q) = ? I(W 0, r) = ? I(W 0, �r) = ? I(W 1, p) = ? I(W 1, �p) = ? 16
Different modal logic systems The modal logic K • A 1. ( ) • A 2. ( ( )) (( ) ( )) • A 3. ((¬ ) (¬ )) ( ) • A 4. �( ) (� � ) § X X “it is impossible for A to be true and B to be false” § Here is an invalidating model: R(w 0, w 1), I(w 0, p)=f, I(w 1, p)=t M |=W � iff w': R(w, w') M |=W' 17
Different modal logic systems The modal logic D Add 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 • ( w W: ( w' W: (w, w') R)) 18
Different modal logic systems The modal logic T Add axiom § X X § A T-model is a K-model whose accessibility relation is reflexive. § A relation R on W is reflexive iff • ( w W: (w, w) R). 19
Different modal logic systems The modal logic S 4 Add axiom § X X § An S 4 -model is a K-model whose accessibility relation is reflexive and transitive. § A relation R on W is transitive iff • ( w 1, w 2, w 3 w W: (w 1, w 2) R (w 2, w 3) R (w 1, w 3) R). 20
Different modal logic systems The modal logic B Add 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 • ( w 1, w 2 W: (w 1, w 2) R (w 2, w 1) R) 21
Different modal logic systems The modal logic S 5 Add the axiom § X X § An S 5 -model is a K-model whose accessibility relation is reflexive, symmetric, and transitive. § That is, it is an equivalence relation § Exercise: Find an S 5 -model in which X X is false. S 5 is the system obtained if every possible world is possible relative to every 22 other world
Different modal logic systems The modal logic S 5 § X X § A relation is euclidian iff ( w 1, w 2, w 3 W: (w 1, w 2) R (w 1, w 3) R (w 2, w 3) R) 23
Different modal logic systems D=K+D T=K+T S 4 = T + 4 B=T+B S 5 = S 4 + B S 5 symmetric transitive S 4 B transitive reflexive symmetric T D reflexive serial K 24
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 Ph. D • intentions - John intends to work hard in order to have a Ph. D • commitments - John will not stop working until getting his Ph. D 25
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, a A, set of agents § Associate with each agent a set of possible worlds § Kripke model Ma of agent 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 26
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 27
Properties of knowledge (A 1) Distribution axiom: K(a, ) "The agent ought to be able to reason with its knowledge" �( ) (� � ) (Axiom of distribution of modality) K(a, ) ( K(a, ) ) (A 2) Knowledge axiom: K(a, ) "The agent can not know something that is false" (T) - satisfied if R is reflexive K(a, ) 28
Properties of knowledge (A 3) Positive introspection axiom K(a, )) X X (S 4) - satisfied if R is transitive K(a, )) (A 4) Negative introspection axiom K(a, )) X X (S 5) - satisfied if R is euclidian 29
Inference rules for knowledge (R 1) Epistemic necessitation |- K(a, ) modal rule of necessity |- � (R 2) Logical omniscience and K(a, ) problematic 30
Properties of belief Distribution axiom: B(a, ) YES Knowledge axiom: B(a, ) NO Positive introspection axiom B(a, )) YES Negative introspection axiom B(a, )) problematic 31
Inference rules for belief (R 1) Epistemic necessitation |- B(a, ) problematic modal rule of necessity |- � (R 2) Logical omniscience and B(a, ) usually NO 32
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(a 1, B(a 2, )) B(a 1, ) 33
Two-wise men problem - Genesereth, Nilsson (1) A and B know that each can see the other's forehead. Thus, for example: (1 a) If A does not have a white spot, B will know that A does not have a white spot (1 b) A knows (1 a) (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 (2 a) 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 WB)) 3. KA( KB(WB)) (1 b) (2 a) (3) 4. WA KB( WA) 5. KB( WA WB) 1, A 2 2, A 2: K(a, ) 6. KB( WA) KB(WB) 7. WA KB(WB) 5, A 1 4, 6 A 1: K(a, ) (K(a, ) K(a, )) 8. KB(WB) WA 9. KA(WA) contrapositive of 7 3, 8, R 2 Proof 34 R 2: and K(a, ) infer K(a, ) 34
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 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 - until Xp - p is true in the next moment - next Pp - p was true in a past moment - past Fp - p will eventually be true in the future - eventually Gp - p will always be true in the future – always Fp true U p Gp F p F – one time point G – each time point 35
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 36
Branching time logic - 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 F – one time point G – each time point 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 A – all path E – some path 37
LB - set of moment formula LS - set of path-formula Semantics M = <W, T, <, | |, R> - every t T has associated a world wt W M |=t iff t | | is true in the set of moments for which holds M |=t p q iff M |=t p and M |=t q M |=t p iff M |=/t p M |=s, t p. Uq iff ( t': t t' 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: s St 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 38
§ § 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) s r s p s q AGs EGr r s q F - eventually G - always A - inevitable E - optional EFp AFq s r - Alice is in Italy s – Paris is the capital of France s q p -Alice visits Paris q - It is spring time 39 39
§ 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 Decision nodes Player 1 Dice Player 2 1/36 1/18 Chance nodes Dice Player 1 • Each arc emanating from a chance node corresponds to a possible world 1/36 1/18 • Each arc emanating from a decision node corresponds to a choice available in a possible world 40 40