1 Introduction

Cyber physical systems (CPS) refer to large-scale interconnected control and communication systems that incorporate physical and computing components at various levels. Real-time decision making is the defining characteristic of cyber physical systems such that it does not only mean responding to soft and hard deadlines but also making decisions in a timely manner based on an ongoing interaction between the system and environment. The design of CPS often involves heterogeneous components that operate on different temporal scales and the correct operation requires a high level of coordination and cooperation among such components. Overall the design results in very complex artifacts to verify the correctness and evaluate the performance. Therefore, we usually resort to conventional simulation and model based testing methods for the analysis of CPS. Current research efforts include developing fast, scalable, and versatile runtime verification techniques and tools that handle complex timing requirements of CPS and provide an additional level of rigor and effectiveness over conventional testing methods.

Metric Temporal Logic (MTL) [6] is a popular formalism to specify temporal properties with timing constraints over the behavior of cyber physical systems. Several existing runtime verification (RV) tools support MTL as their specification and employ different techniques and algorithms to monitor MTL formulas over temporal behaviors (traces) [1, 2, 7,8,9]. From any MTL monitoring tool, we typically expect a linear-time performance in both the length of the trace and the size of the formula. Furthermore, the insensitivity to the base time unit and numeric time values in formulas is a very much desired feature for MTL monitoring tools. This becomes especially crucial for CPS applications since we usually have to use small and large numerical constants in the same formula when specifying timing requirements of components that operate on different timescales. Hence, in this paper, we present Timescales benchmark generator, which can be used to evaluate the performance and scalability of MTL monitoring tools. In particular, Timescales generates temporal behaviors for a predefined set of MTL formulas with parameterized timing constraints. We consider the past and future fragments of MTL separately and our benchmarks consist of one trace file in the comma-separated values (CSVFootnote 1) format and two (past and future) specification files in the YAMLFootnote 2 format. Besides we provide ANTLRFootnote 3 grammar files to parse our MTL formulas. These file formats are widely supported and their implementations are already available for many programming languages.

Timescales is essentially developed to help measure the typical performance of MTL monitoring tools. Therefore, we, first and foremost, consider the most common types of timed properties encountered in real system designs. Such typical properties have been studied in the papers [4, 5], which employs the template system developed by Dwyer et al. for untimed specifications [3]. In this template system, a property consists of (1) a pattern, which describes what must be observed, and (2) a scope, which describes the temporal extent of the pattern. Each property further contains one or two timing parameters, which can be controlled by the user. In Timescales, we support a total of 10 typical timed properties over 4 pattern (absence, universality, recurrence, response) and 4 temporal scopes (before, after, between, globally) for the benchmark generation. Then, the tool generates a discrete time behavior that satisfy the property for a given property, duration, and values of timing parameters. We also provide an option to generate dense time behaviors where the maximum density is controlled by the user. Since we usually want to generate a collection of benchmarks by varying all these parameters over a grid, we include some example scripts to generate such benchmark suites with some predefined values.

The structure of this paper is as follows. Section 2 overviews the syntax and semantics of MTL as used in this paper. In Sect. 3, we describe supported timed properties and corresponding MTL formulas for the benchmark generation. Section 4 explains the benchmark generation generally and gives further details about the implementation including trace generation, output formats, and default benchmark suites generated by Timescales.

2 Metric Temporal Logic

Metric Temporal Logic (MTL) [6] is an extension of linear temporal logic (LTL) in which temporal operators are endowed with timing constraints. In this paper, we interpret MTL formulas over a bounded discrete time domain \(\mathbb {T} = [1, N]\) of total duration N and use so-called non-strict (reflexive) semantics of temporal operators, timed since (\(\mathcal {S}_{I}\)) and timed until (\(\mathcal {U}_{I}\)). Given a finite set P of atomic propositions, the formulas of MTL are defined by the following grammar:

$$\begin{aligned} \varphi \ =\ p \ |\ \lnot \, \varphi \ |\ \varphi _{1} \vee \varphi _{2}\ |\ \varphi _{1}\, \mathcal {S}_{I}\, \varphi _{2}\ |\ \varphi _{1}\, \mathcal {U}_{I}\, \varphi _{2} \end{aligned}$$

where \(p\in P\) and \(I \subseteq [0, \infty )\). Then the satisfaction relation \((w, t) \vDash \varphi \) indicates that the Boolean temporal behavior \(w : \mathbb {T} \rightarrow \mathbb {B}^{P}\) satisfies the formula \(\varphi \) at the time point \(t \in \mathbb {T}\) as follows.

