UPPAAL
UPPAAL
UPPAAL
Chien-Liang Chen
Outline
Simulation
Verification
Real-Time Extensions:
Modelling
UPPAAL
UPPAAL Components
a description language,
a simulator, and
a model checker.
Example (cont.)
(from UPPAAL in a Nutshell)
process B {
state B0 { x<=4 }, B1, B2, B3;
commit B1;
init B0;
trans B0 -> B1 {
guard x>=2;
sync a?;
assign n:=5,x:=0;
},
B1 -> B2 {
assign n:=n+1;
},
B2 -> B3 {
}, B3 -> B0;
}
system A, B;
Example (cont.)
[ ]P = always P
<>P = eventually P
P U Q = P is true until Q becomes true
Examples:
Invariance: [ ] (p)
Response: [ ] ((p) -> (<> (q)))
Precedence: [ ] ((p) -> ((q) U (r)))
Objective: [ ] ((p) -> <>((q) || (r)))
Committed Locations
Transitions
Transitions (cont.)
UPPAAL Transitions
Committed Nodes
UPPAAL Locations
Translation to UPPAAL
P1
P1 ::
:: while
while True
True do
do
T1
T1 :: wait(turn=1)
wait(turn=1)
C1
C1 :: turn:=0
turn:=0
endwhile
endwhile
||
||
P2
P2 ::
:: while
while True
True do
do
T2
T2 :: wait(turn=0)
wait(turn=0)
C2
C2 :: turn:=1
turn:=1
endwhile
endwhile
Off
press?
x:=0
x>3
Light
press?
x<=3
Bright
press?
UPPAAL Model =
Networks of Timed Automata
Timed Automata
Clocks: x, y
Guard
Reset
Action perfomed on clocks
State
( location , x=v , y=u )
x := 0
Transitions
Action
used
for synchronization
( n , x=2.4 , y=3.1415 ) a
( m , x=0 , y=3.1415 )
e(1.1)
( n , x=2.4 , y=3.1415 )
( n , x=3.5 , y=4.2415 )
Clocks: x, y
x<=5
x<=5 & y>3
Location
Invariants
( n , x=2.4 , y=3.1415 )
e(1.1)
y<=10
g4
g2 g3
e(3.2)
( n , x=2.4 , y=3.1415 )
( n , x=3.5 , y=4.2415 )
x := 0
g1
Transitions
A simple program
Int
Intxx
Process
ProcessPP
Process
ProcessQQ
do
do
::::x>0
x>0
x:=x-1
x:=x-1
od
od
Process
ProcessRR
do
do
::::x=2000
x=2000
x:=0
x:=0
od
od
Questions/Properties:
Possible
fork
forkP;P;fork
forkQ;
Q;fork
forkRR
Always
E<>(x>1000)
E<>(x>2000)
A[](x<=2000)
E<>(x<0)
A[](x>=0)
Verification (example.xta)
int x:=0;
Int
process P{
Intxx
state S0;
init S0;
Process
ProcessPP
trans S0 -> S0{guard x<2000; assign x:=x+1; };
do
do
}
::::x<2000
x<2000
x:=x+1
x:=x+1
process Q{
od
od
state S1;
init S1;
Process
ProcessQQ
trans S1 -> S1{guard x>0; assign x:=x-1; };
do
do
}
::::x>0
x>0
x:=x-1
x:=x-1
process R{
od
od
state S2;
init S2;
Process
ProcessRR
trans S2 -> S2{guard x==0; assign x:=0; };
do
do
}
::::x=2000
x=2000
x:=0
x:=0
p1:=P();
od
od
q1:=Q();
r1:=R();
fork
forkP;P;fork
forkQ;
Q;fork
forkRR
system p1,q1,r1;
Example (mutex2.xta)
//Global declarations
int turn;
int in_CS;
//Process template
process P(const id){
clock x;
state Idle, Try, Crit;
init Idle;
trans Idle -> Try{assign turn:=id, x:=0; },
Try -> Crit{guard turn==(1-id); assign in_CS:=in_CS+1; },
Try -> Try{guard turn==id; },
Crit -> Idle{guard x>3; assign in_CS:=in_CS-1; };
}
//Process assignments
P1:=P(1);
P2:=P(0);
//System definition.
system P1, P2;
I1 I2
t=0
T1 I2
t=0
I1 I2
t=1
I1 T2
t=0
T1 T2
t=0
I1 C2
t=0
T1 C2
t=0
I1 T2
t=1
T1 I2
t=1
C1 I2
t=1
T1 T2
t=1
C1 T2
t=1
CTL Models
Example
(from UPPAAL2k: Small Tutorial)
P1
Obs
Example (cont.)
Example (cont.)
P1
Verification:
Obs
Example (cont.)
Example (cont.)
Translation to UPPAAL
P1
P1 ::
:: while
while True
True do
do
T1
T1 :: wait(turn=1)
wait(turn=1)
C1
C1 :: turn:=0
turn:=0
endwhile
endwhile
||
||
P2
P2 ::
:: while
while True
True do
do
T2
T2 :: wait(turn=0)
wait(turn=0)
C2
C2 :: turn:=1
turn:=1
endwhile
endwhile
CTL Models
Path
s1
s2
p
s3...
Formal Semantics
EF p
p
p
...
...
...
...
...
...
...
...
AG p
EG p
...
...
...
...
...
...
...
...
Theorem
All
Alloperators
operatorsare
arederivable
derivablefrom
from
EX
EXff
EG
EGff
E[
E[ff UUgg]]
and
andboolean
booleanconnectives
connectives
A f U g E gU f g EGg
UPPAAL Specification
Language
(AG p)
(EF p)
A[] p
E<> p
process location
data guards
clock guards
Semantics: Example
push
click
y9
push
push
click
y9
AG( x y )
AG( on AFoff )
AG( on AF9 off )
A off U x 2
A off U x 3
E off U x 3
push
A x 2 U on
E x 2 U on
Paths
push
Example Path:
y9
click
(on, x 0, y ) 3(on, x 3, y 3) 9 ( 3)
(on, x 9 ( 3), y 9) click
(off , x 0, y 9) ...
push
Example:
(off , x y 0) 3.5(off , x y 3.5) push
(on, x y 0) (on, x y ) push
(on, x 0, y ) 3(on, x 3, y 3) 9 ( 3)
(on, x 9 ( 3), y 9) click
(off , x 0, y 9) ...
Regions
Finite partitioning of state space
Definitio
n
the form
xi n and xi x j n
where n max
Regions
Finite partitioning of state space
Definitio
n
2
1
where n max
Successor regions,
Succ(r)
Regions
Finite partitioning of state space
Definitio
n w w' iff w and w' satisfy
2
1
{x}r
where n max
THEOREM
r
{y}r 1
Reset
regions
Reachable part
of region graph
Properties
AG( x y )
AG(on AFoff )
AG(on AF3off )
Roughly speaking....
Model
Model checking
checking aa timed
timed automata
automata
against
against aa TCTL-formula
TCTL-formula amounts
amounts to
to
model
model checking
checking its
its region
region graph
graph
against
against aa CTL-formula
CTL-formula
Problem to be solved
State
(n, x=3.2, y=2.5)
y
Zone:
conjunction of
x-y<=n, x<=>n
Symbolic Transitions
y
1<=x<=4
1<=y<=3
n
x>3
y
delays to
x
y
x
y
conjuncts to
x
y:=0
m
1<=x, 1<=y
-2<=x-y<=3
3<x, 1<=y
-2<=x-y<=3
x
projects to
3<x, y=0
Forward Reachability
Final
Waiting
INITIAL Passed := ;
Waiting := {(n0,Z0)}
REPEAT
- pick (n,Z) in Waiting
- if for some Z
Z
(n,Z) in Passed then STOP
- else (explore) add
{ (m,U) : (n,Z) => (m,U) }
to Waiting;
Add (n,Z) to Passed
Init
Passed
UNTIL Waiting =
or
Final is in Waiting
Forward Reachability
Final
Waiting
INITIAL Passed := ;
Waiting := {(n0,Z0)}
REPEAT
- pick (n,Z) in Waiting
- if for some Z
Z
(n,Z) in Passed then STOP
- else (explore) add
{ (m,U) : (n,Z) => (m,U) }
to Waiting;
Add (n,Z) to Passed
n,Z
n,Z
Init
Passed
UNTIL Waiting =
or
Final is in Waiting
Forward Reachability
Waiting
m,U
INITIAL Passed := ;
Waiting := {(n0,Z0)}
REPEAT
- pick (n,Z) in Waiting
- if for some Z
Z
(n,Z) in Passed then STOP
- else /explore/ add
{ (m,U) : (n,Z) => (m,U) }
to Waiting;
Add (n,Z) to Passed
n,Z
n,Z
Init
Final
Passed
UNTIL Waiting =
or
Final is in Waiting
Forward Reachability
Waiting
m,U
INITIAL Passed := ;
Waiting := {(n0,Z0)}
REPEAT
- pick (n,Z) in Waiting
- if for some Z
Z
(n,Z) in Passed then STOP
- else /explore/ add
{ (m,U) : (n,Z) => (m,U) }
to Waiting;
Add (n,Z) to Passed
n,Z
n,Z
Init
Final
Passed
UNTIL Waiting =
or
Final is in Waiting
Local
LocalReduction
Reduction
Global
GlobalReduction
Reduction
Active-Clock
Active-ClockReduction
Reduction
Re-Use
Re-UseState-Space
State-Space
Over-Approximation
Over-Approximation
Under-Approximation
Under-Approximation
Forward Rechability
Waiting
m,U
n,Z
n,Z
Init
Passed
Final
INITIAL Passed := ;
Waiting := {(n0,Z0)}
location
REPEAT
- pick (n,Z) in Waiting zone
Z
- if for some Z
(n,Z) in Passed then STOP
- else /explore/ add
{ (m,U) : (n,Z) => (m,U) }
to Waiting;
Add (n,Z) to Passed
UNTIL Waiting =
or
Final is in Waiting
Order of Exploration
Depth-First vs Breadth-First
Waiting
m,U
n,Z
Depth-First
Depth-First
Waiting
Waitingstored
storedon
on
stack
stack
Breadth-First
Breadth-First
Waiting
Waitingstored
storedin
in
queue
queue
n,Z
Init
Final
Passed
Philips Bounded
Retransmission Protocol
(BRP)
[DArgenio et.al. 97]
Protocol Overview
Overview of BRP
Input: file = p1, , pn
Output: p1, , pn
Sender
Receiver
BRP
pi
K
L
lossy
ack
lossy
How It Works
more parts
will follow
Output: p1, , pn
Sender
Receiver
OK, NOK, DK
BRP
(pi,INDicator,abit)
K
L
lossy
lossy
ack
value-passing
lossy = may drop
messages
Bounded Retransmission