modal, dynamic and temporal logics

32
SWE 623 Duminda Wijesekera 1 Modal, Dynamic and Temporal Logics SWE 623

Upload: xylia

Post on 20-Jan-2016

34 views

Category:

Documents


1 download

DESCRIPTION

Modal, Dynamic and Temporal Logics. SWE 623. Modal Logic. Logic of Necessity and Possibility Has a philosophical background Syntax has two extra symbols [] read as necessity ([] X is “necessarily X”) Also called “box X” read as possibility ( X “possibly X”) Also called “diamond X” - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 1

Modal, Dynamic and Temporal Logics

SWE 623

Page 2: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 2

Modal Logic

• Logic of Necessity and Possibility• Has a philosophical background• Syntax has two extra symbols

– [] read as necessity ([] X is “necessarily X”)• Also called “box X”

– <> read as possibility (<> X “possibly X”)

• Also called “diamond X”

• See http://turing.wins.uva.nl/~mdr/AiML/background.html

Page 3: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 3

Kripke Semantics of Modal Logic

• The “universe” seen as a collection of worlds.

• Truth defined “in each world”.

• Say U is the universe.

• I.e. each w U is a prepositional or predicate model.

W1

W2

W3

W4

Page 4: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 4

Kripke Semantics of Modal Logic

• W1 satisfies [] X if X is satisfied in each world accessible from W1.

– If W3 and W4 satisfy X.

– Notation: • W1 |= [] X if and only if

– W3 |= X and W4 |= X

• W1 W1 satisfies <> X if X is satisfied in at least one world accessible from W1.

W1

W2

W3

W4

–Notation: •W1 |= <> X if and only if

–W3 |= X or W4 |= X

Page 5: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 5

Proof Rules for Modal Logic• Modal Generalization

A

[] A

• Monotonicity of A B

A B

• Monotonicity of A B

[] A []B

Page 6: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 6

An Axiom System for Prepositional Logic

• (A (B C)) (A B) (A C)

• A (B A)

• (( A false ) false ) A

• Modus Ponens

A, A -> B

B

Page 7: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 7

An Axiom System for Predicate Logic

x (A(x) B(x)) (xA(x) xB(x)) x A(x) A[t/x] provided t is free for x in A• A x A(x) provided x is not free in A• Modus Ponens

A, A -> B

B

• Generalization A

x A(x)

Page 8: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 8

Some Facts About Modal Logic

• A couple of Valid Modal Formulas: (A B ) <-> ( A) ( B)– [](A B ) <-> ([] A) ([] B) (false) (false)– ( A) ([]B) (A B )

• Counter-examples to invalid modal formulas– ( A) ( [] A )

Page 9: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 9

Proving Modal Formulas

Page 10: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 10

A counter-example in Modal Logic

Page 11: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 11

Dynamic Logic

• A special kind of Modal Logic where each world is a system statesystem state..

• Definition of State– The set of variables x1, … xn.– x1= a1, … xn= an. is a state, where each variable takes

a value.

• Accessibility is state change perhaps due to executing code.– x1= a1, … xn= an is changed to x1= b1, … xn= an by

the program (x1 := b1).

Page 12: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 12

Dynamic Logic• Issues:

– What kind of program constructs result in what type of state change

– What is the logic

• Two Levels– Prepositional:

• Only deals with state change at (abstract) symbolic level

– Predicate: • Details of variables, values and programming operators

• Deals well with non-determinism, concurrency etc.

Page 13: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 13

Prepositional Dynamic LogicSyntax

• If A, B propositions and , programs,• Following are formulas

– A /\ B, A B, A, A B, [are formulas.

• Following are programsU = non-deterministic choice; = sequential composition(A?) test.non-deterministic iteration

Page 14: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 14

Prepositional Dynamic LogicSemantics

• A collection of states: S = {si : i >= 0}.

• For each state si a notion of satisfiability of atomic prepositions. I.e. si |= A for each A.

• For each each atomic program , a relation R on SxS.

– Ru = Ru R

– R(A?) = { (s,s) : s |= A }

– R; = R; Rs1,s3) : s2 (s1,s2) e Rand (s2,s3) e R }

