Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems...

73
Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universit ¨ at des Saarlandes Reactive Systems Group 2011/02/03 Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 1 / 48

Transcript of Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems...

Page 1: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Formal Methods for Embedded Systems

Bernd Finkbeiner

Universitat des SaarlandesReactive Systems Group

2011/02/03

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 1 / 48

Page 2: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Formal Methods

Model Checking: automatically verify whether certain propertiesare guaranteed by the model; determine safe parameters

Controller Synthesis: automatically construct control strategiesthat keep the system safe

Overview:1 Intro: Analyzing FlexRay2 Timed automata3 Regions & zones4 Model checking and controller synthesis

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 2 / 48

Page 3: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

FlexRay Bus Protocol

FlexRay

communication protocol for distributed components in cars

used in BMW X 5 and BMW’s 7 series for X-by-wire

developed by: BMW, Bosch, Daimler, Freescale, General Motors,NXP Semiconductors, Volkswagen, et al.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 3 / 48

Page 4: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

FlexRay as the Future Drive-by-Wire Standard

⇒ Safety-critical!

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 4 / 48

Page 5: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

FlexRay Physical Layer

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 5 / 48

Page 6: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Jitter and Glitch Correction

wire delayand Rxomitted

voted value

1

0

Rxx

1

0

Tx

1

0

glitc

h

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

Sen

der

Rec

eive

r

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 6 / 48

Page 7: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Protocol Operation

Received Message . . . 1 1 0 1 0 1 1 1 . . .

1 byte

Received Stream. . . 1 0 1 1 0 1 0 1 1 1 1 0 . . .

Strobing . . . 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 . . .Voted Values. . . 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 . . .

. . . 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 . . .

Sent Stream. . . 1 0 1 1 0 1 0 1 1 1 1 0 . . .Sent Message . . . 1 1 0 1 0 1 1 1 . . .

1 byteSender

Receiver

Bus

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 7 / 48

Page 8: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Guaranteed Error Resilience?

Newest FlexRay Specification, Version 2.1, Revision A:

“[FlexRay] attempts to enable tolerance of the physical layeragainst presence of one glitch in a bit cell [. . . ]. There arespecific cases where a single glitch cannot be tolerated andothers where two glitches can be tolerated.”

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 8 / 48

Page 9: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Michael Gerke’s Model of the Protocol

protocol

jitter (parameterized)

glitches

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 9 / 48

Page 10: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 11: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)E.g.: . . . . . .

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 12: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)E.g.: . . . . . .

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 13: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)E.g.: . . . . . .

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 14: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)E.g.: . . . . . .

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 15: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)E.g.: . . . . . .

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 16: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)E.g.: . . . . . .

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 17: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)

2 arbitrarily placed glitches in the complete message (at most 2)

Note: one message ≈ 21.000 samples

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 18: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)

2 arbitrarily placed glitches in the complete message (at most 2)E.g.: . . . . . .

Note: one message ≈ 21.000 samples

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 19: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance

The protocol tolerates

1 glitch in every sequence of 4 consecutive samples (1 out of 4)

2 arbitrarily placed glitches in the complete message (at most 2)

Note: one message ≈ 21.000 samples

The protocol does not tolerate:2 arbitr. placed glitches in every seq. of 82 consec. samples (2 out of 82)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 10 / 48

Page 20: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Automated Analysis: Glitch Tolerance vs. DelayVariance

Parameter exploration using binary search:boundaries for variation of a single parameter

glitch delay variancetolerance(1 out of 4) 1.435ns → 7.6075ns(2 at most) 1.435ns → 7.6075ns(1 at most) 1.435ns → 12.020ns

glitch deviation of clocktolerance from standard rate(1 out of 4) 0.15% → 0.46%(2 at most) 0.15% → 0.46%(1 at most) 0.15% → 1.09%(no glitches) 0.15% → 1.74%

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 11 / 48

Page 21: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Device Specification

Device Descript.architecture behaviourof processor is

process fetch if halt=0 then if mem_wait=0 then nextins <= dport ...

Model Checker

♦(π ⇐ φ)

Hello world

This is DeDuCe V 1.4

Give me your design

Approval/Counterexample

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 12 / 48

Page 22: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Finite-State Model-Checking

InApproach EmptyEmpty

ente

r!

leav

e!

Safety requirement: Gate has to be closed whenever a train is in “In”.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 13 / 48

Page 23: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Finite-State Automata

