50
CIS 4930/6930: Principles of Cyber-Physical Systems Chapter 4: Hybrid Systems Hao Zheng Department of Computer Science and Engineering University of South Florida H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 1 / 50

CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

  • Upload
    others

  • View
    9

  • Download
    1

Embed Size (px)

Citation preview

Page 1: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

CIS 4930/6930: Principles ofCyber-Physical Systems

Chapter 4: Hybrid Systems

Hao Zheng

Department of Computer Science and EngineeringUniversity of South Florida

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 1 / 50

Page 2: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Hybrid Systems

• Differential equations are used to model continuous dynamics.

• State machines are used to model discrete dynamics.

• Cyber-physical systems are hybrid systems that include bothcontinuous and discrete dynamics.

• Hybrid system models must represent continuous and discretedynamics.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 2 / 50

Page 3: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

FSM Model

i1

in om

o1... ...

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 3 / 50

Page 4: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Hybrid System, or Modal Model

i1

in om

o1... ...

time-based system time-based system

Mode

Continuousdynamics

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 4 / 50

Page 5: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Thermostat Model with aContinuous-Time Input Signal

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 5 / 50

Page 6: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Thermostat Model with aContinuous-Time Output Signal

h

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 6 / 50

Page 7: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Modeling and Analysis

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 7 / 50

Page 8: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Motivation

• In time-critical systems, reactions must happen not onlycorrectly but also timely.

• Applications:• ABS in cars• Traffic control• Flight control

• How is time modeled? Discrete or continuous?

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 8 / 50

Page 9: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Discrete Modeling of Time

• Time is represented as multiples of basic units.

• Leads to large state space.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 9 / 50

Page 10: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Overview

• Time automata = FSMs extended with clock variables.

• Clocks are dynamic variables that progress linearly in time.

∀t ∈ Tm, s(t) = 1

• s : R→ R is a continuous-time signal,

• s(t) is the value of the clock at time t,

• All clocks progress synchronously.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 10 / 50

Page 11: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Syntax

A timed automata is defined with (ignoring discrete variables)

• L: a finite set of locations.

• l0 ∈ L: the initial location.

• C : a finite set of clock variables.

• A: a finite set of actions.

• E : a finite set of edges connecting locations.

• I : location invariants.

For each e ∈ E , e = (l1, α, cc , reset, l2) where

• α ∈ A is an action,

• cc ∈ B(C ) is a clock constraint,

• reset ⊂ C is a subset of clocks to reset to 0.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 11 / 50

Page 12: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Clock Constraints:Syntax

• In timed automata, only two operations can be applied to clocks• It is reset to 0, or• its value can read and tested for some condition.

• Atomic clock constraints on clock variables x , y ∈ C ,

x ./ c or x − y ./ c

where c is a rational constant, and ./∈ {<,≤, >,≥}.• Clock constraints B(C ) is a set of conjunctions over the atomic

clock constraints.

• Examples:x = c ≡ (x ≤ c) ∧ (x ≥ c)

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 12 / 50

Page 13: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Clock Constraints:Semantics

Given a clock x ∈ C , let u : C → R≥0 be an assignment ofnon-negative real numbers to clocks in C , and u(x) return the valueof x ∈ C .

u |= x ./ c iff u(x) ./ cu |= x − y ./ c iff u(x)− u(y) ./ cu |= cc1 ∧ cc2 iff u |= cc1 ∧ u |= cc2

Example:x = 0.5, y = 1.39 |= (x < 1) ∧ (y ≤ 5)

whilex = 1.01, y = 1.39 6|= (x < 1) ∧ (y ≤ 5)

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 13 / 50

Page 14: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: An Example

A lamp has a button. When the button is pushed once, the lamplights on at the low level. When the button is pushed twice in a row,the lamp lights on at the bright level. In either level, the lamp lightsoff when the button is pushed again.

brightlowoff

press?

press?

press?press?

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 14 / 50

Page 15: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: An Example

brightlowoff

press?

y>=5press?

y<5press?press?

y:=0

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 15 / 50

Page 16: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Understand Time

l0 x ≥ 10/reset(x)

5 10 15 20 25 30 35 40 45 Time

5

10

15

20

25

30

35

40

45

u(x)

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 16 / 50

Page 17: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Understand Time

l0x ≤ 20

x ≥ 10/reset(x)

5 10 15 20 25 30 35 40 45 Time

5

10

15

20

25

30

35

40

45

u(x)

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 17 / 50

Page 18: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Understand Time

l0 10 ≤ x ≤ 20/reset(x)

5 10 15 20 25 30 35 40 45 Time

5

10

15

20

25

30

35

40

45

u(x)

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 18 / 50

Page 19: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automata: Semantics

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 19 / 50

Page 20: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Transitions

• A state of a timed automata is (l , u).

• The initial state is (l0, u0).

