Slides Print
Slides Print
Given a suitable model M, and a look-up table l , a formula MODULE: SAT PROBLEMS
p can be evaluated as follows:
M |=l p iff for all R in psM , M |=l [p|->R]
11 30-11-2024 0
Algorithm? Satisfiability problems are written as conjunctive normal form (CNF) formulas.
sentence: all truth value assignments for the variables make Clever heuristics exists (we will see it next lectures)
the sentence true.
30-11-2024
11/30/2024
Search Example:
(P Q) (P ¬Q R) (T ¬R) (¬P ¬T) (P S) (T R S)
22
BASIS IDEA - BACKTRACKING BINARY SEARCH (¬S T)
10
11/30/2024
Search Example:
(P Q) (P ¬Q R) (T ¬R) (¬P ¬T) (P S) (T R S) DPLL General Idea
(¬S T)
First need to put into conjunctive normal form
=D ( D A B) ( D A B) ( D A B) A
11
BITS Pilani, Pilani Campus
DPLL algorithm
Else
30-11-2024 13
BITS Pilani, Pilani Campus
DPLL algorithm DPLL example 1
(Q ¬R) ¬Q R U One-Literal on ¬Q
Else
¬R R U One-Literal on R
unsatisable
Unit clause has only one literal
Pure literal only occurs positively or negatively
DPLL example -2
DPLL example -2 (Continued)
30-11-2024 19
RESOLUTION
11/30/2024
11/30/2024
38
26
11/30/2024 11/30/2024
27 28
30-11-2024 0
30-11-2024 30-11-2024
6 7
30-11-2024 30-11-2024
30-11-2024 30-11-2024
10 11
THE ALGORITHM TO TEST FOR SATISFIABILITY The Algorithm to test for Satisfiability
(T q) ^ (T s) ^ (w ) ^ (p^q^s v) ^ (v s) ^ (T r)
Function HORN ( )
//precondition: is a Horn formula
^(r p)
//postcondition: HORN ( ) decides the satisfiability for Mark: q, s, r through (T q),(T s),(T r)
{ (T q) ^ (T s) ^ (w ) ^ (p^q^s v) ^ (v s) ^ (T r)
mark all occurrences of T in ^(r p)
while there is a conjunct p1 ^ p2 ^ pn P of
such that all pj are marked but P is not Mark: p through (r p)
mark P (T q) ^ (T s) ^ (w ) ^ (p^q^s v) ^ (v s) ^ (T r)
end while ^(r p)
if is marked
return Mark: v through (p^q^s v)
else (T q) ^ (T s) ^ (w ) ^ (p^q^s v) ^ (v s) ^ (T r)
return ^(r p)
end if
}
Return?
Satisfiable
30-11-2024 15
30-11-2024
/* At the Zoo */
Prolog
16
As Logic Prog. p; q : . q; r : s. t : r.
20 21
A logic programming program P is defined as a finite Program P (facts and rules in clause form)
set of rules and facts.
Goal G negated and added to program P
For example, To prove G, we need to show P { G} is inconsistent
rule1 fact1 rule2 fact2 Complementary literals
Rules and facts (with exactly one positive literal) are q, t p. , s. Parent clauses
called definite clauses and therefore a program defined Resolving upon p, being on
different sides of
by them is called a definite program.
q, t s. Resolvent
22 23
EXAMPLE (1) EXAMPLE (2)
Program , A1. If Henry has two days off, then if the weather is bad, Henry is
not fishing.
Query A2. if Henry is not fishing and is not drinking in a pub with his
This is already the negated form of our goal!
friends, then he is watching TV at home.
A3. If Henry is working, then he is neither drinking in a pub with
q. : his friends nor watching TV at home.
From logical point of view, we want to prove Q, given A1. If Henry has two days off, then if the p: H has two days off
weather is bad, Henry is not fishing. q: weather is bad
A1, A2, A3. { A 1 , A 2 , A 3 } Q . r: H is fishing
A2. if Henry is not fishing and is not drinking
in a pub with his friends, then he is s: H is drinking in a pub with
By refutation principle, the consistency of watching TV at home. his friends
C {A1, A2, A3} { Q} t: H is watching TV at home
A3. If Henry is working, then he is neither
u: H is working
is examined. drinking in a pub with his friends nor
watching TV at home.
Step 1: Represent as propositional formulas
Step 2: Represent as clauses Q.If Henry is not watching TV at home and ~
Step 3: Determine the consistency of C A3. ( s & t)
he has two days off, then he is drinking in ~
If C is consistent, answer NO (false) a pub with his friends provided that the
Q. (~t & p)
If C is inconsistent, answer YES (true) weather is bad.
26 27
York University CSE York University CSE
3401 V. Movahedi 3401 V. Movahedi
Conversion to clause form Determining the consistency of {C1, C2, ..., C8}
A1: p (q r) p q r C1 : p, q, r.
: p, q, r. r, s,t : . : u, s. : u,t. : t. p : . q : . : s.
A2 : ( r s) t ( r s) t r s t C2 r, s,t : .
A3 : u ( s t) u ( s t) ( u s) ( u t)
C1 C2 C3 C4 C5 C6 C7 C8
C3 : u, s.
C4 : u,t. : q, r. r,s :
Q: ( t p) (q s) ( t p) ( q s) t p q s
C5 : t.
C6 p: . : r. r:
C7 q: .
C8 : s. 04_Resolution 28 04_Resolution : . 29
Peer reviewing
System verification amounts to check whether a system static technique: manual code inspection, no software
fulfillsthe qualitative requirements that have been execution, detects between 31 and 93% of defects with
identified. median of about 60%subtle errors (concurrency and
algorithm defects) hard to catch.
Verification not equal to validation Testing
dynamic technique in which software is executed.
Some figures
30% to 50% of software project costs devoted to testing more time
and effort is spent on validation than on construction
accepted defect density: about 1 defects per 1,000 code lines
Linear-time properties
AP = p1, p2, . . . , pk
Rajesh Kumar
Slide credits: B. Srivathsan
1/8 6/17
AP = p 1 , p 2, . . . , p k AP = p1, p2, . . . , pk
PowerSet(AP) = , p1 , . . . , pk , PowerSet(AP) = , p1 , . . . , pk ,
p1, p2 , p1, p3 , . . . , p k 1 , pk , p1, p2 , p1, p3 , . . . , p k 1 , pk ,
.. . .. .
p1, p2, . . . , pk p 1, p 2 , . . . , p k
6/17 6/17
p1 p1, p2
AP = p 1 , p 2, . . . , p k request=1 request=1
ready busy
PowerSet(AP) = , p1 , . . . , pk ,
p1, p2 , p1, p3 , . . . , p k 1 , pk ,
.. .
p1, p2, . . . , pk
request=0 request=0
ready busy
Traces:
6/17 7/17
p1 p1, p2 p1 p1, p2
request=1 request=1 request=1 request=1
ready busy ready busy
p2 p2
Traces: .. . Traces: .. .
p2 p2 p2 p2 p2 p2 .. .
7/17 7/17
p1 p1, p2 p1 p1, p2
request=1 request=1 request=1 request=1
ready busy ready busy
p2 p2
Traces: .. . Traces: .. .
p2 p2 p2 p2 p2 p2 .. . p2 p2 p2 p2 p2 p2 .. .
p1 p1, p2 p2 p1, p2 p2 p1, p2 .. . p1 p1, p2 p2 p1, p2 p2 p1, p2 .. .
p1, p2 p1, p2 p1, p2 p1, p2 p1, p2 .. .
7/17 7/17
p1 p1, p2
request=1 request=1
ready busy
p2
Traces: .. .
p2 p2 p2 p2 p2 p2 .. .
p1 p1, p2 p2 p1, p2 p2 p1, p2 .. .
p1, p2 p1, p2 p1, p2 p1, p2 p1, p2 .. .
..
7/17 8/17
Behaviour of TS
Atomic propositions Coming next: What is a property?
9/17 10/17
AP-INF = set of infinite words over PowerSet(AP) AP-INF = set of infinite words over PowerSet(AP)
11/17 11/17
AP-INF = set of infinite words over PowerSet(AP) AP-INF = set of infinite words over PowerSet(AP)
p1 p1 p1 p1 p1 p1 p1 .. . p1 p1 p1 p1 p1 p1 p1 .. .
p1 p1, p2 p1 p1, p2 p1 p1, p2 .. . p1 p1, p2 p1 p1, p2 p1 p1, p2 .. .
.. ..
Property 2: p1 is true at least once and p2 is always true
11/17 11/17
AP-INF = set of infinite words over PowerSet(AP)
p1 p1 p1 p1 p1 p1 p1 .. .
p1 p1, p2 p1 p1, p2 p1 p1, p2 .. .
..
A property over AP is a subset of AP-INF
Property 2: p1 is true at least once and p2 is always true
p2 p1, p2 p2 p2 p2 p1, p2 p2 .. .
p1,p2 p2 p2 p2 p2 p2 .. .
.
.
11/17 12/17
13/17 14/17
AP = p1, p2 AP = p1, p2
p1 p1, p2 p1 p1, p2
request=1 request=1 request=1 request=1
ready busy ready busy
p2 p2
15/17 15/17
AP = p1, p2 AP = p1, p2
p1 p1, p2 p1 p1, p2
request=1 request=1 request=1 request=1
ready busy ready busy
G p1 G p1
p2 p2
Traces(TS) P
15/17 15/17
A property over AP is a subset of AP-INF A property over AP is a subset of AP-INF
16/17 16/17
17/17 2/11
Atomic propositions AP = p1, p2
Atomic propositions AP = p1, p2
p1: request=1 p2: status=busy
p1: request=1 p2: status=busy
p1 p1, p2 p1 p1, p2
request=1 request=1
request=1 request=1 ready busy
ready busy
request=0 request=0
ready busy
p2
request=0 request=0
ready busy
p2
3/11 5/11
Atomic propositions AP = p1, p2 AP-INF = set of infinite words over PowerSet(AP) Atomic propositions AP = p1, p2 AP-INF = set of infinite words over PowerSet(AP)
p1: request=1 p2: status=busy Property 1: p1 is always true p1: request=1 p2: status=busy Property 1: p1 is always true
p1 p1, p2 A0A1A2 AP-INF each Ai contains p1 p1 p1, p2 A0A1A2 AP-INF each Ai contains p1
request=1 request=1 request=1 request=1
ready busy p1 p1 p1 p1 p1 p1 p1 .. . ready busy p1 p1 p1 p1 p1 p1 p1 .. .
p1 p1, p2 p1 p1, p2 p1 p1, p2 .. . p1 p1, p2 p1 p1, p2 p1 p1, p2 .. .
.. ..
5/11 5/11
Atomic propositions AP = p1, p2 AP-INF = set of infinite words over PowerSet(AP) Atomic propositions AP = p1, p2
AP-INF = set of infinite words over PowerSet(AP)
p1: request=1 p2: status=busy Property 1: p1 is always true p1: request=1 p2: status=busy
Property 2: p1 p2 is alwaystrue
p1 p1, p2 A0A1A2 AP-INF each Ai contains p1 p1 p1, p2
A0A1A2 AP-INF each Ai satisfies p1 p2
request=1 request=1 request=1 request=1
ready busy p1 p1 p1 p1 p1 p1 p1 .. . ready busy
p1 p1, p2 p1 p1, p2 p1 p1, p2 .. . p1 p1 p1 p1 p1 p1 p1 .. .
..
p2 p2
5/11 6/11
6/11 6/11
Invariants Invariants
AP-INF = set of infinite words over PowerSet(AP) AP-INF = set of infinite words over PowerSet(AP)
It is written as G Ø
7/11 7/11
Algorithm
Atomic propositions AP = p1, p2, p3,p4
8/11 9/11
Atomic propositions AP = p1, p2
Safety properties
p1 p1, p2
request=1 request=1
ready busy
request=0 request=0
ready busy
p2
2/11 3/11
AP-INF = set of infinite words over PowerSet(AP) AP-INF = set of infinite words over PowerSet(AP)
Atomic propositions AP = p1, p2 Atomic propositions AP = p1, p2
Property: Always: if p1 is true, then in the next step p2 is true Property: Always: if p1 is true, then in the next step p2 is true
p1: request=1 p2: status=busy p1: request=1 p2: status=busy
A0A1A2 AP-INF if Ai contains p1, then Ai+1 contains p 2 A0A1A2 AP-INF if Ai contains p1, then Ai+1 contains p 2
p1 p1, p2 p1 p1, p2
p1 p2 p1 p1, p 2 p2 p1 p1, p2 .. . p1 p2 p1 p1, p 2 p2 p1 p1, p2 .. .
request=1 request=1 request=1 request=1
ready busy p2 p2 p2 p2 p2 p2 .. . ready busy p2 p2 p2 p2 p2 p2 .. .
.. . .. .
. .
. .
3/11 3/11
X operator
AP-INF = set of infinite words over PowerSet(AP)
Atomic propositions AP = p1, p2
Property: Always: if p1 is true, then in the next step p2 is true
p1: request=1 p2: status=busy
A0A1A2 AP-INF if Ai contains p1, then Ai+1 contains p 2
G (p1 XXp2):
p1, p2
p1
request=1 request=1
p1 p2 p1 p1, p 2 p2 p1 p1, p2 .. .
Always: if p1 is true then in the next to next step p2 is true
ready busy p2 p2 p2 p2 p2 p2 .. .
.. .
.
.
F (p1 X p1):
request=0 request=0
Somewhere: p1 is true and in the next step it becomesfalse
ready busy
3/11 4/11
l1 m1 l1 m1
l2 m2 l2 m2
5/11 5/11
Atomic propositions AP = p1, p2 Atomic propositions AP = p1, p2
l1 m1 l1 m1
l2 m2 l2 m2
Check: G ( p1 XXp2 )
6/11 6/11
p1 : a >= 10 p2 : b >= 12
l1 m1
Coming next: idea of safety properties
a:= a+1 b:= b+1
a <= 20 b <= 30
b:= b+2 a:= a+2
l2 m2
Check: G ( p1 XXp2 )
6/11 7/11
Property 1: if p1 is true, then p2 should be true in the next step Property 1: if p1 is true, then p2 should be true in the next step
p1 p2 p1 p2
p1 . . . p2
8/11 8/11
Safety properties
Property 1: if p1 is true, then p2 should be true in the next step
AP-INF = set of infinite words over PowerSet(AP)
p1 p2 P: a property over AP
p1 . . . p2
8/11 9/11
Safety properties Safety properties
AP-INF = set of infinite words over PowerSet(AP) AP-INF = set of infinite words over PowerSet(AP)
p1 p2 p1 p2
p1 . . . p2 Bad-Prefixes p1 . . . p2 Bad-Prefixes
.. . .. .
P is a safety property if there exists a set Bad-Prefixes such that P is a safety property if there exists a set Bad-Prefixes such that
P is the set of all words that do not start with a Bad-Prefix
9/11 9/11
p1 -Prefixe
10/11 11/11
Safety: Something bad never happens
Liveness properties
2/11 3/11
G p: Always p
...
Safety: Something bad never happens
F p: Sometime p
Liveness: Something good happens infinitely often
...
...
3/11 4/11
Summary
G p: Always p
...
Behaviour of a TS described as a set of its traces
G F p: Infinitely often p
...
4/11 2/2
28 / 96 29 / 96
Something desirable will eventually happen Something desirable will eventually happen
sooner or later this will happen sooner or later this will happen
Can be refuted by infinite behaviour Can be refuted by infinite behaviour
p
p
an infinite behaviour can be typically presented as a loop an infinite behaviour can be typically presented as a loop
29 / 96 29 / 96
Fairness Properties Fairness Properties
Something desirable will happen infinitely often Something desirable will happen infinitely often
important subcase of liveness important subcase of liveness
whenever a subroutine takes control, it will always return it (sooner or later) whenever a subroutine takes control, it will always return it (sooner or later)
Can be refuted by infinite behaviour Can be refuted by infinite behaviour
a subroutine takes control and never returns it a subroutine takes control and never returns it
p p
p p
p p
p p
an infinite behaviour can be typically presented as a loop an infinite behaviour can be typically presented as a loop
30 / 96 30 / 96
Computation tree vs. computation paths Computation tree vs. computation paths
Consider the following Kripke structure: Consider the following Kripke structure:
Its execution can be seen as: Its execution can be seen as:
32 / 96 32 / 96
Computation tree vs. computation paths Computation tree vs. computation paths
Consider the following Kripke structure: Consider the following Kripke structure:
Its execution can be seen as: Its execution can be seen as:
an infinite set of an infinite an infinite set of an infinite
computation paths computation tree computation paths computation tree
!done !done !done !done !done !done !done !done !done
!done !done !done done !done !done !done done !done done
..... .....
!done !done done done !done !done done done !done done done
!done done done done !done done done done !done done done done
32 / 96 32 / 96
33 / 96 33 / 96
Temporal Logics Linear Temporal Logic (LTL): Syntax
33 / 96 36 / 96
Linear Temporal Logic (LTL): Syntax Linear Temporal Logic (LTL): Syntax
36 / 96 36 / 96
Linear Temporal Logic (LTL): Syntax LTL semantics: intuitions
LTL is given by the standard boolean logic enhanced with the following temporal operators,
which operate through paths s0, s1, ..., sk , ... :
An atomic proposition is a LTL formula; Next X: X is true in st iff is true in st+1
if 1 and 2 are LTL formulae, then ¬ 1, 1 Finally (or F: F is true in st iff is true in some st' with t t
2, 1 2, 1 2, 1 2, 1 2 are
LTL formulae; Globally (or G: G is true in st iff is true in all st' with t t
if 1 and 2 are LTL formulae, then X 1, G 1, F 1, 1U 2 are LTL formulae, where X, G, F, Until U: U is true in st iff, for some state s t ' s.t t t:
U are the temporal operators respectively. is true in s t ' and
is true in all states st ' ' s.t. t t < t
Another operator R (the dual of U) is used sometimes.
Releases R: R is true in st iff, for all states s t ' s.t. t t:
is true or
is true in some states st ' ' with t t < t
can become false only if becomes true first"
36 / 96 37 / 96
finally P globally P Safety: never happens that a train is arriving and the bar is
G(¬(train_arriving bar_up))
(repair_device R ¬working_device)
next P P until q Fairness: often send
GFsend
Strong fairness: often send implies infinitely often
XP PUq GFsend GFrecv
38 / 96 39 / 96
LTL Formal Semantics LTL Formal Semantics (cont.)
LTL properties are evaluated over paths, i.e., over infinite, linear sequences of states:
= s0 s1 ··· st st+1 ···
si |= a iff a L(si ) Given an infinite sequence = s0 , s1 , s2 , . . .
si |= ¬ iff si |= , si |= if is true in state si of .
si |= iff si |= and |= if is true in the initial state s0 of .
si |= The LTL model checking problem M |=
si |= X iff si+1 |= check if |= for every path of the Kripke structure M (e.g., = Fdone)
si |= F iff for some j i : , sj |=
si |= G iff for all j i : , sj |=
si |= U iff for some j i :( , sj |= and
for all k s.t. i k < j : , sk |= )
si |= R iff for all j i :( , sj |= or
for some k s.t. i k < j : , sk |= )
40 / 96 41 / 96
.....
!done !done done done
!done done
41 / 96 41 / 96
Syntactic properties of LTL operators Syntactic properties of LTL operators
1 2 ¬(¬ 1 ¬ 2) 1 2 ¬(¬ 1 ¬ 2)
... ...
F 1 TU 1 F 1 TU 1
G 1 R 1 G 1 R 1
F 1 ¬G¬ 1 F 1 ¬G¬ 1
G 1 ¬F¬ 1 G 1 ¬F¬ 1
¬X 1 X¬ 1 ¬X 1 X¬ 1
1R 2 ¬(¬ 1 U¬ 2) 1R 2 ¬(¬ 1 U¬ 2)
1U 2 ¬(¬ 1 R¬ 2) 1U 2 ¬(¬ 1 R¬ 2)
Note Note
LTL can be defined in terms of , ¬, X, U only LTL can be defined in terms of , ¬, X, U only
Exercise Exercise
Prove that 1R 2 G 2 2 U( 1 2) Prove that 1R 2 G 2 2 U( 1 2)
44 / 96 44 / 96
N = noncritical, T = trying, C = critical N1, N2 User 1 User 2 N = noncritical, T = trying, C = critical N1, N2 User 1 User 2
turn=0 turn=0
M |= G¬(C1 C2 ) ? M |= G¬(C1 C2 ) ?
YES: There is no reachable state in which (C1 C2) holds!
50 / 96 50 / 96
Example 2: liveness Example 2: liveness
N = noncritical, T = trying, C = critical N1, N2 User 1 User 2 N = noncritical, T = trying, C = critical N1, N2 User 1 User 2
turn=0 turn=0
M |= FC1 ? M |= FC1 ?
NO: there is an infinite cyclic solution in which C1 never holds!
51 / 96 51 / 96
N = noncritical, T = trying, C = critical N1, N2 User 1 User 2 N = noncritical, T = trying, C = critical N1, N2 User 1 User 2
turn=0 turn=0
52 / 96 52 / 96
Example 4: fairness Example 4: fairness
N = noncritical, T = trying, C = critical N1, N2 User 1 User 2 N = noncritical, T = trying, C = critical N1, N2 User 1 User 2
turn=0 turn=0
M |= GFC1 ? M |= GFC1 ?
NO: e.g., in the initial state, there is an infinite cyclic solution in which C1 never holds!
53 / 96 53 / 96
N = noncritical, T = trying, C = critical N1, N2 User 1 User 2 N = noncritical, T = trying, C = critical N1, N2 User 1 User 2
turn=0 turn=0
N = noncritical, T = trying, C = critical N1, N2 User 1 User 2 N = noncritical, T = trying, C = critical N1, N2 User 1 User 2
turn=0 turn=0
M |= G(N1 F T1 ) ? M |= G(N1 F T1 ) ?
NO: e.g., in the initial state, there is an infinite cyclic solution in which N1 holds and T1 never
holds!
55 / 96 55 / 96
Transition System
s3 s2
p1, p3 p2
Rajesh Kumar
Slide credits : B. Srivathsan
1/35 3/35
p1 p2 p1 p2
s0 s1 s0 s1
s3 s2 s3 s2
p1, p3 p2 p1, p3 p2
Paths s0 s1 s3 s3 s3 s3 .. . Paths s0 s1 s3 s3 s3 s3 .. .
s0 s1 s2 s3 s2 s3 .. . s0 s1 s2 s3 s2 s3 .. .
Traces p1 p2 p 1 , p3 p 1 , p3 p 1 , p3 p 1 , p3 .. .
p1 p2 p2 p 1 , p3 p2 p 1 , p3 p2 p 1 , p3 .. .
3/35 3/35
p1 p2
s0
s0 s1
s3 s2
s3 s2
p1, p3 p2
s3 s2 s3
... obtained by repeatedly unfolding it
s3 s2 s3 s3 s2
.. .. .. .. ..
4/35 5/35
Computation tree
p1 p2
s0
LTL talks about properties of paths
s0 s1
s1
s3 s2
s3 s2
p1, p3 p2
s3 s2 s3
s3 s2 s3 s3 s2
.. .. .. .. ..
5/35 6/35
.. .. .. .. ..
6/35 7/35
Exists a path satisfying F( red )
.. .. .. .. .. .. .. .. .. ..
7/35 8/35
.. .. .. .. .. .. .. .. .. ..
8/35 10/35
Properties of trees
Exists a path satisfying blue U red
.. .. .. .. ..
10/35 11/35
Properties of trees
Exists a path satisfying F( red ) : E F ( red )
E operator: EØ
.. .. .. .. ..
11/35 12/35
Exists a path satisfying G( red ): E G ( red ) Exists a path satisfying blue U red : E ( blue U red )
.. .. .. .. .. .. .. .. .. ..
13/35 15/35
.. .. .. .. .. .. .. .. .. ..
16/35 16/35
All paths satisfy G( red )
.. .. .. .. .. .. .. .. .. ..
17/35 17/35
Properties of trees
.. .. .. .. ..
18/35 20/35
Properties of trees
All paths satisfy F( red ) : A F( red )
A operator: AØ
.. .. .. .. ..
20/35 21/35
Properties of trees
All paths satisfy G( red ) : A G( red )
22/35 25/35
Recall... Recall...
Exists a path satisfying F( red ) : E F ( red ) All paths satisfy G( red ) : A G( red )
.. .. .. .. .. .. .. .. .. ..
26/35 27/35
E F A G (red)
.. .. .. .. .. .. .. .. .. ..
28/35 28/35
Path formulae
A F A G (red)
:= X Ø1 Ø1 U Ø2 F Ø1 G Ø1
.. .. .. .. ..
.. .. .. .. ..
29/35 5/25
Ø := true p i Ø1 Ø2 Ø1 Ø := true p i Ø1 Ø2 Ø1 E
Path formula
pi AP Ø1, Ø2 : State formulae pi AP Ø1, Ø2 : State formulae
.. .. .. .. .. .. .. .. .. ..
6/25 6/25
State formulae
Ø := true p i Ø1 Ø2 Ø1 E A
Path formula
pi AP Ø1, Ø2 : State formulae
R /* read Release
30-11-2024 30-11-2024
Semantics of binary temporal operators: |= W iff there is some i such that i |= and for all
j = 1,..., i-1, j |= ; or all k>=1 k |=
Let M = (S, , L) be a model and = s1 s2 be a path
in M. [No guarantee on might happen]
Example: execute_program W stackoverflow: the program
Then define the satisfaction relation |= as follows: execution is continued unless there is stack overflow.
|= U iff there is some i such that i |= and |= R iff for some i>=1 i |= and for all j = 1,..., i, j
for all j = 1,..., i-1, j |= |= ; or all k>=1 k |=
true forever.
Example: arrived_at_terminal R driver_on_duty: upon arrival
of train at the terminal the driver on duty is released.
3 4
30-11-2024 30-11-2024
5 6
30-11-2024 30-11-2024
Q: Do we need any unary operators? Thus each of the following sets would be adequate:
X cannot be expressed in terms of other operators. { X, U }
{ X, R }
What about F ? { X, W }
F True U
7 8
30-11-2024
Distributive Properties
F( ) (F ) (F )
CS/IS F214 Prove this.
Logic in Computer Science denotes semantic equivalence
BITS Pilani
Pilani Campus
F( ) (F ) (F )
Prove this:
F( ) --> (F ) (F ) is always TRUE
MODULE: TEMPORAL LOGICS but
Linear Temporal Logic Temporal Operators: (F ) (F ) --> F ( ) is not always TRUE
Properties Provide a counter-example.
30-11-2024 9 10
30-11-2024
Distributive Properties
Since
G (F ) CS/IS F214
we can derive this: Logic in Computer Science
G( ) F( ( ))
BITS Pilani
Pilani Campus
F( ))
((F ) (F ))
(F ) (F )
(G ) (G ) MODULE: TEMPORAL LOGICS
LTL Semantics and Model Checking
30-11-2024 30-11-2024
What about the other temporal operators? because each path is infinite and evaluating in one path
e.g. They can be rewritten using U. may not terminate!
30-11-2024 30-11-2024
LTL Model Checking Marking Algorithm LTL Marking Algorithm: Information Propagation
Given S, , L, and the marking algorithm How does information propagate along paths?
1. recursively decomposes into sub-formulas For instance, say, we need to verify whether G is
satisfied in a state, say, s1 in this model M:
2. marks each s in S with sub-formulas that are satisfied in s
and s4 ...
3. propagates this information to predecessor(s) of a state
as necessary. s1 s2 ...
Note that we are working with a finite state machine and
therefore the graph has a finite number of vertices. s3 ...
Then we can evaluate M,s1|= G
But our paths are infinite because there are cycles in the
graph. by evaluating
(M,s1|= ) AND
How does information propagate (step 3) along
cycles? (M,s2|= G ) AND (M,s3|= G ) AND (M,s4|= G )
LTL Marking Algorithm: Recursive Evaluation LTL Marking Algorithm: Recursive on and M
Evaluation is recursive on the given formula and the given Computing whether M,s|= is done recursively on and M
model : The given formula is finite:
i.e. the result is an aggregate of the results of i.e. the recursion on would terminate
evaluating the formula or its subformulas on the But recursion on paths starting from s may not terminate:
given state and its successors. because, a path may be cyclic.
Computing whether M,s|= is done recursively on and M
where the latter is an aggregation of recursive evaluation
on paths starting from s
30-11-2024 30-11-2024
30-11-2024 30-11-2024
X : ?? /* complete this! */
MC(St, , L, , s) // marking algorithm [contd.] LTL Model Checking Recursion and Fix-Point Computation
30-11-2024
Computation Tree Logic (CTL) - Syntax CTL Model Checking: Input Simplification
Before we look at a model checking algorithm,
Grammar (Gr_CTL):
we simplify the syntax of the input formulas by using an
---> p | | | --> | adequate set of operators:
---> AX | EX
[Propositional:] and
---> AF | EF
[Temporal:] AF, EU, and EX.
---> AG | EG
We will assume that the following equivalences are used in order
---> A[ U ] | E[ U ] to rewrite the input formula:
1) (AF ) EG Eliminate EG and AG
Note: 2) (EF ) AG
Quantifiers A and E are never used separately from the 3) E[T U ] EF Eliminate EF
temporal operators and
Temporal Operators F, G, X, and U are never used
4) (EX ) AX Eliminate AX
without the quantifiers. 5) (E[ U ( )] EG ) A[ U ] Eliminate AU
30-11-2024 30-11-2024
Thus we need an algorithm mark with Given S, , L, and the marking algorithm
inputs 1. recursively decomposes into sub-formulas
i. a model M = (S, , L) and 2. marks each s in S with sub-formulas that are satisfied in
ii. a formula s and
and output: 3. propagates this information to predecessor(s) of a state
the set of states in S that satisfy . as necessary.
Note that we are working with a finite state machine and
therefore the graph has a finite number of vertices.
Then we can
But our paths are infinite because there are cycles in the
decide M,s |= by graph.
verifying s mark(M, ) How does information propagate (step 3) along
cycles?
30-11-2024 30-11-2024
CTL Marking Algorithm: Information Propagation CTL Marking Algorithm: Information Propagation
Evaluation is recursive on the given formula and the given
How does information propagate along paths? model :
For instance, say, we need to verify whether EF is i.e. the result is an aggregate of the results of
satisfied in state say s1 in this model M:
evaluating the formula or its subformulas on the
s4 ... given state and its successors.
Computing whether M,s|= is done recursively on and M
s1 s2 ... where the latter is an aggregation of recursive evaluation
on paths starting from s
s3 ... The given formula is finite:
Then we can evaluate M,s1|= EF i.e. the recursion on would terminate
by evaluating But recursion on paths starting from s may not terminate:
(M,s1|= ) OR (M,s2|= EF ) OR (M,s3|= EF ) OR (M,s4|= EF ) because, a path may be cyclic.
CTL Marking Algorithm: Information Propagation CTL Marking Algorithm: Information Propagation
For instance, given this model M, s4 ... Theorem (w/o proof):
computing M,s1|= EF could require The solution to a recursive equation of the form:
computing M,s3|= EF s1 s2 ... f(X) = { ... f(X) ... }
which in turn could require
computing M,s5|= EF s5 s6
is the (least) fixed point of f.
s3
which in turn could require
computing M,s6|= EF A fixed point of a function f, is a value X, such that f(X) = X
which in turn could require i.e. computationally, we can iterate over values of X,
computing M,s1|= EF
until we find the least value X such that f(X) = X
In general, we have the following question: and that value would be a solution to the recursive
Given an equation of the form equation.
mc(M, s, ) = { ... mc(M, s, ) ... }
how do you compute a solution?
Sundar B. CS&IS, BITS Pilani 9 Sundar B. CS&IS, BITS Pilani 10
30-11-2024 30-11-2024
CTL Marking Algorithm: Information Propagation CTL Model Checking: Marking Algorithm
mark(S, , L, )
Thus our marking algorithm would evaluate a formula at a if is:
state s in model M by FALSE: done /* no state satisfies FALSE */
(basis): evaluating sub-formulas of at s TRUE: done /* all states implicitly marked TRUE */
(step): evaluating or its sub-formulas at successors of s p for some atomic proposition p:
and aggregating the results
mark state s with p, if p is in L(s)
until evaluation does not change:
1 2:
i.e. evaluation in each state remains as is
if a state s is already marked with 1 and 2 then mark
it with 1 2
:
if a state s is not already marked with then mark it
with
CTL Model Checking: Marking Algorithm [contd.] CTL Model Checking: Algorithm [contd.]
if is: if is:
AF : EX :
if a state s is marked with , then mark it with AF mark a state s with EX
repeat { if at least one of its successors is marked with
mark a state s with AF if
all its successors are marked with AF E[ 1 U 2]:
if a state s is marked with 2 then mark it with 1 U
} until no change 2
repeat {
mark a state s with 1 U 2
if it is marked with 1 and
at least one of its successors is marked with 1 U 2
} until (no change)
30-11-2024 30-11-2024
CTL Model Checking Recursion and Fix-Point Computation CTL Model Checking Time Taken
Notes on the marking algorithm: Notes on the marking algorithm:
The no change condition in the two repeat loops (for the The time taken by mark(S, , L, ) is
AF case and the EU case) C *| | * |S| * | | steps
is essentially a test for the fix-point: where | | denotes the number of operators in
mark(M,s, ) is computed iteratively on the states and |S| denotes the number of states
in M and | | denotes the number of edges, which is
until its value (i.e. the set of satisfied sub-formulas (upper-)bounded by |S| * |S|
in s) remains unchanged! and C is a constant