Towards the Modular Specification and Validation of Cyber-Physical Systems

Cyber-Physical Systems (CPS) are systems controlled by one or more computer-based components tightly integrated with a set of physical components, typically described as sensors and actuators, that can either be directly attached to the computer components, or at a remote location, and accessible through a network connection. The modeling and verification of such systems is a hard task and error prone that require rigorous techniques. Hybrid automata is a formalism that extends finite-state automata with continuous behavior, described by ordinary differential equations. This paper uses a rewriting logic-based technique to model and validate CPS, thus exploring the use of a formal technique to develop such systems that combines expressive specification with efficient state-based analysis. Moreover, we aim at the modular specification of such systems such that each CPS component is independently specified and the final system emerges as the synchronous product of its constituent components. We model CPSs using Linear Hybrid Automaton and implement them in Real-Time Maude, a rewriting logic tool for real-time systems. With this method, we develop a specification for the n-reservoir problem, a CPS that controls a hose to fill a number of reservoirs according to the physical properties of the hose and the reservoirs.



page 1

page 2

page 3

page 4


A Rewriting Framework for Cyber-Physical Systems

The analysis of cyber-physical systems (CPS) is challenging due to the l...

A Passive Online Technique for Learning Hybrid Automata from Input/Output Traces

Specification synthesis is the process of deriving a model from the inpu...

Sampling of Shape Expressions

Cyber-physical systems (CPS) are increasingly becoming driven by data, u...

Specification description and verification of multitask hybrid systems in the OTS/CafeOBJ method

To develop IoT and/or CSP systems, we need consider both continuous data...

Towards Physical Hybrid Systems

Some hybrid systems models are unsafe for mathematically correct but phy...

Mining Environment Assumptions for Cyber-Physical System Models

Many complex cyber-physical systems can be modeled as heterogeneous comp...

From English to Signal Temporal Logic

Formal methods provide very powerful tools and techniques for the design...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Cyber-Physical Systems (CPS) [2] are ever present in our daily life. They can be intuitively described as systems that are controlled by one or more computer based components tightly integrated with a set physical components, typically described as sensors and actuators that can either be directly attached to the computer components, or at a remote location and accessible through a network connection.

Most CPS have to cope with design requirements that are imposed onto them by their multiple applications in the real world. Typically a CPS has to be specified and tested against environments that require the system to:

  • operate in real-time,

  • realize reactive computations,

  • leverage concurrent and distributed processing,

  • deal with synchronization issues.

In  [2], one of the major books on CPS in a vast (e.g.  [3, 15, 10, 27, 26, 24, 4, 17]) literature on the subject, Alur describes how Linear Hybrid Automata (LHA) can be used for modeling CPS. In this context, the -reservoirs problem [17], a text-book problem on dynamic systems where a control system needs to decide to which of two tanks a hose needs to be moved given the reservoirs and hose’s physical characteristics, is a CPS and therefore can be modeled as a LHA. In this paper we generalize this problem to an arbitrary number of reservoirs, each with their individual physical characteristics, and by adding latency to hose dislocation. We model and analyze both the standard problem description and the generalized version using Rewriting Logic [19], an expressive formalism for the specification and verification of concurrent and distributed systems [22]. Moreover, we specify the -reservoir system modularly as the synchronous product [5] of its constituent components.

This paper contribution is manifold : (i) a precise definition of the synchronous product of real-time rewrite systems, extending [18], (ii) a model of the -reservoir problem as an LHA, (iii) how to describe a CPS as a LHA in Rewriting Logic by representing its components, sensors, actuators and controllers, as mathematical tuples denoting objects that communicate asynchronously, (iv) a modular specification of the -reservoir system, based on (i), and (v) its implementation and model checking in Real-Time Maude (RTM) [21], a Rewriting Logic tool designed for the formal specification and analysis of real-time and hybrid systems. This is a first-step in the development of a formal method and its tooling to modularly specify and verify Cyber-Physical Systems based on its Rewriting Logic semantics of the associated Linear Hybrid Automata.

The remainder of this paper is organized as follows. Section 2 describes foundational requirements related to LHA and RTM. In Section 3, we discuss our prototype implementation of the reservoir problem in RTM. Section 4 presents the synchronous product of rewrite systems and its extension to real-time, together with the modular specification of the -reservoir problem. Section 5 describes related work. Section 6 concludes this paper describing the insights and future research based on our findings.

2 Preliminaries

In oder to develop the implementation of the -reservoirs problem and its model check through the use of Linear Hybrid Automaton and Real-Time Maude an understanding of what they are is required. This section provides a basic introduction of these topics.

2.1 Linear Hybrid Automaton (LHA)

