The text of a manual · part 11 of 14
Feasibility of formal model checking in the Vitatron environment: Chapter 6Model checking approaches andresults, pages 61 to 68
Pages 61 to 68 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 61
Chapter 6
Model checking approaches and results As has already been mentioned in chapter 5, several model checking approaches have been exploited to investigate the feasibility of model checking on Vitatron’s firmware designs. In this chapter, these approaches are described together with the results and experiences that were found by using the approaches. Note that we only describe verification results here; the development of the formal models itself can also be regarded as a result, but this has been described in chapter 5. Because any model checking approach comes down to applying abstractions and eliminations to certain parts of the system behavior, we indicate for each approach what the reliability level is of any results that potentially can be obtained by using this approach. Because the duration of the project did not permit us to translate the complete firmware design to a formal model, no approach is exploited that verifies the complete firmware design. In order to obtain a good perception of the feasibility of model checking at Vitatron, it is at least necessary to verify a model that contains the most characteristic firmware design elements, the firmware design elements that have the largest influence on the external behavior of the firmware, and firmware design elements with a large flaw risk. Elements with a large flaw risk are elements with a high complexity (e.g. firmware parts consisting of many collaborating and interdependent processes) through which it is hard to evaluate their behavior ‘manually’ by exploring the firmware design specification. Which specific approaches have been exploited is mainly invented through consultations with Vitatron. These consultations for example resulted in the decision that we omitted including many pacemaker therapies (pacing rate controlling subprocesses of The Umpire that can be switched on or off by the patient’s cardiologist; see section 4.2) in the formal model. Although verifying the complete firmware process The Umpire would be a very interesting approach because this is a complex process that decides which of the ‘competitive’ therapies controls the pacing rate, we omitted this approach in favor of being able to verify other parts of the firmware design. Instead of modeling the complete process The Umpire, only the Lower Rate therapy has been modeled that maintains a certain minimum rate under all circumstances. Furthermore the decision has been made to abstract away from all pacemaker parameters that are programmable by the patient’s cardiologist. In reality most of these parameters can vary within some range (taking interdependencies into account). It could be the case that the firmware behavior contains a flaw for some extraordinary parameter configuration; to verify
60
Page 62
the firmware extensively, one should have to vary all these parameters within their ranges and verify the formal model for each combination of the parameters. But this would have dramatic effects on the model state space; in fact the state space would be multiplied by the number of possible parameter value combinations. In this project we have chosen to set all pacemaker parameters to their factory settings in order to investigate model checking on the default firmware design. How model checking could be improved for systems with many programmable parameters might be a topic of future research. Before we describe the three model checking approaches and their results, it must be noted that two of the three approaches were not fully investigated in Uppaal. Halfway in the project, we experienced relatively large verification times for the verifications in Uppaal, compared to the same verifications in mCRL2. This was even the case for simple models with state spaces of a few millions of states (if the state spaces of these models were generated by mCRL2). Because Uppaal does not give any information about the number of already verified states during the verification, it was very hard to find reasons for these large verification times. At a certain stage of the formal modeling, all optimizations were invented through analysis by the mCRL2 toolset. Carrying these optimizations and other changes in the mCRL2 models through in the Uppaal models was a time intensive job considering the lack of results that we achieved via verification of the Uppaal models. These considerations made us decide to stop modeling in Uppaal and to focus completely on verifications of the mCRL2 models. However, we have reproduced one important result from verification with mCRL2 in Uppaal; this is described in section 6.4.2. Note that we do not have completely turned down Uppaal as a model checking tool for pacemaker firmware by making this decision. The prior knowledge of mCRL2 and the available support from the mCRL2 developers might have influenced the comparison between the two model checkers. Whether the use of Uppaal as a model checker for firmware designs could be improved might also be a topic of further research.
6.1
Verified requirements
It has appeared to be rather hard to invent appropriate requirements to the firmware design which were suitable to be verified by means of model checking. Because we had only limited knowledge of the pacemaker firmware, the verified requirements have been invented through consultations with Vitatron. This resulted in only three requirements to the complete firmware model; these requirements are verified in the approaches that are described in section 6.2 and section 6.3. Note that this set of requirements is by no means complete, but at least it is a representative subset of all kinds of requirements. Verifying these three requirements will probably give us a clear picture of the feasibility of verifying requirements to the formal firmware model in general. Besides these three requirements to the complete firmware model, it would probably be more easy to invent requirements to parts of the firmware design. It is desirable that each component of the firmware design is designed with a clear and specific purpose. If this purpose is well documented, model checking approaches can be developed in which it can be verified whether the design component indeed accomplishes this purpose. We describe one example of such an approach in section 6.4. Next we describe the three requirements to the complete firmware model, followed by
61
Page 63
their formalizations that are used in the verifications with mCRL2 and Uppaal: • Absence of deadlocks: Absence of deadlocks is of course essential for the correct behavior of the pacemaker firmware, but besides that we experienced that modeling errors often cause deadlocks to occur in the models. E.g. if a process in the formal model contains a flaw so that it tries to send an event to another process that can not receive that event, a deadlock state will be reached because the first mentioned process can not proceed. So checking whether the formal models are deadlock free also acts as a debugging facility, although the absence of deadlocks is of course no guarantee for the absence of modeling errors. mCRL2: Verifying this requirement on the mCRL2 models can either be done during state space generation by lps2lts or by formulating the simple logic formula [true ∗ ]htrueitrue which can be verified by the tool pbes2bool. If the first method is used, lps2lts must be instructed to print a message for every deadlock that it detects in the state space. We have used this lps2lts method, because we ran lps2lts anyway to determine the size of the model state space. Uppaal: Note that section 2.2.3 mentions the special property A[] not deadlock in Uppaal’s requirement specification language that can be used to verify this requirement on the Uppaal models. Here some text is removed for confidentiality reasons. This text describes the ‘second requirement’ to the complete firmware model.
• High-Rate-Limiter (HRL): On a higher level, the external behavior of the pacemaker can be observed by inspecting the behavior of the heart. The pacemaker must maintain an adequate heart rate; one of the basic requirements to this heart rate is that it may not become too high. In other words, the time interval between two ventricular contractions must be higher than a certain threshold value called the High-Rate-Limiter (310 ms). Because this is a requirement to the ventricular behavior, this requirement has only been verified in those models that contain the formal heart model. mCRL2: The ventricular contraction itself does not have a distinctive action and can furthermore have a number of causes. It can be a contraction that is caused by anterograde conduction of an atrial contraction, a contraction that is caused by a ventricular pace, or a spontaneous contraction of the ventricle itself (a PVC). Therefore we have formulated a logic formula which specifies that the time interval between two end refractory v actions must always be larger than the High-Rate-Limiter. The end refractory v action marks the end of the refractory period after each ventricular contraction; because the
62
Page 64
refractory period has a constant length, the time interval between two such actions equals the time interval between the corresponding contractions. To formalize this requirement, we need the modal µ-calculus extended with data, because the time interval between two consecutive end refractory v actions must be ‘measured’ after which it can be compared to the High-Rate-Limiter. Unfortunately we experienced serious difficulties in obtaining a correct logic formula representing this requirement. Therefore we based it on the following example from section 4.4 of [11]: “A very powerful feature is the ability of putting data as parameters in fixed point variables. Using this it is possible to for instance count the number of events. Saying that a buffer may never deliver more messages than it has received can be done as follows: νX(n : N := 0).[deliver ∪ receive]X(n)∧[receive]X(n+1)∧[deliver ](n > 0∧X(n−1)) Here n counts the number of received messages that have not been delivered yet. The notation n : N := 0 says that n is a natural number that is initially set to 0. The core of the formula is in its last conjunct, which is false if a deliver is possible while n > 0. This conjunct then becomes false, turning the whole modal formula into false.” Inspired by this example formula, we created the following modal formula, saying that an end refractory v action may only occur when at least 62 tick ALL actions (which equals 310 ms, because every tick ALL action represents 5 ms) have occurred since the preceding end refractory v action. νX(n : N := 0).[tick ALL]X(n + 1)∧ [end refractory v ](n ≥ 62 ∧ X(0))∧ [tick ALL ∪ end refractory v ]X(n) Because we have based this formula on the mentioned example, we have high confidence that the formula is a valid representation of the HRL-requirement. Nevertheless, it is unsatisfactory that we were not able to invent a formula from scratch. From our opinion, this is mainly due to the complexity of the modal µ-calculus, which will probably also give some trouble if Vitatron would decide to use mCRL2 as a model checking environment. We have verified this logic formula on the mCRL2 models by the tool pbes2bool. Uppaal: Since there are no tick-actions involved in the Uppaal models we can not use the above described formula to verify this requirement in these models. Instead we have created a formula that depends on the clock variable of the Ventricle process: A[]((Ventricle.Conducted contraction ∨ Ventricle.PVC ∨ Ventricle.Pace) ⇒ Ventricle.c≥62)) Literally this formula states that the value of the clock variable c in the process Ventricle must always be at least 62 if the process is in the location Conducted contraction, PVC, or Pace. Note that these three locations all indicate that a ventricular contraction has just passed and that c is reset upon leaving these locations. Hence the value of c 63
Page 65
in one of these three locations represents the length of the time interval since the last ventricular contraction. Upon each contraction this time interval is compared to the HRL value.
6.2
Heart model approach
The main approach that has been exploited during the project consists of verifying the formal firmware model in the presence of models that simulate the heart and the hardware module PG; these environmental models are described in chapter 5. As has already been indicated briefly in that chapter, any results that are obtained by verifying the firmware model in the presence of this heart model must be judged by keeping the modeled heart behavior in mind. Our heart model can show some of the mostly occurring arrhythmias (sinus tachycardia, sinus bradycardia, PVCs, retrograde conduction and crosstalk; see section 3.4) besides the natural heart behavior, but the various types of AV block and more rare types of arrhythmias are not included in the heart model. If the firmware model contains a flaw which only results in undesired external firmware behavior when the heart would show behavior that is not modeled, we certainly can not detect this flaw by verifying in the presence of this specific heart model. The modeled heart behavior strongly influences the state space size of the verified model (the composition of the heart model, the PG model, and the firmware model); each modeled arrhythmia introduces non-determinism into the heart model. E.g. after each received atrial pace, the formal atrium process non-deterministically decides whether or not the atrial pace results in a ventricular crosstalk sense that is sent to the PG within 90 ms after the pace (see section 5.4). Therefore the modeled heart behavior must be limited to make model checking feasible. The behavior that is present in our heart model has emerged from taking its effects on the state space into consideration and again through consultation with Vitatron. Recall that the atrium process in the formal heart model non-deterministically chooses its new rate after each contraction. By allowing a choice for a very slow rate, sinus bradycardia is modeled and likewise a very high rate models sinus tachycardia. In the approaches that include the formal heart model, we have varied the possible atrial rates that are specified in the atrium process to test their effects on the state space size and the model behavior. Note that we have left the conduction time intervals through the AV node (anterogradely 100 ms and retrogradely 450 ms) constant; also varying these time intervals would again mean a significant impact on the state space size. In this main approach the following firmware processes are included (refer to section 4.2 and figure 4.5 for a more detailed description of the mentioned firmware processes): • The processes Accept R Channel and PVC Astim Generator that are responsible for detecting and handling crosstalk ventricular senses and PVCs, respectively. • The Umpire is included as a driver process that only provides some parameters to other processes in order to maintain the minimum rate of the Lower Rate therapy. • The functionality of the process Escape Timing that is applicable for DDD pacemakers. • The processes AV Monitor and Ventricular Monitor are entirely included in the model.
64
Page 66
• The Atrial Monitor is included, except the Tachy Classifier that provides a detailed classification of too high atrial rates. In the formal model, this classification has been simplified and included in another subprocess of the Atrial Monitor that is responsible for classifying all atrial rates. Furthermore the RC Monitor is omitted from the Atrial Monitor in this approach.
6.2.1 mCRL2 results
On the mCRL2 model1 of this approach, we have verified all requirements from section 6.1 for several combinations of rates that can be shown by the atrium process. Basically we can conclude that all verified models satisfy all formulated requirements. Unfortunately, we were not able to verify the model for all combinations of atrial rates, because the state space size exploded dramatically when certain combinations of rates were possible. Because a model must first have a reasonable state space size before any requirement can be verified on the model, it is probably more interesting to consider how the state space size relates to these atrium configurations. Being aware of this relationship might enable us to draw conclusions about the feasibility of model checking firmware designs by this heart model approach. The atrial rate corresponds to the sinus rate in the human heart which has the greatest influence on the complete heart behavior. Therefore the test coverage of this model checking approaches is directly proportional to the number of possible atrial rates. To maximize the test coverage of the firmware design the atrium process must be able to perform spontaneous contractions in rates that vary from very low to very high, but of course the state space explosion problem is inevitable here. Possible atrial rates (bpm) 40/80/120 40/60/80/100/120 40/80/120/160 140/180 80/180
Model state space size (# states) 24.539.395 43.837.681 476.503.913 116.692.481 3.865.364
HRL verified yes (valid) yes (valid) no no yes (valid)
Table 6.1: State space sizes of some mCRL2 models
Table 6.1 shows the state space sizes of some model configurations. What immediately draws our attention in this table is the fact that allowing high rates causes a dramatic increase to the model state space size, although that is only the case if the gaps between the possible rates are not too large. An explanation for this is that information about the current rate is stored in variables that represent the physiological band on which tracking decisions2 are made. As described in section 4.2 this band is only updated for limited rate changes to avoid too sudden changes in the ventricular rate. The physiological rate is initialized to the minimum rate of 60 bpm that is maintained by the Lower Rate therapy. In the model that shows atrial rates 1
This model can be found in the electronic appendix: mCRL2/Heart model approach section 6.2.mcrl2 An atrial sense is tracked by planning a ventricular pace a certain time interval after the sense. This is only done if the atrial rate is found to be appropriate by the firmware. 2
65
Page 67
of 80 and 180 bpm, the 80 bpm senses will cause the physiological rate to become 80. Any 180 bpm atrial sense that is shown by the heart model does not cause an increase of the band, because the jump of 100 bpm is far too sudden. Therefore the value of the physiological rate is 80 bpm in almost the complete state space which explains the relatively small size of the state space. On the other hand we see that the state space of the 40/80/120/160 model is quite large; here the gaps between the possible rates are smaller and probably the physiological rate can become any value between 40 and 160 bpm in the model state space. For every value of the physiological rate, other tracking decisions are made for the four possible atrial senses which again enlarge the state space. But this latter explanation still does not explain the difference in state space size between the 40/60/80/100/120 model and the 40/80/120/160 model. In the former model the physiological rate can become any value between 40 and 120 bpm, but the consequences on the state space size are not just as much as in the latter model. Most probably this difference is explained by the fact that the pacemaker firmware performs a lot of calculations in the presence of high atrial rates; planned paces are sometimes advanced in time to ensure that safety critical paces can still be given if needed. These calculations determine new values for variables which influences the behavior of the model in handling later events. Any new variable value possibly multiplies the state space and in combination with the possible atrial rates this soon leads to an exploding state space as we have experienced. Note that this effect can also be seen in the state space size of the 140/180 model. On the first two models in table 6.1, in which the atrium can show a range of rates from very low to ‘average’, all three requirements are verified completely and found to be correct. Unfortunately, we were not able to verify the model completely for atrial rates that vary from very low to very high. We also tried to verify the 40/60/100/140/180 model, but we killed its state space generation after the generation of more than a billion states (which took more than a week on a machine with 128 GB of memory). Based on this fact and the state space size of the 40/80/120/160 model, the state space size of the 40/60/80/.../180 model (providing an even more complete range of atrial rates) would probably be extremely large, thus making model checking of such a model infeasible. In this approach the process The Umpire has been included as a driver process that provides the so-called escape interval of the Lower Rate therapy which maintains a minimum rate of 60 bpm. To investigate the feasibility of extending The Umpire such that it can provide escape intervals for more different rates, we adapted the driver process of The Umpire (in the 40/80/120 model) slightly such that it non-deterministically would deliver the escape intervals for a rate of 60 bpm or a rate of 100 bpm. To verify the behavior of the firmware design extensively, many more options must of course be provided, but as a start we considered these 2 options. Unfortunately, the state space of the resulting model exploded dramatically again (more than 500 million states), thus making clear that varying these escape intervals in this approach is infeasible. Another point of concern that we have about the large state spaces that are generated by this approach is that visualization techniques can not be applied on these state spaces. The mCRL2 toolset contains a set of visualization tools which have been proved to be rather useful in several investigations in the past. By visualizing the state space of a model, it can be visu66
Page 68
ally explored. By trying to explain the visible patterns in the state space one can potentially obtain much insight in the modeled system and in the consequences of the made choices while formally modeling the system. This insight can again lead to improvements to the model and to the discovery of possible state space reductions that can be applied. Unfortunately using these visualization tools is only feasible to state spaces up till approximately 1 million states.
6.2.2
Uppaal results
Because we prematurely stopped modeling in Uppaal, some parts of the Uppaal model3 for the heart model approach do not entirely conform to the corresponding mCRL2 model. The mCRL2 model contains a more elaborated version of a subprocess of Escape Timing whereas the Uppaal model contains a depleted version of this subprocess. Nevertheless we have verified the Uppaal model, because this difference between the models certainly does not make the state space of the Uppaal model bigger than the state space of the mCRL2 model. We have chosen to verify the Uppaal model for possible atrial rates of 40, 80 and 120 bpm because the state space of the mCRL2 40/80/120 model was relatively small. Note that we have only verified the ‘absence of deadlocks’-requirement and the HRL-requirement. Uppaal’s verifier reported that the ‘absence of deadlocks’-requirement holds on the model after approximately 5,5 days of verification time (compare this to the verification time of a few hours that the mCRL2 toolset needed). The HRL-requirement was validated on the model after approximately 14 days of verification time, which is again a rather lot more than the verification time that mCRL2 needed to verify the requirement (approximately 1 day). These large verification times for this relatively ‘simple’ model explain the reason why we stopped modeling in Uppaal on a certain moment during the project. Although model checking firmware designs is certainly possible by using Uppaal, our investigations have shown that mCRL2 can verify more complicated models while requiring less runtime.
6.3
Heart model approach extended with RC functionality
The H&P firmware design contains a rather cohesive group of processes that is responsible for the detection and the handling of retrograde conduction (RC; see section 3.4). Because the group of collaborating processes is rather large and this group is a typical example of the firmware design style, Vitatron suggested including this RC functionality in the verifications. Therefore we extended the heart model approach with the processes from the RC Monitor and the RC Test. The RC Monitor is a collection of subprocesses of the Atrial Monitor that constantly monitors all incoming senses and paces to check whether the RC Test should be started; this is the case when a certain amount of ventricular paces and suspected retrogradely conducted atrial senses (atrial senses that are received within 450 ms after a ventricular event) have been received. The RC Test is a pacemaker therapy which has been modeled as a subprocess of The Umpire. If the RC Test therapy is active, it alters the AV-delay between the atrial sense and the ventricular pace that tracks this sense in order to verify whether retrograde conduction is really present. The RC Test reports its findings to the RC Monitor again, so that the RC Monitor can classify each incoming atrial sense as being a normal atrial 3
This model can be found in the electronic appendix: Uppaal/Heart model approach section 6.2.xml
67