Verification and Parameter Synthesis for Real-Time Programs using Refinement of Trace Abstraction111A preliminary version of this work appeared in [13].
Abstract
We address the safety verification and synthesis problems for real-time systems. We introduce real-time programs that are made of instructions that can perform assignments to discrete and real-valued variables. They are general enough to capture interesting classes of timed systems such as timed automata, stopwatch automata, time(d) Petri nets and hybrid automata. We propose a semi-algorithm using refinement of trace abstractions to solve both the reachability verification problem and the parameter synthesis problem for real-time programs. All of the algorithms proposed have been implemented and we have conducted a series of experiments, comparing the performance of our new approach to state-of-the-art tools in classical reachability, robustness analysis and parameter synthesis for timed systems. We show that our new method provides solutions to problems which are unsolvable by the current state-of-the-art tools.
1 Introduction
Model-checking is a widely used formal method to assist in verifying software systems. A wide range of model-checking techniques and tools are available and there are numerous successful applications in the safety-critical industry and the hardware industry – in addition the approach is seeing an increasing adoption in the general software engineering community. The main limitation of this formal verification technique is the so-called state explosion problem. Abstraction refinement techniques were introduced to overcome this problem. The most well-known technique is probably the Counter Example Guided Abstraction Refinement (CEGAR) method pioneered by Clarke et al. [19]. In this method the state space is abstracted with predicates on the concrete values of the program variables. The (counter-example guided) trace abstraction refinement (TAR) method was proposed later by Heizmann et al. [26, 27] and is based on abstracting the set of traces of a program rather than the set of states. These two techniques have been widely used in the context of software verification. Their effectiveness and versatility in verifying qualitative (or functional) properties of C programs is reflected in the most recent Software Verification competition results [8].
Analysis of timed systems.
Reasoning about quantitative properties of programs requires extended modeling features like real-time clocks. Timed Automata [2] (TA), introduced by Alur and Dill in 1989, is a very popular formalism to model real-time systems with dense-time clocks. Efficient symbolic model-checking techniques for TA are implemented in the real-time model-checker Uppaal [5]. Extending TA, e.g., with the ability to stop and resume clocks (stopwatches), leads to undecidability of the reachability problem [14, 29] which is the basic verification problem. As a result, semi-algorithms have been designed to verify extended classes of TA e.g., hybrid automata, and are implemented in a number of dedicated tools [23, 25, 28]. However, a common difficulty with the analysis of quantitative properties of timed automata and extensions thereof is that specialized data-structures are needed for each extension and each type of problem. As a consequence, the analysis tools have special-purpose efficient algorithms and data-structures suited and optimized only towards their specific problem and extension.
In this work we aim to provide a uniform solution to the analysis of timed systems by designing a generic semi-algorithm to analyze real-time programs which semantically captures a wide range of specification formalisms, including hybrid automata. We demonstrate that our new method provides solutions to problems which are unsolvable by the current state-of-the-art tools. We also show that our technique can be extended to solve specific problems like robustness and parameter synthesis.
Related work.
The trace abstraction refinement (TAR) technique was proposed by Heizmann et al. [26, 27]. Wang et al. [35] proposed the use of TAR for the analysis of timed automata. However, their approach is based on the computation of the standard zones which comes with usual limitations: it is not applicable to extensions of TA (e.g., stopwatch automata) and can only discover predicates that are zones. Moreover, their approach has not been implemented and it is not clear whether it can outperform state-of-the-art techniques e.g., as implemented in Uppaal.
Several works have investigated CEGAR techniques in both timed and hybrid settings [1, 21, 24, 34]. The CEGAR technique has also been extended to parameter-synthesis [24]. As proved by Heizmann et al. [26], such methods are special cases of the TAR framework.
The IC3 [10] verification approach has also been deployed for the verification of hybrid systems [9] but relies on a fix-point computation over a combined encoding of the transition-function, rather than a trace-subtraction approach. IC3 approaches and the likes have also been used for parameter synthesis [7, 9, 18]. While similar fundamental techniques are leveraged in these approaches (e.g. [7] utilizes Fourier-Motzkin-elimination), we note that our refinement method (TAR) is radically different in nature. IC3 is an iterative fix-point computation over an up-front and complete encoding of the transition-function.
Since the publication of a preliminary version of this paper [13], Kafle et al. [31] have demonstrated a novel method of parameter synthesis for timed systems via Constrained Horn Clauses (CHC). While their approach shows promising results for the Fischers parameter synthesis examples from [13], it currently relies on manual translation of a given problem into CHC format, hindering its applicability to large systems.
As mentioned earlier, our technique allows for a unique and logical (predicates) representation of sets of states accross different models (timed, hybrid automata) and problems (reachability, robustness, parameter synthesis), which is in contrast to state-of-the-art tools such as Uppaal [5], SpaceEx [25], HyTech [28], PHAver [23], verifix [32], symrob [33] and Imitator [3] that rely on special-purpose polyhedra libraries to realize their computation.
We propose a new technique which is radically different to previous approaches and leverages the power of SMT-solvers to discover non-trivial invariants for a large class of real-time systems including the class of hybrid automata. All the previous analysis techniques compute, reduce and check the state-space either up-front or on-the-fly, leading to the construction of significant parts of the state-space. In contrast our approach is an abstraction refinement method and the refinements are built by discovering non-trivial program invariants that are not always expressible using zones, or polyehdra. For instance they can express constraints that combine discrete and continuous variables of the system. This enables us to use our algorithm on non-decidable classes like stopwatch automata, and successfully (i.e., the algorithm terminates) check instances of these classes. A simple example is discussed in Section 2.
Our contribution.
We propose a variant of the trace abstractions refinement (TAR) technique to solve the reachability problem and the parameter synthesis problem for real-time programs. Our approach combines an automata-theoretic framework and state-of-the-art Satisfiability Modulo Theory (SMT) techniques for discovering program invariants. We demonstrate on a number of case-studies that this new approach can compute answers to problems unsolvable by special-purpose tools and algorithms in their respective domain.
2 Motivations
Real-Time Programs.
Figure 1 is an example of a real-time program . It is defined by a finite automaton (Figure 1, top) which is the control flow graph (CFG) of , and some continuous and discrete instructions (bottom). The control flow graph accepts the regular language : the program starts in (control) location and is completed when (accepting location) is reached. The program variables are which are real numbers. This real-time program is the specification of a stopwatch automaton with 2 clocks, and , and one stopwatch . The variables are updated according to the following rules:
-
•
Each edge’s label defines a guard (a condition on the variables) for which the edge is enabled, and an update which is an assignment to the variables when the edge is taken. For instance the edge can be taken when the valuation of the variable is and when it is taken, is reset. This corresponds to a discrete transition of the program.
-
•
Each location is associated with a rate vector that defines the derivatives of the variables. The default derivative for a variable is (we omit the rates for in the Figure). For instance in location the derivatives are (order is ). When the program is in location the variables increase at a rate defined by their respective derivatives: increase by each time unit, and is frozen (derivative is ). This corresponds to a continuous transition of the program.
A sequence of program instructions defines a (possibly empty) set of timed words, , of the form where is the time elapsed between two discrete transitions. For instance, the timed words associated with are of the form , for all such that the following constraints (predicates that define that each transition can be fired after time units) can be satisfied222We assume the program starts in and all the variables are initially zero.:
() | ||||
() | ||||
() |
These constraints encode the following semantics: is taken after time units and at that time are equal to and hence are the values of the variables when location is entered. The program remains in for time units. When is taken after time units, the values of is given by . Finally the program remains time units in and is taken to reach which is the end of the program. It follows that the program can execute (or in other words, is feasible) if and only if we can find such that is satisfiable. Hence the set of timed words associated with is not empty iff is satisfiable.
Language Emptiness Problem.
The timed language, , accepted by is the set of timed words associated with all the (untimed) words accepted by i.e., .
The language emptiness problem is a standard problem in Timed Automata theory [2] and is stated as follows for real-time programs:
given a real-time program , is empty?
It is known that the emptiness problem is decidable for some classes of real-time programs like Timed Automata [2], but undecidable for more expressive classes like Stopwatch Automata [29]. It is usually possible to compute symbolic representations of sets of reachable valuations after a sequence of transitions. However, to compute the set of reachable valuations we may need to explore an arbitrary and unbounded number of sequences. Hence only semi-algorithms exist to compute the set of reachable valuations. For instance, using PHAver to compute the set of reachable valuations for does not terminate (Table 1). To force termination, we can compute an over-approximation of the set of reachable valuations. Computing an over-approximation is sound (if we declare an over-approximation of a timed language to be empty the timed language is empty) but incomplete i.e., it may result in false positives (we declare a timed language non empty whereas it is empty). This is witnessed by the column “Uppaal” in Table 1 where Uppaal over-approximates sets of valuations in the program using DBMs. After , the over-approximation is (this is the smallest DBMs that contains the actual set of valuations reachable after ). This over-approximation intersects the guard of which enables . Using this over-approximate set of valuations we would declare that is reachable in but this is an artifact of the over-approximation.333Uppaal terminates with the result “the language may not be empty”. Neither Uppaal nor PHAver can prove that .
Sequence | PHAver | Uppaal |
… | … | … |
… | … | … |
Trace Abstraction Refinement for Real-Time Programs.
The technique we introduce can discover arbitrary abstractions and invariants that enable us to prove . Our method is a version of the trace abstraction refinement (TAR) technique introduced in [26] and is depicted in Figure 2.
Let us first introduce how the trace abstraction refinement algorithm (Figure 2) operates on a real-time program :
-
1.
the algorithm starts using the control flow graph of , , and initially .
-
2.
if then is empty and the algorithm terminates (green block).
-
3.
otherwise, there is . We check whether is empty or not:
-
•
If it is not empty then is not empty and the algorithm terminates (red block).
-
•
Otherwise, we can find444How this language is built is defined in Section 4. a regular language over the alphabet of , , that satisfies: 1) and 2) , . In the next iteration of the algorithm, we look for a candidate trace in , i.e., we refine the trace abstraction by subtracting from it.
-
•
Assume the algorithm terminates after iterations. In this case we were able to build a finite number of regular languages such that . If we terminate with then . Otherwise if we terminate with we found a witness trace such that i.e., a feasible timed trace.
Example 1: Stopwatch Automaton.
We illustrate the algorithm using our program :
-
•
we initially let . Since and thus the check fails. We therefore check whether which can be done by encoding the corresponding set of timed traces as described by Equations ()–() and then check whether is satisfiable (e.g., using an SMT-solver and the theory of Linear Real Arithmetic). is not satisfiable and this establishes .
-
•
from the proof that is not satisfiable, we can obtain an inductive interpolant that comprises of two predicates – one for each conjunction – over the variables . An example of an inductive interpolant555This is the pair returned by Z3 for . is and . These predicates are invariants of any timed word of the untimed word , and can be used to annotate the sequence of transitions with pre- and post-conditions (Equation 1), which are Hoare triples of the form :
(1) A triple is valid if whenever we start in a state satisfying , and execute instruction , the resulting new state is in . means that no state exists after executing from , i.e., the trace is infeasible. The inductiveness of the interpolants is due to the fact that each triple in the sequence (1) is a valid Hoare triple. Hoare triples (and validity) generalise to sequences of instructions in the form .
Because we can also prove that is a valid Hoare triple, if we combine this fact with Equation 1 we obtain a regular set of traces annotated with pre/post-conditions as per Equation 2.
(2) This implies that the regular set of traces does not have any associated timed traces: for each word , and as we can conclude that .
Example 2: Extended Timed Automaton.
The following example (Figure 3) illustrates how extensions of timed automata with constraints that mix discrete and real variables can be analyzed. The real-time program (Figure 3) is given by the CFG (left) and the instructions666The rates table is omitted as all the variables are clocks with rate . (right): it specifies a timed automaton with clocks (real variables) and one integer variable .
This is an extended version of timed automata as the constraint mixes integer and real variables (clocks) and this is not permitted in the standard definition of timed automata. Initially all the variables are set to . The objective is to prove that location is unreachable and thus that . Note that Uppaal does allow this specification but is unable to prove that is unreachable because is unbounded.
Our method is able to discover invariants that mix integer and real variables and can prove that is unreachable as follows:
-
1.
the first iteration of the TAR algorithm starts with . The check is negative as . However every timed word in must satisfy the following constraints that correspond to taking and then :
() () is not satisfiable and hence and thus we can safely remove from . We can extract interpolants from the proof of unsatisfiability of and we establish the following sequence of valid Hoare triples:
(3) -
2.
the second iteration of the TAR algorithm starts with an updated . Again is not empty and for instance is in . The encoding for checking the emptiness of is:
() () () () is unsatisfiable and hence . We can extract interpolants from the proof of unsatisfiability and we establish the following sequence of valid Hoare triples.
(4) As can be seen as holds we can generalize this sequence to an arbitrary number of iterations of :
(5) which entails that . This implies that we can remove from .
-
3.
observe that in the next iteration of TAR as given that . We have thus proved that as any word of instructions in induces an infeasible trace and the algorithm terminates.
In the rest of the paper, we provide a formal development of the methods we have introduced so far.
3 Real-Time Programs
Our approach is general enough and applicable to a wide range of timed systems called real-time programs. As an example, timed, stopwatch, hybrid automata and time Petri nets are special cases of real-time programs.
In this section we formally define real-time programs. Real-time programs specify the control flow of instructions, just as standard imperative programs do. The instructions can update variables by assigning new values to them. Each instruction has a semantics and together with the control flow this precisely defines the semantics of real-time programs.
3.1 Notations
A finite automaton over an alphabet is a tuple where is a finite set of locations s.t. is the initial location, is a finite alphabet of actions, is a finite transition relation, is the set of accepting locations. A word is a finite sequence of letters from ; we let be the -th letter of , be the length of which is . Let be the empty word and , and let be the set of finite words over . The language, , accepted by is defined in the usual manner as the set of words that can lead to from .
Let be a finite set of real-valued variables. A valuation is a function . The set of valuations is .
We denote by the set of constraints (or Boolean predicates) over and given , we let be the set of unconstrained variables in . Given a valuation, we let the truth value of a constraint (Boolean predicate) be denoted by , and write when and let .
An update is a binary relation over valuations. Given an update and a set of valuations , we let . We let be the set of updates on the variables in .
Similar to the update relation, we define a rate function (rates can be negative), i.e., a function from a variable to a real number777We can allow rates to be arbitrary terms but in this paper we restrict to deterministic rates or bounded intervals.. A rate is then a vector . Given a valuation and a timestep the valuation is defined by: for .
3.2 Real-Time Instructions
Let be a countable set of instructions – and intentionally also the alphabet of the CFG. Each is a tuple denoted by . Let and be two valuations. For each pair we define the following transition relation :
The semantics of is a mapping and for
(6) |
It follows that:
Fact 1
.
This mapping can be straightforwardly extended to sets of valuations as follows:
(7) |
3.3 Post Operator
Let be a set of valuations and . We inductively define the (strongest) post operator as follows:
The post operator extends to logical constraints by defining . In the sequel, we assume that, when , then is also definable as a constraint in . This inductively implies that can also be expressed as a constraint in for sequences of instructions .
3.4 Timed Words and Feasible Words
A timed word (over alphabet ) is a finite sequence such that for each , and . The timed word is feasible if and only if there exists a set of valuations such that:
We let be the untimed version of . We extend the notion feasible to an untimed word : is feasible iff for some feasible timed word .
Lemma 1
An untimed word is feasible iff .
Proof 1
We prove this Lemma by induction on the length of . The induction hypothesis is:
which is enough to prove the Lemma.
Base step. If , then .
Inductive step. Assume . By induction hypothesis, , and . By definition of Post this implies that .
3.5 Real-Time Programs
The specification of a real-time program decouples the control (e.g., for Timed Automata, the locations) and the data (the clocks or integer variables). A real-time program is a pair where is a finite automaton over the alphabet888 can be infinite but we require the control-flow graph (transition relation) of to be finite. , defines the control-flow graph of the program and provides the semantics of each instruction.
A timed word is accepted by if and only if:
-
1.
is accepted by and,
-
2.
is feasible.
The timed language, , of a real-time program is the set of timed words accepted by , i.e., if and only if and is feasible.
Remark 1
We do not assume any particular values initially for the variables of a real-time program (the variables that appear in ). This is reflected by the definition of feasibility that only requires the existence of valuations without containing the initial one . When specifying a real-time program, initial values can be explicitly set by regular instructions at the beginning of the program. This is similar to standard programs where the first instructions can set the values of some variables.
3.6 Timed Language Emptiness Problem
The (timed) language emptiness problem asks the following:
Given a real-time program , is empty?
Theorem 1
iff such that .
Proof 2
iff there exists a feasible timed word such that is accepted by . This is equivalent to the existence of a feasible word , and by Lemma 1, feasibility of is equivalent to .
3.7 Useful Classes of Real-Time Programs
Timed Automata are a special case of real-time programs. The variables are called clocks. is restricted to constraints on individual clocks or difference constraints generated by the grammar:
(8) |
where , and 999 While difference constraints are strictly disallowed in most definitions of Timed Automata, the method we propose retain its properties regardless of their presence.. We note that wlog. we omit location invariants as for the language emptiness problem, these can be implemented as guards. An update in is defined by a set of clocks to be reset. Each pair is such that or for each . The valid rates are fixed to 1, and thus .
Stopwatch Automata can also be defined as a special case of real-time programs. As defined in [14], Stopwatch Automata are Timed Automata extended with stopwatches which are clocks that can be stopped. and are the same as for Timed Automata but the set of valid rates is defined by the functions of the form (the clock rates can be either or ). An example of a Stopwatch Automaton is given by the timed system in Figure 1.
As there exists syntactic translations (preserving timed languages or reachability) that map hybrid automata to stopwatch automata [14], and translations that map time Petri nets [6, 16] and extensions [12, 11] thereof to timed automata, it follows that time Petri nets and hybrid automata are also special cases of real-time programs. This shows that the method we present in the next section is applicable to a wide range of timed systems. What is remarkable as well, is that it is not restricted to timed systems that have a finite number of discrete states but can also accommodate infinite discrete state spaces. For example, the real-time program in Figure 3, page 3 has two clocks and and an unbounded integer variable . Even though is unbounded, our technique discovers the loop invariant of the and locations – an invariant is over a real-time clock and the integer variable . It allows us to prove that as the guard of never can be satisfied ().
4 Trace Abstraction Refinement for Real-Time Programs
In this section we give a formal description of a semi-algorithm to solve the language emptiness problem for real-time programs. The semi-algorithm is a version of the refinement of trace abstractions (TAR) approach [26] for timed systems.
4.1 Refinement of Trace Abstraction for Real-Time Programs
We have already introduced our algorithm in Figure 2, page 2. We now give a precise formulation of the TAR semi-algorithm for real-time programs, in Algorithm 1. It is essentially the same as the semi-algorithm as introduced in [26] – we therefore omit theorems of completeness and soundness as these will be equivalent to the theorems in [26] and are proved in the exact same manner.
The input to the semi-algorithm TAR-RT is a real-time program . An invariant of the semi-algorithm is that the refinement , which is subtracted to the initial set of traces, is either empty or containing infeasible traces only. In the coarsets, initial abstraction, all the words are potentially feasible. In each iteration of the algorithm, we then chip away infeasible behaviour (via the set ) of , making the set difference move closer to the set of feasible traces, thereby shrinking the overapproximation of feasible traces ().
Initially the refinement is the empty set. The semi-algorithm works as follows:
- Step 1
-
line 1, check whether all the (untimed) traces in are in . If this is the case, is empty and the semi-algorithm terminates (line 8). Otherwise (line 2), there is a sequence , goto Step 2;
- Step 2
-
if is feasible (line 3) i.e., there is a feasible timed word such that , then and and the semi-algorithm terminates (line 4). Otherwise is not feasible, goto Step 3;
- Step 3
-
is infeasible and given the reason for infeasibility we can construct (line 6) a finite interpolant automaton, , that accepts and other words that are infeasible for the same reason. How is computed is addressed in the sequel. The automaton is added (line 7) to the previous refinement and the semi-algorithm starts a new round at Step 1 (line 1).
In the next paragraphs we explain the main steps of the algorithms: how to check feasibility of a sequence of instructions and how to build .
4.2 Checking Feasibility
Given a arbitrary word , we can check whether is feasible by encoding the side-effects of each instruction in using linear arithmetic as demonstrated in Examples 1 and 2.
We now define a function Enc for constructing such a constraint-system characterizing the feasibility of a given trace. We first show how to encode the side-effects and feasibility of a single instruction . Recall that where the three components are respectively the guard, the update, and the rates. Assume that the variables101010The union of the variables in . in are . We can define the semantics of using the standard unprimed111111 denotes the vector of variables . and primed variables (). We assume that the guard and the updates can be defined by predicates and write with:
-
•
is the guard of the instruction,
-
•
a set of constraints in ,
-
•
defines the rates of the variables.
The effect of from a valuation , which is composed of 1) discrete step if the guard is true followed by the updates leading to a new valuation , and 2) continuous step i.e., time elapsing , leading to a new valuation , can be encoded as follows:
(9) |
Let be a set of valuations that can be defined as constraint in . It follows that is defined by:
(10) |
In other terms, is not empty iff is satisfiable.
We can now define the encoding of a sequence of instructions . Given a set of variables , we define the corresponding set of super-scripted variables . Instead of using we use super-scripted variables (and for the intermediate variables ) to encode the side-effect of each instruction in the trace:
It is straighgforward to prove that the function constructs a constraint-system characterizing exactly the feasibility of a word :
Fact 2
For each , iff is satisfiable.
If the terms we build are in a logic supported by SMT-solvers (e.g., Linear Real Arithmetic) we can automatically check satisfiability. If is satisfiable we can even collect some model which provides witness values for the . Otherwise, if is unsatisfiable, there are some options to collect some reasons for unsatisfiability: unsat cores or interpolants. The latter is discussed in the next section.
An example of an encoding for the real-time program (Figure 1) and the sequence is given by the predicates in Equation ()–(). Hence the sequence is feasible iff is satisfiable. Using a SMT-solver, e.g., with Z3, we can confirm that is unsatisfiable. The interpolating121212The interpolating feature of Z3 has been phased out from version 4.6.x. However, there are alternative techniques to obtain inductive interpolants e.g., using unsat cores [22]. solver Z3 can also generate a sequence of interpolants, and , that provide a general reason for unsatisfiability and satisfy:
We can use the interpolants to build interpolant automata as described in the next section.
4.3 Construction of Interpolant Automata
4.3.1 Inductive Interpolant
When it is determined that a trace is infeasible, we can easily discard such a single trace and continue searching for a different one. However, the power of the TAR method is to generalize the infeasibility of a single trace into a family (regular set) of traces. This regular set of infeasible traces is computed from a reason of infeasibility of and is formally specified by an interpolant automaton, . The reason for infeasibility itself can be the predicates obtained by computing strongest post-conditions or weakest-preconditions or anything in between but it must be an inductive interpolant131313Strongest post-conditions and weakest pre-conditions can provide inductive interpolants.
Given a conjunctive formula , if is unsatisfiable, an inductive interpolant is a sequence of predicates s.t:
-
•
,
-
•
,
-
•
For each , , and the variables in appear in both and i.e., .
If the predicates encode the side effects of a sequence of instructions , then one can intuitively think of each interpolant as a sufficient condition for infeasibility of the post-fix of the trace and this can be represented by a sequence of valid Hoare triples of the form :
Consider the real-time program of Figure 3 and the two infeasible untimed words and . Some inductive interpolants for and can be given by: , for and , , , for . From the inductive interpolants one can obtain valid Hoare triples by de-indexing the predicates in the inductive interpolants141414This is a direct result of the encoding function Enc. The interpolants can only contain at most one version of each indexed variables. as shown in Equations 11-12:
(11) | ||||
(12) |
where is the same as where each indexed variable replaced by . As can be seen in Equation 12, the sequence contains two occurrences of : this suggests that a loop occurs in the program, and this loop may be infeasible as well. Formally, because , any trace of the form is infeasible. This enables us to construct an interpolant automaton accepting the regular set of infeasible traces . Overall, because is also infeasible, the union of the languages accepted by and is a set of infeasible traces as defined by the finite automaton in Figure 4.
Given such that is unsatisfiable we can always find an inductive interpolant: the strongest post-conditions or (the weakest pre-conditions from ) defines an inductive interpolant. More generally, we have:
Lemma 2
Let . If is unsatisfiable and is an inductive interpolant for , the following sequence of Hoare triples
is valid.
Proof 3
The proof follows from the encoding and the fact that each is included in the weakest pre-condition which can be proved by induction using the property of inductive interpolants.
4.3.2 Interpolant Automata
Let us formalize the interpolant-automata construction. Let , and assume i.e., is unsatisfiable (Fact 2).
Let be an inductive interpolant for . We can construct an interpolant automaton for , as follows:
-
•
, (note that if two de-indexed interpolants are the same they account for one state only),
-
•
,
-
•
,
-
•
satisfies following conditions:
-
1.
,
-
2.
,
-
3.
, if then .
-
1.
Notice that as the word itself is accepted by and is never empty.
Theorem 2 (Interpolant Automata)
Let be an infeasible word over , then for all , is infeasible.
Proof 4
This proof is essentially the same as the original one in [26]. The proof uses rule 3 in the construction of : every word accepted by goes through a sequence of states that form a sequence of valid Hoare triples and end up in . It follows that if , .
4.4 Union of Interpolant Automata
In the TAR algorithm we construct interpolant automata at each iteration and the current refinement is the union of the regular languages for each infeasible . The union can be computed using standard automata-theoretic operations. This assumes that we somehow forget the predicates associated with each state of an interpolant automaton.
In this section we introduce a new technique to re-use the information computed in each and obtain larger refinements.
Let be a finite automaton such that each is a predicate in . We say that is sound if the transition relation satisfies: implies that (or ).
Let be a sound finite automaton that accepts only infeasible traces. Let with infeasible. The automaton built as described in section 4.3 is sound. We can define an extended union, of and with:
It is easy to see that but also:
Theorem 3
Let . Then .
Proof 5
Each transition in corresponds to a valid Hoare triple. It is either in or and then is valid by construction or it is weaker than an established Hoare triple in or .
This theorem allows us to use the operator in Algorithm 1 instead of the standard union of regular languages. The advantage is that we re-use already established Hoare triples to build a larger refinement at each iteration.
4.5 Feasibility Beyond Timed Automata
Satisfiability can be checked with an SMT-solver (and decision procedures exist for useful theories). In the case of timed automata and stopwatch automata, the feasibility of a trace can be encoded in linear arithmetic. The corresponding theory, Linear Real Arithmetic (LRA) is decidable and supported by most SMT-solvers. It is also possible to encode non-linear constraints (non-linear guards and assignments). In the latter cases, the SMT-solver may not be able to provide an answer to the SAT problem as non-linear theories are undecidable. However, we can still build on a semi-decision procedure of the SMT-solver, and if it provides an answer, get the status of a trace (feasible or not).
4.6 Sufficient Conditions for Termination
Let us now construct a set of criteria on a real-time program s.t. our proposed method is guaranteed to terminate.
Lemma 3
Termination The algorithm presented in Figure 2 terminates if the following three conditions hold.
-
1.
For any word , then is expressible within a decidable theory (supported by the solver), and
-
2.
the statespace of has a finite representation, and
-
3.
the solver used returns interpolants within the finite statespace representation.
Proof 6
First consider the algorithm presented in Figure 2, then we can initially state that for each iteration of the loop grows and thus the NFA representing () must also. As per the construction presented in Section 4.4 we can observe that the transition-function of will increase by at least one in each iteration in Step 3. If not, the selection of between step 1 and step 2 is surely violated or the construction of ITA in step 3 is.
From Conditions 2 and 3 we have that the statespace is finitely representable and that these representatives are used by the solver. Thus we know that the interpolant automata also has a finite set of states as per the construction of Section 4.4. Together with the finiteness of the set of instructions, this implies that the transition-function of the interpolant automata must also be finite. Hence, the algorithm can (at most) introduce a transition between each pair of states with each instruction, but must at least introduce a new one in every iteration.
As this termination condition relies on the solver, it is heavily dependent on the construction of the solver. However, if we consider the class of real-time programs captured by Timed Automata, we know that condition 1 is satisfied (in fact it is Linear Real Arithmetic), condition 2 is satisfied via the region-graph construction. This leaves the construction of a solver satisfying condition 3, which in turn should be feasible already from condition 2, but is practically achievable for TA via extrapolation-techniques and difference bound matrices (or for systems with only non-strict guards; timed-darts or integer representatives).
5 Parameter Synthesis for Real-Time Programs
In this section we show how to use the trace abstraction refinement semi-algorithm presented in Section 4 to synthesize good initial values for some of the program variables, and to check robustness of timed automata. We first define the Maximal Safe Initial State problem and then show how to reduce parameter synthesis and robustness to special cases of this problem.
5.1 Maximal Safe Initial Set Problem
Given a real-time program , the objective is to determine a set of initial valuations such that, when we start the program in , is empty.
Given a constraint , we define the corresponding assume instruction by: . This instruction leaves all the variables unchanged (discrete update is the identity function and the rate vector is ) and this acts as a guard only.
Let be a real-time program and . We define the real-time program .
The maximal safe initial state problem asks the following:
Given a real-time program , find a maximal s.t. .
5.2 Semi-Algorithm for the Maximal Safe Initial State Problem
Let be a feasible word. It follows that must be satisfiable. We can define the set of initial values for which is satisfiable by projecting away all the variables in the encoding except the ones indexed by . Let be the resulting (existentially quantified) predicate and be the corresponding constraint on the program variables without indices. We let . It follows that is the maximal set of valuations for which is feasible. Note that existential quantification for the theory of Linear Real Arithmetic is within the theory via Fourier–Motzkin-elimination – hence the computation of by an SMT-solver only needs support for Linear Real Arithmetic when encodes a linear hybrid, stopwatch or timed automaton.151515This idea of using Fourier-Motzkin elimination has already been proposed [7] in the context of timed Petri nets.
The TAR-based semi-algorithm for the maximal safe initial state problem is presented in Figure 5.
The semi-algorithm in Figure 5 works as follows:
-
1.
initially
-
2.
using the semi-algorithm 1, check whether is empty
-
3.
if so does not accept any timed word when we start from ;
-
4.
Otherwise, there is a witness word , implying that is satisfiable. It follows that cannot be part of the maximal set. It is used to strengthen and repeating from step 2.
If the semi-algorithm terminates, it computes exactly the maximal set of values for which the system is safe (), captured formally by Theorem 4.
Theorem 4
If the semi-algorithm terminates and outputs , then:
-
1.
and
-
2.
for any , implies .
Proof 7
The fact that follows from termination.
The fact that is maximal is an invariant of the semi-algorithm: at the beginning, and is clearly maximal. At each iteration, we may subtract a set of valuations from the previously computed , but these valuations are all such that for any by definition of existential quantification.
Hence every time a set of valuations is removed by strengthening only unsafe initial valuations are removed. It follows that if safeInit terminates, is maximal.
5.3 Parameter Synthesis
Let be a real-time program over a set of variables such that: and . In words, variables in are constant variables. Note that they can appear in the guard .
The parameter synthesis problem asks the following:
Given a real-time program , find a maximal set s.t. .
The parameter synthesis problem is a special case of the maximal safe initial state problem. Indeed, solving the maximal safe initial state problem allows us to find the maximal set of parameters such that . Let be a solution161616For now assume there is a unique maximal solution. to the maximal safe initial state problem. Then is a maximal set of parameter values such that .
5.4 Robustness Checking
Another remarkable feature of our technique is that it can readily be used to check robustness of real-time programs and hence timed automata. In essence, checking robustness amounts to enlarging the guards of a real-time program by an . The resulting program is .
The robustness problem asks the following:
Given a real-time program , is there some , s.t. .
Using our method we can solve the robustness synthesis problem which asks the following:
Given a real-time program , find a maximal , s.t. .
This problem asks for a witness (maximal) value for .
The robustness synthesis is a special case of the parameter synthesis problem where is a parameter of the program .
Note that in our experiments (next section), we assume that is robust and in this case we can compute a maximal value for . Proving that a program is non-robust requires proving feasibility of infinite traces for ever decreasing . We have developed some techniques (similar to proving termination for standard programs) to do so but this is still under development.
6 Experiments
We have conducted three sets of experiments, each testing the applicability of our proposed method (denoted by rttar) compared to state-of-the-art tools with specialized data-structures and algorithms for the given setting. All experiments were conducted on AMD EPYC 7551 Processors and limited to 1 hour of computation. The rttar tool uses the Uppaal parsing-library, but relies on Z3 [20] for the interpolant computation. Our experimental setup is available online [30].
6.1 Verification of Timed and Stopwatch Automata
The real-time programs, of Figure 1 and of Figure 3 can be analyzed with our technique. The analysis (rttar algorithm 1) terminates in two iterations for the program , a stopwatch automaton. As emphasized in the introduction, neither Uppaal (over-approximation with DBMs) nor PHAver can provide the correct answer to the reachability problem for .
To prove that location is unreachable in program requires to discover an invariant that mixes integers (discrete part of the state) and clocks (continuous part). Our technique successfully discovers the program invariants. As a result the refinement depicted in Figure 4 is constructed and as it contains the refinement algorithm RTTAR terminates and proves that is not reachable. can only be analyzed in Uppaal with significant computational effort and bounded integers.
6.2 Parametric Stopwatch Automata
We compare the rttar tool to Imitator [3] – the state-of-the-art parameter synthesis tool for reachability171717We compare with the EFSynth-algorithm in the Imitator tool as this yielded the lowest computation time in the two terminating instances.. We shall here use the semi-algorithm presented in Section 5 For the test-cases we use the gadget presented initially in Figure 1, a few of the test-cases used in [4], as well as two modified versions of Fischers Protocol, shown in Figure 6. In the first version we replace the constants in the model with parameters. In the second version (marked by robust), we wish to compute an expression, that given an arbitrary upper and lower bound yields the robustness of the system – in the same style as the experiments presented in Section 6.3, but here for arbitrary guard-values.
imitator-2.12 | rttar | |
---|---|---|
A1 | DNF | 0.08 |
Sched2.100.0 | 7.16 | 492.73 |
Sched2.50.0 | 4.95 | 273.36 |
fischer_2 | DNF | 0.26 |
fischer_2_robust | DNF | 0.25 |
fischer_4 | DNF | 47.96 |
fischer_4_robust | DNF | 50.26 |