A LHA is a Finite State Machine that is associated with a finite set of variables that are described by ordinary differential equations (ODE). To guarantee that the solutions of the differential equation are well defined, we assume that the ODE are Lipschitz continuous [17]. Moreover, these differential equations are such that any test and attribution within the model of the LHA are affine, that is, a linear equation of the form where is a comparison operation that can be one of and an attribution is in the form and are integer or real constants.

A LHA HP consists of:

  1. An asynchronous process P, where some of its state variables can be of type cont, and appear only in affine tests and affine assignments in the guards and updates of the tasks of P;

  2. A continuous-time invariant CI, which is a Boolean expression over the state variables S, where the variables are continuous (that is, of type cont) and appear only in affine tests;

  3. A rate constraint RC, which is a Boolean expression over the discrete state variables and the derivatives of the continuously updated state variables that appear only in affine tests.

Inputs, outputs, states, initial states, internal actions, input actions, and output actions of the LHA HP are the same as that of the asynchronous process P. Given a state s and a real-valued time , is a timed action of HP

, for a rate vector

r consisting of a constant for every continuously updated variable if:

  1. The expression RC is satisfied for every continuously updated variable , the derivative is assigned the value and every discrete variable is assigned the value ;

  2. The state satisfies the expression CI for all values .

As such, a LHA can be represented as an extended state machine as shown in Figure 1, where the Initial Variables represent the starting values of all constants and discrete variables in the LHA; State(), , represents one of the many states in LHA together with tests and assignments that occur while the system is evolving in time while not changing state; the arrow with a test and attribution represents the boolean test that needs to be satisfied for the transition between one state and another to happen, alongside any changes that must be assigned to LHA variables.

Figure 1: Simple extended state machine diagram of a LHA

2.2 Real-time rewrite systems and Real-Time Maude

A Rewriting Logic theory is essentially a triple where is a typed (or sorted) signature (many sorted, order-sorted or membership equational, that is, Rewriting Logic is parameterized by a choice of equational logic), is a set of -equations and is a set of -rules where the terms being rewritten are those in the initial -algebra identified by -equations .

A real-time rewrite theory is a tuple  [23], where: (i) contains an equational subtheory , satisfying the TIME axioms that specifies sort Time as the time domain (which can be discrete or dense) and is a built-in constructor of sort GlobalSystem. The rules in are decomposed into: (i) instantaneous rewrite rules, that do not act on the system as a whole, but only on some system components, and (ii) tick rules that model the elapse of time in a system, having the form , where and are terms of sort System, is a term of sort Time denoting the duration of the rewrite. Given a real-time rewrite theory , a computation is a non-extensible sequence (that is, one for which cannot be further rewritten) or an infinite sequence of one-step -rewrites , with and ground terms, starting with a given initial term of sort System.

Maude [14] is a system/language that implements concurrent systems through the use of equations and rewrite rules specified in one or more modules. Maude itself has been extended through Full Maude, which is fully written in Maude itself, to add several features to the system/language. These features include, but are not limited to, object-oriented modules, module parameterization, and -tuple declaration.

Real-Time Maude (RTM) is an extension of Full Maude that includes the requirements and tooling to model and check real-time systems. The time evolution is achieved through tick rules that determine the effects of time in the system. As such, RTM allows for a very granular control over how a system can evolve both in time and instantaneously by means of two classes of rewrite rules that specify either timed or discrete transitions. Although a timed module is parametric on the time domain, Real-Time Maude provides some predefined modules specifying useful time domains. For example, the modules NAT-TIME-DOMAIN-WITH-INF and POSRAT-TIME-DOMAIN-WITH-INF define the time domain to be, respectively, the natural numbers and the nonnegative rational numbers, and contain the subsort declarations Nat < Time and Pos-Rat < Time. In Real-Time Maude, tick rules, together with their durations, are specified using the syntax crl [l] : {t} => {t’} in time u if condition.

Essentially, an RTM specification representing a hybrid automaton , with the set of states of , the set of timed transitions, and the set of discrete transitions, is given by a structure where the equational specification specifies the set of states of the hybrid automaton , is the set of -timed rewrite rules representing transitions in , and the set of -discrete rewrite rules representing transitions in .

We describe RTM specification language in Section 3, by example, while describing the implementation of the -reservoir problem.

3 The reservoir problem in RTM

The -reservoir problem was presented by John Lygeros et al. in [17]. The problem has been fully defined in that work, alongside its differential equations and its LHA.

Succinctly, the problem has as a pair of reservoirs that are flowing water out of the system at a constant rate. Water is added to the system through a hose that has a constant intake rate. The hose can be moved from one reservoir to the other instantaneously. There is a control system that is designed to make sure that the water level in each reservoir does not fall below a predefined level. This can be seen in Figure 2.

Figure 2: -reservoirs Diagram [17]