Open

Opening

~enter

enter

~leave

leave

Closing

Closed

*

*

leave

enterEmpty Appr. In

tick tick tick

~leave = enter, tick

~enter = leave, tick

tick

* = leave,enter,tick

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 14 / 48

Page 24: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 25: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 26: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 27: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 28: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 29: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 30: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Model Checking

Closed

Opening

Closed

Closing

Opening

Open

Closed

Closing

Opening

Open

Closing

Open

Empty

Empty

Empty

Empty In

In

In

InAppr.

Appr.

Appr.

Appr.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 15 / 48

Page 31: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

A Discrete-Time Coffee Machine

tick

tick

tick

tick

tick

tick

tick

tick

tick

tick

coffee−ordered tea−ordered

coffee−prepared tea−prepared

idle

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 16 / 48

Page 32: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Automata

edgelocation

off on

a graph with locations and edges

a location is labeled with the valid atomic propositions

taking an edge is instantaneous, i.e, consumes no time

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 17 / 48

Page 33: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Automata

x >= 2

x >= 2on off

y=9

guard

equipped with real-valued clocks x , y , z, . . .

clocks advance implicitly, all at the same speed

logical constraints on clocks can be used as guards of actions

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 18 / 48

Page 34: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Automata

off on x >= 2 reset(x)

y=9 reset(x)

reset(x,y)

clock resetx >= 2

clocks can be reset when taking an edge

assumption:all clocks are zero when entering the initial location initially

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 19 / 48

Page 35: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Automata

y <= 9x <= 2

invariant

off on x >= 2 reset(x)

y=9 reset(x)

