Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 13 of 14

Feasibility of formal model checking in the Vitatron environment: Chapter 7Recommendations to Vitatron

Pages 77 to 85 of 91, from Feasibility of formal model checking in the Vitatron environment

The original document is the PDF (6.4 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

Filed in the catalog under the Vitatron EE244

Page 77

Chapter 7

Recommendations to Vitatron From the found results, we can state that applying model checking to firmware designs is certainly not straightforward. Based on our experiences with formally modeling the pacemaker firmware, the actual model checking and its results, we give some recommendations for the future application of model checking at Vitatron. These recommendations also include some open questions that could be a topic of future research in the academic world. In section 7.1 we give recommendations about the ‘model checking aimed’-design of future firmware systems and the formal modeling of such designs. Recommendations about how and whereupon model checking should be applied are sketched in section 7.2. Section 7.3 gives some recommendations about resources and skills that are needed in order to apply model checking and finally section 7.4 suggests some topics for future research.

7.1

‘Model checking aimed’-design

During formally modeling the pacemaker firmware we met some constructs in the H&P model which caused problems in our formal models. This was the case either because a modeling construct had dramatic effects on the state space size, or because it was hard to invent a correct formal translation of the modeling construct. In this section we will address these problems together with recommendations to prevent such problems in future firmware designs in order to make model checking of such systems more feasible.

Deterministic design Because some process activation tables (PATs) in the H&P model do not specify the ordering in which child DFDs and PSPECs are triggered and output events are sent, we have modeled the ordering that is chosen in the implementation code of the firmware (see section 5.5). We described that this is undesirable, because we want to verify the design specification itself instead of its implementation. Therefore we recommend specifying an explicit order of such PAT-consequences in the specification of future firmware designs, if such a design would be the basis for a formal model on which model checking is applied. This is recommended for two reasons: in section 5.5 we already discussed its state space reducing effect and besides that it eases the creation of formal models with a better conformance to the design specification. We realize that leaving the ordering of triggers and output events unspecified has advan-

76

Page 78

tages from implementation perspective. If the ordering in which certain actions must be performed has not been specified in the system design, because their ordering really does not matter for the behavior of the system, the implementor can choose the most efficient ordering from the possible options. But from model checking perspective, this is undesirable. To obtain the best conformance between the system design and the formal model of this design, one would generally also leave the ordering of such actions undetermined in the formal model. In fact, all possible orderings then can occur in the model state space, which causes a dramatic explosion of this state space as we have experienced. To reduce the state space, one could choose a specific ordering during the translation of the design to a formal model; but this will harm the conformance between the design and the formal model and it could be the case that certain design flaws are disguised by this specific choice. If during the implementation stage later on, another choice for this ordering would be made for which these flaws do occur, the implementation will contain errors while model checking resulted in a validation of the design. Of course this is highly undesirable and therefore it is clear that determinism in the design is always preferred above non-determinism if this design will be verified by model checking. Related to this point we have another concern about the style in which the pacemaker firmware is specified. In some large DFDs it is hard to find out which behavior is exactly specified for each incoming event. Sometimes this is caused by a lack of order specification as mentioned above, but also the way certain H&P constructs are used sometimes makes the meant behavior unclear. For instance, triggering of a child DFD is often used where sending an event to the child DFD would provide much more clarity about the meant behavior of this child DFD (process the specific event instead of react to a general trigger). These arguments have to be considered carefully while designing future firmware systems, if model checking will be used as a verification method of these designs. For future firmware designs that are verified by model checking, we therefore recommend the following: • Apply as much determinism as possible while specifying firmware designs. • Specify future firmware designs in a more formal language or in a less ambiguous way to create more clarity about the meant behavior. The used language does not have to be a purely formal language that is suitable for model checking, but using a more formal design language or specifying the design in a less ambiguous way will certainly ease the translation of the design into a purely formal language. Note that specifying a system design directly in a formal language that is suitable for model checking, will generally not lead to a formal model on which model checking can be applied directly. While specifying a system design, you do not want to worry about the consequences on the state space size of the used design constructs. However, if the system design is specified in a formal language, the translation to a formal model on which model checking can be applied, becomes just a matter of applying simplifications and reductions to the system design. Obeying these two recommendations will ease the translation of future firmware designs to formal models, but may have disadvantages from implementation perspective: implementing may become more difficult and the resulting implementations may become more inefficient.

77

Page 79

State space reducing modeling In section 5.5 we described two relatively simple state space reductions that are applied in the formal translation of the firmware design. From these reductions, we draw some recommendations. The resets of the counter variables in the processes Multiple Successive VS and NOA Detection that we added, avoid that any value ‘stays behind’ in such a counter variable while this value is no longer needed. Although this does not form a problem during runtime of the firmware, it does increase the state space size of a formal model that represents the firmware. Therefore a recommendation to force resetting of variables whose variable is no longer needed in future firmware designs would be too outrageous, but at least one has to be alert on this issue in the design specification during formally modeling of such a design. The same arguments apply to the bounding of the counter variable Successive VP cntr in the process VP AS Pattern that we added; during normal runtime of the firmware (and generally also in the model state space if the firmware model is placed in the context of the formal heart model) the infinite increase of the counter variable does not occur. But we met the problem of the possibly infinite increasing of the variable when we exploited the isolated RC approach (section 6.4), because the nature of this approach made the specific input event sequence, which causes the infinite increase, possible. Once again we recommend being alert on such issues during formally modeling future firmware designs, because they can have dramatic effects on the state space size.

Explicit purpose and interface specification of design components In section 6.4 we described that during the exploitation of the isolated RC approach, we initially had some trouble in finding the right requirements to the RC part. At first we were not aware of the main purpose of the RC part, i.e. classifying each incoming atrial sense as normal atrial sense or retrogradely conducted atrial sense. Because of this, we only focused on the ‘absence of deadlocks’-requirement, which did not result in finding the known deadlock. We attribute the lack of awareness of the mentioned purpose of the RC part to the somewhat unclear modeling style in the H&P model, which is mainly inherent to the H&P method itself. Looking at the sphere that represents the process RC Monitor (figure 6.1 shows a simplified version of this), we see several incoming and outgoing control flows and data flows. Among several control flows for communication to the RC Test and data flows that provide diagnostic information to other processes and the ‘outside world’, there is an outgoing control flow on which the AS/RAS-classification is sent to other processes. But unfortunately this latter control flow does not attract attention as being the most crucial outgoing control flow of the process or as being linked to the incoming atrial sense control flow. Also the documentation and the model itself do not explicitly mention the requirement that the RC Monitor must always deliver the AS/RAS-classification on receipt of an atrial sense event. The described problem clearly is caused by a lack of an explicit definition of the purpose and the interface of the RC Monitor. From these considerations about the design specification of the RC Monitor, we think that it is justified to draw the following recommendations for the design of the complete firmware. The H&P model of the firmware design describes how the behavior of each individual de-

78

Page 80

sign component is accomplished (i.e. all actions that are performed upon receipt of a specific input event can be tracked), but does not define what exact purpose is intended by designing this behavior. The purpose of a design component is always (mainly textual) described in the accompanying documentation, but reading this purpose description mostly requires much background knowledge and linking this description to the design in the H&P model is sometimes quite difficult. Next to this, the H&P model contains small textual descriptions of the purpose of most components, but such textual descriptions are generally rather ambiguous. Hence extracting the intended purpose of a design component is quite hard and requires much detailed knowledge of the design and the domain in which the designed firmware operates. To be able to verify whether the behavior of a design component is correct, its intended purpose must be absolutely clear. Therefore it is recommended to state an explicit and formal specification of the purpose and the interface of each component in future firmware design specifications. This specification should define the relationships between the input interface and the output interface (containing events and variables) of the component and must abstract away from the precise internal behavior that accomplishes these relationships. Because all interaction of the component with its environment takes place via its interfaces, it is always possible to define its purpose explicitly in such relationships. Preferably the specification is made purely formal, e.g. by using logical propositions for all interface relationships, so that the ambiguity of the design component purpose is minimized. Preferably this purpose and interface specification is included in the design specification itself in order to make the design as complete as possible, but it is also an option to put it in the accompanying documentation. In the latter case, it must be guaranteed that the purpose and interface specification can be linked easily to the design specification. Obeying these recommendations will probably ease the invention and the formulation of requirements to the models that can be verified by model checking. If each design component has a clearly specified purpose, it can be verified whether this purpose is really accomplished by the design component by means of model checking.

Low coupling/high cohesion design pattern From the isolated RC approach we also have experienced that model checking parts of a system by such an approach can be feasible and can result in important knowledge about the behavior of the complete system. Because the behavior of the RC part is determined by only 7 incoming control flows and 1 incoming data flow (besides the programmable parameters that are constant during runtime) we were able to create a formal model of this behavior with a relatively small state space. The RC part itself consists of many processes that collaborate with each other. This is a clear example of how applying the well-known ‘low coupling/high cohesion’ design pattern to a firmware design can have positive effects on the feasibility of model checking. Of course the specific design of the RC part contained a flaw, so with respect to that flaw the design must not be copied onto other designs. But mainly because the RC part satisfies the ‘low coupling/high cohesion’ design pattern, we were able to discover the flaw by means of model checking. Therefore we recommend designing future systems according to this design pattern as much as possible to make a kind of unit testing by model checking possible. We come back to the point of unit testing by model checking in the next section.

79

Page 81

7.2

Application of model checking

During the project, we experienced that formalizing system behavior can greatly improve the comprehension of the modeled system. At the start of the project, many manual explorations of the firmware H&P model were required to get some first insight in the model. But this was totally insufficient to get a really precise understanding of the system details. Nevertheless we started modeling some parts of the system based on our limited knowledge. Formalizing a system means that responsibilities of processes and communication between the processes are made explicit. Because of that, we were forced to invent formal modeling techniques for formally representing the firmware behavior. By exploiting these invented modeling techniques we translated all details of the firmware design, although we were not totally aware of the purpose of all design details that we were modeling. After the first parts had been formally modeled, we used the formal analysis techniques to verify whether the formal model represented the system correctly: Exploring the formal model by simulating actions, trying to verify the ‘absence of deadlocks’-requirement, and raising questions to Vitatron based on our observations from these simulations and verifications, led to correction of modeling errors but also gave much understanding of how events flow through the various firmware processes. This better understanding of the firmware functionality often resulted in ideas for improving the model and the used modeling techniques. In this way we used an iterative procedure consisting of alternating stages of modeling the system details and analyzing the resulting formal model. This modeling approach gradually made clear the best way of modeling the firmware design and furthermore improved our understanding of the firmware behavior itself. What do these experiences mean for the application of model checking in the development of future firmware systems? If formal modeling and model checking would be exploited during early design of future systems, a better understanding of the consequences of made design decisions can possibly be obtained before the complete design has been finished. We recommend a parallel development of the formal model that is suitable for model checking besides the development of the firmware design. Although our heart model approach from section 6.2 and 6.3 has shown that verifying a firmware design extensively (by using a heart model showing many possible rates, including very high rates) is yet a rather infeasible task, it is possible to analyze the firmware behavior for some basic heart behavior (for example with a heart model that shows a constant spontaneous atrial rate). By providing such basic heart behavior to a formal model of the firmware design, at least big problems in the design can be detected. Next to this, a formal model of the design in which the heart model can show an extensive set of behavior, is analyzable by using a simulator tool to explore the model by manually performing actions. This is because for such simulations of a formal model, it is not necessary to be able to generate the complete state space of the model. Sometimes such ‘manual’ simulations can be useful, for instance when one wants to analyze the firmware behavior for a specific sequence of heart behavior. However, the results of such simulations are also limited, because by simulation only a small part of the complete state space can be analyzed. Furthermore, design parts of limited size can be verified extensively by using an approach similar to the one we have used to verify the RC part in isolation (section 6.4). We have already mentioned that model checking can act as a kind of unit testing technique in this way. 80

Page 82

By these different model checking approaches, unwanted behavior in the firmware design can possibly be detected (and hopefully corrected) in an early stage of development. When such unwanted consequences should be discovered by unit tests at the end of the design stage, such corrections might be much more expensive.

Model checking separate design parts Coming back to the point of unit testing by model checking, we have seen one successful example of such an approach in the isolated RC approach (section 6.4). In this approach the RC part was taken out of its normal context and placed in a formal model wherein its input events and input variables were provided by driver processes. Because the RC part only depends on one external variable, we were able to verify this part extensively by letting the driver processes provide all possible variable values and all combinations of input event sequences. Of course it highly depends on the specific design that is verified, whether some parts of that design can be verified by such an approach. Although not described in chapter 6 because the results were very disappointing, we have also investigated applying similar approaches to the Escape Timing part of the design and to the complete firmware design. In case of the Escape Timing part the approach was not successful because this part depends on too much external variables (2 time intervals from the PG and several data variables from the Atrial Monitor and The Umpire); varying all these variables resulted in a huge state space explosion, even varying only the time intervals and keeping the other variables constant was certainly not feasible. It may be clear that the same problem appeared when applying the approach to the complete firmware design. What can we conclude from these investigations? At least the results from the isolated RC approach show that model checking can be applied to design parts whose behavior does not depend too much on the values of external variables. It seems that the number of possible input events to a design part has less influence on the feasibility of model checking on this part; in the firmware H&P model the number of input events to a process is limited anyhow and usually there are lot of dependencies between them through which the number of possible event sequences is also limited. On the other hand, if the number of external variables or the size of their value ranges increases, the number of possible value combinations of these external variables increases exponentially, which soon causes the state space to explode and the model checking approach to become infeasible. Therefore it is recommended to be careful in selecting on which parts of a design, model checking is going to be applied. A kind of bottom-up approach is recommendable, i.e. start with verification of the smallest parts of the design, followed by combining several parts in the verification, and so on until the number of external variable dependencies becomes too large and model checking starts being infeasible. Of course the function of the verified design parts and the requirements to them must be clear before model checking can actually verify these requirements (obeying the recommendations from section 7.1 should imply this). If the complete design would have only few dependencies on external variables, it could appear that model checking of the complete design is feasible by this approach, although the nature of the firmware for implantable heart devices does not make this plausible. Another approach that can be applied in order to verify larger design parts can be the following. Validated design parts can be replaced by driver/stub processes that can show all possible external behavior of this design part, but whose internal behavior is omitted. 81

Page 83

In this way these design parts do not contribute to the state space size too much, through which larger design parts that include these design parts, can be verified. We have not investigated such an approach in this project, but it is likely that such an approach would be feasible. Recall from section 6.4.1 that it is recommended to start such approaches, in which design parts of limited size are verified, with as much abstraction as possible to avoid possible missing of flaws in the system. This high abstraction level can mainly be reached by initially modeling the driver processes such that they provide all combinations of input events and input variables, without taking interdependencies into account. However, if the resulting state space would become too large, the abstraction level can be lowered to make the approach feasible. The abstraction can also be lowered if it appears that the driver processes provide impossible input event sequences. So with respect to the abstraction level, a top-down approach is recommended. Decreasing the abstraction level can be done by modeling extra dependencies between the several input events and input variables into the driver processes that provide these inputs. Decreasing the abstraction level however must be considered carefully, because it can also mean a disguise of crucial flaws in the system behavior.

Model checking tools Besides these general recommendations on the application of model checking to firmware designs, we also try to give some recommendations on the choice of a tool for model checking firmware systems. Although this is rather difficult because we have only investigated the application of two specific model checkers from the several ones that are available. mCRL2 has appeared to be a tool in which firmware designs can be very well modeled and that can deliver very useful results in analyses and verifications of the resulting models. Disadvantages of mCRL2 could be that using the language and the toolset requires rather much tool-specific knowledge and that the toolset and its documentation are still under development. The latter can of course also be an advantage, because the toolset is continuously improved. Furthermore the mCRL2 development team is always accessible to receive questions and comments on the mCRL2 language and its toolset. In this project Uppaal has appeared as a tool in which formal designs can be constructed very easily because of its graphical interface. Through this interface the conformance between the firmware design and its formal representation is a bit clearer than when mCRL2 is used. We were able to analyze and verify some small models with Uppaal, but when the models grew larger, the runtimes for analyses and verifications on these models exploded a lot sooner than was the case with mCRL2. Because of this, the model checking results that we obtained by using Uppaal are unfortunately very limited. Based on these experiences we would recommend using mCRL2 as a model checker at Vitatron, but it is certainly also recommended to investigate the usability of other available tools.

7.3

Model checking resources and skills

In this project we have used the TU/e compute server elephant to perform our analyses and verifications of the models. This machine has 128 GB of memory through which we could handle larger state spaces and perform quicker verifications than on a personal computer or 82

Page 84

a ‘normal’ server. Being able to generate these huge state spaces was very useful in order to investigate to which extent the parameters of the model were responsible for the state space explosions. But as we have concluded earlier, generating and verifying these huge state spaces have not led to important results because we were only able to vary a limited set of parameters in the models. Even though, our isolated RC approach has a relatively small state space and has led to useful results. Regarding the necessary computation power to apply model checking, we can therefore conclude that these do not have to be gigantic, although more resources are always useful to be able to cope larger states spaces. Because state spaces grow exponentially with the size of the verified models, more resources will only cause a limited shift to the model size boundary above which model checking starts being infeasible. Engineers that are going to apply model checking need to have certain skills. General knowledge of model checking is required; [6] is a good source for this. An important skill that must be developed in order to apply model checking is the ability to use functional programming as contrasted with imperative programming which would be very familiar to Vitatron engineers. With functional programming it is defined what purpose a certain component must accomplish, instead of how this purpose is accomplished. Formal models on which model checking can be applied are constructed using a functional programming like language in most model checkers. Constructing a formal model of a system and formulating requirements in logic formulas of course also requires knowledge of the specific model checker language and the available logics; for mCRL2 and Uppaal introductions are included in this report. For mCRL2 it is furthermore very useful to obtain general knowledge about process algebras; this is for instance provided in [11]. But probably the best way to learn using a model checker tool is practicing by trying to model and verify some simple example systems. Experience is also required for inventing and formulating the right model requirements. Sometimes a model requirement can be verified more easily by using an auxiliary action that is performed if the requirement is violated. To determine which approach must be used for verification of a certain requirement, experience is essential.

7.4

Future research

This section describes some points that can be a topic of future research, either in the academic world (perhaps as a master project) or in collaboration with Vitatron or other companies. Because the formal modeling of firmware designs appeared to be a rather time intensive job (as probably is the case with most other system designs), it would certainly be useful to look for better methods for obtaining formal models from these designs. Perhaps tools can be developed for automatic translation of design specifications to formal models (note that such tools are already available for the conversion of UML diagrams to Uppaal models: [1] and for the conversion of Petri nets to mCRL2 models). Note that we have already mentioned the suggestion to specify future firmware designs directly into a formal model checker language. Although model checking most often can not be applied directly on such a ‘formal design’, the translation of such a design to a feasible

83

Page 85

(with respect to its state space size) formal model becomes much easier. In fact this translation then becomes only a matter of applying simplifications and reductions to the ‘formal design’. Another point of future research could be the investigation of more efficient techniques for applying model checking on system designs that depend on many programmable parameters. This is a point that we do not have addressed in this project, because it would certainly make model checking of the pacemaker firmware design infeasible. Perhaps techniques can be developed that reuse parts of the already generated state space when some parameters are changed and the state space is generated again. Changing some parameters does not necessarily mean that the complete state space is changed, so our intuition is that the parts which remain the same could be reused rather easy. In section 6.1 we described that formulating a requirement in the modal µ-calculus for verification on the mCRL2 models was rather hard. After having obtained a logic formula of a model requirement in the modal µ-calculus, it is especially hard to verify whether this formula forms a valid representation of the model requirement. Perhaps improvements can be made on this point by TU/e researchers, for instance by inventing a higher-order language in which requirements can be easier formulated. The µ-calculus then might act as the underlying basis for this language.

84