The LHA of the -reservoirs problem is described in Figure 3, where: is the water level at the reservoir (that is time dependent), is the flow of water out of the reservoir , is the state of the system with the hose filling reservoir , and is the hose’s water flow rate.

Figure 3: -reservoir LHA Diagram

The generalized -reservoir problem

is the extension of the -reservoirs problem where the system has a finite non-predetermined number of reservoirs, each with its own individual physical characteristics. In this new structure, the control system has to make the decision to which reservoir it will move the hose to when multiple reservoirs are potentially below the minimum water level threshold.

Although the differential equations of each individual reservoir stay the same, the total number of continuous variables that are tracked by the system scales with the size of the instance ( continuous variables). Additionally, the number of states in the LHA grows with the number of reservoirs as well ( states). Similarly, the problem will have a considerably larger number of state transitions. These extra states and transitions force the control system to cope with a more complex decision process to choose where to move the hose at any specific point in time ( transitions).

We are now ready to inspect how the reservoirs problems can be implemented in RTM with LHA in place and a clear understanding of the differences between the simple (with reservoirs) and the generalized versions of the reservoir problem.

3.1 The -reservoir problem in RTM

The states of the hybrid automaton modeling the -reservoir problem is defined in RTM through a triple where denotes the hose position (either on the right or left reservoir) and is the set of positive rational numbers denoting the height of the water column for each reservoir.

The triple and constants can be defined through the code below where keywords op and ops declare operations for the left and right position of the hose, the system configuration (that is, the triple ) and constants for the hose flow rate , each reservoir flow rate , and the water level on each reservoir , with , and NNegRat is the sort for , respectively.

1ops left right : -> Hose [ctor] .
2op _‘,_‘,_ : Hose NNegRat NNegRat -> System [ctor] .
3ops w v1 v2 r1 r2 : -> NNegRat .
Listing 1: Signature for the states of the -reservoir hybrid automaton

The movement of the hose can be represented by rules that change the system configuration. Rule moveright moves the hose from left to right, while moveleft goes the other way around. The rules are triggered when the water level of the proper reservoir reaches the minimum acceptable level.

1crl [moveright] : left,x1,x2 => right,x1,x2 if x2 <= r2 .
2crl [moveleft] : right,x1,x2 => left,x1,x2 if x1 <= r1 .

The last step is to create the rules specifying how water levels change in time, the so called tick rules. The water levels increase in linear time by and decreases, also in linear time, by .

1crl [tick-right] :
2  {right, x1, x2} => {right, x1 - (v1 * R), x2 + ((w - v2) * R)} in time R
3if x1 > r1 [nonexec] .
5crl [tick-left] :
6  {left, x1, x2} => {left, x1 + ((w - v1) * R), x2 - (v2 * R)} in time R
7if x2 > r2 [nonexec] .

The evolution in time does not happen when the water level of the reservoir with the hose is above the water threshold and the second reservoir is below or at its water threshold. Without this restriction, the system can evolve to undesired configurations where it keeps filing a reservoir that is above minimum threshold while letting the other reservoir dry out.

3.2 The -reservoir problem in RTM

The implementation of the -reservoir problem requires a dynamic structure to accommodate the run-time defined reservoir count. For that we leverage Maude’s sets to create a System configuration made of a hose and each individual reservoir as shown below.

In this structure we have a hose element that has an in-take rate of units per time unit and it is positioned on top of reservoir . The hose is followed by multiple structures in the form 0 thr: (15, 50), hth: 30, rte: 5 that represent a single reservoir with its unique identifier, the upper and lower water thresholds, the current water level and the constant flow of water out of the reservoir.

The hose is defined by:

1op hose : NNegRat Nat -> Hose [format(m! o)] .

A single reservoir, logically defined as N List of attributes , can be coded as:

1op <_|_> : Nat ReservoirAttributes -> Reservoir [ctor format(b! o b! o b! o)] .
2op _‘,_ : ReservoirAttributes ReservoirAttributes -> ReservoirAttributes [ctor assoc comm] .

Then the reservoir attributes are defined.

1op thr: : NNegRat NNegRat -> ReservoirAttribute [ctor format(b! o)] .
2*** Water Level
3op hth:_ : NNegRat -> ReservoirAttribute [ctor format(b! o b!)] .
4*** Leak Rate
5op rte:_ : NNegRat -> ReservoirAttribute [ctor format(b! o b!)] .

The whole system is put together by concatenating a Hose and as many reservoirs as desired.

1op __ : System System -> System [ctor assoc comm] .

Keep in mind that in Maude, computations are identified with rewritings. One of the distinguished features of Maude is to implement rewriting modulo axioms, such as associativity and commutativity. Thus the use of definition of many assoc and comm in the operators definition.

