SlideShare a Scribd company logo
1 of 46
Download to read offline
CIS 4930/6930: Principles of
Cyber-Physical Systems
Homework Solutions
Hao Zheng
Department of Computer Science and Engineering
University of South Florida
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 1 / 44
HW 2
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 2 / 44
HW 2: Chapter 3, Problem 2
Cooling Heating
wait1
wait2
wait3
temp ≤ 20/heaton
temp > 20/heatoff
true/
true/
true/
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 3 / 44
HW 2: Chapter 3, Problem 2
Cooling Heating
input: temp, clk : R
outputs: heaton, heatoff: pure
clk := 121
temp ≤ 20 ∧ clk > 120/heaton, clk := 0
temp > 20 ∧ clk > 30/heatoff , clk := 0
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 4 / 44
HW 2: Chapter 3, Problem 5
A B C
X/0 X/0
X/1
Problem 5:
b x = (p, p, p, p, p, . . .), y = (0, 1, 1, 0, a, . . .) Yes
c x = (a, p, a, p, a, . . .), y = (a, 1, a, 0, a, . . .) No
d x = (p, p, p, p, p, . . .), y = (0, 0, a, a, a, . . .) Yes
e x = (p, p, p, p, p, . . .), y = (0, a, 0, a, a, . . .) No
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 5 / 44
HW 2: Chapter 3, Problem 5
A B C
X/0 X/0
X/1
Problem 5:
a x = (p, p, p, p, p, . . .), y = (0, 1, 1, 0, 0, . . .) No
b x = (p, p, p, p, p, . . .), y = (0, 1, 1, 0, a, . . .) Yes
c x = (a, p, a, p, a, . . .), y = (a, 1, a, 0, a, . . .) No
d x = (p, p, p, p, p, . . .), y = (0, 0, a, a, a, . . .) Yes
e x = (p, p, p, p, p, . . .), y = (0, a, 0, a, a, . . .) No
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 5 / 44
HW 2: Problem 3
Traffic Pedestrian
sigR, sigY , sigG
Pedestrian
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 6 / 44
HW 2: Problem 3
red, crossing
(green, none)
count := 0
count ≥ 60/SigG, count := 0
count := count + 1
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 7 / 44
HW 2: Problem 3
(green, none)
(yellow, waiting)
(pending, waiting)
count < 60/count := count + 1
count < 60/count := count + 1
count ≥ 60/sigY , count := 0
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 8 / 44
HW 2: Problem 3
(yellow, waiting)
(pending, waiting) count := count + 1
count ≥ 60/sigY , count := 0
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 9 / 44
HW 2: Problem 3
red, crossing
(yellow, waiting)
count := 0
count ≥ 5/count := 0
count := count + 1
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 10 / 44
HW 2: Problem 3
red, crossing
(green, none)
(yellow, waiting)
(pending, waiting)
count := 0
count ≥ 60/SigG, count := 0
count := count + 1
count < 60/count := count + 1
count < 60/count := count + 1
count ≥ 60/sigY , count := 0
count ≥ 60/sigY , count := 0
count ≥ 60/sigY , count := 0
count ≥ 5/sigR, count := 0
count := count + 1
count := count + 1
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 11 / 44
HW 3: Pointers and Hints
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 12 / 44
HW 3, Problem 1
mtype = {sigR, sigY, sigG};
chan signal = [0] of {mtype};
chan ped = [0] of {bit};
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 13 / 44
HW 3, Problem 1
active proctype traffic() {
...
Green:
if /* Not allowed by SPIN */
:: ped?1 && count < 60 -> ...; goto Pending;
:: ped?1 && count >= 60 -> ...; goto Yellow;
:: count < 60 -> ...; goto Green;
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 14 / 44
HW 3, Problem 1
active proctype traffic() {
...
Green: ped?pedBit; /* Lead to invalid end state! */
if
:: pedBit==1 && count < 60 -> ...; goto Pending;
:: pedBit==1 && count >= 60 -> ...; goto Yellow;
:: count < 60 -> count++; goto Green;
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 15 / 44
HW 3, Problem 1
/* Also lead to invalid end state! */
active proctype traffic() {
...
Green:
if
:: ped?1 -> count < 60 -> ...; goto Pending;
:: ped?1 -> count >= 60 -> ...; goto Yellow;
:: count < 60 -> ...; goto Green;
...
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 16 / 44
HW 3, Problem 1
/* Still lead to invalid end state! */
active proctype traffic() {
...
Green:
if
:: ped?1 -> if
:: count < 60 -> count++; goto Pending;
:: count >= 60 -> signal!sigY;
count=0;
goto Yellow;
fi
:: count < 60 -> ...; goto Green;
...
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 17 / 44
HW 3, Problem 1
/* Finally ... */
active proctype traffic() {
...
Green:
if
:: ped?1 -> if
:: count < 60 -> count++; goto Pending;
:: count >= 60 -> count=0;
goto Yellow;
fi
:: count < 60 -> ...; goto Green;
...
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 18 / 44
HW 3, Problem 1, Check Properties
Property #1
Pedestrians are allowed to cross the street only when the traffic light
is red,
bool traffic_red = false;
active proctype traffic() {
Red: ... traffic_red = false; goto Green; ...
Green: ...
Pending: ...
Yellow: ... traffic_red = true; goto red ... }
active proctype traffic() { ... }
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 19 / 44
HW 3, Problem 1, Check Properties
Property #1
Pedestrians are allowed to cross the street only when the traffic light
is red,
bool traffic_red = false;
bool ped_cross = false;
active proctype traffic() { ... }
active proctype pedestrian() {
Crossing: signal?sigG -> ped_cross = false; goto None;
None: ped!1 -> ped_cross = false; goto Waiting;
Waiting: signal?sigR -> ped_cross = true; goto Crossin
}
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 20 / 44
HW 3, Problem 1, Check Properties
Property #1
Pedestrians are allowed to cross the street only when the traffic light
is red,
bool traffic_red = false;
bool ped_cross = false;
active proctype traffic() { ... }
active proctype pedestrian() { ... }
active proctype monitor() { /* Prop #1 is checked */
assert( ped_cross -> traffic_red );
}
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 21 / 44
HW 3: Post-Submission Discussioins
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 22 / 44
HW 3, Problem 1
mtype = {sigR, sigY, sigG};
chan signal = [0] of {mtype};
chan ped = [0] of {bit};
int count;
bool traffic_red = true; /* The initial state of traffic light is
bool ped_cross = true; /* The initial state of pedestrian light is c
bool ped_pres = false;
active proctype traffic()
{
red:
if
:: atomic { count >= 60 -> signal!sigG; count = 0;
traffic_red = false; goto green; }
:: atomic { else -> count++; traffic_red = true; goto red; }
fi;
...
}
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 23 / 44
HW 3, Problem 1, How SPIN Works?
active proctype traffic()
{
red:
if
:: atomic { count >= 60 -> signal!sigG; count = 0;
traffic_red = false; goto green; }
:: atomic { else -> count++; traffic_red = true; goto red; }
fi;
...
}
active proctype pedestrian()
{ crossing: atomic { signal?sigG -> ped_pres = false;
ped_cross = false; goto none; }
... }
active proctype monitor()
{ assert(!ped_cross || traffic_red); }
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 24 / 44
HW 3, Problem 1, How SPIN Works?
active proctype traffic()
{
red:
if
:: atomic { count >= 60 -> signal!sigG; count = 0;
traffic_red = false; goto green; }
:: atomic { else -> count++; traffic_red = true; goto red; }
fi;
...
}
active proctype pedestrian()
{ crossing: atomic { signal?sigG -> ped_pres = false;
ped_cross = false; goto none; }
... }
ltl prop1 { [](!ped_cross || traffic_red) }
ltl prop2 { [](ped_pres -> <> ped_cross) }
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 25 / 44
HW 3, Problem 1, Another Version
#define RED 1
#define YELLOW 2
#define GREEN 3
#define PENDING 4
#define CROSSING 5
#define NONE 6
#define WAITING 7
byte traffic_state = RED;
byte ped_state = CROSSING;
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 26 / 44
HW 3, Problem 1, Another Version
active proctype traffic()
{
do
:: traffic_state==RED ->
if
:: atomic { count >= 60 -> signal!GREEN; count = 0;
traffic_state = GREEN; }
:: atomic { else -> count++; traffic_state = RED; }
fi;
:: traffic_state==GREEN ->...
:: traffic_state == PENDING -> ...
:: traffic_state == YELLOW -> ...
od
}
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 27 / 44
HW 3, Problem 1, Another Version
active proctype pedestrian()
{ do
:: ped_state == CROSSING ->
atomic { signal?GREEN -> ped_state = NONE; }
:: ped_state == NONE -> atomic { ped!1 -> ped_state = WAITING; }
:: ped_state == WAITING ->
atomic { signal?RED -> ped_state = CROSSING; }
od }
ltl prop1 { []((ped_state != CROSSING) || (traffic_state==RED)) }
ltl prop2 { [](ped_state == WAITING -> <> (ped_state == CROSSING)) }
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 28 / 44
HW 4
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 29 / 44
Problem 1
true
false: a
x
−
→ b
¬x
−
−
→ c
x
−
→ c . . .
true
true
true
false: b and c are different states.
false: a
x
−
→ b
x
−
→ a
¬x
−
−
→ a
x
−
→ b
x
−
→ a
¬x
−
−
→ a . . .
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 30 / 44
Problem 2
(a) ∨1≤i≤nFpi
(b) ∧1≤i≤nFpi
(c) F(p1 ∧ F(P2 ∧ F(p3 ∧ . . .)))
F(p1 ∧ XF(P2 ∧ XF(p3 ∧ . . .))) is the same as in (c). Why?
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 31 / 44
HW 5
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 32 / 44
Question 1
— Exercises
1. Construct (on paper is sufficient) a timed automaton similar to that of Figure 4.7 which pro-
duces tick at times 1,2,3,5,6,7,8,10,11,···. That is, ticks are produced with intervals be-
tween them of 1 second (three times) and 2 seconds (once).
olution: The following hybrid system will do the job:
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 33 / 44
Question 1
— Exercises
1. Construct (on paper is sufficient) a timed automaton similar to that of Figure 4.7 which pro-
duces tick at times 1,2,3,5,6,7,8,10,11,···. That is, ticks are produced with intervals be-
tween them of 1 second (three times) and 2 seconds (once).
olution: The following hybrid system will do the job:
1. Construct (on paper is sufficient) a timed automaton similar to that of Figure 4.7 which pro-
duces tick at times 1,2,3,5,6,7,8,10,11,···. That is, ticks are produced with intervals be-
tween them of 1 second (three times) and 2 seconds (once).
Solution: The following hybrid system will do the job:
23
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 33 / 44
Question 2(a)
he objective of this problem is to understand a timed automaton, and then to modify it as
ecified.
a) For the timed automaton shown below, describe the output y. Avoid imprecise or sloppy
notation.
n: The system generates a discrete signal with the event sequence
(1,3,4,6,7,9,10,···)
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 34 / 44
Question 3
3. You have an analog source that produces a pure tone. You can switch the source on or off by
the input event on or off. Construct a timed automaton that provides the on and off signals
as outputs, to be connected to the inputs of the tone generator. Your system should behave as
follows. Upon receiving an input event ring, it should produce an 80 ms-long sound consisting
of three 20 ms-long bursts of the pure tone separated by two 10 ms intervals of silence. What
does your system do if it receives two ring events that are 50 ms apart?
olution: Assume the input alphabet is {ring,absent} and the output alphabet is {on,off,absent}.
hen the following timed automaton will control the source of the tone:
g1/ on
s(t) := 0
silent 1 tone 1
toneController
v(t) ∈{on, off, absent}
c(t) ∈{ring, absent}
silent 2
g2 / off
s(t) := 0
g / on
g / off
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 35 / 44
Question 3
l0
tone1
t ≤ 20
silent1
t ≤ 10
tone2
t ≤ 10
silent2
t ≤ 10
tone3
t ≤ 20
t := 0
ring/t := 0, on t = 20/off
t = 10/on
t = 20/off
t = 10/on
t = 20/off
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 36 / 44
Question 5
he guards are given by
g1 = {(x(t),s(t)) | x(t) = warn}
g2 = {(x(t),s(t)) | x(t) = noWarn}
g3 = {(x(t),s(t)) | s(t) = 30 ^ x(t) = absent}.
5. A programmable thermostat allows you to select 4 times, 0  T1  ···  T4 < 24 (for a
24-hour cycle) and the corresponding setpoint temperatures a1,··· ,a4. Construct a timed
automaton that sends the event ai to the heating systems controller. The controller maintains
the temperature close to the value ai until it receives the next event. How many timers and
modes do you need?
e & Seshia, Introduction to Embedded Systems, Solutions 27
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 37 / 44
Question 5
l0
t ≤ T1
l1
t ≤ T2
l2
t ≤ t3
l3
t ≤ T4
l3
t ≤ 24h
t := 0
t = T1/a1
t = T2/a2
t = T3/a3
t = T4/a4 t = 24h/t := 0
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 38 / 44
HW 7
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 39 / 44
Water Tank
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 40 / 44
Water Tank Trajectory
SOLUTIONS
tank1
tank2
0.0
0.2
0.4
0.6
0.8
1.0
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Tank Levels
time
level
The model exhibits Zeno behavior because the net outflow is 0.5 + 0
the net inflow of 0.75. Thus, no matter how we switch the inflow bet
water in both tanks past time 4.0. The hybrid system is designed to
becomes empty, and the time between these events gets infinitely sma
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 41 / 44
Problem P2
• To show that concurrent access to a list may corrupt the data
structure.
• Modeling a linked list?
next
listener
next
listener
next
listener
next
listener
Use arrays in Promela.
bool next[4];
bool listener[4];
int tail = -1;
int head = -1;
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 42 / 44
Problem P2
proctype addListener()
{
if
:: head==-1 -> head = 0;
next[head]=true;
listener[head] = true;
tail = head;
:: else -> tail = tail+1;
next[tail] = true;
listener[tail] = true;
fi
}
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 43 / 44
Problem P2
init
{
next[0] = false; next[1] = false;
next[2] = false; next[3] = false;
listener[0] = false; listener[1] = false;
listener[2] = false; listener[3] = false;
atomic { run addListener(); run addListener();
run addListener(); run addListener(); };
(_nr_pr==1) ->
assert(listener[0] && ... && listener[3]);
}
H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 44 / 44

More Related Content

Similar to hw-sol.pdf

Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...
Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...
Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...wvanroos
 
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)jon_bell
 
Graph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph AlgorithmsGraph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph Algorithmshtttuneti
 
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...Iosif Itkin
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit Prabhu R
 
Silent error detection in numerical time stepping schemes (SIAM PP 2014)
Silent error detection in numerical time stepping schemes (SIAM PP 2014)Silent error detection in numerical time stepping schemes (SIAM PP 2014)
Silent error detection in numerical time stepping schemes (SIAM PP 2014)Austin Benson
 
Comparison GUM versus GUM+1
Comparison GUM  versus GUM+1Comparison GUM  versus GUM+1
Comparison GUM versus GUM+1Maurice Maeck
 
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by OraclesEfficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by OraclesVissarion Fisikopoulos
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
 
Introduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning ProgrammersIntroduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning ProgrammersKimikazu Kato
 
Bayesian Experimental Design for Stochastic Kinetic Models
Bayesian Experimental Design for Stochastic Kinetic ModelsBayesian Experimental Design for Stochastic Kinetic Models
Bayesian Experimental Design for Stochastic Kinetic ModelsColin Gillespie
 
Numerical approach for Hamilton-Jacobi equations on a network: application to...
Numerical approach for Hamilton-Jacobi equations on a network: application to...Numerical approach for Hamilton-Jacobi equations on a network: application to...
Numerical approach for Hamilton-Jacobi equations on a network: application to...Guillaume Costeseque
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C CodeSyed Ahmed Zaki
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
 
PBL1-v1-004j.pptx
PBL1-v1-004j.pptxPBL1-v1-004j.pptx
PBL1-v1-004j.pptxNAIST
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECERamesh Naik Bhukya
 
Model-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical ConstraintsModel-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical ConstraintsQuoc-Sang Phan
 

Similar to hw-sol.pdf (20)

Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...
Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...
Invited presentation at SIAM PP 18: Communication Hiding Through Pipelining i...
 
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
CROCHET - Checkpoint Rollback in JVM (ECOOP 2018)
 
Graph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph AlgorithmsGraph Algorithms Graph Algorithms Graph Algorithms
Graph Algorithms Graph Algorithms Graph Algorithms
 
Tech-1.pptx
Tech-1.pptxTech-1.pptx
Tech-1.pptx
 
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
Parametrized Model Checking of Fault Tolerant Distributed Algorithms by Abstr...
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit
 
Silent error detection in numerical time stepping schemes (SIAM PP 2014)
Silent error detection in numerical time stepping schemes (SIAM PP 2014)Silent error detection in numerical time stepping schemes (SIAM PP 2014)
Silent error detection in numerical time stepping schemes (SIAM PP 2014)
 
Ch4
Ch4Ch4
Ch4
 
Comparison GUM versus GUM+1
Comparison GUM  versus GUM+1Comparison GUM  versus GUM+1
Comparison GUM versus GUM+1
 
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by OraclesEfficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
Efficient Volume and Edge-Skeleton Computation for Polytopes Given by Oracles
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
Introduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning ProgrammersIntroduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning Programmers
 
Bayesian Experimental Design for Stochastic Kinetic Models
Bayesian Experimental Design for Stochastic Kinetic ModelsBayesian Experimental Design for Stochastic Kinetic Models
Bayesian Experimental Design for Stochastic Kinetic Models
 
Numerical approach for Hamilton-Jacobi equations on a network: application to...
Numerical approach for Hamilton-Jacobi equations on a network: application to...Numerical approach for Hamilton-Jacobi equations on a network: application to...
Numerical approach for Hamilton-Jacobi equations on a network: application to...
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
 
PBL1-v1-004j.pptx
PBL1-v1-004j.pptxPBL1-v1-004j.pptx
PBL1-v1-004j.pptx
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Model-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical ConstraintsModel-counting Approaches For Nonlinear Numerical Constraints
Model-counting Approaches For Nonlinear Numerical Constraints
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 

hw-sol.pdf

  • 1. CIS 4930/6930: Principles of Cyber-Physical Systems Homework Solutions Hao Zheng Department of Computer Science and Engineering University of South Florida H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 1 / 44
  • 2. HW 2 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 2 / 44
  • 3. HW 2: Chapter 3, Problem 2 Cooling Heating wait1 wait2 wait3 temp ≤ 20/heaton temp > 20/heatoff true/ true/ true/ H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 3 / 44
  • 4. HW 2: Chapter 3, Problem 2 Cooling Heating input: temp, clk : R outputs: heaton, heatoff: pure clk := 121 temp ≤ 20 ∧ clk > 120/heaton, clk := 0 temp > 20 ∧ clk > 30/heatoff , clk := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 4 / 44
  • 5. HW 2: Chapter 3, Problem 5 A B C X/0 X/0 X/1 Problem 5: b x = (p, p, p, p, p, . . .), y = (0, 1, 1, 0, a, . . .) Yes c x = (a, p, a, p, a, . . .), y = (a, 1, a, 0, a, . . .) No d x = (p, p, p, p, p, . . .), y = (0, 0, a, a, a, . . .) Yes e x = (p, p, p, p, p, . . .), y = (0, a, 0, a, a, . . .) No H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 5 / 44
  • 6. HW 2: Chapter 3, Problem 5 A B C X/0 X/0 X/1 Problem 5: a x = (p, p, p, p, p, . . .), y = (0, 1, 1, 0, 0, . . .) No b x = (p, p, p, p, p, . . .), y = (0, 1, 1, 0, a, . . .) Yes c x = (a, p, a, p, a, . . .), y = (a, 1, a, 0, a, . . .) No d x = (p, p, p, p, p, . . .), y = (0, 0, a, a, a, . . .) Yes e x = (p, p, p, p, p, . . .), y = (0, a, 0, a, a, . . .) No H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 5 / 44
  • 7. HW 2: Problem 3 Traffic Pedestrian sigR, sigY , sigG Pedestrian H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 6 / 44
  • 8. HW 2: Problem 3 red, crossing (green, none) count := 0 count ≥ 60/SigG, count := 0 count := count + 1 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 7 / 44
  • 9. HW 2: Problem 3 (green, none) (yellow, waiting) (pending, waiting) count < 60/count := count + 1 count < 60/count := count + 1 count ≥ 60/sigY , count := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 8 / 44
  • 10. HW 2: Problem 3 (yellow, waiting) (pending, waiting) count := count + 1 count ≥ 60/sigY , count := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 9 / 44
  • 11. HW 2: Problem 3 red, crossing (yellow, waiting) count := 0 count ≥ 5/count := 0 count := count + 1 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 10 / 44
  • 12. HW 2: Problem 3 red, crossing (green, none) (yellow, waiting) (pending, waiting) count := 0 count ≥ 60/SigG, count := 0 count := count + 1 count < 60/count := count + 1 count < 60/count := count + 1 count ≥ 60/sigY , count := 0 count ≥ 60/sigY , count := 0 count ≥ 60/sigY , count := 0 count ≥ 5/sigR, count := 0 count := count + 1 count := count + 1 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 11 / 44
  • 13. HW 3: Pointers and Hints H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 12 / 44
  • 14. HW 3, Problem 1 mtype = {sigR, sigY, sigG}; chan signal = [0] of {mtype}; chan ped = [0] of {bit}; H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 13 / 44
  • 15. HW 3, Problem 1 active proctype traffic() { ... Green: if /* Not allowed by SPIN */ :: ped?1 && count < 60 -> ...; goto Pending; :: ped?1 && count >= 60 -> ...; goto Yellow; :: count < 60 -> ...; goto Green; H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 14 / 44
  • 16. HW 3, Problem 1 active proctype traffic() { ... Green: ped?pedBit; /* Lead to invalid end state! */ if :: pedBit==1 && count < 60 -> ...; goto Pending; :: pedBit==1 && count >= 60 -> ...; goto Yellow; :: count < 60 -> count++; goto Green; H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 15 / 44
  • 17. HW 3, Problem 1 /* Also lead to invalid end state! */ active proctype traffic() { ... Green: if :: ped?1 -> count < 60 -> ...; goto Pending; :: ped?1 -> count >= 60 -> ...; goto Yellow; :: count < 60 -> ...; goto Green; ... H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 16 / 44
  • 18. HW 3, Problem 1 /* Still lead to invalid end state! */ active proctype traffic() { ... Green: if :: ped?1 -> if :: count < 60 -> count++; goto Pending; :: count >= 60 -> signal!sigY; count=0; goto Yellow; fi :: count < 60 -> ...; goto Green; ... H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 17 / 44
  • 19. HW 3, Problem 1 /* Finally ... */ active proctype traffic() { ... Green: if :: ped?1 -> if :: count < 60 -> count++; goto Pending; :: count >= 60 -> count=0; goto Yellow; fi :: count < 60 -> ...; goto Green; ... H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 18 / 44
  • 20. HW 3, Problem 1, Check Properties Property #1 Pedestrians are allowed to cross the street only when the traffic light is red, bool traffic_red = false; active proctype traffic() { Red: ... traffic_red = false; goto Green; ... Green: ... Pending: ... Yellow: ... traffic_red = true; goto red ... } active proctype traffic() { ... } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 19 / 44
  • 21. HW 3, Problem 1, Check Properties Property #1 Pedestrians are allowed to cross the street only when the traffic light is red, bool traffic_red = false; bool ped_cross = false; active proctype traffic() { ... } active proctype pedestrian() { Crossing: signal?sigG -> ped_cross = false; goto None; None: ped!1 -> ped_cross = false; goto Waiting; Waiting: signal?sigR -> ped_cross = true; goto Crossin } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 20 / 44
  • 22. HW 3, Problem 1, Check Properties Property #1 Pedestrians are allowed to cross the street only when the traffic light is red, bool traffic_red = false; bool ped_cross = false; active proctype traffic() { ... } active proctype pedestrian() { ... } active proctype monitor() { /* Prop #1 is checked */ assert( ped_cross -> traffic_red ); } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 21 / 44
  • 23. HW 3: Post-Submission Discussioins H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 22 / 44
  • 24. HW 3, Problem 1 mtype = {sigR, sigY, sigG}; chan signal = [0] of {mtype}; chan ped = [0] of {bit}; int count; bool traffic_red = true; /* The initial state of traffic light is bool ped_cross = true; /* The initial state of pedestrian light is c bool ped_pres = false; active proctype traffic() { red: if :: atomic { count >= 60 -> signal!sigG; count = 0; traffic_red = false; goto green; } :: atomic { else -> count++; traffic_red = true; goto red; } fi; ... } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 23 / 44
  • 25. HW 3, Problem 1, How SPIN Works? active proctype traffic() { red: if :: atomic { count >= 60 -> signal!sigG; count = 0; traffic_red = false; goto green; } :: atomic { else -> count++; traffic_red = true; goto red; } fi; ... } active proctype pedestrian() { crossing: atomic { signal?sigG -> ped_pres = false; ped_cross = false; goto none; } ... } active proctype monitor() { assert(!ped_cross || traffic_red); } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 24 / 44
  • 26. HW 3, Problem 1, How SPIN Works? active proctype traffic() { red: if :: atomic { count >= 60 -> signal!sigG; count = 0; traffic_red = false; goto green; } :: atomic { else -> count++; traffic_red = true; goto red; } fi; ... } active proctype pedestrian() { crossing: atomic { signal?sigG -> ped_pres = false; ped_cross = false; goto none; } ... } ltl prop1 { [](!ped_cross || traffic_red) } ltl prop2 { [](ped_pres -> <> ped_cross) } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 25 / 44
  • 27. HW 3, Problem 1, Another Version #define RED 1 #define YELLOW 2 #define GREEN 3 #define PENDING 4 #define CROSSING 5 #define NONE 6 #define WAITING 7 byte traffic_state = RED; byte ped_state = CROSSING; H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 26 / 44
  • 28. HW 3, Problem 1, Another Version active proctype traffic() { do :: traffic_state==RED -> if :: atomic { count >= 60 -> signal!GREEN; count = 0; traffic_state = GREEN; } :: atomic { else -> count++; traffic_state = RED; } fi; :: traffic_state==GREEN ->... :: traffic_state == PENDING -> ... :: traffic_state == YELLOW -> ... od } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 27 / 44
  • 29. HW 3, Problem 1, Another Version active proctype pedestrian() { do :: ped_state == CROSSING -> atomic { signal?GREEN -> ped_state = NONE; } :: ped_state == NONE -> atomic { ped!1 -> ped_state = WAITING; } :: ped_state == WAITING -> atomic { signal?RED -> ped_state = CROSSING; } od } ltl prop1 { []((ped_state != CROSSING) || (traffic_state==RED)) } ltl prop2 { [](ped_state == WAITING -> <> (ped_state == CROSSING)) } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 28 / 44
  • 30. HW 4 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 29 / 44
  • 31. Problem 1 true false: a x − → b ¬x − − → c x − → c . . . true true true false: b and c are different states. false: a x − → b x − → a ¬x − − → a x − → b x − → a ¬x − − → a . . . H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 30 / 44
  • 32. Problem 2 (a) ∨1≤i≤nFpi (b) ∧1≤i≤nFpi (c) F(p1 ∧ F(P2 ∧ F(p3 ∧ . . .))) F(p1 ∧ XF(P2 ∧ XF(p3 ∧ . . .))) is the same as in (c). Why? H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 31 / 44
  • 33. HW 5 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 32 / 44
  • 34. Question 1 — Exercises 1. Construct (on paper is sufficient) a timed automaton similar to that of Figure 4.7 which pro- duces tick at times 1,2,3,5,6,7,8,10,11,···. That is, ticks are produced with intervals be- tween them of 1 second (three times) and 2 seconds (once). olution: The following hybrid system will do the job: H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 33 / 44
  • 35. Question 1 — Exercises 1. Construct (on paper is sufficient) a timed automaton similar to that of Figure 4.7 which pro- duces tick at times 1,2,3,5,6,7,8,10,11,···. That is, ticks are produced with intervals be- tween them of 1 second (three times) and 2 seconds (once). olution: The following hybrid system will do the job: 1. Construct (on paper is sufficient) a timed automaton similar to that of Figure 4.7 which pro- duces tick at times 1,2,3,5,6,7,8,10,11,···. That is, ticks are produced with intervals be- tween them of 1 second (three times) and 2 seconds (once). Solution: The following hybrid system will do the job: 23 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 33 / 44
  • 36. Question 2(a) he objective of this problem is to understand a timed automaton, and then to modify it as ecified. a) For the timed automaton shown below, describe the output y. Avoid imprecise or sloppy notation. n: The system generates a discrete signal with the event sequence (1,3,4,6,7,9,10,···) H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 34 / 44
  • 37. Question 3 3. You have an analog source that produces a pure tone. You can switch the source on or off by the input event on or off. Construct a timed automaton that provides the on and off signals as outputs, to be connected to the inputs of the tone generator. Your system should behave as follows. Upon receiving an input event ring, it should produce an 80 ms-long sound consisting of three 20 ms-long bursts of the pure tone separated by two 10 ms intervals of silence. What does your system do if it receives two ring events that are 50 ms apart? olution: Assume the input alphabet is {ring,absent} and the output alphabet is {on,off,absent}. hen the following timed automaton will control the source of the tone: g1/ on s(t) := 0 silent 1 tone 1 toneController v(t) ∈{on, off, absent} c(t) ∈{ring, absent} silent 2 g2 / off s(t) := 0 g / on g / off H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 35 / 44
  • 38. Question 3 l0 tone1 t ≤ 20 silent1 t ≤ 10 tone2 t ≤ 10 silent2 t ≤ 10 tone3 t ≤ 20 t := 0 ring/t := 0, on t = 20/off t = 10/on t = 20/off t = 10/on t = 20/off H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 36 / 44
  • 39. Question 5 he guards are given by g1 = {(x(t),s(t)) | x(t) = warn} g2 = {(x(t),s(t)) | x(t) = noWarn} g3 = {(x(t),s(t)) | s(t) = 30 ^ x(t) = absent}. 5. A programmable thermostat allows you to select 4 times, 0  T1  ···  T4 < 24 (for a 24-hour cycle) and the corresponding setpoint temperatures a1,··· ,a4. Construct a timed automaton that sends the event ai to the heating systems controller. The controller maintains the temperature close to the value ai until it receives the next event. How many timers and modes do you need? e & Seshia, Introduction to Embedded Systems, Solutions 27 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 37 / 44
  • 40. Question 5 l0 t ≤ T1 l1 t ≤ T2 l2 t ≤ t3 l3 t ≤ T4 l3 t ≤ 24h t := 0 t = T1/a1 t = T2/a2 t = T3/a3 t = T4/a4 t = 24h/t := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 38 / 44
  • 41. HW 7 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 39 / 44
  • 42. Water Tank H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 40 / 44
  • 43. Water Tank Trajectory SOLUTIONS tank1 tank2 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 Tank Levels time level The model exhibits Zeno behavior because the net outflow is 0.5 + 0 the net inflow of 0.75. Thus, no matter how we switch the inflow bet water in both tanks past time 4.0. The hybrid system is designed to becomes empty, and the time between these events gets infinitely sma H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 41 / 44
  • 44. Problem P2 • To show that concurrent access to a list may corrupt the data structure. • Modeling a linked list? next listener next listener next listener next listener Use arrays in Promela. bool next[4]; bool listener[4]; int tail = -1; int head = -1; H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 42 / 44
  • 45. Problem P2 proctype addListener() { if :: head==-1 -> head = 0; next[head]=true; listener[head] = true; tail = head; :: else -> tail = tail+1; next[tail] = true; listener[tail] = true; fi } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 43 / 44
  • 46. Problem P2 init { next[0] = false; next[1] = false; next[2] = false; next[3] = false; listener[0] = false; listener[1] = false; listener[2] = false; listener[3] = false; atomic { run addListener(); run addListener(); run addListener(); run addListener(); }; (_nr_pr==1) -> assert(listener[0] && ... && listener[3]); } H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 44 / 44