Introduction to Uppaal Gerd Behrmann Aalborg University April 13, - - PowerPoint PPT Presentation

introduction to uppaal
SMART_READER_LITE
LIVE PREVIEW

Introduction to Uppaal Gerd Behrmann Aalborg University April 13, - - PowerPoint PPT Presentation

Introduction to Uppaal Gerd Behrmann Aalborg University April 13, 2005 Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 1 / 37 Outline A short look at Uppaal 1 Demo Architecture Syntax of Uppaal 2 Declarations


slide-1
SLIDE 1

Introduction to Uppaal

Gerd Behrmann

Aalborg University

April 13, 2005

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 1 / 37

slide-2
SLIDE 2

Outline

1

A short look at Uppaal Demo Architecture

2

Syntax of Uppaal Declarations Expressions Locations and synchronisation Properties

3

Train Gate Example

4

Verification Options How Uppaal works State space reduction techniques Reusing the state space State space representation techniques.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 2 / 37

slide-3
SLIDE 3

Demo

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 3 / 37

slide-4
SLIDE 4

Uppaal’s Architecture

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 4 / 37

slide-5
SLIDE 5

Declarations

Clocks

clock x1, x2,...,xn;

Bounded Integer Variables

int[0,5] i1, i2,... in; Default range is -32767;32768.

Constants

const int delay = 5, a = 0;

Arrays

int x[4] = { 1, 4, 7, 2 };

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 5 / 37

slide-6
SLIDE 6

Declarations

New in version 3.5

Booleans

bool b;

Records

struct { int a; int b; } a = { 1, 2 };

Type declarations

typedef struct { int a; int b; } A;

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 6 / 37

slide-7
SLIDE 7

Expressions

Expression ::= ID | NAT | ’true’ | ’false’ | Expression ’[’ Expression ’]’ | ’(’ Expression ’)’ | Expression ’++’ | ’++’ Expression | Expression ’--’ | ’--’ Expression | Expression AssignOp Expression | UnaryOp Expression | Expression BinOp Expression | Expression ’?’ Expression ’:’ Expression | ID ’.’ ID | ID ’(’ [ Expression ( ’,’ Expression )* ] ’)’

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 7 / 37

slide-8
SLIDE 8

Operators

Unary

’-’ | ’+’ | ’!’ | ’not’

Binary

’<’ | ’<=’ | ’==’ | ’!=’ | ’>=’ | ’>’ ’+’ | ’-’ | ’*’ | ’/’ | ’%’ | ’&’ ’|’ | ’^’ | ’<<’ | ’>>’ | ’&&’ | ’||’ ’and’ | ’or’ | ’imply’

Assignment

’=’ | ’+=’ | ’-=’ | ’*=’ | ’/=’ | ’%=’ ’|=’ | ’&=’ | ’^=’ | ’<<=’ | ’>>=’

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 8 / 37

slide-9
SLIDE 9

Guards

Any expression satisfying the following conditions is a guard: It is side effect free, type correct and evaluates to a boolean. Only clock variables, integer variables and constants are referenced (or arrays of these types). Clocks and differences between clocks are only compared to integer expressions (no inequality). Guards over clocks are essentially conjunctions (i.e. disjunctions are

  • nly allowed over integer conditions).

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 9 / 37

slide-10
SLIDE 10

Assignments

Any expression satisfying the following conditions is an assignment: It has a side effect and is type correct. Only clock variables, integer variables and constants are referenced (or arrays of these types). Only integers are assigned to clocks.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 10 / 37

slide-11
SLIDE 11

Invariants

Any expression satisfying the following conditions is an invariant: It is side effect free and is type correct. Only clock variables, integer variables and constants are referenced (or arrays of these types). It forms a conjunction of conditions on the form x < e or x <= e, where x is a clock reference and e evaluates to an integer.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 11 / 37

slide-12
SLIDE 12

Functions

New in version 3.5

User defined functions can be declared globally or locally. An extended subset of C. Supports while, for, do while, if, return. Tests on clock variables are not allowed. Reset of clocks are allowed. Always evaluated atomically:

◮ No interleaving with other processes. ◮ If your function does not return, neither does Uppaal.

Still experimental. int sum(int a, int b) { return a + b; }

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 12 / 37

slide-13
SLIDE 13

Binary Synchronisation

Channels can be declared like: chan a, b, c[3]; If a is channel, then: a! is an emission a? is a reception Two edges in different processes can synchronise if one is emitting and the

  • ther is receiving on the same channel.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 13 / 37

slide-14
SLIDE 14

Broadcast Synchronization

Broadcast channels can be de declared like: broadcast chan a, b, c[2]; If a is a broadcast channel, then: a! is an emission of a broadcast a? is a reception of a broadcast A set of edges in different processes can synchronise if one is emitting and the others are receiving on the same broadcast channel. A process can always emit on a broadcast channel.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 14 / 37

slide-15
SLIDE 15

Urgency

Definition (Urgent State)

A state is urgent if either a process is in an urgent location, or an action transition on an urgent channel can be taken.

Definition (Semantics)

An urgent state has no delay transitions.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 15 / 37

slide-16
SLIDE 16

Urgency

Urgent channels

urgent chan a,b,c[3];

Urgent locations

Right click location and mark it urgent. Equivalent to having an invariant x ≤ 0 and reseting x before entering the location.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 16 / 37

slide-17
SLIDE 17

Committed Locations

Definition (Committed Process)

A process is committed if it is in a committed location.

Definition (Committed State)

A state is committed if any of the processes is committed.

Definition (Semantics)