{x >= 2reset(x,y)

guards indicate when an edge may be takena location invariant specifies the amount of time that may be spentin a location

before a location invariant becomes invalid, an edge must be taken

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 20 / 48

Page 36: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

A Real-Time Coffee Machine

idle

coffee−ordered tea−ordered

coffee−prepared

True reset(x) True reset(x)

x <= 10

x <= 10 x <= 15

x <= 15

x = 15 reset(x)

x = 15 reset(x)x = 10 reset(x)

x = 10 reset(x)

tea−prepared

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 21 / 48

Page 37: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Clock Constraints

Clock constraints over set C of clocks are defined by:

g ::= True∣

∣x < c

∣x ≤ c

∣¬g

∣g ∧ g

where c ∈ N and clocks x , y ∈ C

rational constants would do; neither reals nor addition of clocks!

let CC(C) denote the set of clock constraints over C

shorthands: x ≥ c denotes ¬ (x < c)and x ∈ [c1, c2) or c1 ≤ x < c2 denotes ¬(x < c1) ∧ (x < c2)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 22 / 48

Page 38: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Automaton

A timed automaton is a tuple

TA =(

Loc,Act,C,;, Loc0, inv,AP, L)

where:

Loc is a finite set of locations.

Loc0 ⊆ Loc is a set of initial locations

C is a finite set of clocks

L : Loc → 2AP is a labeling function for the locations

; ⊆ Loc × CC(C)× Act × 2C × Loc is a transition relation, and

inv : Loc → CC(C) is an invariant-assignment function

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 23 / 48

Page 39: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Intuitive Interpretation

Edge ℓg:α,C′

−−−−−→ ℓ′ means:action α is enabled once guard g holdswhen moving from location ℓ to ℓ′, any clock in C′ will be reset tozero

inv(ℓ) constrains the amount of time that may be spent inlocation ℓ

the location ℓ must be left before the invariant inv(ℓ) becomesinvalid

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 24 / 48

Page 40: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Guards vs. Location Invariants

The effect of a lowerbound guard:

2

4

time

2 4 6 8 10

valueof x

x >= 2 reset(x)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 25 / 48

Page 41: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Guards vs. Location Invariants

The effect of a lowerbound and upperbound guard:

2

4

time

2 4 6 8 10

valueof x 3

2 <= x <= 3 reset(x)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 26 / 48

Page 42: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Guards vs. Location Invariants

The effect of a guard and an invariant:

2

4

time

2 4 6 8 10

valueof x

x >= 2 reset(x)

x <= 3

3

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 27 / 48

Page 43: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Arbitrary Clock Differences

clock xclock y

2

4

time

2 4 6 8 10

clockvalue

y >= 2 reset(y)

x >= 2 reset(x)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 28 / 48

Page 44: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Composing Timed Automata

Let TAi =(

Loci ,Acti ,Ci ,;i , Loc0,i , invi ,AP, Li)

and H an action-set

TA1 ||H TA2 =(

Loc,Act1 ∪ Act2,C,;, Loc0, inv,AP, L)

where:

Loc = Loc1 × Loc2 and Loc0 = Loc0,1 × Loc0,2 and C = C1 ∪ C2

inv(〈ℓ1, ℓ2〉) = inv1(ℓ1) ∧ inv2(ℓ2) and L(〈ℓ1, ℓ2〉) = L1(ℓ1) ∪ L2(ℓ2)

; is defined by the inference rules:

for α ∈ Hℓ1

g1:α,D1;1 ℓ′1 ∧ ℓ2

g2:α,D2;2 ℓ′2

〈ℓ1, ℓ2〉g1∧g2:α,D1∪D2

; 〈ℓ′1, ℓ′

2〉

for α 6∈ H:ℓ1

g:α,D;1 ℓ′1

〈ℓ1, ℓ2〉g:α,D; 〈ℓ′1, ℓ2〉

andℓ2

g:α,D;2 ℓ′2

〈ℓ1, ℓ2〉g:α,D; 〈ℓ1, ℓ

′2〉

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 29 / 48

Page 45: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Example: Railroad Crossing

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 30 / 48

Page 46: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Example: Railroad Crossing

Gate

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 31 / 48

Page 47: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Example: Railroad Crossing

(Train{approach,exit}||Controller)||{lower ,raise}Gate

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 32 / 48

Page 48: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Clock valuations

A clock valuation v for set C of clocks is a function v : C → R≥0

assigning to each clock x ∈ C its current value v(x)

Clock valuation v+d for d ∈ R≥0 is defined by:(v+d)(x) = v(x) + d for all clocks x ∈ C

Clock valuation reset x in v for clock x is defined by:

(reset x in v)(y) ={

v(y) if y 6= x0 if y = x .

reset x in (reset y in v) is abbreviated by reset x , y in v

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 33 / 48

Page 49: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed automaton semantics

For timed automaton TA =(

Loc,Act,C,;, Loc0, inv,AP, L)

:state graph S(TA) = (Q,Q0,E , L′) over AP where:

Q = Loc × val(C), state s = 〈ℓ, v〉 for location ℓ and clockvaluation v

Q0 = { 〈ℓ0, v0〉 | ℓ0 ∈ Loc0 ∧ v0(x) = 0 for all x ∈ C }

L′(〈ℓ, v〉) = L(ℓ)

E is the edge set defined on the next slide

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 34 / 48

Page 50: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed automaton semantics

The edge set E consist of the following two types of transitions:

Discrete transition: 〈ℓ, v〉 α−−→〈ℓ′, v ′〉 if all following conditions hold:there is an edge labeled (g : α,D) from location ℓ to ℓ′ such that:g is satisfied by v , i.e., v |= gv ′ = v with all clocks in D reset to 0, i.e., v ′ = reset D in vv ′ fulfills the invariant of location ℓ′, i.e., v ′ |= inv(ℓ′)

Delay transition: 〈ℓ, v〉 d−−→〈ℓ, v+d〉 for positive real dif for any 0 ≤ d ′ ≤ d the invariant of ℓ holds for v+d ′, i.e.v+d ′ |= inv(ℓ)

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 35 / 48

Page 51: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Time divergence

Let for any t < d , for fixed d ∈ R>0, clock valuation η+t |= inv(ℓ)

A possible execution fragment starting from the location ℓ is:

〈ℓ, η〉d1−−→ 〈ℓ, η+d1〉

d2−−→ 〈ℓ, η+d1+d2〉d3−−→〈ℓ, η+d1+d2+d3〉

d4−−→ . .

where di > 0 and the infinite sequence d1 + d2 + . . . convergestowards dsuch path fragments are called time-convergent

⇒ time advances only up to a certain value

Time-convergent execution fragments are unrealistic and ignored

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 36 / 48

Page 52: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Example: light switch

on off x <= 2

x >= 1

reset(x)

The path

π = 〈off , 0〉 〈off , 1〉 〈on, 0〉 〈on, 1〉 〈off , 1〉 〈off , 2〉 〈on, 0〉 〈on, 1〉 〈off , 1〉 . . .

is time-divergent.The path

π′ = 〈off , 0〉 〈off , 1/2〉 〈off , 3/4〉 〈off , 7/8〉 〈off , 15/16〉 . . .

is time-convergent.

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 37 / 48

Page 53: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timelock

on off

reset(x)

1 <= x < 2

x < 3

State s ∈ S(TA) contains a timelock if there is a reachable state swhere there is no time-divergent path from s

Timelocks are considered as modeling flaws that should beavoided

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 38 / 48

Page 54: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 55: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3 Equivalence relation ≃R

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 56: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3 Equivalence relation ≃R

1 constraints

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 57: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3 Equivalence relation ≃R

1 constraints2 time elapsing

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 58: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3 Equivalence relation ≃R

1 constraints2 time elapsing

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 59: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3 Equivalence relation ≃R

1 constraints2 time elapsing3 maximal constants

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 60: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Region Abstraction

Consider a timed automaton with clocks x and y

having maximal constants 3 and 2, respectively.

0 x

y

1 2 3 4

1

2

3 Equivalence relation ≃R

1 constraints2 time elapsing3 maximal constants

=⇒ finite index!

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 39 / 48

Page 61: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Finite Semantics: Region Automaton

l0A l1

l2

a, x > 0

b,x < 1,x := 0

l0x = 0

JAKr

l00 < x < 1

l0x = 1

l01 < x

l1x = 0

l10 < x < 1

l1x = 1

l11 < x

l2x = 0

l20 < x < 1

l2x = 1

l21 < x

τ

τ

τ

τ

τ

τ

τ

τ

τ

a

a

a

b

b

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 40 / 48

Page 62: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Analysis

Reachability is decidableTheorem [Alur, 1994]:

∃ path (l ,~t) −→ (l ′,~t ′)iff

∃ path (l , [~t ]R) −→ (l ′, [~t ′]R)

Symbolic data structuresClock Region = Finest integral unit

Clock Zone = Convex union of clock regions

Federation = (Non-convex) union of clock zones

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 41 / 48

Page 63: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Finite Semantics: Zone Graph

l0A l1

l2

a, x > 0

b,x < 1{x} l0

true

JAKz

l1x > 0

l2true

a b

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 42 / 48

Page 64: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Controller Synthesis

We distinguish between external (uncontrolled) and internal(controlled) nondeterminism

order coffee

show warning

order espresso

brew drink

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 43 / 48

Page 65: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Games

Game between two players

Environment Controllervs.

“wants to violate the spec.” “wants to satisfy the spec.”

controlled moves

uncontrolled moves

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 44 / 48

Page 66: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Games

Plants are modeled as timed game automata (TGA)

coffeex := 0

espressox := 0

heatx ≤ 9

warm

drink

warning

heatx ≤ 15

warm

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 45 / 48

Page 67: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Timed Controllers

Controller = subautomaton representing winning strategies

coffeex := 0

espressox := 0

heatx = 5

warm

drinkx ≤ 20

warningx > 20

heatx = 10

warm

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 46 / 48

Page 68: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Reachability Games Played on Timed Automata

From where can 99K enforce a run to c ?

a b cx > 1

x := 0

x > 4

x > 2

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 47 / 48

Page 69: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Zone-based Timed Game Solving

From where can 99K enforce a run to c ?

a b cx > 1

x := 0

x > 4

x > 2

Attr[c] = {True}

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 47 / 48

Page 70: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Zone-based Timed Game Solving

From where can 99K enforce a run to c ?

a b cx > 1

x := 0

x > 4

x > 2

Attr[c] = {True}Attr[a] = {x > 4}

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 47 / 48

Page 71: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Zone-based Timed Game Solving

From where can 99K enforce a run to c ?

a b cx > 1

x := 0

x > 4

x > 2

Attr[c] = {True}Attr[a] = {x > 4}

Attr[b] = {x > 2}

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 47 / 48

Page 72: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Zone-based Timed Game Solving

From where can 99K enforce a run to c ?

a b cx > 1

x := 0

x > 4

x > 2

Attr[c] = {True}

Attr[b] = {x > 2}

Attr[a] = {x > 2}

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 47 / 48

Page 73: Automated Formal Methods for Embedded Systems€¦ · Automated Formal Methods for Embedded Systems Bernd Finkbeiner Universitat des Saarlandes¨ Reactive Systems Group 2011/02/03

Summary

Timed automataAutomatic verificationAutomatic controller synthesis

Bernd Finkbeiner (UdS) Embedded Systems 2011/02/03 48 / 48