Upload
xylia
View
31
Download
1
Embed Size (px)
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
Citation preview
SWE 623 Duminda Wijesekera 1
Modal, Dynamic and Temporal Logics
SWE 623
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
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
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
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
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
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)
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 )
SWE 623 Duminda Wijesekera 9
Proving Modal Formulas
SWE 623 Duminda Wijesekera 10
A counter-example in Modal Logic
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).
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.
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
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.
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
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
SWE 623 Duminda Wijesekera 17
PDL Axiom System: Rules
• Modus Ponens
A, A -> B
B
• Modal Generalization A
[] A
SWE 623 Duminda Wijesekera 18
Some Derived Rules for PDL
• Monotonicity of <>
A -> B
<>A -> <>B
• Monotonicity of []
A -> B
[]A -> []B
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)
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?)
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.
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.
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
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
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)
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)
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
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
SWE 623 Duminda Wijesekera 29
Prepositional Semantics
• A collection of Kripke Worlds including the current one.
• Accessibility relation is evolution of time.
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.
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 ))
SWE 623 Duminda Wijesekera 32
PTL Axioms and Rules II
• Rules– modus ponens– generalization
A
[] A
A
O A