












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













IJICIS, Vol.17 No. 3 JULY 2017
E. K. Elsayed E. E. El-Sharawy A. A. Ibrahim
Mathematical Department., Faculty of s Science, Al-Azhar University, Nasr City, Cairo, Egypt [email protected] [email protected] [email protected]
Abstract: The correct formal design is an achievement in software engineering, but we faced with challenges to satisfy that. The informal problems types are general or special. The special informal problems depend on the case study and the general informal problems come from an inexperienced designer called anti-patterns". In this paper we discuss these two types on Insulin Infusion Pump (IIP) and sample of UML class diagrams. The proposed approach to formalize IIP is based on using event B. Finally, we could verify that the code generated from the proposed approach is correct and formal to use as a pattern. The accuracy of the proposed verification steps are suitable for using to any systems or medical device. We applied the proposed approach on the sample of eight famous UML class diagrams used as templates. The method ameliorates the proof percentage . Keywords: Event-B, Insulin Infusion Pump (IIP), patterns, anti-patterns.
1. Introduction
Insulin Infusion pumps are medical devices used to drugs delivery to patients at specific rates and in precise amounts. It is necessary to design and manufacture of these medical devices correctly so as for ensuring the safety of patients and defects, but there are many of the informal problems types are general like an anti-pattern or special problems such as in the IIP.
There are many works introduce to detect only special problems like in references [1], [2] and [3]. In addition, there were many works for the general problems detection such as in references [4], [5] and [6], but our proposed method covered all the informal problems (special and general). In addition, Using Formal methods languages like Event-B can be support mathematical reasoning required for detecting this kind of problems.
Formal methods can, and must play an important role to verify the system requirements, and in guaranteeing the correctness, reliability and safety of developing system software. Since software plays an important role in all fields as the medical field, like the FDA, it needs an effective way to evaluate embedded in the devices. That is to certify the systems developed and to guarantee the safe behavior of each system [7, 8, 9]. Many people believe that formal methods have the potential to develop dependable, safe and secure systems that are also more amenable to certification with required features that can be used to certify dependable medical systems [9, 10].
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
Event- B is a formal method for specifying, modeling and reasoning systems. Event- B is an evolution of the B-Method [11] developed by Jean-Raymond Abrial. A model in Event-b consists of contexts and machines, Contexts contain the static part (types and constants) of a model while Machines contain the dynamic part (variables and events). The modeling elements of a context [12, 13] have four types: sets, constants, axioms, and theorems. A Machine consists of variables, invariants, events, theorems and variants. Variables, v, define the state of a model. All events are Atomic and can be executed only when their guards hold [4]. There are various relationships between contexts and machines. A context can be "extended" by other contexts and "referenced" or "seen" by machines. A Machine can be "refined" by other machines and can reference to contexts as its static part.
A Design pattern is a general repeatable solution to a problem which usually occurring in software design. It's not a finished design which can be converted directly into code. But It is a description or template for how to solve a problem that can be used in various positions. In object-oriented programming, a pattern may include the description of certain objects and object classes to be used, side by side of their attributes and dependencies. The intention of Design Patterns in Event-B is to have a methodological approach to reuse former developments (referred to as patterns) in a new development. The patterns approach is a promising avenue to let inexperienced designers build conceptual models and as a tool for building domain models [14].
In Event-b pattern the proofs of the pattern can be reused too. It was shown that for the special case of a model that does not see any context and its events do not have any parameters, the generation of a refinement of the problem at hand is correct by construction and no proof obligation needs to be generated again. The correctness of the construction relies on a correct matching of the pattern with the problem [15].
Anti-patterns have a negative impact on the comprehension and maintainability of a software system. The designer may introduce anti-patterns in their models because of time pressure, lack of understanding, communication, and–or skills. To develop high-quality models, a designer must have the support of expressive engineering tools such as detection anti-patterns tools. Anti-patterns are defined as design patterns whose purpose is to document common bad practices in software design [16].
The ability to successfully design software projects is highly depending on using patterns without informal problems “Anti-pattern”. This will lead us to believe that having a general tool for verification and validation of a pattern design is important. In software engineering, the levels of detection of anti- patterns are project management level, design level, and code level. Good results have been obtained in all levels. There is a tool under implementation for detecting the project management anti-patterns [17]. Also, there are many papers that propose detection techniques at the design level as proposed in [18], but the code level in [19] focuses on certain types of anti-patterns. The remainder of this paper is organized as follows: Section 2 presents related work. The proposed method phases are presented in Section 3. Our approach is applied in a case study in section 4. Section 5 presents the analysis of results. Finally, we present the Conclusion and future work in section 6.
2. Related Work
In this section, we will present some attempts to improve the pattern quality or solve certain anti- pattern. In 2014 Eman k. [4], proposed an attempt to enhance the software quality by detecting the anti- patterns problems on certain model as ATM model. The proposed approach improved the proof obligation by SMT solver. This method detected only some general anti-patterns in the event B model.
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
3. Case Study
We implement our case study by using a RODIN platform on IIP. Where event-b is supported by a RODIN platform [21], an open-source tool implemented in the Eclipse framework, this tool provides an Event-B integrated development environment, automated proof strategies, a model checking and code generation.
Also, Insulin Infusion Pump (IIP) is a small, complex, software-intensive medical device that allows controlling continuous under the skin infusion of insulin to patients. It delivers physiological quantities of insulin between meals and at meal times. An insulin pump composed of the physical pump mechanism, a disposable reservoir and a disposable infusion set. The pump system includes a controller, and a battery. The disposable infusion set includes a cannula for subcutaneous insertion, and a tubing system to interface the insulin reservoir to the cannula. At present, open-loop and closed-loop insulin pumps exist. A closed-loop insulin pump is also known as an artificial pancreas, which automatically monitors and controls the blood glucose level of a patient. In an open-loop insulin pump, patients' needs to monitor the blood glucose level manually. An insulin pump can be programmed to release small doses of insulin continuously (basal), or one shot dose (bolus) before a meal, to control the rise in blood glucose.
The application of the phases is as the following:
The First phase is detecting and correcting all types of informal problems from a model.
1- The special informal problems which depend on the case study as in IIP model. These are as:
Prob1: the basal profile process which the interaction between the user and device doesn’t clear. Prob2: the pause and resume of the IIP are essential behavior it satisfies the definition of unpredictable events. prob3: The device can't suspend all active basal delivery or bolus deliver during pump refilling and in the case of system failure. Prob4: The device doesn't allow undergo a power-on-self-test (POST) whenever the device power is turned on. Prob5: The device doesn't allow the user to manage system functionalities that related to: stopping the insulin delivery; validating basal profile parameters; reminder management and validating bolus preset parameters. Prob6: the user doesn't enable to create a food database that can be used to store food or meal descriptions and the carbs associated with them. Prob7: The device doesn't allow for the user to change parameter setting basal profile, bolus preset, and temporary basal. Prob8: The device doesn't allow the user to define a basal profile that consists of an ordered set of basal rates of the user. Prob9: The device can contain several basal profiles, but not only one basal profile can be active at any single point in time. Prob10: The device doesn't allow the user to override an active basal profile with a temporary basal, without changing the existing basal profile. Prob11: the active basal profile, can't resume after the temporary basal ends. Prob12: The user doesn't be able to stop the active normal or extended bolus. Prob13: The device doesn't maintain a history of basal and bolus dosages over the past n-days.
IJICIS, Vol.17 No. 3 JULY 2017
Prob14: The device doesn't maintain of an electronic log of every operation associated with a user alert Prob15: The device doesn't provide feedback to the user regarding system and delivery status. Prob16: The device can't enforce a maximum dosage for the normal bolus or extended bolus.
To solve these special informal problems we present ten incremental refinements of IIP model. These refinements are implemented by Event-B modeling language to formalize the given system. The eleven incremental refinements are briefly described as in different references as [2] [3]. Initial Model (Power Status) includes two phases. Practically, by using the Rodin platform in the preparation phase consisted of the power on/off, pump priming; input settings (user programmed variables).
The insulin infusion phase is the main activation phase of the system. The INFU_START and the INFU_ PROC indicate the main functional behavior of the system. An Event-B context declares enumerated set power State defined using axioms ( axm 1 – axm 2) for power status. An abstract model declares a list of variables defined by invariants ( inv1 – inv3 ).
We introduce four events to specifying the desired functional behavior for controlling the power status of an IIP. These events include guard(s) for enabling the given action(s), and the actions that define the changes to the states of the power status here, we provide all events related to The preparation phase (POWER ON, INFU START, INFU PROC and POWER OFF).
Ref1 : This refinement refined the initial model behavior into two phases; one focus on the basal profile setting and the priming process and the other phase refined the infusion process event into several sub
IJICIS, Vol.17 No. 3 JULY 2017
Ref3 : This refinement introduce the time issues and the corresponding solutions for them prob2 by applying several timing patterns to the infusion process in the IIP. According to the requirements, the main behaviors of the IIP are described in two kinds of insulin infusion processes, called basal and bolus. The insulin infusion process is classified into four groups: basal, temporary basal, bolus and extended bolus. Twenty seven events are introduced to refine the infusion process and use a special event TICK TOCK to control time incrementing in the whole system.
Ref4 : This refinement helps to solve both prob3and prob4 by introducing new ten events for specifying the desired functional behavior for controlling the power status of an IIP such as POST_Completed event.
Ref5 : This refinement applies to solve each prob5, prob6 and prob8. This refinement displays 35 events to determine all the possible of user operations related to the IIP given problems such as event CurrActiUserOper_Idle1 that allows a user to create a new basal profile.
Ref6: It introduces to overcoming prob6 and prob7. That is by adding 58 events to model the basal profile management, which contain some functions such as checking the completion of removing task, checking the validity of the selected basal profile, activating basal profile.
Ref7 : This refinement can conquer prob10 and prob11_._ This refinement offer 22 events to model temporary basal profile management. That includes multiple operations like activating, checking validity of entered profile and deactivating the temporary basal profile.
Ref8 : This refinement applied to overcome all prob5 and prob12. This refinement submits total 37 events to model the bolus preset Management, which have different subtasks such as creating, activating, checking validity of entered data and removing the bolus preset.
Ref9 : This refinement presents to fix prob12 and prob13. It introduces 33 events to model bolus delivery calculation, which includes checking validity of bolus calculation.
Ref10 : This refinement can solve prob14 and prob15 by introducing 28 events to model the reminder management, which includes various operations like creating a new reminder, checking validity of a new entered reminder and removing an old reminder. Finally,
Ref11: This refinement produces a solution for prob16 and prob13. This refinement presents 40 events. Where, 14 events to refine other previously abstractly defined events and 26 events to model the insulin calculator.
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
2- Detection of the general informal problems called "anti-patterns".
In this part of phase one, we start to detect the anti-patterns from any model. That is by converting it to event-b first. In this case study, we detect the IIP anti-patterns problems by using the Event-b. When you need to construct models, you must be alert to any anti-patterns and solve them. Anti-patterns classify into three main parts; semantic anti-pattern, behavior anti-pattern and structure anti-pattern [4]. Our proposal detects the structure anti-pattern automatically. That is by creating Event-b model and solving the problems.
The following examples present some structure anti-patterns. Figure 1 presents the anti-pattern in Event-B machine of IIP model when loose association between Event-B components. The error description list helps designer to know that. Also Figure 2 shows “The default case of the variable not determined anti-pattern” and how Event-B detects it. Another example is “Concatenation to Empty guard anti-pattern” and" unused parameters, anti-pattern "as shown in Figure 3, 4 respectively.
Figure1: Missing a relation between Event-B component
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
Figure4: Anti-pattern When unused parameters
Also, we detected a general informal problem in another case study called (Hospital UML class diagram). The Hospital UML class diagram contains six classes (Hospital, Booking, Doctor, Patient, Continues and not Continues). The class "Booking" has five attributes and three operations, the class "Doctor" has five attributes and no operations, the class "patient" has no attributes and four operations, the class "Hospital" has two attributes and no operations, the class "Continuous " has two attributes and no operations and finally the class "not Continuous" has two attributes and no operations. The model also has seven associations, some of them with known multiplicity and some not known. That is as shown in Figure
IJICIS, Vol.17 No. 3 JULY 2017
Figure5: Hospital UML class diagram
The UML structure general informal problems (anti-patterns) are detected practically in three levels, some detected during the first level in UML-B or iUML-B when we start by using UML-B plugin certainly. Some detected during the second level “convert UML-B to Event B”. Finally, some detected in the third level “proof obligations”.
The anti–patterns have been detected in these phases are shown in Figure's 6, 7, 8,9,10 respectively. There are:
Figure 6: Attribute doesn't have a data type
IJICIS, Vol.17 No. 3 JULY 2017
Figure9: event make operation in class patient
Figure10: Invalid expression guard of the event make operation
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
From the importance of detecting general anti-patterns we created a new Eclipse plugin in Rodin platform. That is by using the eclipse platform to create this plugin. The plugin has information about all structure anti-patterns to help the users of RODIN. It will only contain documentation files, and then the easiest way to proceed for beginners is to start from the available template. In RODIN Help, the user can see that a new Anti-pattern item has been created in help contents for help menu as shown in Figure11.
Figure11: Help contents of RODIN which contain new anti-pattern files.
The second phase is applying SMT solver for increasing the automation degree by decrease the proof obligation. We used SMT-solvers as Automatic verification of proof obligations. The configuration of the plug-in includes a choice of SMT-solvers. It is now available to the formal methods community as an exploratory package through Rodin’s official source code repository. Currently, the verification with the SMT-solver has to be activated as shown in Figure 12. The verification was successes as shown in Figure13.
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
The third phase converts model to confidence pattern with saving proof.
Practically, in this phase we use "pattern plugin" in RODIN platform. That is for more abstract solution. The screenshot in figure(s) 14, 15,16 and 17 present the convert steps. Where, figure8 is illustrates the matching step between the problem and the specification. This phase contains a dialog for the developers to choose the matching between variables and events.
Figure 9 presents the syntax checking of the matching provided by the user in the previous step. Figure 10 presents the incorporating of the refinement of the pattern into the development. And Figure 11 presents the renaming pattern of both variables and events.
Figure14 First step. Matching Figure15 Second step. Syntax Checking
Figure 16 Third step. Incorporating Figure 17 Fourth step. Renaming
IJICIS, Vol.17 No. 3 JULY 2017
The fourth phase is Automatic C++ Code Generation for IIP Pattern Model. Once the pattern has been converted manually, all selected events- without explicit- was translated automatically using the EB2C++ plugin for the RODIN Platform. A single C++ file is produced for each machine. C++ code generation has a different phase of the translation process. An Event-b pattern is initially restated in an easily translatable subset of the notation “Rewrite Phase”. C++ code is then automatically generated from the pattern through a suitable tool “Translation Phase”. Finally “Build Phase” adds support functions and the compiler of the source code language. After applying three phases for generating C++ code from IIP algorithm in Event-B model we obtained the code as in Figure 18.
4. Analysis of result
In this section, we analysis the results of our proposed method as in the following:-
In RODIN platform, a model can’t prove full automatic, so we unable to generate code from the Rodin event B model directly. But by using the SMT solver help for increasing the proof obligation automatically and save it. By using SMT-Solver approach the proof raised to (62%) proof instead of (44%) that obtained by applying Rodin only as shown in table1 that present the Proof statistics of Insulin Infusion Pump (IIP) model after solving all informal and anti-patterns from the model and using SMT solver.
POs Methods / POs
Total POs
Auto Interactive (SMT)
Proved POs %
Undercharged
Rodin 214 96 0 96(44%) 118 SMT 214 96 38 134(62%) 80
Table1. Proof Obligation analysis of IIP pattern.
Now, to verify and ensure that there are not anti-patterns problems were found in our IIP pattern, we used reverse engineering tools like Imagix4D [22] which check all properties of C++ generated code (according to the fourth phase ). Then we produce a list of reports such as:
Figure18: Example of Event PPOWERON translated in C++ code
IJICIS, Vol.17 No. 3 JULY 2017
5. Conclusions and Further Works
The proposed method is used to verify a medical model such as insulin pump. That is by using formal method to ensure the correctness and stability during proof stage. Using pattern after removing the anti- patterns give us two properties reusability and save the effort of modeling. The code was generated after detection anti-patterns are more confident.
In the future, we are going to correct the anti-patterns automatically. Also we will create a plugin in RODIN to detect and fix the anti-patterns automatically. Also, we will make a comparative study between our method and the methods based on ontological analysis.
References
Ibrahim Et Al: A METHODOLOGY FOR DESIGNING HIGH CONFIDENCE PATTERN VIA EVENT B
system-UML, access at Jan. 2017.
overview.html, access at Jan. 2017.