The text of a manual · part 12 of 14
Feasibility of formal model checking in the Vitatron environment: Chapter 6Model checking approaches andresults, pages 69 to 76
Pages 69 to 76 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 69
sense or a retrogradely conducted atrial sense. This classification is used by other processes like Escape Timing in combination with the other classifications from the Atrial Monitor. Because through the addition of the RC Test there appears more than one therapy in the formal model, The Umpire had to be extended as well. The priority of the RC Test therapy is always higher than the priority of the Lower Rate therapy, hence we modeled The Umpire so that it outputs the Lower Rate therapy data if the RC Test is inactive and the RC Test therapy data if the RC Test is active. The reliability level of this approach is similar to the one of the previous approach, because we verify in the environment of the same heart model. Hence once again the results that possibly are obtained by this approach must be judged by taking the modeled heart behavior into account. Although we have produced an Uppaal model4 for this approach, we have only verified the models in this approach by mCRL2, because of the limited Uppaal results in the previous approach.
6.3.1 mCRL2 results
Verification of the mCRL2 model5 that correspond to this approach actually shows the same patterns as the verifications in the heart model approach from the previous section: The successful verifications (for possible atrial rates that vary from low to ‘average’) of the heart model approach are repeated in the models of this extended approach; this has shown us that all verified models satisfy the three requirements. Furthermore, the model state spaces are even dependent on the possible atrial rates, allowing high rates also causes a dramatic increase of the state space size in this approach. The sizes of the state spaces are multiplied by a factor 2 due to the addition of the RC functionality. Because this is only a constant factor, this extended heart model approach is just as much feasible as the heart model approach from the previous section: For possible atrial rates that vary from low to ‘average’, the firmware design can be verified by this approach, but providing a more complete heart behavior by allowing higher atrial rates soon makes the approach infeasible, because the state space size increases too much.
6.4
Isolated RC functionality approach
Because the RC functionality is such a typical example of collaborating processes in the firmware design and because Vitatron indicated that in the past a flaw had been found in this part that can cause a deadlock6 , we investigated the application of model checking on this RC part separately. This means that we have constructed a formal model that besides the RC Monitor and RC Test processes only contains some driver processes and stub processes that represent the processes in the context of the RC part. The driver processes provide the 4
This model can be found in the electronic appendix: Uppaal/Heart model RC approach section 6.3.xml This model can be found in the electronic appendix: mCRL2/Heart model RC approach section 6.3.mcrl2 6 Vitatron has successfully identified the root cause of this problem. The problem occurs only for very specific parameter settings and therefore the probability that this problem occurs is very small. Note that the problem has been solved successfully; also all already implanted pacemakers with this problem have been updated to fix the problem. 5
68
Page 70
RC part with its input events and input variables and the stub processes accept its output events. In its normal context in the firmware design, the RC part processes 7 different input events and needs one time interval variable from the PG; see figure 6.1.
Figure 6.1: Context overview of RC part One of the driver processes repeatedly sends one of the 7 possible events to the RC part. Some of these events only must be sent to the process RC Monitor and others must be sent to both processes RC Monitor and RC Test. After sending an event to RC Monitor or RC Test, the driver process waits on an acknowledgment message from this process as to simulate the original sender of the message in the complete firmware model. After handling an event completely (the acknowledgment message is received from the processes to which the event has been sent), the driver process non-deterministically decides the next event it shall send. In this decision some dependencies between the possible events are taken into account, e.g. according to its definition a PVC can only occur if the previous sent event was a ventricular sense, a ventricular pace or also a PVC. The external variable va int is provided by a separate driver process. In practice, this variable can have a lot of different values (any value between 0 and approximately 1000 ms in steps of 5 ms), but we have limited the number of possible values in the formal model to reduce the model state space size. Because va int is compared to two thresholds (a lower threshold of 150 ms and an upper threshold of 450 ms), we have modeled a possible value of va int for each of the three possible equivalence classes of the variable. So va int can be 100 ms (lower than the lower threshold), 300 ms (between the lower and the upper threshold) or 600 ms (higher than the upper threshold). How the variable value is precisely provided to the RC part depends on the tool specific modeling of data flows. So in mCRL2 the driver process can perform an s va int action parameterized with one of the three values. In the Uppaal model the global variable va int is non-deterministically changed into one of the three values by the first process in the RC part that needs va int (there are only two processes that use the variable and one of them is always the first one that uses it). The driver processes can arbitrarily send one of the input events and one of the va int values in each iteration, respectively. Therefore all combinations of input events and variable values end up in the state space in any event processing transition sequence where the combi69
Page 71
nation can possibly occur. In this way the RC part is extensively tested and flaws that reside in the RC part must be found by this approach. However note that we still do not vary the programmable pacemaker parameters that are used in the RC part, hence only flaws for the factory settings of these parameters can be found. Although the driver processes take some interdependencies into account while providing all combinations and sequences of input events and variable values to the RC part, impossible event sequences can occur if these interdependencies are modeled incorrectly or incompletely. Note that modeling all interdependencies between the input events is hard, because the occurrence of many events depends on the behavior of processes that are not included in this approach. This does not have to be a problem; the set of all provided event sequences includes the set of all possible event sequences and hence the RC part is at least verified for all possible behavior of its natural environment. If any provided impossible event sequence results in a violation of the requirements to the RC part, the trace that corresponds to this violation can be inspected. When this inspection makes clear that the provided input sequence is impossible with respect to the natural behavior of the RC part environment, the violation can be ignored because it will not occur during normal operation of the RC part. If the behavior in this violation trace makes clear that a dependency must be added to the driver processes and adding this dependency is also feasible, this can be done. This is preferred because adding dependencies to the driver processes will decrease the number of input combinations which also means a reduction of the state space size. Otherwise, when adding a dependency is not possible or too complicated, this can be omitted; but then one has to be alert on the occurrence of impossible event sequences which can cause requirement violations.
Determination of the RC part requirement The basic purpose of the RC part is classifying whether an incoming atrial sense is a normal atrial sense (output AS event) or a retrogradely conducted atrial sense (output RAS event). Besides these two events the only output of the RC part is diagnostic information that is not responsible for the behavior of the firmware (not in figure 6.1) and therapy data of the RC Test. This latter therapy data is only used if the RC Test therapy is active and even then it is just an adaptation of the therapy data that was used before RC Test was made active. So model checking of the isolated RC part must be focused on verifying the requirement that each incoming atrial sense is classified by the processes in the RC part. At the start of this approach we were not aware of the need of focusing on this requirement (which was mainly due to a lack of understanding of the purpose of the RC processes) and we modeled a separate stub process for receiving the output events AS and RAS. Because Vitatron indicated that the present flaw in the RC part could result in a deadlock, we only verified the ‘absence of deadlock’-requirement (note that the other two requirements from section 6.1 also make no sense here, because the formal models of the heart and PG are not included in this approach). From this verification, the model appeared to be deadlock free which normally would be great, but not in this case because we wanted to find the known deadlock by means of model checking. After this unsatisfactory result, some consultations with Vitatron gave awareness of the mentioned requirement to the RC part. Although it may seem like we were aiming at changing 70
Page 72
the model in order to find the specific flaw by means of model checking, these consultations were more meant to invent the requirement(s) that must be verified on the RC part. Getting aware of the ‘AS/RAS-classification requirement’ to the RC part led to changing the driver processes and stub processes. Instead of receiving the AS/RAS-classification by a separate stub process, we changed the event sending driver process such that it expects the classification after sending an atrial sense to the RC part. So when this driver process has sent an atrial sense event to the RC Monitor, it waits on the AS/RAS-classification (coming from some subprocess of the RC Monitor) before it accepts an acknowledgment message of the RC Monitor (note that the AS/RAS-classification is normally sent to another firmware process that is not present in this approach, so the driver process acts as this process to receive the classification). If the model does not satisfy the requirement, because on a certain moment the atrial sense event is not classified in the RC part, then the driver process will keep waiting on the classification while the RC Monitor waits until it can send an acknowledgment message to the driver process. This is a deadlock situation which can be detected by the model checker; the model satisfies the formulated requirement if and only if the model is deadlock free.
6.4.1 mCRL2 results
We have verified the constructed mCRL2 model7 by instructing the tool lps2lts to detect deadlocks in the model during state space generation. Furthermore we have requested traces to any found deadlocks, which enabled us to inspect them in order to check whether a found deadlock is caused by a problem in the firmware design or by an error in the formal model. This resulted in finding the deadlock that is known at Vitatron. The deadlock state can be reached by various traces8 , but is always caused by the fact that the AS/RAS-classification is not delivered by the RC part under certain circumstances. The verification has been executed by the mCRL2 tools in approximately four minutes on a state space of less than a million states. Compare this to the state space sizes in the heart model approach in section 6.2.1; the big difference can be explained by the absence of many processes that store information about the rate of recent events in their variables (e.g. the physiological band) and by the absence of time representing tick-actions in the RC part. An essential element in all found deadlock traces was the occurrence of a PFAS after a ventricular pace. PFAS stands for Potential Farfield Atrial Sense and depicts that the received atrial sense event has not been caused by a real atrial contraction, but by ventricular activity that is sensed on the atrial lead of the pacemaker. In the RC part an atrial sense is classified as PFAS if it is received at most 150 ms after the preceding ventricular event (this 150 ms is the lower threshold that is mentioned on page 69). Figure 6.2(a) shows when an atrial sense is classified as PFAS. But in the natural environment of the pacemaker firmware, the PG hardware contains a mechanism to prevent that farfield atrial senses are sent to the firmware, which is called farfield blanking (FF-blanking). By default this FF-blanking mechanism ignores a sense on the atrial lead if it is received within 150 ms after the last ventricular pace or within 50 ms after the 7
This model can be found in the electronic appendix: mCRL2/Isolated RC approach section 6.4.mcrl2 Five of these witnessing traces can be found in the electronic appendix: mCRL2/RC dlk 0.trc . . . mCRL2/RC dlk 4.trc 8
71
Page 73
last ventricular sense. This is shown in figure 6.2(b). So in the standard configuration of the FF-blanking mechanism, no PFAS can ever occur after a ventricular pace in the pacemaker, because the blanking time interval hides all atrial senses in the time interval below the lower threshold. However, the blanking time interval after a ventricular pace (by default 150 ms) is programmable by the cardiologist in a range from 50 to 300 ms. Clearly if this time interval would be programmed smaller than 150 ms, PFASs are possible after a ventricular pace, thus making it possible that the found deadlock traces occur. This is shown in figure 6.2(c) wherein the blanking time interval after a ventricular pace has been set to 50 ms.
Figure 6.2: Relationship between PFASs and FF-blanking mechanism In our driver process that is responsible for sending the variable va int to the RC part we had not taken the FF-blanking mechanism into account. Because of that we got the mentioned deadlock traces in which a PFAS does occur after a ventricular pace. When we realized that these traces could actually not occur in the standard configuration of the pacemaker firmware, we modeled the FF-blanking mechanism into the driver process by disallowing sending the value 100 for the variable va int if the last ventricular event was a ventricular pace. Recall that the driver process could send three different values for va int, namely 100, 300 or 600 ms; from these three values 100 is not possible if the last ventricular event has been a ventricular pace and the FF-blanking time interval has been programmed to its default value of 150 ms. After this change to the driver process, we verified the model once again. This resulted in finding other deadlock states in the model, whose witnessing traces9 all contained the processing of at least three successive ventricular paces (without any intermediate atrial event) that have been sent by the driver process. This is highly unlikely behavior in the natural RC part environment, because the process Escape Timing always plans an atrial pace after a ventricular pace; there is one exception in which a new ventricular pace is planned after a ventricular pace, but this planned pace itself will certainly cause Escape Timing to 9 All these witnessing traces can be found in the electronic appendix: mCRL2/RC+FF dlk 3.trc
72 mCRL2/RC+FF dlk 0.trc . . .
Page 74
plan an atrial pace. So the maximum number of successive ventricular paces without any intermediate atrial event is two. Therefore the deadlocks that are found in this approach, wherein we added the FF-blanking mechanism to the driver process, can be safely ignored. While reflecting on these results, we discovered a potential risk in model checking by this approach. If one would not be familiar with the known deadlock and would only have verified a model containing the modeling of FF-blanking (in its default configuration where the blanking time interval after a ventricular pace is 150 ms), only the highly unlikely deadlock states, resulting from action sequences containing at least three successive ventricular paces, would have been found. Because PFASs can not occur in this model with default FFblanking, the more likely deadlocks are not present in this model. Furthermore, the length of the FF-blanking time interval after a ventricular pace is just one of the numerous programmable parameters, so it is plausible that this parameter would not have been lowered in this verification which would also have been an option to find the likely deadlock. Finally by ignoring the found deadlock states (resulting from the traces that contain at least three ventricular paces) that have been classified as highly unlikely, no deadlock states are left in the state space of the model that includes the FF-blanking mechanism in its default configuration (blanking time interval after a ventricular pace of 150 ms). Therefore, one would wrongly draw the conclusion that the RC part behavior satisfies the ‘AS/RAS-classification requirement’. Although this observation depends on the specific system that is verified, we can conclude that it is recommendable to start a model checking approach like this with as much abstraction (i.e. allowing the driver processes to send all combinations of input events and input variables, without taking interdependencies into account) as possible (with respect to modeling techniques and feasibility of the state space size) to avoid potential missing of flaws in the behavior. Note that adding interdependencies to the model decreases the abstraction level and vice versa; before adding the FF-blanking mechanism to the driver process in the isolated RC approach the abstraction level was higher than after this addition. However, the addition of the FF-blanking mechanism hid crucial aspects of the behavior, which would not be known if the approach was started on this level of abstraction. Initially we also applied much abstraction to the driver process that sends the possible events to the RC part; this was done by allowing this driver process to send all events without taking dependencies on preceding sent events into account. This high abstraction level resulted in a rather unnecessary state space explosion, because the state space contained impossible traces from pacemaker perspective (for instance traces occurred in which the driver process sends a PVC immediately after an atrial sense, while a PVC can only occur after another ventricular event according to its definition). Through getting aware of the presence of such impossible traces and the increasing effect on the model state space size, we encountered the need for modeling dependencies between events in the driver process. This means that we have constructed the isolated RC model by using a kind of topdown approach, with respect to the abstraction level. Decreasing the abstraction level means decreasing the state space size but also a potential disguise of crucial flaws in the system behavior, so any decrease of abstraction must be considered carefully.
73
Page 75
6.4.2
Uppaal results
After we have found the known deadlock in the RC part with mCRL2, we tried to reach the same result with Uppaal. Because the state space of the mCRL2 model was relatively small and the verification was done in just several minutes, we were good-tempered in achieving this goal. So we verified the ‘no deadlock’-property A[] not deadlock on the constructed model10 ; FF-blanking has not been included in this model in order to find the likely deadlock. After approximately 4,5 days of verification time, Uppaal reported that the model does not satisfy the ‘no deadlock’-property and delivered a witnessing trace11 . This trace conforms to one of the (likely) traces that we found with mCRL2. Note that the Uppaal model of this approach does not contain any clock variables, because there is no time involved in the RC part. Because Uppaal actually is designed to verify timed transition systems, this fact might have influenced the verification time negatively in this case.
6.4.3 mCRL2 verification of the deadlock consequences
In this section some small changes are made for confidentiality reasons. In the original text, too many details of the ‘second requirement’ are mentioned.
At Vitatron it is known that the found deadlock in the RC part can result in a situation in which the ‘second requirement’ is violated, which is undesirable. This known consequence of the RC deadlock has even been the inspiration to formulate the ‘second requirement’. Therefore after we found the RC deadlock we were curious whether this undesirable consequence could also be found in the formal model that includes the heart model and the RC functionality. In the approach that is described in section 6.3 we clearly have not found this consequence because there can not occur a PFAS after a ventricular pace in this default configuration of the FF-blanking mechanism, which is included in the formal PG process. Therefore we adapted the model such that PFASs could occur after a ventricular pace12 and verified the ‘second requirement’ on the resulting model. We found several traces to a violation of this requirement in the model state space. All these traces correspond to one of the traces that have been found in the isolated RC model. After the atrial sense event that is not classified by the RC part (causing the deadlock in the isolated RC model) the next ventricular sense event causes a violation of the ‘second requirement’. Explaining the exact reason why this violation occurs after the absence of the AS/RAS-classification is beyond the scope of this report, but it is important to notice that the reason resides in the cooperating core firmware processes AV Monitor and Escape Timing. 10
This model can be found in the electronic appendix: Uppaal/Isolated RC approach section 6.4.xml This witnessing trace can be found in the electronic appendix: Uppaal/RC dlk-1.xtr 12 This has been done by decreasing the FF-blanking time interval to 50 ms, fixing the sensed AV delay to 200 ms, and allowing the atrium to show a high rate of 180 bpm (the latter is necessary to make PFAS occurrences possible). 11
74
Page 76
Because we have found this violation of the ‘second requirement’ through adapting the formal model by using knowledge of the deadlock, this result is not that important from model checking perspective. But on the other hand it is a nice example of investigating the consequences of a found flaw (in a part of the model) on the external behavior of the complete model. Finding a flaw in an isolated part of a model is generally much easier, because often a model part does have fewer dependencies on external variables and parameters which makes it possible to vary these variables and parameters in order to verify the model part more extensively. After finding a flaw in a model part, the precise external variables and parameters for which this flaw occurs can be put in the complete model in order to discover the consequences of the found flaw on the external behavior of the complete model.
75