A committed state cannot delay. A committed state only has action transitions involving at least one committed processes. Main purpose of committed locations is to create atomic sequences of

  • transitions. Committed locations reduce the state space considerably by

eliminating interleaving.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 17 / 37

slide-18
SLIDE 18

Templates

Templates can be instantiated to form processes. Templates are parameterised. Call-by-value is the default (except for arrays). Call-by-reference is used if identifier is prefixed with &. Example of parameter declaration of a template A: process A(int &v, const int min, const int max) Example of instantiation: P = A(i, 1, 5); Q = A(j, 0, 4); Example of system declaration: system P, Q;

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 18 / 37

slide-19
SLIDE 19

Syntax of Properties

A[] Expression E<> Expression A<> Expression E[] Expression Expression --> Expression A[] not deadlock The expressions must be type safe, side effect free, and evaluate to a

  • boolean. Only references to integers variables, constants, clocks, and

locations are allowed (and arrays of these).

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 19 / 37

slide-20
SLIDE 20

Operators A[] and A<>

For all paths

A[]ϕ ϕ ϕ ϕ A<>ϕ ϕ ϕ ϕ ϕ

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 20 / 37

slide-21
SLIDE 21

Operators E[] and E<>

There is a path

E[]ϕ

ϕ

E<>ϕ ϕ ϕ

Remark

¬(A[]ϕ)=E<>(¬ϕ) and ¬(E[]ϕ)=A<>(¬ϕ)

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 21 / 37

slide-22
SLIDE 22

Operator -->

Leads to (response)

ϕ --> ψ

def

⇐ ⇒ A[](ϕ ⇒A<>ψ)

ϕ ϕ ψ ψ

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 22 / 37

slide-23
SLIDE 23

State Property: deadlock

A deadlock is a state in which no action transition will ever be enabled again. In other words (l, u) | = deadlock iff: ∀d ≥ 0, a ∈ Act : (l, u + d) a → Checking for absence of deadlocks: A[] not deadlock

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 23 / 37

slide-24
SLIDE 24

Bounded Liveness

Whenever ϕ becomes true, then ψ becomes true within t.

ϕ-->≤tψ

≤ t ≤ t ϕ ϕ ψ ψ

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 24 / 37

slide-25
SLIDE 25

Bounded Liveness

Reduction to unbounded liveness

We can reduce p -->≤t q to an unbounded liveness property: Add a clock x and reset it whenever p becomes true. Check p --> (q and x <= t).

p q x = 0

Care must be taken that x is not reset several times before q becomes true.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 25 / 37

slide-26
SLIDE 26

Bounded Liveness

Reduction to reachability by decoration

We can reduce p -->≤t q to a reachability property: Add a clock x and reset it whenever p becomes true. Add a boolean b, set it to true when p starts to hold and to false when p ceases to hold. Check A[] (b implies x <= t).

p q b = false b = false b = true, x = 0

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 26 / 37

slide-27
SLIDE 27

Bounded Liveness

Reduction to reachability with test automaton

We can reduce p --><t q to a reachability property: Add two broadcast channels a and b. Send on a when p becomes true, on b when q becomes true. Add a process that goes to an error state when the time between a signal on a and b reaches t. Check A[] not Test.bad. Works even when p becomes true several times before q.

p q b! b! a! x <= t bad a? x = 0 b? x == t

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 27 / 37

slide-28
SLIDE 28

The Train Gate Example

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 28 / 37

slide-29
SLIDE 29

Verification Options in Uppaal

Breadth-first Depth-first State space reduction Reuse state space State space representation

◮ DBM ◮ Compact ◮ Under approximation ◮ Over approximation

Diagnostic trace

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 29 / 37

slide-30
SLIDE 30

Reachability analysis in Uppaal

waiting = {(l0, Z0 ∧ I(l0))} passed = ∅ while waiting = ∅ do (l, Z) = select state from waiting waiting = waiting \ {(l, Z)} if testProperty(l, Z) then return true if ∀(l, Y ) ∈ passed : Z ⊆ Y then passed = passed ∪ {(l, Z)} ∀(l′, Z ′) : (l, Z) ⇒ (l′, Z ′) do if ∀(l′, Y ′) ∈ waiting : Z ′ ⊆ Y ′ then waiting = waiting ∪ {(l′, Z ′)} endif done endif done return false

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 30 / 37

slide-31
SLIDE 31

To store or not to store

State space reduction

For acyclic systems, a passed list is not needed to guarantee termination.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 31 / 37

slide-32
SLIDE 32

To store or not to store

State space reduction

For acyclic systems, a passed list is not needed to guarantee termination. However, it is useful for efficiency.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 31 / 37

slide-33
SLIDE 33

Loop entry points

State space reduction

Only symbolic states involving loop-entry points need to be stored in the passed list to guarantee termination.

Loop entry point Loop entry point

Options for state space reduction

None Store all states. Conservative Store all non-committed states. Aggressive Only store loop entry points.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 32 / 37

slide-34
SLIDE 34

Effect of reduction techniques

117 symbolic states 81 loop entry points. 9 states identified by more extensive analysis. Less than 10% time overhead.

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 33 / 37

slide-35
SLIDE 35

Reuse state space

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 34 / 37

slide-36
SLIDE 36

Over-approximation

Convex Hull

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 35 / 37

slide-37
SLIDE 37

Under-approximation

Bit state hashing

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 36 / 37

slide-38
SLIDE 38

Under-approximation

Bit state hashing

Gerd Behrmann (Aalborg University) Introduction to Uppaal April 13, 2005 37 / 37