The next step is to define functions - done through operators in Maude - to fill and drain the reservoirs alongside tests to validate that the evolution in time can occur. First, a function to add water to the reservoir that the hose is currently pointing to:

1vars N M : Nat .
2vars L U Ln Un Lm Um Xn Xm Dn Dm W : NNegRat .
3var T : Time . var S : System .
4vars RA RAn RAm : ReservoirAttributes .
6op fill : Reservoir NNegRat NNegRat -> Reservoir .
7eq fill(< N | thr: (L, U) , hth: Xn , rte: Dn >, W, T) =
8  < N | thr: (L, U), hth: (Xn + ((W - Dn) * T)), rte: Dn > .

Next, a function that drains water from all reservoirs:

1eq drain(< N | thr: (L, U), hth: Xn, rte: Dn >, T) =
2  < N | thr: (L, U), hth: sd(Xn,(Dn * T)), rte: Dn > .
3eq drain(< N | thr: (L, U), hth: Xn, rte: Dn > S, T) =
4  < N | thr: (L, U), hth: sd(Xn,(Dn * T)), rte: Dn > drain(S, T) .

and a test to identify if there is a reservoir that needs refill:

1ceq refill?(< N | thr: (L, U), hth: Xn, RAn >) = true if Xn <= L .
2ceq refill?(< N | thr: (L, U), hth: Xn, RAn > S) = true if Xn <= L .
3eq refill?(S) = false [owise] .

Next, the rules to control the movement of the hose and the evolution in time must be defined. A single rule is capable of moving the hose from a reservoir above the lower threshold to one that is below the lower threshold. If there is no reservoir below the lower threshold, or the current reservoir is below the threshold, the hose stays in the same place.

1  hose(W, N) < N | thr: (Ln, Un), hth: Xn, RAn >
2  < M | thr: (Lm, Um), hth: Xm, RAm > S =>
3  hose(W, M) < N | thr: (Ln, Un), hth: Xn, RAn >
4  < M | thr: (Lm, Um), hth: Xm, RAm > S
5if (Xm <= Lm) and (N =/= M) and (Xn >= Ln) .

In rule move-hose, the configuration hose(10, 0) 0 thr: (15, 50), hth: 40, rte: 5 1 thr: (15, 50), hth: 15, rte: 5 changes to configuration hose(10, 1) 0 thr: (15, 50), hth: 40, rte: 5 1 thr: (15, 50), hth: 15, rte: 5 as the reservoir hth attribute value is less or equal to the lower threshold defined in the thr attribute.

Once the system is in a configuration with no reservoir below the lower threshold or if there is at least one reservoir that needs water and the hose is placed on one of them, the system can evolve in time.

1  {hose(W, N) fill(< N | RAn >, W, T) drain(S, T)} in time T
2if not refill?(S) [nonexec] .

In this rule, the system hose(10, 1) 0 thr: (15, 50), hth: 40, rte: 5 1 thr: (15, 50), hth: 15, rte: 5 can evolve to hose(10, 1) 0 thr: (15, 50), hth: 30, rte: 5 1 thr: (15, 50), hth: 20, rte: 5 while the system hose(10, 0) 0 thr: (15, 50), hth: 40, rte: 5 1 thr: (15, 50), hth: 15, rte: 5 is not eligible to evolve in time because there is a reservoir below the lower threshold, and the hose is on a reservoir above the threshold.

Maude offers techniques to search for states that are reachable from the initial states and match a given search pattern. To demonstrate this property, we search the first six steps of the system evolution starting with initial state given by 0 hth: 30, rte: 5, thr:(15,50) 1 hth: 30, rte: 5, thr:(15, 50) 2 hth: 30, rte: 5, thr:(15,50).

1  {init2} =>* {S:System}
2in time < 5 and with mode default time increase 1 :
4Solution 1
5S:System –> < 0 | hth: 30,rte: 5,thr:(15,50)> < 1 | hth: 30,rte: 5,thr:(15,
6    50)> < 2 | hth: 30,rte: 5,thr:(15,50)> hose(10,0); TIME_ELAPSED:Time –> 0
8Solution 2
9S:System –> < 0 | hth: 35,rte: 5,thr:(15,50)> < 1 | hth: 25,rte: 5,thr:(15,
10    50)> < 2 | hth: 25,rte: 5,thr:(15,50)> hose(10,0); TIME_ELAPSED:Time –> 1
12Solution 3
13S:System –> < 0 | hth: 40,rte: 5,thr:(15,50)> < 1 | hth: 20,rte: 5,thr:(15,
14    50)> < 2 | hth: 20,rte: 5,thr:(15,50)> hose(10,0); TIME_ELAPSED:Time –> 2
16Solution 4
17S:System –> < 0 | hth: 45,rte: 5,thr:(15,50)> < 1 | hth: 15,rte: 5,thr:(15,
18    50)> < 2 | hth: 15,rte: 5,thr:(15,50)> hose(10,0); TIME_ELAPSED:Time –> 3
20Solution 5
21S:System –> < 0 | hth: 45,rte: 5,thr:(15,50)> < 1 | hth: 15,rte: 5,thr:(15,
22    50)> < 2 | hth: 15,rte: 5,thr:(15,50)> hose(10,1); TIME_ELAPSED:Time –> 3
24Solution 6
25S:System –> < 0 | hth: 45,rte: 5,thr:(15,50)> < 1 | hth: 15,rte: 5,thr:(15,
26    50)> < 2 | hth: 15,rte: 5,thr:(15,50)> hose(10,2); TIME_ELAPSED:Time –> 3
28No more solutions