– R= U {Ri iWhereR

i is defined inductively as

R(i+1) = R

i ; RandR= Identity.

Page 15: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 15

PDL Semantics - Satisfaction

• Prepositional connectives as usual: – I.e. si |= A /\ B if si |= A and si |= B

– I.e. si |= A B if si |= A or si |= B

• Modal Connectives as in Modal Logic– I.e. si |= []A, if for all states sj such that (si , sj)

Rsj |= A

– I.e. si |= <A, there is a state sj with (si , sj) Randsj |= A

Page 16: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 16

PDL Axiom System• Axioms of prepositional logic• [] (A B) ([]A []B)

• [] (A /\ B) <-> ([]A /\ []B)

• [U]A <-> ([] A /\ [] A)

• [;]A <-> [] [] A

• [B?]A <-> (B /\ A)

• B /\ [] [] A <-> [] A

• B /\ []( A []A) [] A

Page 17: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 17

PDL Axiom System: Rules

• Modus Ponens

A, A -> B

B

• Modal Generalization A

[] A

Page 18: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 18

Some Derived Rules for PDL

• Monotonicity of <>

A -> B

<>A -> <>B

• Monotonicity of []

A -> B

[]A -> []B

Page 19: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 19

Some Provable Properties• [] (A /\ B) ([]A /\[]B)• <> (A \/ B) <-> (<>A \/ <>B)• (<A /\ [ B) <>(A /\ B)• []A <-> ( <>( A))• <>false <-> false• <><>A <-> <>A, A <-> [ A• < U<-> (<A \/ <>B)• [ U<-> ([A /\ []B)

Page 20: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 20

Translating Gires’s Style Pre/Post Conditions to PDL

• Skip == True?

• Fail == false?

• If A then else == (A?;) U (A?;)

• While A do == (A?;)*; (A?)

Page 21: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 21

First-Order Dynamic Logic

• Syntax: – The same definition as predicate logic except

for the additions• If A is a formula and is a program, then []A,

<>A are formulas.

• If A is a formula, then A? is a test. (I.e. a program)– If A is quantifier free then its said to be a basic test, and

otherwise a rich test.

Page 22: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 22

First-Order Dynamic Logic

• Semantics: Transitions between states defined as – R(X :=a) = { (S, S’) : if S’(x) = S(a) and

S’(y) = S(y) for Y != X }

– R(A?) = {(S,S) : S |= A }– Definitions of U, ; are same as in the

prepositional case.

Page 23: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 23

Axiomatization

• Axioms– All axioms for predicate logic– All axioms for PDL

– A[t/x] <-> < x:= t>A(x)

– A <-> A’, A’ is obtained by replacing any program by z:=x; ’; x:=z, where ’ is a with all occurrences of x replaced by z, and z does not appear in

Page 24: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 24

Axiomatization: Rules

• modus ponensA, A -> B B

• Generalization A A

[] A x A(x)

• Infinitary convergenceA -> [n]B for all n

B -> [*]B

Page 25: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 25

Some Example Reductions I

• Reduce: X:=X+1; ((X:=a) U (X:=b)) A(X)

• Step1: X=X+1; (X=a) (X=b) A(X)

• Step2: X=X+1 (X=a) A(X) <X=X+1 (X=b) A(X)

• Step3: X=X+1 A

• Step4: A(a) A(b)

Page 26: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 26

Some Example Reductions II

• Reduce: [x:=x+1;(x:=a U x:=b)] B(X)

• Step1: [x:=a+1 U x:=b+1]B(x)

• Step 2: [x:=a+1]B(x) /\ [x:=b+1]B(x)

• Step 3: B(a+1) /\ B(b+1)

Page 27: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 27

Temporal Logic• Special kind of modal logic to reason about time.• There are many kinds of Temporal Logics

– Linear and Branching Time

– Future and Past times

– Discrete and Continuous time

• Operators in Temporal Logics (MacMillan’s Notation)– O = next time F

– [] = always G = some times X = until U

Page 28: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 28

Prepositional Syntax

• Atomic Proposition letters p, q etc.

• If p, q are propositions then so are.– Meaning Logical Notation Model Checking– Next Time p: Op Xp– All ways p: []p Gp– In the future p: p Fp– p until q: p q pUq

Page 29: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 29

Prepositional Semantics

• A collection of Kripke Worlds including the current one.

• Accessibility relation is evolution of time.

Page 30: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 30

Prepositional Semantics II• |= Op if some world

accessible from the current satisfies p.

• |= []p if every world accessible from the current satisfies p.

• |= p if some world in the future from the current satisfies p.

Page 31: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 31

PTL Axioms and Rules I• Axioms

– [](A ->B) ->([]A -> []B)

– O(A ->B) -> (OA -> OB)

– (O A) <-> (OA)

– []A -> (A /\ O[]A)

– [](A -> OA) -> (A -> []A)

– A B -> B

– A B <-> B \/ (A /\ O(A B ))

Page 32: Modal, Dynamic and Temporal Logics

SWE 623 Duminda Wijesekera 32

PTL Axioms and Rules II

• Rules– modus ponens– generalization

A

[] A

A

O A