figure a

where we use \(w_p : \mathbb {T} \rightarrow \mathbb {B}\) to denote the projection of w onto its component p. Other timed modalities include time constrained variants of sometime in the past (\(\blacklozenge _{I}\)) and always in the past (\(\blacksquare _{I}\)) as well as sometime in the future (\(\lozenge _{I}\)) and always in the future (\(\square _{I}\)). For any temporal operator, we usually omit the time bound if there is no constraint and call such an operator untimed. The past fragment of MTL, or past MTL in short, is defined as a restriction of MTL without the until operator. Similarly we do not use the since operator in the future fragment. In this paper, we write MTL formulas either in the past or future fragment of MTL.

3 Supported Properties

This section overviews supported timed properties in Timescales. By default a single benchmark consists of a logical formula that capture the property either in the past or future fragment of MTL and a temporal behavior that satisfies the formula. We select 10 typical timed properties for the benchmark generation and we cover in these properties all types of temporal operators and different types of intervals for timing constraints. Each timed property is parameterized with one or two timing parameters in order to generate benchmarks with different timing characteristics. Note that we do not claim or seek the logical equivalence between the past and future MTL formulas in the following but capture the intention in both fragments.

Bounded Absence After Q. This property has one timing parameter u. Intuitively it means that it is always the case that the event P does not occur at least for U time units after the event Q occurs. We capture this property by the formula

figure b

in the past fragment of MTL and by the formula

figure c

in the future fragment of MTL.

Bounded Absence Before R. This property has one timing parameter u. Intuitively it means that it is always the case that the event P does not occur at least for u time units before the event R occurs. We capture this property by the formula

figure d

in the past fragment of MTL and by the formula

figure e

in the future fragment of MTL.

Bounded Absence Between Q and R. This property has two timing parameters l and u. Intuitively it means that it is always the case that the event P does not occur between events Q and R and the duration between Q and R is in l and u time units. We capture this property by the formula

figure f

in the past fragment of MTL and by the formula

figure g

in the future fragment of MTL.

Bounded Universality After Q. This property has one timing parameter u. Intuitively it means that it is always the case that the event P always occurs at least for u time units after the event Q occurs. We capture this property by the formula

figure h

in the past fragment of MTL and by the formula

figure i

in the future fragment of MTL.

Bounded Universality Before R. This property has one timing parameter u. Intuitively it means that it is always the case that the event P always occurs at least for u time units before the event R occurs. We capture this property by the formula

figure j

in the past fragment of MTL and by the formula

figure k

in the future fragment of MTL.

Bounded Universality Between Q and R. This property has two timing parameters l and u. Intuitively it means that it is always the case that the event P always occurs between events Q and R and the duration between Q and R is in l and u time units. We capture this property by the formula

figure l

in the past fragment of MTL and by the formula

figure m

in the future fragment of MTL.

Bounded Recurrence Globally. This property has one timing parameter u. Intuitively it means that it is always the case that the event P occurs at least for every u time units. We capture this property by the formula

figure n

in the past fragment of MTL and by the formula

figure o

in the future fragment of MTL.

Bounded Recurrence Between Q and R. This property has one timing parameter u. Intuitively it means that it is always the case that the event P occurs at least for every u time units between events Q and R. We capture this property by the formula

figure p

in the past fragment of MTL and by the formula

figure q

in the future fragment of MTL.

Bounded Response Globally. This property has two timing parameters l and u. Intuitively it means that it is always the case that the event S responds to the event P in l and u time units. We capture this property by the formula

figure r

in the past fragment of MTL and by the formula

figure s

in the future fragment of MTL.

Bounded Response Between Q and R. This property has two timing parameters l and u. Intuitively it means that it is always the case that the event S responds to the event P in l and u time units between events Q and R. We capture this property by the formula

figure t

in the past fragment of MTL and by the formula

figure u

in the future fragment of MTL.

4 Implementation

Timescales is an open source command line programFootnote 4 written in Python. For example, using Timescales, we generate a benchmark for the property bounded universality property between Q and R by executing the command

figure v

where the argument specifies the duration of trace and arguments lbound and ubound specify the value for lower and upper timing parameters of the property, respectively. Then Timescales produces a concrete specification file, which contains an MTL formula, as a standard YAML file and a trace as a standard CSV file. These output formats are simple human-readable text files and very well supported in virtually all major programming languages. In the following, we give further details on the trace generation, output formats, and default benchmark suites.

4.1 Trace Generation