Next, in order to estimate RTM’s efficiency when executing in entry-level computer devices, we executed a search looking for a specific system configuration from the

init2 configuration.

1  {init2} =>* {< 0 | hth: 45,RA0:ReservoirAttributes > < 1 | hth: 10,
2    RA1:ReservoirAttributes > < 2 | hth: 10,RA2:ReservoirAttributes >}
3in time < 100 and with mode default time increase 1 :
5No solution

In order to make sure we looked through the full state space, a state that the system will not reach was selected, and as Table 1 demonstrates the whole process took ms of processing and executed over rewritings to accomplish the task.

Test Time (in ms) Rewrites Rewrites/second
Table 1: Evaluation of Search Technique in Maude

3.3 Model Checking

An RTM specification induces a timed automaton. Standard Maude model checking techniques may be applied to validate timed Linear Temporal Logic formula over a given timed automaton. This is achieved in RTM through a module extension that includes the TIMED-MODEL-CHECK module into the reservoir problems implemented.

With the TIMED-MODEL-CHECK in a new RTM module, it is possible to verify if the system evolves to a point where it has reservoirs that are below the lower water threshold, and need the hose to be moved to - as a temporal logic: , where one-down represents the event of at least one reservoir below the lower water threshold. The second test executed verified if, at any point in time, all reservoirs need are below the lower treshold - as a temporal logic proposition: , where macondo represents the event of all reservoirs reaching the lower threshold at any point in time.

If the system is well-formed - where - the checker should not find a state where all reservoirs reach their low threshold or their upper threshold. During the execution of such system up to reservoirs could cross below the low threshold. This behavior is achieved after the model check execution. It can not find a solution where all reservoirs fall below the lower threshold; and it produces a counter example when asked if we can identify a state where the the water of a least one reservoir drops to or below the lower threshold.

1  5 with mode default time increase 1
2Result Bool :
3  true
5Model check{init2}  |=t[]~ <> one-down in TEST in time < 5
6  with mode default time increase 1
7Result ModelCheckResult :
8  counterexample(
9  {{  < 0 | hth: 30,rte: 5,thr:(15,50)> < 1 | hth: 30,rte: 5,thr:(15,50)>
10        < 2 | hth: 30,rte: 5,thr:(15,50)> hose(10,0)} in time 0,’tick}
11    {{  < 0 | hth: 35,rte: 5,thr:(15,50)> < 1 | hth: 25,rte: 5,thr:(15,50)>
12        < 2 | hth: 25,rte: 5,thr:(15,50)> hose(10,0)} intime 1,’tick}
13    {{  < 0 | hth: 40,rte: 5,thr:(15,50)> < 1 | hth: 20,rte: 5,thr:(15,50)>
14        < 2 | hth: 20,rte: 5,thr:(15,50)> hose(10,0)} in time 2,’tick}
15    {{  < 0 | hth: 45,rte: 5,thr:(15,50)> < 1 | hth: 15,rte: 5,thr:(15,50)>
16        < 2 | hth: 15,rte: 5,thr:(15,50)> hose(10,0)} in time 3,’move-hose}
17    ,{{ < 0 | hth: 45,rte: 5,thr:(15,50)> < 1 | hth: 15,rte: 5,thr:(15,50)>
18        < 2 | hth: 15,rte: 5,thr:(15,50)> hose(10,1)} in time 3,’move-hose}
19    {{  < 0 | hth: 45,rte: 5,thr:(15,50)> < 1 | hth: 15,rte: 5,thr:(15,50)>
20        < 2 | hth: 15,rte: 5,thr:(15,50)> hose(10,2)} in time 3,’move-hose})

Table 2 demonstrates the amount of time required to complete the model checking of the safety and liveness requirements for the system using the init2 configuration, with both proofs computed under 100 ms in an entry level x86 system, this indicates how efficient the rewriting system in RTM is at running these LTL based model-checks.