Discrete transition: (l1, u1)e−→ (l2, u2)

• An edge (l1, α, cc , reset, l2) ∈ E is enabled/executable in a state(l , u) if• l = l1, u |= cc , and• there is a matching synchronization action to a.

• A new state (l ′, u′) after executing e such that

l ′ = l2, u′ is the same as u except all clocks in reset reset to 0.

Delay transition: (l , u1)δ−→ (l , u2), δ ∈ R+

u2 = u1 + δ where u1 + δ means u(x) + δ for every x ∈ C .

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 20 / 50

Page 21: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Execution Traces

• Execution step: −→=e−→ ∪ δ−→

• Execution trace:

(l0, u0) −→ (l1, u1) −→ (l2, u2) . . .

• Reachability: (i , u) is reachable if there exists a trace

(l0, u0) −→ (l1, u1) . . . −→ (ln, un)

such that l = ln and u = un.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 21 / 50

Page 22: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Timed Automaton that Generates a PureOutput

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 22 / 50

Page 23: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automaton Model of a Thermostat

h

time to stay in heating

time to stay in cooling

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 23 / 50

Page 24: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Possible Execution of the TimedThermostat Model

h

h(t)

t...

(a)

(b)

(c)

s(t)

t...

τ(t)

t...20 t1 t1 + Th

0

Tc

01

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 24 / 50

Page 25: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

FSM for the Traffic Light Controller

It reacts in every second.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 25 / 50

Page 26: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automaton for the Traffic LightController

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 26 / 50

Page 27: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Automaton: Exercise

l0x ≤ 2

l1x ≤ 4

x ≥ 1/

x ≥ 3/x := 0

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 27 / 50

Page 28: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Zenoness

A zeno trace of a timed automata has infinite number of discretetransitions within finite amount of time.

l0x ≤ ∞

l1x ≤ 4

x := 0

x ≥ 1/x := 0

x := 0 l0x = 0

l1x = 0

x := 0

x ≥ 1/x := 0

x := 0

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 28 / 50

Page 29: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Eliminate Zenoness

Make sure that time can progress on every cycle in timed automata.

l0x = 0

l1x ≤ 4

x := 0

x ≥ 1/x := 0

x ≥ 1/x := 0

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 29 / 50

Page 30: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Composing Timed Automata

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 30 / 50

Page 31: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Parallel Composition of Timed Automata

Two TAs T1 = (L1, l10,C1,A1,E1, Inv1) andT2 = (L2, l20,C2,A2,E2, Inv2) such that C1 ∩ C2 = ∅, their parallelcomposition, T1‖T2 is a TA (L, l0,C ,A,E , Inv) where

• L = L1 × L2,

• l0 = (l10, l20);

• C = C1 ∪ C2,

• A = A1 ∪ A2,

• Inv = I1(l1) ∧ I2(l2) for all (l1, l2) ∈ L,

• E = {. . .},

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 31 / 50

Page 32: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Parallel Composition of Timed Automata

E includes edges defined as follows.

(l1, α, cc1, reset1, l′1) ∈ E1 (l2, α, cc2, reset2, l

′2) ∈ E2

Sync((l1, l2), α, cc1 ∧ cc2, reset1 ∪ reset2, (l ′1, l

′2)) ∈ E

(l1, α, cc1, reset1, l′1) ∈ E1 α /∈ A2

Async((l1, l2), α, cc1, reset1, (l ′1, l2)) ∈ E

(l2, α, cc2, reset2, l′2) ∈ E2 α /∈ A1

Async((l1, l2), α, cc2, reset2, (l1, l

′2)) ∈ E

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 32 / 50

Page 33: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Lamp

brightlowoff

press?

y>=5press?

y<5press?press?

y:=0

idle press!

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 33 / 50

Page 34: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Classic Example

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 34 / 50

Page 35: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control Example

A road crosses a railway. In the cross, gates are controlled to blocktraffic on the road for safety.

• Trains communicates with the controller about its positionrelative to the cross. Trains signal the controller with approachand exit.

• The controller reacts to approach by signaling the gate withlower , and reacts to exit by signaling the gate with raise.

• The gate reacts to lower by closing the gate, and reacts to raiseby opening the gate.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 35 / 50

Page 36: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control Example

Trains communicates with the controller about its position relative tothe cross. Trains signal the controller with approach and exit.

far near pastapproach! enter !

exit!

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 36 / 50

Page 37: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control Example

The controller reacts to approach by signaling the gate with lower ,and reacts to exit by signaling the gate with raise.

s0 s1

s2s3

approach?

lower !

exit?

raise!

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 37 / 50

Page 38: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control Example

The gate reacts to lower by closing the gate, and reacts to raise byopening the gate.

up coming down

downgoing up

lower?

raise?

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 38 / 50

Page 39: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Train-Gate-Control: the Whole Picture

far near pastapproach! enter !

exit!

s0 s1