Given a timed property and parameter values, Timescales generate a temporal behavior in a periodic fashion where each period contains a sequence of propositional values that satisfies the property. For each period, we randomly determine actual timings of the sequence according to timing constraints specified by --lbound and --ubound arguments. Consequently, the duration of each period varies accordingly and we terminate the generation process once we exceed the total duration specified by the argument --duration. For example, suppose we want to generate a trace for the property always_bqr for \(l=300\) and \(u=600\). We start each period with a time point where Q holds and end with a time point where R holds. Then the actual number of time points where P holds between Q and R is randomly selected between 300 and 600. We repeat this procedure as many times as needed.

Fig. 1.
figure 1

Timescales command line interface

For benchmark generation, the command line interface of Timescales provides a few more customization options as shown in Fig. 1. First, properties that contain some kind of recurrence have additional parameters to specify the minimum and maximum number of recurrence inside a single period. By the arguments --min-recur and --max-recur, we can specify a range and actual number of recurrences is randomly selected to be within this range. Secondly, generated temporal behaviors may involve the repetition of the same value over long periods called stuttering periods. We provide an option to condense such behaviors by omitting a time point in the trace file if the next time point also has the same value. By the argument --condense, we can control the amount of condensation, which caps the duration of such omitted periods. Choosing a large value (such as larger than the total duration) would eliminate any stuttering in the trace file while choosing zero means there would be no condensation and the trace file explicitly includes every time point. Finally, we provide another option to append a sequence that makes the property fail at the end of the trace. This trick often serves a sanity check for that the monitoring algorithm does actually find an error (thus not silently fails) during the benchmarking. The option --failing-end enables this behavior.

4.2 Output Formats

Timescales produces a specification file in the standard YAML format and a temporal behavior in the standard CSV format as its output. These are simple human-readable text files and several implementations to read and write these formats already exist in virtually all major programming languages. Hence, Timescales can be used directly for RV tools that support these formats or else requires little implementation effort for the rest.

Fig. 2.
figure 2

(Top) An example specification file generated for the property with timing values 300 and 600. (Bottom Left) An example discrete time behavior in CSV format. (Bottom Middle) A dense time behavior with limited 10. (Bottom Right) A dense time behavior with limited 100. Note that whitespaces in CSVs are for the aesthetics.

At the top of Fig. 2, we show an example specification file that we have generated using Timescales. The name attribute indicates the name of property, which can be overwritten via the command line, and the spec attribute denotes the actual MTL formula. We provide our MTL grammar as an ANTLR grammar file so that an ANTLR parser can be automatically generated to parse our MTL formulas. The bottom row of Fig. 2 demonstrates three example CSV files generated using Timescales. The leftmost CSV file contains a row of propositional values for each time point in the time domain and represents a discrete time behavior. The CSV file show a condensed trace where some time points are omitted in the file if the next time has the same value of propositions. Finally the rightmost CSV is generated with the option --condense 100 and therefore the duration of time jumps in the file is capped by 100 time units.

4.3 Default Benchmark Suites

In the source code distribution, we also include a Makefile script to generate three predefined sets of benchmarks named as small, large, and full suites using the generator. First, the small suite is intended for initial testing and demonstration purposes. It contains one benchmark for each supported property (10 in total) with small timing bounds over short traces with a duration of 1000 time units. Secondly, the large suite targets discrete time MTL monitoring tools and contains three benchmarks for each property (30 in total) with increasingly larger time bounds (1\(\times \), 10\(\times \), and 100\(\times \)) over traces with a duration of one million time units. These numbers are often sufficient to check whether a runtime verification tool scales towards large time bounds in the specification. The total size of the large suite is about 400 MB and not included in the distribution. Finally, the full suite extends the large suite by varying the length of generated traces (10K, 100K, 1M) and the amount of condensation (1, 10, 100). These benchmarks can be used to check the scalability of the tool with respect to the trace length as well as compare discrete and dense time implementations if the tool supports both settings.

5 Conclusion

In this paper, we presented Timescales benchmark generator to help testing the performance and scalability of MTL monitoring tools over the most common types of timed properties encountered in real designs. In particular, we have been interested in checking such tools when the specification contains large values of timing constraints and ideally expect that large timing constraints do not deteriorate the performance. This is especially important in runtime verification of cyber-physical systems, which involves various cooperating components operating in different timescales. Hence, our main motivation has been to generate benchmarks of the same property with the varying timing constraints and measuring the performance of the tool over them. In our tool, we have considered 10 typical properties for the benchmark generation and provided various customization options, which can be accessed easily via the command line interface. We adhered standard file formats for the implementation and tried to conform current practices in runtime verification as much as possible.