Test Time (in ms) Rewrites Rewrites/second
Table 2: Model checking Evaluation

The RTM code for both the -reservoir and the -reservoir modules and the model checking can be retrieved from

3.4 Preliminary Analysis of LHA and RTM for CPS Design

A criteria to review a CPS design process has to turn the CPS characteristics into key metrics in its evaluation. The control logic should be embedded in the specification itself. The same should apply for sensors and actuators. Considering that reactive computing and synchronization are intrinsic characteristics of a CPS, the computing model process must naturally support and handle them. Moreover, the time dependency of the differential equations are a constant that has to be managed by the formalization process in order to generate a precise model that represents the physical processes managed by the CPS.

The RTM code used in both variations of the reservoir problem is elegant. It follows a very logical and straight forward principle that satisfies the statements above. Implementing the LHA from figure 3 does not pose a challenge in RTM. The model check tools provided by RTM proved to be straight forward once the tests have been formalized in temporal logic.

However, the choice of using LHA as the formalization tool imposes a limitation. A LHA is limited to problems that falls into ordinary differential equations in respect to time. Additionally, it must only use affine tests and attributions. Although many problems that translate into a CPS can fit this model, there are problems that do not fit these requirements.

4 The synchronous product of rewrite systems and real-time rewrite systems

The synchronous product of two systems is a procedure to compose such systems such that they evolve simultaneously if they synchronize in a given step. A key concept in the synchronous product is the compatibility relation, denoted by . Two states, and , synchronize on a given action if they are compatible, that is, iff for each property (or atomic proposition) shared by both states holds in iff holds in .

In [18], the authors specify that given two rewrite systems , for , their synchronous product, denoted , is a new rewrite system as follows, (i) , where denotes the disjoint union of two ets, contains, among other declarations, (a) a declaration for the operator R.|= : R.State R.Prop R.Bool, where notation R.Sort, or R.op, denotes sort Sort, or operation op, from rewrite system R; (b) a declaration for the predicate R. : R.State R.State R.Bool. (ii) , where contains, among other declarations: (a) equations to reduce to true; (iii) ; (iv) is composed of the following set of rules: (a) for each rule label that exists in both systems, say , we have in the conditional rule , with constructor denoting the product state; (b) for each rule label that exists in but not in , say , we have in the conditional rule (with a variable of sort R.State); (c) correspondingly for rule labels in but not in .

Now in this paper we propose that given two real-time rewrite systems with instantaneous rewrite rules and tick rules , with the same subequational theory for TIME, the synchronized real-time system has each individual component composed as above but each tick rule in requires its left-hand side and right-hand side to be -compatible, that is, each in relate product states that are compatible using the rules in . Therefore, a (possibly infinite, Zeno) computation in the synchronized real-time system has a step such that the product state is reached from after a computation composed by -compatible untimed transitions, that is, transitions resulting from the application of rules in where each state in the computation is compatible with its predecessor.

In what follows, we specify (a simplified version) of a modular -reservoir problem using the synchronous product extension of Full-Maude available in (An extension of Real-Time Maude with real-time synchronous product as described above is under development.) In Listing 2 we specify the behavior of a reservoir as a component whose state is either below (its fluid threshold) or ok. Whenever the clock ticks, modeled by rule labeled tick, the reservoir (actually, all of them as they will synchronize with this action) may change its state from ok to below. And by (re)filling it, it may change from below to ok. State predicate refill1? is true when the state of the reservoir is below.

