Formal analysis of real-time requirements: findings of a feasibility study at Bosch

Post and Hoenicke formally checked 16 sets of real-time requirements for consistency, rt-consistency and vacuity – and found eight previously unknown errors.

Published on

Manual reviews can reveal errors in requirements but cannot demonstrate their absence. In a feasibility study, Post and Hoenicke investigate whether a formal, automatic analysis can close this gap for real-time requirements, and at what cost (Post and Hoenicke, 2012). The study covers sixteen sets of requirements from automotive projects at Bosch, all of which had already undergone extensive reviews. The analysis nevertheless revealed eight previously unknown errors. This article presents the method, results and limitations of the study and puts them in context.

Subject and procedure

In the study, a real-time requirement is any requirement with an explicit timing bound, for example: if the diagnostic request IRTest is set, the infrared lamps are turned on after at most ten seconds. The authors justify the choice by noting that such requirements tend to be formulated concretely and are therefore amenable to formalisation, while they are also considered error-prone and occur in safety-critical projects (section 1).

The sample was stratified over five application domains: driving assistance, engine control, car multimedia, catalytic converter development and power train. One project per domain was selected by convenience sampling. The responsible requirements engineers provided one to four sets of requirements per project, each specifying a system component (section 3.2): sixteen sets in all, each with 9 to 81 requirements.

The requirements were first rewritten in a specification language and agreed with the responsible requirements engineers until there was consensus that the formalised version represented the meaning of the informal one. In one project the requirements engineer formalised the requirements directly, with the authors acting as coaches. Each set was then checked. Errors found were fixed and the check repeated until the set satisfied all three properties under study (section 3.3).

Specification language and translation

The tool chain separates a manual step from an automatic one. Manually, each requirement is formulated in the specification language, a restricted English grammar based on the real-time specification pattern system of Konrad and Cheng from 2005. A pattern consists of fixed wording and placeholders for propositional conditions and constants. A scope such as “Globally” or “After Q” is added. In this language the example reads: “Globally, it is always the case that if IRTest holds then IRLampsOn holds after at most 10 Seconds.” The grammar distinguishes qualitative patterns, real-time patterns with a timing bound and an invariant pattern (table 1). In IREB terminology these are phrase templates; see What makes a good requirement?.

Automatically, a compiler translates the requirements formulated in this way into formulae of a fragment of the real-time logic Duration Calculus, and these in turn into Phase Event Automata, on which the checks are performed (section 2.2). Only the tool needs the logical representation; the people involved work with the specification language. The prototype is written in Java and builds on a toolkit for Phase Event Automata and the model checker UPPAAL. According to the authors the algorithms are sound and complete, that is, they return a correct answer for every input (section 2.4).

Informal requirement natural language manual Specification language restricted English automatic Formula Duration Calculus automatic Automatic check three properties
Fig. 1: The tool chain of the study. Only the rewriting into the specification language is manual; the checks cover consistency, rt-consistency and vacuity. After Post and Hoenicke (2012), figures 1 and 2.

Correctness properties checked

The tool does not assess whether a requirement is right for the product. It checks three properties whose violation indicates an error in the specification (section 2.3).

Consistency. A set of requirements is inconsistent if no system exists that satisfies it. As an example the authors give the requirements that a signal, once it holds, is to hold for at least five seconds and at the same time for at most three.

Rt-consistency. This property captures conflicts between timing bounds, which can occur even in consistent sets. Formally, a set is rt-inconsistent if there is a finite trace that satisfies all requirements but cannot be extended to an infinite trace. In the authors' example, one requirement demands that the lamps are on no later than ten seconds after IRTest, and a second that they stay off for at least six seconds whenever IRTest holds. If IRTest holds from time 4 to time 10, the lamps must be on by 14. Since the second requirement applies at every point in time at which IRTest holds, including the last, they must not be turned on before 16. If IRTest holds only once and for less than four seconds, both requirements can still be satisfied; if it holds continuously for more than four seconds, the conflict is unavoidable.

Vacuity. A requirement is vacuously satisfied in a set if, in combination with the other requirements, its precondition can never occur. The authors assume that only behaviour meant to be visible in the system is specified, and therefore count a vacuous requirement as an error.

Results

Table 3 of the study gives the results per set of requirements. All sets that could be checked were consistent; the authors suspect that inconsistencies had already been removed in the reviews. For two sets with 48 and 58 requirements, none of the three properties could be decided because memory was insufficient.

Most errors concerned rt-consistency: seven of the sixteen sets were rt-inconsistent. Fixing them required major changes in places. In one set, two requirements were deleted, five changed and seven added. Correction took up to ten iterations, because after a supposed fix another rt-inconsistency was found. The authors conclude that this kind of error appears to occur frequently and is hard for humans to detect (section 4.1).