As illustrated by Table 2 the performance of rttar is slower than Imitator when Imitator is able to compute the results. On the other hand, when using Imitator to verify our motivating example from Figure 1, we observe that Imitator never terminates, due to the divergence of the polyhedra-computation. This is the effect illustrated in Table 1.
When trying to synthesize the parameters for Fischers algorithm, in all cases, Imitator times out and never computes a result. For both two and four processes in Fischers algorithm, our tool detects that the system is safe if and only if . Notice that is a trivial constraint preventing the system from doing anything. The constraint is the only useful one. Our technique provides a formal proof that the algorithm is correct for .
In the same manner, our technique can compute the most general constraint ensuring that Fischers algorithm is robust. The result of rttar algorithm is that the system is robust iff – which for (modulo the initial non-zero constraint on ) reduces to the constraint-system obtained in the non-robust case.
6.3 Robustness of Timed Automata
To address the robustness problem for a real-time program , we use the semi-algorithm presented in Section 5 and reduce the robustness-checking problem to that of parameter-synthesis. Notice the delimitation of the input-problems to robust-only instances from Section 5.4.
rttar_robust | symrob | |||
---|---|---|---|---|
csma_05 | 32.38 | 1/3 |
0.51 | 1/3 |
csma_06 | 87.55 | 1/3 |
1.91 | 1/3 |
csma_07 | 294.30 | 1/3 |
7.37 | 1/3 |
fischer_04 | 17.64 | 1/2 |
0.19 | 1/2 |
fischer_05 | 102.50 | 1/2 |
0.77 | 1/2 |
fischer_06 | 519.41 | 1/2 |
2.83 | 1/2 |
M3 | 17.14 | N/A | N/A | |
M3c | 17.72 | 3.91 | 250/3 |
|
a | 3470.95 | 1/2 |
19.66 | 1/4 |
As Table 3 demonstrates, symrob [33] and rttar do not always agree on the results. Notably, since the TA M3 contains strict guards, symrob is unable to compute the robustness of it. Furthermore, symrob under-approximates , an artifact of the so-called “loop-acceleration”-technique and the polyhedra-based algorithm. This can be observed in the modified model M3c, which is now analyzable by symrob, but differs in results compared to rttar. This is the same case with the model denoted a. We experimented with -values to confirm that M3 is safe for all the values tested – while a is safe only for values tested respecting . We can also see that our proposed method is significantly slower than the special-purpose algorithms deployed by symrob, but in contrast to symrob, it computes the maximal set of good paramaters.
7 Conclusion
We have proposed a version of the trace abstraction refinement approach to real-time programs. We have demonstrated that our semi-algorithm can be used to solve the reachability problem for instances which are not solvable by state-of-the-art analysis tools.
Our algorithms can handle the general class of real-time programs that comprises of classical models for real-time systems including timed automata, stopwatch automata, hybrid automata and time(d) Petri nets.
As demonstrated in Section 6, our tool is capable of solving instances of reachability problems, robustness, parameter synthesis, that current tools are incapable of handling.
For future work we would like to improve the scalability of the proposed method, utilizing well known techniques such as extrapolations, partial order reduction [17] and compositional verification [15]. Another short-term improvement is to use unsat cores to compute interpolant automata as proposed in [22]. Furthermore, we would like to extend our approach from reachability to more expressive temporal logics.
Acknowledgments.
The research was partially funded by Innovation Fund Denmark center DiCyPS and ERC Advanced Grant LASSO. Furthermore, these results was made possible by an external stay partially funded by Otto Mønsted Fonden.
References
- [1] Rajeev Alur, Thao Dang, and Franjo Ivančić. Reachability analysis of hybrid systems via predicate abstraction. In Claire J. Tomlin and Mark R. Greenstreet, editors, Hybrid Systems: Computation and Control, pages 35–48, Berlin, Heidelberg, 2002. Springer Berlin Heidelberg.
- [2] Rajeev Alur and David L. Dill. A theory of timed automata. Theor. Comput. Sci., 126(2):183–235, April 1994.
- [3] Étienne André, Laurent Fribourg, Ulrich Kühne, and Romain Soulat. Imitator 2.5: A tool for analyzing robustness in scheduling problems. In Dimitra Giannakopoulou and Dominique Méry, editors, FM 2012: Formal Methods: 18th International Symposium, Paris, France, August 27-31, 2012. Proceedings, pages 33–36, Berlin, Heidelberg, 2012. Springer Berlin Heidelberg.
- [4] Étienne André, Giuseppe Lipari, Hoang Gia Nguyen, and Youcheng Sun. Reachability preservation based parameter synthesis for timed automata. In Klaus Havelund, Gerard Holzmann, and Rajeev Joshi, editors, NASA Formal Methods: 7th International Symposium, NFM 2015, Pasadena, CA, USA, April 27-29, 2015, Proceedings, pages 50–65, Cham, 2015. Springer International Publishing.
- [5] G. Behrmann, A. David, K.G. Larsen, J. Hakansson, P. Petterson, Wang Yi, and M. Hendriks. Uppaal 4.0. In QEST’06, pages 125–126, 2006.
- [6] Béatrice Bérard, Franck Cassez, Serge Haddad, Didier Lime, and Olivier H. Roux. Comparison of the expressiveness of timed automata and time petri nets. In Paul Pettersson and Wang Yi, editors, Formal Modeling and Analysis of Timed Systems, Third International Conference, FORMATS 2005, Uppsala, Sweden, September 26-28, 2005, Proceedings, volume 3829 of Lecture Notes in Computer Science, pages 211–225. Springer, 2005.
- [7] Béatrice Bérard and Laurent Fribourg. Reachability analysis of (timed) petri nets using real arithmetic. In Jos C. M. Baeten and Sjouke Mauw, editors, CONCUR’99 Concurrency Theory, pages 178–193, Berlin, Heidelberg, 1999. Springer Berlin Heidelberg.
- [8] Dirk Beyer, Marieke Huisman, Fabrice Kordon, and Bernhard Steffen, editors. Tools and Algorithms for the Construction and Analysis of Systems - 25 Years of TACAS: TOOLympics, Held as Part of ETAPS 2019, Prague, Czech Republic, April 6-11, 2019, Proceedings, Part III, volume 11429 of Lecture Notes in Computer Science. Springer, 2019.
- [9] Marco Bozzano, Alessandro Cimatti, Alberto Griggio, and Cristian Mattarei. Efficient anytime techniques for model-based safety analysis. In Daniel Kroening and Corina S. Păsăreanu, editors, Computer Aided Verification, pages 603–621, Cham, 2015. Springer International Publishing.
- [10] Aaron R. Bradley. Sat-based model checking without unrolling. In Ranjit Jhala and David Schmidt, editors, Verification, Model Checking, and Abstract Interpretation, pages 70–87, Berlin, Heidelberg, 2011. Springer Berlin Heidelberg.
- [11] J. Byg, M. Jacobsen, L. Jacobsen, K.Y. Jørgensen, M.H. Møller, and J. Srba. TCTL-preserving translations from timed-arc Petri nets to networks of timed automata. TCS, 2013. Available at http://dx.doi.org/10.1016/j.tcs.2013.07.011.
- [12] Béatrice Bérard, Franck Cassez, Serge Haddad, Didier Lime, and Olivier H. Roux. The expressive power of time Petri nets. Theoretical Computer Science, 474:1–20, 2013.
- [13] Franck Cassez, Peter Gjøl Jensen, and Kim Guldstrand Larsen. Refinement of trace abstraction for real-time programs. In Matthew Hague and Igor Potapov, editors, Reachability Problems, pages 42–58, Cham, 2017. Springer International Publishing.
- [14] Franck Cassez and Kim Guldstrand Larsen. The impressive power of stopwatches. In Catuscia Palamidessi, editor, CONCUR 2000 - Concurrency Theory, 11th International Conference, University Park, PA, USA, August 22-25, 2000, Proceedings, volume 1877 of Lecture Notes in Computer Science, pages 138–152. Springer, 2000.
- [15] Franck Cassez, Christian Müller, and Karla Burnett. Summary-based inter-procedural analysis via modular trace refinement. In Venkatesh Raman and S. P. Suresh, editors, 34th International Conference on Foundation of Software Technology and Theoretical Computer Science, FSTTCS 2014, December 15-17, 2014, New Delhi, India, volume 29 of LIPIcs, pages 545–556. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2014.
- [16] Franck Cassez and Olivier Henri Roux. Structural translation from time petri nets to timed automata. Journal of Software and Systems, 79(10):1456–1468, October 2006.
- [17] Franck Cassez and Frowin Ziegler. Verification of concurrent programs using trace abstraction refinement. In Martin Davis, Ansgar Fehnker, Annabelle McIver, and Andrei Voronkov, editors, Logic for Programming, Artificial Intelligence, and Reasoning - 20th International Conference, LPAR-20 2015, Suva, Fiji, November 24-28, 2015, Proceedings, volume 9450 of Lecture Notes in Computer Science, pages 233–248. Springer, 2015.
- [18] A. Cimatti, A. Griggio, S. Mover, and S. Tonetta. Parameter synthesis with ic3. In 2013 Formal Methods in Computer-Aided Design, pages 165–168, Oct 2013.
- [19] Edmund M. Clarke, Orna Grumberg, Somesh Jha, Yuan Lu, and Helmut Veith. Counterexample-guided abstraction refinement. In E. Allen Emerson and A. Prasad Sistla, editors, Computer Aided Verification, 12th International Conference, CAV 2000, Chicago, IL, USA, July 15-19, 2000, Proceedings, volume 1855 of Lecture Notes in Computer Science, pages 154–169. Springer, 2000.
- [20] Leonardo De Moura and Nikolaj Bjørner. Z3: An efficient smt solver. In Proceedings of the Theory and Practice of Software, 14th International Conference on Tools and Algorithms for the Construction and Analysis of Systems, TACAS’08/ETAPS’08, pages 337–340, Berlin, Heidelberg, 2008. Springer-Verlag.
- [21] Henning Dierks, Sebastian Kupferschmid, and Kim G Larsen. Automatic abstraction refinement for timed automata. In International Conference on Formal Modeling and Analysis of Timed Systems, pages 114–129. Springer, 2007.
- [22] Daniel Dietsch, Matthias Heizmann, Betim Musa, Alexander Nutz, and Andreas Podelski. Craig vs. newton in software model checking. In Eric Bodden, Wilhelm Schäfer, Arie van Deursen, and Andrea Zisman, editors, Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017, Paderborn, Germany, September 4-8, 2017, pages 487–497. ACM, 2017.
- [23] Goran Frehse. Phaver: Algorithmic verification of hybrid systems past hytech. In Manfred Morari and Lothar Thiele, editors, Hybrid Systems: Computation and Control, volume 3414 of Lecture Notes in Computer Science, pages 258–273. Springer Berlin Heidelberg, 2005.
- [24] Goran Frehse, Sumit Kumar Jha, and Bruce H. Krogh. A counterexample-guided approach to parameter synthesis for linear hybrid automata. In Magnus Egerstedt and Bud Mishra, editors, Hybrid Systems: Computation and Control, pages 187–200, Berlin, Heidelberg, 2008. Springer Berlin Heidelberg.
- [25] Goran Frehse, Colas Le Guernic, Alexandre Donzé, Scott Cotton, Rajarshi Ray, Olivier Lebeltel, Rodolfo Ripado, Antoine Girard, Thao Dang, and Oded Maler. Spaceex: Scalable verification of hybrid systems. In Ganesh Gopalakrishnan and Shaz Qadeer, editors, Computer Aided Verification, volume 6806 of Lecture Notes in Computer Science, pages 379–395. Springer Berlin Heidelberg, 2011.
- [26] Matthias Heizmann, Jochen Hoenicke, and Andreas Podelski. Refinement of trace abstraction. In Jens Palsberg and Zhendong Su, editors, Static Analysis, 16th International Symposium, SAS 2009, Los Angeles, CA, USA, August 9-11, 2009. Proceedings, volume 5673 of Lecture Notes in Computer Science, pages 69–85. Springer, 2009.
- [27] Matthias Heizmann, Jochen Hoenicke, and Andreas Podelski. Software model checking for people who love automata. In Natasha Sharygina and Helmut Veith, editors, CAV, volume 8044 of LNCS, pages 36–52. Springer, 2013.
- [28] Thomas A. Henzinger, Pei-Hsin Ho, and Howard Wong-toi. Hytech: A model checker for hybrid systems. Software Tools for Technology Transfer, 1:460–463, 1997.
- [29] Thomas A. Henzinger, Peter W. Kopke, Anuj Puri, and Pravin Varaiya. What’s decidable about hybrid automata? Journal of Computer and System Sciences, 57(1):94 – 124, 1998.
- [30] Peter Gjøl Jensen, Franck Cassez, and Kim Guldstrand Larsen. Repeatability for ”Verification and Parameter Synthesis for Real-Time Programs using Refinement of Trace Abstraction”, July 2020.
- [31] Bishoksan Kafle, John P. Gallagher, Graeme Gange, Peter Schachte, Harald Søndergaard, and Peter J. Stuckey. An iterative approach to precondition inference using constrained horn clauses. CoRR, abs/1804.05989, 2018.
- [32] Piotr Kordy, Rom Langerak, Sjouke Mauw, and Jan Willem Polderman. A symbolic algorithm for the analysis of robust timed automata. In Cliff B. Jones, Pekka Pihlajasaari, and Jun Sun, editors, FM 2014: Formal Methods - 19th International Symposium, Singapore, May 12-16, 2014. Proceedings, volume 8442 of Lecture Notes in Computer Science, pages 351–366. Springer, 2014.
- [33] Ocan Sankur. Symbolic quantitative robustness analysis of timed automata. In Christel Baier and Cesare Tinelli, editors, Tools and Algorithms for the Construction and Analysis of Systems - 21st International Conference, TACAS 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015. Proceedings, volume 9035 of Lecture Notes in Computer Science, pages 484–498. Springer, 2015.
- [34] Ashish Tiwari. Abstractions for hybrid systems. Formal Methods in System Design, 32(1):57–83, Feb 2008.
- [35] Weifeng Wang and Li Jiao. Trace abstraction refinement for timed automata. In Franck Cassez and Jean-François Raskin, editors, Automated Technology for Verification and Analysis - 12th International Symposium, ATVA 2014, Sydney, NSW, Australia, November 3-7, 2014, Proceedings, volume 8837 of Lecture Notes in Computer Science, pages 396–410. Springer, 2014.