1(mod RESERVOIR1 is
2   including SATISFACTION .   declares State, Prop, and |=.
3   ops below ok : -> State [ctor] .
4   rl [tick] : ok => below .
5   rl [fill1] : below => ok .
6   op refill1? : -> Prop .
7   eq below |= refill1? = true .
8   eq ok |= refill1? = false .
Listing 2: Modular specification of a reservoir

Now, the -reservoir system is given by the synchronous product of reservoirs and , as declared in Listing 3 by the statement pr RESERVOIR1 || RESERVOIR2 .. Module 2-RESERVOIR-SYSTEM also declares a state proposition specifying that the -reservoir system is safe if reservoirs and are not in state below at the same time.

3   op safe : -> Prop [ctor] .
4   eq S:State |= safe = not (S:State |= refill1? and S:State |= refill2?) .
Listing 3: The -reservoir system as the product of reservoirs

We may now model check this specification and prove that it is not the case that the system is always safe starting from state < ok, ok > where both reservoirs are above their thresholds. A counter-example is produced showing the infinite loop < ok,ok > < below,below > < below,ok > < ok,ok > .

3   inc MODEL-CHECKER * (sort State to Conf) .
5   subsort Conf < State .
6   op init : -> State .
7   eq init = < ok, ok > .
10(red modelCheck(init, [] safe) .)
12  modelCheck(init,[]safe)
13result [ModelCheckResult] :
14  counterexample({< ok,ok >,’tick},{< below,below >,’fill2}{< below,ok >,
15    fill1}{< ok,ok >,’tick})
Listing 4: Model checking the -reservoir as a synchronous product

5 Related work

Even though CPS are not a new concept, to this day an optimal set of formalisms, languages and tools are not properly defined. In David Broman et al. [9] describe an extensive list of formal methods, languages and tools that can be combined to let an entity specify, design, develop and test a CPS.

Some problems were approached through the eyes of the Model checking methodology to verify the safety properties. Akella and McMillin [1] modeled a CPS as a Security Process Algebra. They used model checker, CoPs, to check the confidentially properties. Bu et al.[10] analyzed CPS aspects using a statistical model checker. Highlight that in this approach the state space explosion also occurs like in classical model checking problems.

Zhang et al. [27] present a model to verify the safety properties in mobile CPS based on a SAT-based model checking algorithm. The system was modeled as a Petri net and presented a lower memory consumption.

A combined model checking and a new version of PALS (physically asynchronous, logically synchronous) were applied to verified an airplane turning control system in [6] and [7]. Bae et al. [7] also present other applications as a networked thermostat controllers and networked water tank controllers with gravity component .

This paper takes advantage of one possible set of such techniques to model (LHA), develop (Maude) and model check (Maude) the leaking reservoir problem specified in [17]. Additional formalisms that are capable of modeling the reservoir problem are presented in [9]. Some examples are: Differential Equations, additional State Machines model beyond LHA, Dataflow, Discrete Events. Each of these methods can be used alongside a plethora of tools and languages to develop and model check phases of a CPS.

Each formalism technique is going to favor a set of tools and languages when development moves to the next phase. The LHA approach used in this paper favors a model check approach such as Maude. Of course other checkers such as SAL [20], Spin [16], NuSMV [13] and UPPAAL [8] are viable options for the design process of a LHA based CPS. For an approach based on Discrete Event techniques, the language and tools would most likely been based on Hard Description Languages based on VHDL like Verilog [25] or AMS with added extensions [12]. Meanwhile, a DataFlow based approach is more likely to leverage a language like Lustre [11]. Each bringing their own set advantages and limitations, making it even harder to create consensus on a standardized end-to-to process to specify, validate and develop a CPS.

This situation highlights the toughest aspect of CPS design and implementation. Depending on the context of the project sponsors, their perspective can influence the formalism path adopted and push the project toward one of another set of languages and tools. This is an area of CPS design that could be improved through increased availability of references that provide a study case of such methods applied to the same problem, and provide a qualitative and quantitative comparison of the results of each individual implementation. Such works seem to be at a preliminary stage at this point in time.

6 Conclusion

This work presents a first step in creating a formal model to modularly specify and model check CPS by precisely describing the concept of modular CPS modeling and illustrating it with a case study on how to model a CPS as a LHA and effectively implement it in RTM. It creates succinct code to simulate and model check the problem in this study scope.

We are currently developing an extension of RTM to support the notion of synchronous product of real-time systems as described in this paper. Our results are encouraging, as illustrated in this paper.

There are also opens further questions, which require further studies in terms of creating more precise models for the leaking reservoir models and other types of automata that can be used as starting point for CPS modeling alongside their respective implementation in RTM.


This work was developed with the support of CAPES - Coordenação de Aperfeiçoamento de Pessoal de Nível Superior (Coordination for Enhancement of Higher Education Personnel, in Brazil) and FAPERJ - Fundação de Amparo a Pesquisa do Rio de Janeiro.


  • [1] R. Akella and B. McMillin. Model-cheking bndc properties in cyber-physical systems. In Proceedings of the 33rd Annual IEEE International Computer Software and Applications Conference COMPSAC 09, pages 660–663. IEEE, 2009.
  • [2] R. Alur. Principles of Cyber-Physical Systems. The Mit Press, 2015.
  • [3] R. Alur, C. Courcoubetis, T. A. Henzinger, and P. H. Ho. Hybrid automata: An algorithmic approach to the specification and verification of hybrid systems. In R. L. Grossman, A. Nerode, A. P. Ravn, and H. Rischel, editors, Hybrid Systems, pages 209–229, Berlin, Heidelberg, 1993. Springer Berlin Heidelberg.
  • [4] R. Alur and D. L. Dill. A theory of timed automata. Theoretical Computer Science, 126(2):183 – 235, 1994.
  • [5] A. Arnold. Finite Transition Systems: Semantics of Communicating Systems. Prentice Hall International (UK) Ltd., Hertfordshire, UK, UK, 1994.
  • [6] K. Bae, J. Krisiloff, J. Meseguer, and P. Ölveczky. Designing and verifying distributed cyber-physical systems using multirate pals: An airplane turning control system case study. Science of Computer Programming, 2015.
  • [7] K. Bae, P. Ölveczky, S. Kong, S. Gao, and E. M. Clarke. Smt-based analysis of virtually synchronous distributed hybrid systems. In Proceedings of the 19th International Conference on Hybrid Systems: Computation and Control, HSCC ’16, pages 145–154, New York, NY, USA, 2016. ACM.
  • [8] K. Bengtsson, J.and Larsen, F. Larsson, P. Pettersson, and W. Yi. Upaal: a tool suite for automatic verification of real-time systems. Proccedings of the 4th DIMACS Workshop on Verification and Control of Hybrid Systems, 1995.
  • [9] D. Broman, E. Lee, S. Tripakis, and M. Torngren. Viewpoints, formalisms, languages, and tools for cyber-physical systems. Proceedings of the 6th International Workshop on Multi-Paradigm Modeling Page 49-54, 2012.
  • [10] L. Bu, Q. Wang, and X. a. Chen. Toward online hybrid systems model checking of cyber-physical systems time-bounded short-run behavior. ACM SIGBED Review, 8:7–10, 2011.
  • [11] P. Caspi, D. Pilaud, N. Halbwachs, and J. A. Plaice. Lustre: A declarative language for real-time programming. Proceedings of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages ser. POPL ’87, pp. 178-188, 1987.
  • [12] E. Christen and K. Bakalar. Vhdl-ams-a hardware description language for analog and mixed-signal applications. Circuits and Systems II: Analog and Digital Signal Processing, IEEE Transactions on [see also Circuits and Systems II: Express Briefs, IEEE Transactions on] Volume 46, Issue 10, pp. 1263 - 1272., 1999.
  • [13] A. Cimatti, E. Clarke, E. Giunchiglia, F. Giunchiglia, M. Pistore, M. Roveri, R. Sebastiani, and A. Tacchella. Nusmv 2: An opensource tool for symbolic model checking. Computer Aided Verification. CAV 2002. Lecture Notes in Computer Science, vol 2404, 2002.
  • [14] M. Clavel, F. Durán, S. Eker, S. Escobar, P. Lincoln, N. Martí-Oliet, J. Meseguer, and C. Talcott. Maude Manual (Version 2.7.1). SRI International, 2016.
  • [15] T. A. Henzinger. The Theory of Hybrid Automata, pages 265–292. Springer Berlin Heidelberg, Berlin, Heidelberg, 2000.
  • [16] G. Holzmann. Spin model checker, the: primer and reference manual. Addison-Wesley Professional, 2003.
  • [17] J. Lygeros, C. Tomlin, and S. Sastry. Hybrid Systems: Modeling, Analysis and Control. University of California, 2008.
  • [18] Ó. Martín, A. Verdejo, and N. Martí-Oliet. Synchronous products of rewrite systems. In C. Artho, A. Legay, and D. Peled, editors, Automated Technology for Verification and Analysis, pages 141–156, Cham, 2016. Springer Publishing.
  • [19] J. Meseguer. Conditional rewriting logic as a unified model of concurrency. Theoretical Computer Science, 96(1):73 – 155, 1992.
  • [20] L. Moura, S. Owre, and N. Shankar. The SAL Language Manual. SRI International, 2003.
  • [21] P. Ölveczky. Real-Time Maude 2.3 Manual. University of Oslo,, 2007.
  • [22] P. Ölveczky. Designing Reliable Distributed Systems: A Formal Methods Approach Based on Executable Modeling in Maude. Undergraduate Topics in Computer Science. Springer London, 2018.
  • [23] P. C. Ölveczky and J. Meseguer. Specification of real-time and hybrid systems in rewriting logic. Theor. Comput. Sci., 285(2):359–405, 2002.
  • [24] Q. Shafi. Cyber physical systems security: A brief survey. In 12th International Conference on Computational Science and Its Applications (ICCSA), pages 146–150, Salvador, Brazil, 2012. IEEE.
  • [25] D. Smith. Vhdl and verilog compared and contrasted-plus modeled example written in vhdl, verilog and c. Design Automation Conference Proceedings 1996, 33rd, 1996.
  • [26] W. Thomas. Handbook of theoretical computer science (vol. b). chapter Automata on Infinite Objects, pages 133–191. MIT Press, Cambridge, MA, USA, 1990.
  • [27] L. Zhang, W. Hu, W. Qu, Y. Guo, and S. Li. A formal approach to verify parameterized protocols in mobile cyber-physical systems. Mobile Information Systems, 2017.