s2s3

approach?

lower !

exit?

raise!

up coming down

downgoing up

lower?

raise?

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 39 / 50

Page 40: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control: Timing

2 or 3 minutes after the train signals the controller approach, itreaches the gate. At most 5 minutes after the train signals approach,it leaves the gate.

farnearx ≤ 3

inx ≤ 5

approach!x := 0

enter !x ≥ 2

exit!

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 40 / 50

Page 41: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control: Timing

After receiving approach, it takes the controller 1 minute to producesignal lower to the gate. After receiving exit, it takes no more than 1minute for the controller to produce raise.

s0s1

y ≤ 1

s2s3

y ≤ 1

approach?/y := 0

y = 1lower !

exit?y := 0

raise!

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 41 / 50

Page 42: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

A Train-Gate-Control: Timing

The gate needs at most 1 minute to be closed, and between 1 and 2minutes to be open.

up coming downz ≤ 1

downgoing upz ≤ 2

lower?z := 0

raise?z := 0

z ≥ 1

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 42 / 50

Page 43: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Train-Gate-Control: the WholePicture

farnearx ≤ 3

inx ≤ 5

approach!x := 0

enter !x ≥ 2

exit!

s0 s1y ≤ 1

s2s3y ≤ 1

approach?/y := 0

y = 1lower !

exit?y := 0

raise!

up coming downz ≤ 1

downgoing upz ≤ 2

lower?z := 0

raise?z := 0

z ≥ 1

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 43 / 50

Page 44: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Specification in UPPAAL

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 44 / 50

Page 45: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Computation Tree

A state of TA = current locations + values of discrete and clockvariables.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 45 / 50

Page 46: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Computation Tree Logic

• State formulas ϕ: expressions whose truth can be decided onindividual states.

i = 7, x ≤ 7 ∧ y > 9

UPPAAL has a keyword deadlock, which, when true, indicatesa deadlock.

• Path formulas φ are• �ϕ: ϕ holds in every state of a trace,• ♦ϕ: ϕ holds in some state of a trace.

• Path quantifiers:• Aφ: φ holds on every path from the initial state.• Eφ: φ holds on some path from the initial state.

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 46 / 50

Page 47: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Timed Computation Tree Logic

• Reachability Properties: decide if certain states are reachable.

A[] ϕ

A<> ϕ

E<> ϕ

E[] ϕ

ψ

ϕ ϕ

ϕ

ψ ϕ!

Fig. 4. Path formulae supported in Uppaal. The filled states are those for which agiven state formulae ! holds. Bold edges are used to show the paths the formulaeevaluate on.

by any reachable state. Another way of stating this is: Does there exist a pathstarting at the initial state, such that ! is eventually satisfied along that path.

Reachability properties are often used while designing a model to performsanity checks. For instance, when creating a model of a communication protocolinvolving a sender and a receiver, it makes sense to ask whether it is possiblefor the sender to send a message at all or whether a message can possibly bereceived. These properties do not by themselves guarantee the correctness of theprotocol (i.e. that any message is eventually delivered), but they validate thebasic behaviour of the model.

We express that some state satisfying ! should be reachable using the pathformula E! !. In Uppaal, we write this property using the syntax E<> !.

Safety Properties Safety properties are on the form: “something bad will neverhappen”. For instance, in a model of a nuclear power plant, a safety propertymight be, that the operating temperature is always (invariantly) under a certainthreshold, or that a meltdown never occurs. A variation of this property is that“something will possibly never happen”. For instance when playing a game, asafe state is one in which we can still win the game, hence we will possibly notloose.

In Uppaal these properties are formulated positively, e.g., something goodis invariantly true. Let ! be a state formulae. We express that ! should be truein all reachable states with the path formulae A" !,3 whereas E" ! says that

3 Notice that A" " = ¬E! ¬"

8

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 47 / 50

Page 48: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Computation Tree Logic: Example

loop x>=2reset!

takenidle

x := 0

reset?

TCTL Properties:

• A[] Obs.taken imply x>=2

• E[] Obs.idle and x>3

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 48 / 50

Page 49: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Computation Tree Logic: Example

loopx <= 3

x>=2reset!

takenidle

x := 0

reset?

TCTL Properties:

• A[] Obs.taken imply x>=2

• E[] Obs.idle and x>3

• A[] Obs.taken imply (x >=2 and x <=3)

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 49 / 50

Page 50: CIS 4930/6930: Principles of Cyber-Physical Systems ...haozheng/teach/Principles... · 1;u 1)!e (l 2;u 2) An edge ( l 1; ;cc ;reset 2) 2E is enabled/executable in a state (l;u) if

Computation Tree Logic: Example

loop x>=2 and x <= 3reset!

takenidle

x := 0

reset?

TCTL Properties:

• A[] Obs.taken imply (x >=2 and x <=3)

• E<> deadlock

H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 50 / 50