16 sets of requirements rt-inconsistent 7 with a vacuous requirement 1 all three properties established 6 no result (out of memory) 2
Fig. 2: Result of the formal analysis for sixteen sets of 9 to 81 requirements each, all previously reviewed. For two sets the analysis ran out of memory and yielded no result. Vacuous means that the precondition can never occur. Numbers from Post and Hoenicke (2012), table 3.

Vacuity was established in one set, one of the two largest with 81 requirements each. The precondition of the requirement concerned demanded, among other things, that the accelerator pedal takes the value 0. Another requirement gave the pedal's value range as “between 0 and 100” and had been interpreted as an open interval, which excluded the value 0. The ambiguity of the original wording only became visible through the analysis and was resolved by adding that the endpoints of the interval are included.

In total, eight previously unknown errors were found, three of them in the smallest sets with nine and ten requirements. For six sets the tool established consistency, rt-consistency and the absence of vacuity. Such a demonstration that defined kinds of error are absent cannot, in principle, be obtained from a review.

Effort and computation time

The effort of formalisation averaged two to three minutes per requirement and went mostly into understanding the informal requirement, not into rewording it (section 4.1). The learning curve was steep: the first requirements took up to ten minutes, and one to three minutes once a pattern had been used (section 4.2). The authors point out that the effort grows linearly with the number of requirements and becomes considerable for products with several thousand of them (sections 1 and 4.1). It would disappear if requirements were written in the specification language from the outset.

Computation time ranged from a few seconds to 1 hour 32 minutes, measured on a machine with a 2 GHz processor, of which one core was used, and 1 GB of memory. This spread is too large for checking while writing; for batch processing the authors consider it more than acceptable. As a point of comparison they name the waiting time of some days for the result of a manual review.

Scalability is limited. Besides the two sets that yielded no result, the vacuity check also ran out of memory for a small set of ten requirements, whereas the two largest sets were checked completely. The authors suspect that the solution space grows explosively for large sets. Table 3 shows, however, that size alone does not explain the effort. For the vacuity check the authors observe that the solution space grows precisely when there are few interdependencies between the requirements, and shrinks when there are many. For human reviewers it is the reverse, so automatic and manual analysis can complement each other. The authors consider the approach suited to checking the requirements of individual components, but probably not all system requirements together.

Observations on formalisation

The study also documents effects of the formalisation itself (section 4.2). First, it makes the level of abstraction explicit. The requirement that the assist function has to be deactivated in error mode can be captured as an invariant or as a response with a timing bound of ten milliseconds. The natural-language wording stays the same at every level; the formalised version has to commit itself.

Second, implicit knowledge becomes explicit. A requirement on the use of a voltage value from the bus was given, in the specification language, the additional condition that the bus is not off; the informal text lacked it.

Third, few patterns sufficed. About two thirds of the requirements were formalised with the invariant pattern (if P holds, S holds as well) or a response pattern with or without a timing bound. The authors attribute this to the systems being specified as black boxes, so that the requirements mostly relate input and output variables to each other. The invariant pattern itself was added at the request of the requirements engineers, who found expressing invariants through the absence pattern unintuitive. The authors also identify the need for a further pattern for error qualification: an error is stored in the error memory only after it has been detected for a minimum time.

Fourth, contrary to the authors' expectation, there was no need to express uncertainty or priority in the specification language. Uncertainty was captured through application parameters, such as a threshold that has not yet been fixed.

The specification language was judged easy to learn and to read. The engineers could interpret the check results without training, but the runs with which the tool demonstrates an rt-inconsistency only with difficulty. The authors therefore recommend that many may write requirements in the specification language, but that checking remains with the requirements engineer.

Validity and subsequent work

The authors do not claim generalisability: the results hold for the context studied, since only requirements from projects of one company were included. Against an expectancy effect in the formalisation they put forward two arguments: according to an earlier investigation, applying the specification language is sufficiently independent of the evaluator, and the number of errors was determined by the tool and hence objectively. Whether the three properties adequately capture erroneous requirements was discussed by the authors with experts; the discussion indicated that they do (section 5). The tool, moreover, was a prototype; as open issues the authors name scalability and usability, and further properties that can be formalised (section 6).

The approach has been continued. In 2021 Becker and colleagues presented the tool Hanfor, which supports pattern-based formalisation; an attached analysis tool again translates the requirements into Phase Event Automata via Duration Calculus. For the patterns and for rt-consistency they refer to work by Post, Hoenicke and Podelski and to the study discussed here. According to them, Hanfor has been used on industrial sets of 20 to 1,000 raw requirements from the automotive and railway domain (Becker et al., 2021).

A comparison with the review of requirements by language models, the subject of an earlier post, brings out the character of the method. A language model delivers a reasoned judgement on every requirement, the correctness of which a person has to assess. The formal analysis covers only three properties and presupposes that the requirements can be expressed in patterns; in return, its result is a proof. That proof, however, refers to the formalised version. Whether it renders the original requirement accurately remains a matter of agreement with the requirements engineers.

Sources

All publications