contents...23.01.2018 12:37 page 1 of 196 an event-b speci cation of insulin pump whole 7 context c...
TRANSCRIPT
![Page 1: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/1.jpg)
An Event-B Specification of Insulin pump whole 7
Contents
CONTEXT c basal 2
CONTEXT c basal2 3
CONTEXT c prog 4
CONTEXT c prog2 5
CONTEXT c prog2 anim 6
CONTEXT c sd bolus 7
CONTEXT c normalbolus 8
CONTEXT c normalbolus anim 9
MACHINE control 10
MACHINE control2 12
MACHINE control3 14
MACHINE control4 17
MACHINE control5 22
MACHINE control6 27
MACHINE control Basal6 33
MACHINE control Basal6 2 45
MACHINE control Basal6 NormalBolus 58
MACHINE control Basal6 NormalBolus 2 71
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 86
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3 102
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4 122
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 142
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 159
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2 178
23.01.2018 12:37 Page 1 of 196
![Page 2: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/2.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c basal
CONTEXT c basal
SETS
BASALMODE
CONSTANTS
basal max
c
suspended
delivering
stop
AXIOMS
axm1: basal max ∈ N1
axm2: c = 48
axm3: partition(BASALMODE, {suspended}, {delivering}, {stop})END
23.01.2018 12:37 Page 2 of 196
![Page 3: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/3.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c basal2
CONTEXT c basal2
EXTENDS c basal
SETS
PROG0
CONSTANTS
null
call get min
return get min
call get max
return get max
PROC BASAL
AXIOMS
axm2: PROC BASAL ⊆ PROG0
axm1: partition(PROC BASAL, {null}, {call get min}, {return get min}, {call get max}, {return get max})
END
23.01.2018 12:37 Page 3 of 196
![Page 4: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/4.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c prog
CONTEXT c prog
EXTENDS c basal2
CONSTANTS
PROG
call basal start
return basal start
call basal stop
return basal stop
call basal suspend
return basal suspend
call basal resume
return basal resume
call basal update
return basal update
call normal suspend
return normal suspend
call normal finish
return normal finish
call normal resume
return normal resume
call normal start
return normal start
AXIOMS
axm2: PROG ⊆ PROG0
axm1:partition(PROG, {null}, {call basal start}, {return basal start}, {call basal stop}, {return basal stop},{call basal suspend}, {return basal suspend}, {call basal resume}, {return basal resume},{call basal update}, {return basal update}, {call normal start}, {return normal start},{call normal suspend}, {return normal suspend}, {call normal finish}, {return normal finish},{call normal resume}, {return normal resume})
END
23.01.2018 12:37 Page 4 of 196
![Page 5: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/5.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c prog2
CONTEXT c prog2
EXTENDS c prog
CONSTANTS
call sd start s
return sd start s
call sd start d
return sd start d
call sd update
return sd update
call sd finish
return sd finish
call sd suspend
return sd suspend
call sd resume
return sd resume
call sd preempt
return sd preempt
call sd resume preempt
return sd resume preempt
pg2
AXIOMS
axm2: pg2 ⊆ PROG0
axm1: partition(pg2, {call sd start s}, {return sd start s}, {call sd start d}, {return sd start d},{call sd update}, {return sd update}, {call sd finish}, {return sd finish}, {call sd suspend},{return sd suspend}, {call sd resume}, {return sd resume}, {call sd preempt},{return sd preempt}, {call sd resume preempt}, {return sd resume preempt})
axm3: PROG ∩ pg2 = ∅END
23.01.2018 12:37 Page 5 of 196
![Page 6: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/6.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c prog2 anim
CONTEXT c prog2 anim
EXTENDS c prog2
AXIOMS
axm1: PROG0 = PROG ∪ pg2 ∪ PROC BASAL
END
23.01.2018 12:37 Page 6 of 196
![Page 7: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/7.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c sd bolus
CONTEXT c sd bolus
SETS
SD
SDF
CONSTANTS
deliver
off
suspend
preempt
s
d
AXIOMS
axm1: partition(SD, {deliver}, {off}, {suspend}, {preempt})axm2: partition(SDF, {s}, {d})
END
23.01.2018 12:37 Page 7 of 196
![Page 8: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/8.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c normalbolus
CONTEXT c normalbolus
CONSTANTS
normal bolus rate
AXIOMS
axm1: normal bolus rate > 0
END
23.01.2018 12:37 Page 8 of 196
![Page 9: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/9.jpg)
An Event-B Specification of Insulin pump whole 7 CONTEXT c normalbolus anim
CONTEXT c normalbolus anim
EXTENDS c normalbolus
AXIOMS
axm1: normal bolus rate = 2
END
23.01.2018 12:37 Page 9 of 196
![Page 10: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/10.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control
MACHINE control
VARIABLES
normal bolus work
sd bolus work
sd preempted by normal
INVARIANTS
inv1: normal bolus work ∈ BOOLinv2: sd bolus work ∈ BOOLinv3: sd preempted by normal ∈ BOOLinv4: normal bolus work = TRUE⇒ (sd bolus work = FALSE∨sd preempted by normal = TRUE)
inv5: sd preempted by normal = TRUE⇒ sd bolus work = TRUE
EVENTS
Initialisation
beginact1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
end
Event normal bolus start 1 〈ordinary〉 =̂
whengrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
end
Event normal bolus start 2 〈ordinary〉 =̂
whengrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
thenact1: normal bolus work := TRUE
end
Event normal bolus finish 〈ordinary〉 =̂
whengrd1: normal bolus work = TRUE
thenact1: normal bolus work := FALSE
end
Event square or dual bolus start 〈ordinary〉 =̂
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
thenact1: sd bolus work := TRUE
end
Event square or dual bolus finish 〈ordinary〉 =̂
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
thenact1: sd bolus work := FALSE
end
Event square or dual bolus resume of normal 〈ordinary〉 =̂
when
23.01.2018 12:37 Page 10 of 196
![Page 11: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/11.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control
grd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
thenact1: sd preempted by normal := FALSE
end
END
23.01.2018 12:37 Page 11 of 196
![Page 12: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/12.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control2
MACHINE control2
REFINES control
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
INVARIANTS
inv2 8: sd suspend ∈ BOOLinv3 9: normal suspend ∈ BOOLinv4 10: sd suspend = TRUE⇒ sd bolus work = TRUE ∧ sd preempted by normal = FALSE
inv5 11: normal suspend = TRUE⇒ normal bolus work = TRUE
EVENTS
Initialisation
beginact1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
end
Event normal bolus start 1 〈ordinary〉 =̂
refines normal bolus start 1
whengrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
end
Event normal bolus start 2 〈ordinary〉 =̂
refines normal bolus start 2
whengrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
thenact1: normal bolus work := TRUE
end
Event normal bolus finish 〈ordinary〉 =̂
refines normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal bolus work := FALSE
end
Event square or dual bolus start 〈ordinary〉 =̂
refines square or dual bolus start
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
23.01.2018 12:37 Page 12 of 196
![Page 13: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/13.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control2
thenact1: sd bolus work := TRUE
end
Event square or dual bolus finish 〈ordinary〉 =̂
refines square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd bolus work := FALSE
end
Event square or dual bolus resume from normal 〈ordinary〉 =̂
refines square or dual bolus resume of normal
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: sd preempted by normal := FALSE
end
Event normal suspend 〈ordinary〉 =̂
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
end
Event normal resume 〈ordinary〉 =̂
extends normal bolus finish
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
thenact1: normal bolus work := FALSE
act2: normal suspend := FALSE
end
Event sd suspend 〈ordinary〉 =̂
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
end
Event sd resume 〈ordinary〉 =̂
refines square or dual bolus finish
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
end
END
23.01.2018 12:37 Page 13 of 196
![Page 14: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/14.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control3
MACHINE control3
REFINES control2
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
INVARIANTS
inv1 12: basal work ∈ BOOLinv2 13: basal suspend ∈ BOOLinv3 14: basal suspend = TRUE⇒ basal work = TRUE
EVENTS
Initialisation
beginact1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
end
Event normal bolus start 1 〈ordinary〉 =̂
extends normal bolus start 1
whengrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
end
Event normal bolus start 2 〈ordinary〉 =̂
extends normal bolus start 2
whengrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
thenact1: normal bolus work := TRUE
end
Event normal bolus finish 〈ordinary〉 =̂
extends normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal bolus work := FALSE
end
Event square or dual bolus start 〈ordinary〉 =̂
extends square or dual bolus start
23.01.2018 12:37 Page 14 of 196
![Page 15: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/15.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control3
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
thenact1: sd bolus work := TRUE
end
Event square or dual bolus finish 〈ordinary〉 =̂
extends square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd bolus work := FALSE
end
Event square or dual bolus resume from normal 〈ordinary〉 =̂
extends square or dual bolus resume from normal
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: sd preempted by normal := FALSE
end
Event normal suspend 〈ordinary〉 =̂
extends normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
end
Event sd suspend 〈ordinary〉 =̂
extends sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
end
Event normal resume 〈ordinary〉 =̂
extends normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
thenact1: normal bolus work := FALSE
act2: normal suspend := FALSE
end
Event sd resume 〈ordinary〉 =̂
extends sd resume
whengrd1: sd suspend = TRUE
then
23.01.2018 12:37 Page 15 of 196
![Page 16: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/16.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control3
act1: sd bolus work := FALSE
act2: sd suspend := FALSE
end
Event basal start 〈ordinary〉 =̂
whengrd1: basal work = FALSE
grd3: basal suspend = FALSE
thenact1: basal work := TRUE
end
Event basal stop 〈ordinary〉 =̂
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
thenact1: basal work := FALSE
end
Event basal suspend 〈ordinary〉 =̂
whengrd1: basal work = TRUE
grd3: basal suspend = FALSE
thenact1: basal suspend := TRUE
end
Event basal resume 〈ordinary〉 =̂
whengrd1: basal suspend = TRUE
thenact1: basal suspend := FALSE
end
END
23.01.2018 12:37 Page 16 of 196
![Page 17: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/17.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control4
MACHINE control4
REFINES control3
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
INVARIANTS
inv1 15: pump rate ∈ Ninv2 16: basal rate ∈ Ninv3 17: normal rate ∈ Ninv4 18: sd rate ∈ Ninv8 19: basal suspend = TRUE⇒ basal rate = 0
inv9 20: normal suspend = TRUE⇒ normal rate = 0
inv10 21: sd suspend = TRUE⇒ sd rate = 0
inv11 22: sd rate = 0 ∨ normal rate = 0
inv12 23: sd rate 6= 0⇒ (sd bolus work = TRUE ∧ sd preempted by normal = FALSE)
inv13 24: normal rate 6= 0⇒ normal bolus work = TRUE
inv14 25: pump rate = normal rate+ sd rate+ basal rate
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
end
Event normal bolus start 1 〈ordinary〉 =̂
extends normal bolus start 1
anyr
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ Nthen
act1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
act3: normal rate := r
23.01.2018 12:37 Page 17 of 196
![Page 18: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/18.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control4
act4: sd rate := 0
act5: pump rate := r + basal rate
end
Event normal bolus start 2 〈ordinary〉 =̂
extends normal bolus start 2
anyr
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
grd4: r ∈ Nthen
act1: normal bolus work := TRUE
act2: normal rate := r
act3: pump rate := r + basal rate
end
Event normal bolus finish 〈ordinary〉 =̂
extends normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal bolus work := FALSE
act2: normal rate := 0
act3: pump rate := basal rate
end
Event square or dual bolus start 〈ordinary〉 =̂
extends square or dual bolus start
anyr
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
end
Event square or dual bolus finish 〈ordinary〉 =̂
extends square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
end
Event square or dual bolus resume from normal 〈ordinary〉 =̂
extends square or dual bolus resume from normal
anyr
where
23.01.2018 12:37 Page 18 of 196
![Page 19: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/19.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control4
grd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
end
Event normal suspend 〈ordinary〉 =̂
extends normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
act2: normal rate := 0
act3: pump rate := basal rate
end
Event sd suspend 〈ordinary〉 =̂
extends sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
end
Event square or dual update rate 〈ordinary〉 =̂
anyr
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
thenact1: sd rate := r
act2: pump rate := r + basal rate
end
Event normal resume 〈ordinary〉 =̂
extends normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
thenact1: normal bolus work := FALSE
act2: normal suspend := FALSE
act4: normal rate := 0
act3: pump rate := basal rate
end
Event sd resume 〈ordinary〉 =̂
extends sd resume
whengrd1: sd suspend = TRUE
23.01.2018 12:37 Page 19 of 196
![Page 20: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/20.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control4
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
end
Event basal start 〈ordinary〉 =̂
extends basal start
anyr
wheregrd1: basal work = FALSE
grd3: basal suspend = FALSE
grd4: r ∈ Nthen
act1: basal work := TRUE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
end
Event basal stop 〈ordinary〉 =̂
extends basal stop
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
thenact1: basal work := FALSE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
end
Event basal suspend 〈ordinary〉 =̂
extends basal suspend
whengrd1: basal work = TRUE
grd3: basal suspend = FALSE
thenact1: basal suspend := TRUE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
end
Event basal resume 〈ordinary〉 =̂
extends basal resume
anyr
wheregrd1: basal suspend = TRUE
grd2: r ∈ Nthen
act1: basal suspend := FALSE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
end
Event basal update rate 〈ordinary〉 =̂
anyr
wheregrd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: r ∈ N
23.01.2018 12:37 Page 20 of 196
![Page 21: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/21.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control4
thenact1: basal rate := r
act2: pump rate := r + normal rate+ sd rate
end
END
23.01.2018 12:37 Page 21 of 196
![Page 22: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/22.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control5
MACHINE control5
REFINES control4
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
INVARIANTS
inv1 26: time ∈ Ninv2 27: t basal ∈ Zinv3 28: t normal ∈ Zinv4 29: t sd ∈ Zinv5 30: basal work = FALSE⇒ t basal = 0
inv6 31: normal bolus work = FALSE⇒ t normal = 0
inv7 32: sd bolus work = FALSE⇒ t sd = 0
inv1: normal suspend = TRUE⇒ normal bolus work = TRUE
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
end
Event normal bolus start 1 〈ordinary〉 =̂
extends normal bolus start 1
anyr
t
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
23.01.2018 12:37 Page 22 of 196
![Page 23: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/23.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control5
grd4: sd suspend = FALSE
grd5: r ∈ Ngrd6: t ∈ N
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
act3: normal rate := r
act4: sd rate := 0
act5: pump rate := r + basal rate
act6: t normal := time+ t
act7: t sd := t sd− timeend
Event normal bolus start 2 〈ordinary〉 =̂
extends normal bolus start 2
anyr
t
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N
thenact1: normal bolus work := TRUE
act2: normal rate := r
act3: pump rate := r + basal rate
act4: t normal := time+ t
end
Event normal bolus finish 〈ordinary〉 =̂
extends normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: time = t normal
thenact1: normal bolus work := FALSE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := 0
end
Event square or dual bolus start 〈ordinary〉 =̂
extends square or dual bolus start
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
end
23.01.2018 12:37 Page 23 of 196
![Page 24: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/24.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control5
Event square or dual bolus finish 〈ordinary〉 =̂
extends square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
end
Event square or dual bolus resume from normal 〈ordinary〉 =̂
extends square or dual bolus resume from normal
anyr
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t sd
end
Event normal suspend 〈ordinary〉 =̂
extends normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := t normal − timeend
Event sd suspend 〈ordinary〉 =̂
extends sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeend
Event square or dual update rate 〈ordinary〉 =̂
extends square or dual update rate
anyr
wheregrd2: sd suspend = FALSE
23.01.2018 12:37 Page 24 of 196
![Page 25: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/25.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control5
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
thenact1: sd rate := r
act2: pump rate := r + basal rate
end
Event normal resume 〈ordinary〉 =̂
refines normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
thenact1: normal bolus work := FALSE
act2: normal suspend := FALSE
act4: normal rate := 0
act3: pump rate := basal rate
act5: t normal := 0
end
Event sd resume 〈ordinary〉 =̂
extends sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event basal start 〈ordinary〉 =̂
extends basal start
anyr
t
wheregrd1: basal work = FALSE
grd3: basal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N1
thenact1: basal work := TRUE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
act4: t basal := time+ t
end
Event basal stop 〈ordinary〉 =̂
extends basal stop
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
thenact1: basal work := FALSE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
act4: t basal := 0
end
Event basal suspend 〈ordinary〉 =̂
23.01.2018 12:37 Page 25 of 196
![Page 26: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/26.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control5
extends basal suspend
whengrd1: basal work = TRUE
grd3: basal suspend = FALSE
thenact1: basal suspend := TRUE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
act4: t basal := 0
end
Event basal resume 〈ordinary〉 =̂
extends basal resume
anyr
t
wheregrd1: basal suspend = TRUE
grd2: r ∈ Ngrd3: t ∈ N1
thenact1: basal suspend := FALSE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
act4: t basal := t+ time
end
Event basal update rate 〈ordinary〉 =̂
extends basal update rate
anyr
t
wheregrd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: r ∈ Ngrd5: t basal = time
grd6: t ∈ N1
thenact1: basal rate := r
act2: pump rate := r + normal rate+ sd rate
act3: t basal := time+ t
end
Event timer 〈ordinary〉 =̂
beginact1: time := time+ 1
end
END
23.01.2018 12:37 Page 26 of 196
![Page 27: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/27.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control6
MACHINE control6
REFINES control5
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
dmodule
d update time
INVARIANTS
inv1: dmodule ∈ BOOLinv2: d update time ∈ Ninv3: dmodule = TRUE⇒ sd bolus work = TRUE ∧ sd suspend = FALSE ∧ d update time > 0
inv8: basal work = TRUE ∧ basal suspend = FALSE⇒ t basal ≥ timeinv9: t basal ∈ Zinv10: t normal ∈ Zinv14: dmodule = TRUE∧sd preempted by normal = FALSE∧sd suspend = FALSE⇒d update time ≥
time
inv15: dmodule = TRUE ∧ sd preempted by normal = TRUE⇒ d update time ≥ 0
inv16: dmodule = FALSE⇒ d update time = 0
inv17: time = t sd ∧ sd preempted by normal = FALSE⇒ dmodule = FALSE
inv18: time ≥ d update time ∧ d update time = 0 ∧ sd preempted by normal = FALSE⇒ dmodule =
FALSE
inv19: time = d update time ∧ d update time 6= 0⇒ dmodule = TRUE
inv20: d update time 6= 0⇒ t sd > d update time
inv21: sd preempted by normal = TRUE⇒ t sd ≥ 0
inv22: sd preempted by normal = FALSE∧sd bolus work = TRUE∧sd suspend = FALSE⇒t sd ≥time
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
23.01.2018 12:37 Page 27 of 196
![Page 28: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/28.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control6
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
end
Event normal bolus start 1 〈ordinary〉 =̂
extends normal bolus start 1
anyr
t
t2
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ Ngrd6: t ∈ Ngrd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
act3: normal rate := r
act4: sd rate := 0
act5: pump rate := r + basal rate
act6: t normal := time+ t
act7: t sd := t sd− timeact8: d update time := t2
end
Event normal bolus start 2 〈ordinary〉 =̂
extends normal bolus start 2
anyr
t
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N
thenact1: normal bolus work := TRUE
act2: normal rate := r
act3: pump rate := r + basal rate
act4: t normal := time+ t
end
Event normal bolus finish 〈ordinary〉 =̂
extends normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: time = t normal
thenact1: normal bolus work := FALSE
act2: normal rate := 0
act3: pump rate := basal rate
23.01.2018 12:37 Page 28 of 196
![Page 29: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/29.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control6
act4: t normal := 0
end
Event normal suspend 〈ordinary〉 =̂
extends normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := t normal − timeend
Event normal resume 〈ordinary〉 =̂
extends normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
grd3: >then
act1: normal bolus work := FALSE
act2: normal suspend := FALSE
act4: normal rate := 0
act3: pump rate := basal rate
act5: t normal := 0
end
Event square or dual bolus start s 〈ordinary〉 =̂
extends square or dual bolus start
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := FALSE
end
Event square or dual bolus start d 〈ordinary〉 =̂
extends square or dual bolus start
anyr
t
t0 t: both bolus, t0:for normal bolus
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
grd6: t0 ∈ N1
grd7: t > t0
23.01.2018 12:37 Page 29 of 196
![Page 30: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/30.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control6
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := TRUE
act6: d update time := time+ t0
end
Event square or dual bolus finish 〈ordinary〉 =̂
extends square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
act5: dmodule := FALSE
end
Event square or dual bolus resume from normal 〈ordinary〉 =̂
extends square or dual bolus resume from normal
anyr
t2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE⇒ t2 = time+ d update time
grd7: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t sd
act5: d update time := t2
end
Event sd suspend 〈ordinary〉 =̂
extends sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: d update time := 0
end
Event square or dual update rate 〈ordinary〉 =̂
extends square or dual update rate
23.01.2018 12:37 Page 30 of 196
![Page 31: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/31.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control6
anyr
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE
grd7: time = d update time
thenact1: sd rate := r
act2: pump rate := r + basal rate
act3: dmodule := FALSE
act4: d update time := 0
end
Event sd resume 〈ordinary〉 =̂
extends sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event basal start 〈ordinary〉 =̂
extends basal start
anyr
t
wheregrd1: basal work = FALSE
grd3: basal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N1
thenact1: basal work := TRUE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
act4: t basal := time+ t
end
Event basal stop 〈ordinary〉 =̂
extends basal stop
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
thenact1: basal work := FALSE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
act4: t basal := 0
end
Event basal suspend 〈ordinary〉 =̂
extends basal suspend
whengrd1: basal work = TRUE
grd3: basal suspend = FALSE
23.01.2018 12:37 Page 31 of 196
![Page 32: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/32.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control6
thenact1: basal suspend := TRUE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
act4: t basal := 0
end
Event basal resume 〈ordinary〉 =̂
extends basal resume
anyr
t
wheregrd1: basal suspend = TRUE
grd2: r ∈ Ngrd3: t ∈ N1
thenact1: basal suspend := FALSE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
act4: t basal := t+ time
end
Event basal update rate 〈ordinary〉 =̂
extends basal update rate
anyr
t
wheregrd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: r ∈ Ngrd5: t basal = time
grd6: t ∈ N1
thenact1: basal rate := r
act2: pump rate := r + normal rate+ sd rate
act3: t basal := time+ t
end
Event timer 〈ordinary〉 =̂
extends timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
END
23.01.2018 12:37 Page 32 of 196
![Page 33: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/33.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
MACHINE control Basal6
REFINES control6
SEES c basal2
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
dmodule
d update time
basal rate in
basal mode
btime
rate setting2
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
par t max
prog basal
par get t
add resume
add update
add start
INVARIANTS
Basal6.inv1: prog basal ∈ PROC BASAL
Basal6.inv3: par get t ∈ 0 .. c− 1
Basal6.inv13: add resume ∈ 0 .. 3
Basal6.inv14: add update ∈ 0 .. 3
Basal6.inv15: add start ∈ 0 .. 3
inv1: btime ∈ 1 .. c
inv2: par t ∈ Ninv3: temp min ∈ 0 .. c
inv4: par t max ∈ 0 .. c− 1
inv5: basal rate in ∈ 0 .. basal max
inv6: basal mode ∈ BASALMODE
inv7: rate setting2 ∈ 0 .. c− 1→ 0 .. basal max ∪ {−1}
23.01.2018 12:37 Page 33 of 196
![Page 34: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/34.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
inv8: min value ∈ 0 .. c
inv9: max value ∈ 0 .. basal max
inv10: get min value add ∈ 0 .. 3
inv11: get max value add ∈ 0 .. 2
inv12: get min start t ∈ 0 .. c− 1
inv13:get max start t ∈ 0 .. c− 1
inv619: rate setting2(0) 6= − 1
inv51: get min value add ∈ 0 .. 3
inv52: par t ∈ Ninv53: temp min ∈ 0 .. c
inv54: get min start t ∈ 0 .. c− 1
inv57: get min value add = 3⇒{i|i ∈ dom(rate setting2 B− {−1}) ∧ i > get min start t} 6= ∅inv55: get min value add = 3⇒temp min = min({i|i ∈ dom(rate setting2B−{−1})∧i > get min start t})
inv58: get min value add = 1⇒ par t = get min start t+ 1
inv510: get min value add = 2⇒ par t > get min start t
inv512: get min value add = 2 ⇒ {i|i ∈ dom(rate setting2 B− {−1}) ∧ i > get min start t ∧ i ≤par t− 1} = ∅
inv511: get max start t ∈ 0 .. c− 1
inv518: get max value add ∈ 0 .. 2
inv513: par t max ∈ 0 .. c− 1
inv514: get max value add ∈ {1, 2}⇒ get max start t ∈ 0 .. c− 1
inv515: get max value add = 2⇒par t max = max({i|i ∈ dom(rate setting2B−{−1})∧i ≤ get max start t})
inv516: get max value add = 1 ⇒ {i|i ∈ dom(rate setting2 B− {−1}) ∧ i ≤ get max start t ∧ i ≥par t max+ 1} = ∅
inv517:get max value add ∈ {1, 2}⇒ par t max ≤ get max start t
inv61: prog basal ∈ PROC BASAL
inv62: prog basal = null⇒ get max value add = 0 ∧ get min value add = 0
inv63: par get t ∈ 0 .. c− 1
inv64: add resume ∈ 0 .. 3
inv614: add update ∈ 0 .. 3
inv615: add start ∈ 0 .. 3
inv617: prog basal = null⇒ add resume = 0 ∧ add update = 0 ∧ add start = 0
inv618: add resume 6= 0⇒ add update = 0 ∧ add start = 0
inv611: get max value add 6= 0⇒ prog basal = call get max
inv612: get min value add 6= 0⇒ prog basal = call get min
inv613: prog basal ∈ {call get min, return get min, call get max, return get max} ⇒ par get t ∈ 0 ..
c− 1
inv68: get min value add ∈ {1, 2, 3}∨ prog basal ∈ {return get min, call get max, return get max}⇒get min start t = par get t
inv69: get max value add ∈ {1, 2} ∨ prog basal = return get max⇒ get max start t = par get t
inv65: (add resume = 1 ∧ prog basal = return get min) ∨ add resume = 2
⇒ ((∀j ·j ∈ dom(rate setting2) ∧ j > par get t⇒ rate setting2(j) = −1)⇒min value = c)
inv66: (add resume = 1 ∧ prog basal = return get min) ∨ add resume = 2
⇒ ((∃j ·j ∈ dom(rate setting2) ∧ j > par get t ∧ rate setting2(j) 6= − 1)⇒min value = min({i|i ∈dom(rate setting2 B− {−1}) ∧ i > par get t}))
inv67: prog basal = return get max⇒max value = rate setting2(max({i|i ∈ dom(rate setting2 B− {−1}) ∧ i ≤ get max start t}))
inv16: add update ∈ {1, 2}⇒ par get t ∈ dom(rate setting2 B− {−1})inv20: (add start = 1 ∧ prog basal = return get min) ∨ add start = 2
⇒ ((∀j ·j ∈ dom(rate setting2) ∧ j > par get t⇒ rate setting2(j) = −1)⇒min value = c)
23.01.2018 12:37 Page 34 of 196
![Page 35: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/35.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
inv19: (add start = 1 ∧ prog basal = return get min) ∨ add start = 2
⇒ ((∃j ·j ∈ dom(rate setting2) ∧ j > par get t ∧ rate setting2(j) 6= − 1)⇒min value = min({i|i ∈dom(rate setting2 B− {−1}) ∧ i > par get t}))
inv22:add update = 1 ∧ prog basal = return get min
⇒ ((∀j ·j ∈ dom(rate setting2) ∧ j > par get t⇒ rate setting2(j) = −1)⇒min value = c)
inv21:add update = 1 ∧ prog basal = return get min
⇒ ((∃j ·j ∈ dom(rate setting2) ∧ j > par get t ∧ rate setting2(j) 6= − 1)⇒min value = min({i|i ∈dom(rate setting2 B− {−1}) ∧ i > par get t}))
inv23: add resume ∈ {1, 2}⇒ basal rate in = 0 ∧ basal mode = suspended
inv25: add start ∈ {1, 2}⇒ basal mode = stop
inv26: add start 6= 0⇒ add update = 0 ∧ add resume = 0
inv627: add update 6= 0⇒ add resume = 0 ∧ add start = 0
inv624: add update = 1⇒ basal mode = delivering ∧ prog basal ∈ {call get min, return get min}EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
end
Event control6.normal bolus start 1 〈ordinary〉 =̂
extends normal bolus start 1
anyr
23.01.2018 12:37 Page 35 of 196
![Page 36: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/36.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
t
t2
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ Ngrd6: t ∈ Ngrd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
act3: normal rate := r
act4: sd rate := 0
act5: pump rate := r + basal rate
act6: t normal := time+ t
act7: t sd := t sd− timeact8: d update time := t2
end
Event control6.normal bolus start 2 〈ordinary〉 =̂
extends normal bolus start 2
anyr
t
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N
thenact1: normal bolus work := TRUE
act2: normal rate := r
act3: pump rate := r + basal rate
act4: t normal := time+ t
end
Event control6.normal bolus finish 〈ordinary〉 =̂
extends normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: time = t normal
thenact1: normal bolus work := FALSE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := 0
end
Event control6.normal suspend 〈ordinary〉 =̂
extends normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
act2: normal rate := 0
23.01.2018 12:37 Page 36 of 196
![Page 37: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/37.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
act3: pump rate := basal rate
act4: t normal := t normal − timeend
Event control6.normal resume 〈ordinary〉 =̂
extends normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
grd3: >then
act1: normal bolus work := FALSE
act2: normal suspend := FALSE
act4: normal rate := 0
act3: pump rate := basal rate
act5: t normal := 0
end
Event control6.square or dual bolus start s 〈ordinary〉 =̂
extends square or dual bolus start s
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := FALSE
end
Event control6.square or dual bolus start d 〈ordinary〉 =̂
extends square or dual bolus start d
anyr
t
t0 t: both bolus, t0:for normal bolus
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
grd6: t0 ∈ N1
grd7: t > t0
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := TRUE
act6: d update time := time+ t0
end
Event control6.square or dual bolus finish 〈ordinary〉 =̂
extends square or dual bolus finish
23.01.2018 12:37 Page 37 of 196
![Page 38: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/38.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
act5: dmodule := FALSE
end
Event control6.square or dual bolus resume from normal 〈ordinary〉 =̂
extends square or dual bolus resume from normal
anyr
t2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE⇒ t2 = time+ d update time
grd7: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t sd
act5: d update time := t2
end
Event control6.sd suspend 〈ordinary〉 =̂
extends sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: d update time := 0
end
Event control6.square or dual update rate 〈ordinary〉 =̂
extends square or dual update rate
anyr
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE
grd7: time = d update time
then
23.01.2018 12:37 Page 38 of 196
![Page 39: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/39.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
act1: sd rate := r
act2: pump rate := r + basal rate
act3: dmodule := FALSE
act4: d update time := 0
end
Event control6.sd resume 〈ordinary〉 =̂
extends sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event control6.basal start 〈ordinary〉 =̂
extends basal start
anyr
t
wheregrd1: basal work = FALSE
grd3: basal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N1
thenact1: basal work := TRUE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
act4: t basal := time+ t
end
Event control6.basal stop 〈ordinary〉 =̂
extends basal stop
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
thenact1: basal work := FALSE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
act4: t basal := 0
end
Event control6.basal suspend 〈ordinary〉 =̂
extends basal suspend
whengrd1: basal work = TRUE
grd3: basal suspend = FALSE
thenact1: basal suspend := TRUE
act2: basal rate := 0
act3: pump rate := normal rate+ sd rate
act4: t basal := 0
end
Event control6.basal resume 〈ordinary〉 =̂
extends basal resume
any
23.01.2018 12:37 Page 39 of 196
![Page 40: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/40.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
r
t
wheregrd1: basal suspend = TRUE
grd2: r ∈ Ngrd3: t ∈ N1
thenact1: basal suspend := FALSE
act2: basal rate := r
act3: pump rate := r + normal rate+ sd rate
act4: t basal := t+ time
end
Event control6.basal update rate 〈ordinary〉 =̂
extends basal update rate
anyr
t
wheregrd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: r ∈ Ngrd5: t basal = time
grd6: t ∈ N1
thenact1: basal rate := r
act2: pump rate := r + normal rate+ sd rate
act3: t basal := time+ t
end
Event control6.timer 〈ordinary〉 =̂
extends timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
Event Basal6.basal suspend 〈ordinary〉 =̂
whenBasal6.grd3: prog basal = null
Basal6.grd1: basal rate in 6= 0
Basal6.grd2: basal mode = delivering
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
end
Event Basal6·change setting 〈ordinary〉 =̂
anyt
r
whereBasal6.grd5: prog basal = null
23.01.2018 12:37 Page 40 of 196
![Page 41: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/41.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
end
Event Basal6.basal resume call 〈ordinary〉 =̂
anyt
whereBasal6.grd4: t ∈ 0 .. c− 1
Basal6.grd5: prog basal = null
Basal6.grd6: add resume = 0
Basal6.grd1: basal rate in = 0
Basal6.grd3: basal mode = suspended
thenBasal6.act1: par get t := t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
whenBasal6.grd1: prog basal = return get min
23.01.2018 12:37 Page 41 of 196
![Page 42: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/42.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
end
Event Basal6.rate update call 〈ordinary〉 =̂
anyt
whereBasal6.grd6: t ∈ 0 .. c− 1
Basal6.grd2: prog basal = null
Basal6.grd3: add update = 0
Basal6.grd5: basal mode = delivering
Basal6.grd7: rate setting2(t) 6= − 1
thenBasal6.act1: par get t := t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
end
Event Basal6.start call 〈ordinary〉 =̂
anyt
whereBasal6.grd1: t ∈ 0 .. c− 1
Basal6.grd2: prog basal = null
Basal6.grd3: add start = 0
Basal6.grd4: basal mode = stop
thenBasal6.act1: par get t := t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
then
23.01.2018 12:37 Page 42 of 196
![Page 43: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/43.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
Basal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
end
Event Basal6.get min value 1 〈ordinary〉 =̂
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
whenBasal6.grd2: get max value add = 2
23.01.2018 12:37 Page 43 of 196
![Page 44: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/44.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6.get max value 1 〈ordinary〉 =̂
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 44 of 196
![Page 45: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/45.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
MACHINE control Basal6 2
REFINES control Basal6
SEES c prog
VARIABLES
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
dmodule
d update time
basal rate in
basal mode
btime
rate setting2
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
par t max
prog basal
par get t
add resume
add update
add start
prog
par basal start t
par basal resume t
par basal update rate t
INVARIANTS
inv1: prog ∈ PROGinv2: prog = call basal start⇒ par basal start t ∈ 0 .. c− 1
inv8: par basal resume t ∈ Ninv9: prog = call basal resume⇒ par basal resume t ∈ 0 .. c− 1
inv5: prog = return basal start⇒ basal rate in ∈ Ninv6: prog = return basal start⇒ btime ∈ N1
inv12: par basal update rate t ∈ Ninv13: prog = call basal update⇒ par basal update rate t ∈ dom(rate setting2 B− {−1})
23.01.2018 12:37 Page 45 of 196
![Page 46: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/46.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
inv14: prog = return basal suspend⇒ basal rate in = 0
inv15: prog = return basal stop⇒ basal rate in = 0
inv3:prog = call basal suspend⇒ basal rate in 6= 0
inv42: add resume ∈ {1, 2}⇒ prog = call basal resume
inv43: add update = 1⇒ prog = call basal update
inv44:add start ∈ {1, 2}⇒ prog = call basal start
inv27: prog = null⇒ (basal work = TRUE ∧ basal suspend = FALSE⇒ basal mode = delivering)
inv26: prog = null⇒ (basal rate 6= 0⇔ basal rate in 6= 0)
inv25: prog = return basal update⇒(basal work = TRUE∧basal suspend = FALSE⇒basal mode =
delivering)
inv24: prog = return basal resume⇒ basal mode = delivering
inv23:prog = return basal start⇒ basal mode = delivering
inv22: prog = call basal suspend⇒ basal rate in 6= 0 ∧ basal mode = delivering
inv21: prog = call basal resume⇒ basal rate in = 0 ∧ basal mode = suspended
inv20: prog = call basal update⇒ basal mode = delivering
inv19: prog = call basal start⇒ basal mode = stop
inv18: prog = call basal stop⇒ basal mode = delivering
inv17: prog = null ∧ basal work = FALSE ∧ basal suspend = FALSE⇒ basal mode = stop
inv16: prog = return basal stop⇒ basal mode = stop
inv29: basal suspend = TRUE ∧ prog = null ∧ basal work = TRUE⇒ basal mode = suspended
inv41: prog = return basal suspend⇒ basal mode = suspended
inv30: prog = return basal start⇒ basal work = FALSE ∧ basal suspend = FALSE
inv31: prog = call basal start⇒ basal work = FALSE ∧ basal suspend = FALSE
inv32: prog = return basal stop⇒ basal suspend = FALSE ∧ basal work = TRUE
inv33: prog = call basal stop⇒ basal suspend = FALSE ∧ basal work = TRUE
inv34: prog = return basal suspend⇒ basal suspend = FALSE ∧ basal work = TRUE
inv35: prog = call basal suspend⇒ basal suspend = FALSE ∧ basal work = TRUE
inv36: prog = return basal resume⇒ basal suspend = TRUE
inv37: prog = call basal resume⇒ basal suspend = TRUE
inv38: prog = return basal update⇒basal suspend = FALSE∧basal work = TRUE∧t basal = time
inv39: prog = call basal update⇒ basal suspend = FALSE ∧ basal work = TRUE ∧ t basal = time
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
23.01.2018 12:37 Page 46 of 196
![Page 47: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/47.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act21: prog := null
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
end
Event control6.normal bolus start 1 〈ordinary〉 =̂
extends control6.normal bolus start 1
anyr
t
t2
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ Ngrd6: t ∈ Ngrd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
act3: normal rate := r
act4: sd rate := 0
act5: pump rate := r + basal rate
act6: t normal := time+ t
act7: t sd := t sd− timeact8: d update time := t2
end
Event control6.normal bolus start 2 〈ordinary〉 =̂
extends control6.normal bolus start 2
anyr
t
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
23.01.2018 12:37 Page 47 of 196
![Page 48: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/48.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
grd3: normal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N
thenact1: normal bolus work := TRUE
act2: normal rate := r
act3: pump rate := r + basal rate
act4: t normal := time+ t
end
Event control6.normal bolus finish 〈ordinary〉 =̂
extends control6.normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: time = t normal
thenact1: normal bolus work := FALSE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := 0
end
Event control6.normal suspend 〈ordinary〉 =̂
extends control6.normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := t normal − timeend
Event control6.normal resume 〈ordinary〉 =̂
extends control6.normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
grd3: >then
act1: normal bolus work := FALSE
act2: normal suspend := FALSE
act4: normal rate := 0
act3: pump rate := basal rate
act5: t normal := 0
end
Event control6.square or dual bolus start s 〈ordinary〉 =̂
extends control6.square or dual bolus start s
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
23.01.2018 12:37 Page 48 of 196
![Page 49: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/49.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := FALSE
end
Event control6.square or dual bolus start d 〈ordinary〉 =̂
extends control6.square or dual bolus start d
anyr
t
t0 t: both bolus, t0:for normal bolus
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
grd6: t0 ∈ N1
grd7: t > t0
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := TRUE
act6: d update time := time+ t0
end
Event control6.square or dual bolus finish 〈ordinary〉 =̂
extends control6.square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
act5: dmodule := FALSE
end
Event control6.square or dual bolus resume from normal 〈ordinary〉 =̂
extends control6.square or dual bolus resume from normal
anyr
t2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE⇒ t2 = time+ d update time
grd7: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
23.01.2018 12:37 Page 49 of 196
![Page 50: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/50.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
act4: t sd := time+ t sd
act5: d update time := t2
end
Event control6.sd suspend 〈ordinary〉 =̂
extends control6.sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: d update time := 0
end
Event control6.square or dual update rate 〈ordinary〉 =̂
extends control6.square or dual update rate
anyr
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE
grd7: time = d update time
thenact1: sd rate := r
act2: pump rate := r + basal rate
act3: dmodule := FALSE
act4: d update time := 0
end
Event control6.sd resume 〈ordinary〉 =̂
extends control6.sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event control5·basal suspend return 〈ordinary〉 =̂
refines control6.basal suspend
whengrd1: prog = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
when
23.01.2018 12:37 Page 50 of 196
![Page 51: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/51.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
grd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd3: prog = null
thenact1: prog := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
refines control6.basal resume
whengrd1: prog = return basal resume
withr: r = basal rate in
t: t = btime
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
end
Event control5·basal resume call 〈ordinary〉 =̂
whengrd1: basal suspend = TRUE
grd2: prog = null
thenact1: prog := call basal resume
act2: par basal resume t := timemodc
end
Event control5·basal update rate return 〈ordinary〉 =̂
refines control6.basal update rate
whengrd1: prog = return basal update
witht: t = btime
r: r = basal rate in
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: prog = null
grd5: t basal ∈ dom(rate setting2 B− {−1})then
act1: prog := call basal update
act2: par basal update rate t := t basal
end
Event control5·basal start return 〈ordinary〉 =̂
refines control6.basal start
whengrd1: prog = return basal start
23.01.2018 12:37 Page 51 of 196
![Page 52: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/52.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
witht: t = btime
r: r = basal rate in
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
end
Event control5·basal start call 〈ordinary〉 =̂
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd3: prog = null
thenact1: prog := call basal start
act2: par basal start t := timemodc
end
Event control5·basal stop return 〈ordinary〉 =̂
refines control6.basal stop
whengrd1: prog = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
end
Event control5·basal stop call 〈ordinary〉 =̂
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd3: prog = null
thenact1: prog := call basal stop
end
Event control6.timer 〈ordinary〉 =̂
extends control6.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
Event Basal6.basal suspend 〈ordinary〉 =̂
refines Basal6.basal suspend
whengrd1: prog = call basal suspend
Basal6.grd3: prog basal = null
23.01.2018 12:37 Page 52 of 196
![Page 53: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/53.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act1: prog := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
23.01.2018 12:37 Page 53 of 196
![Page 54: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/54.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
act1: prog := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
refines Basal6.basal resume call
whengrd1: prog = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
Basal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
witht: t = par basal resume t
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act5: prog := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
refines Basal6.rate update call
whengrd1: prog = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
Basal6.grd3: add update = 0
Basal6.grd2: prog basal = null
witht: t = par basal update rate t
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
23.01.2018 12:37 Page 54 of 196
![Page 55: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/55.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
Basal6.grd9: prog basal = return get max
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act5: prog := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
refines Basal6.start call
whengrd1: prog = call basal start
Basal6.grd3: add start = 0
Basal6.grd4: 〈theorem〉 basal mode = stop
Basal6.grd2: prog basal = null
witht: t = par basal start t
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
extends Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd1: prog = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act1: prog := return basal stop
end
Event Basal6.get min value 1 〈ordinary〉 =̂
extends Basal6.get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
23.01.2018 12:37 Page 55 of 196
![Page 56: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/56.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6.get max value 1 〈ordinary〉 =̂
extends Basal6.get max value 1
when
23.01.2018 12:37 Page 56 of 196
![Page 57: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/57.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 2
Basal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 57 of 196
![Page 58: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/58.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
MACHINE control Basal6 NormalBolus
REFINES control Basal6 2
SEES c normalbolus,c prog
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
prog
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
par t max
prog basal
par get t
add resume
add update
add start
INVARIANTS
NormalBolus.inv1: insulin needed ∈ NNormalBolus.inv5: normal add ∈ 0 .. 3
NormalBolus.inv2: normal delivering time ∈ N
23.01.2018 12:37 Page 58 of 196
![Page 59: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/59.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
NormalBolus.inv3: normal delivering rate ∈ NNormalBolus.inv4: normal delivering rate = 0 ∨ normal delivering rate = normal bolus rate
NormalBolus.inv6: normal add = 0⇒ normal delivering rate = 0
NormalBolus.inv7: normal add = 1⇒ insulin needed 6= 0 ∧ normal delivering rate = 0
NormalBolus.inv9: normal add = 2⇒ normal delivering rate = 0
NormalBolus.inv8: normal add = 3⇒ normal delivering rate = normal bolus rate
NormalBolus.inv10: normal bolus suspend ∈ BOOLNormalBolus.inv11: normal add = 1⇒ normal bolus suspend = FALSE
NormalBolus.inv12: normal add = 2⇒ normal bolus suspend = FALSE
inv19: normal add = 1⇒ normal bolus suspend = FALSE ∧ normal delivering rate = 0
∧ normal delivering time = 0
inv20: normal add = 2⇒ normal bolus suspend = FALSE ∧ normal delivering rate = 0
inv21: normal add = 3⇒ normal bolus suspend = FALSE ∧ normal delivering rate > 0
inv22: normal add = 0⇒ normal delivering rate = 0 ∧ normal delivering time = 0
inv23: 〈theorem〉 normal bolus suspend = TRUE⇒ normal add = 0
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act21: prog := null
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
23.01.2018 12:37 Page 59 of 196
![Page 60: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/60.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
end
Event control5.normal bolus start 1 〈ordinary〉 =̂
extends control6.normal bolus start 1
anyr
t
t2
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ Ngrd6: t ∈ Ngrd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: normal bolus work := TRUE
act2: sd preempted by normal := TRUE
act3: normal rate := r
act4: sd rate := 0
act5: pump rate := r + basal rate
act6: t normal := time+ t
act7: t sd := t sd− timeact8: d update time := t2
end
Event control5.normal bolus start 2 〈ordinary〉 =̂
extends control6.normal bolus start 2
anyr
t
wheregrd1: normal bolus work = FALSE
grd2: sd bolus work = FALSE
grd3: normal suspend = FALSE
grd4: r ∈ Ngrd5: t ∈ N
thenact1: normal bolus work := TRUE
act2: normal rate := r
act3: pump rate := r + basal rate
act4: t normal := time+ t
end
Event control5.normal bolus finish 〈ordinary〉 =̂
extends control6.normal bolus finish
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: time = t normal
thenact1: normal bolus work := FALSE
act2: normal rate := 0
act3: pump rate := basal rate
23.01.2018 12:37 Page 60 of 196
![Page 61: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/61.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
act4: t normal := 0
end
Event control5·square or dual bolus start s 〈ordinary〉 =̂
extends control6.square or dual bolus start s
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := FALSE
end
Event control5·square or dual bolus start d 〈ordinary〉 =̂
extends control6.square or dual bolus start d
anyr
t
t0 t: both bolus, t0:for normal bolus
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
grd6: t0 ∈ N1
grd7: t > t0
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := TRUE
act6: d update time := time+ t0
end
Event control5.square or dual bolus finish 〈ordinary〉 =̂
extends control6.square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
act5: dmodule := FALSE
end
Event control5.square or dual bolus resume from normal 〈ordinary〉 =̂
extends control6.square or dual bolus resume from normal
23.01.2018 12:37 Page 61 of 196
![Page 62: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/62.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
anyr
t2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE⇒ t2 = time+ d update time
grd7: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t sd
act5: d update time := t2
end
Event control5.normal suspend 〈ordinary〉 =̂
extends control6.normal suspend
whengrd1: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: normal suspend := TRUE
act2: normal rate := 0
act3: pump rate := basal rate
act4: t normal := t normal − timeend
Event control5.sd suspend 〈ordinary〉 =̂
extends control6.sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: d update time := 0
end
Event control5.square or dual update rate 〈ordinary〉 =̂
extends control6.square or dual update rate
anyr
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE
grd7: time = d update time
thenact1: sd rate := r
act2: pump rate := r + basal rate
act3: dmodule := FALSE
23.01.2018 12:37 Page 62 of 196
![Page 63: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/63.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
act4: d update time := 0
end
Event control5.normal resume 〈ordinary〉 =̂
extends control6.normal resume
whengrd1: normal bolus work = TRUE
grd2: normal suspend = TRUE
grd3: >then
act1: normal bolus work := FALSE
act2: normal suspend := FALSE
act4: normal rate := 0
act3: pump rate := basal rate
act5: t normal := 0
end
Event control5.sd resume 〈ordinary〉 =̂
extends control6.sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
whengrd1: prog = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd3: prog = null
thenact1: prog := call basal start
act2: par basal start t := timemodc
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
whengrd1: prog = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
23.01.2018 12:37 Page 63 of 196
![Page 64: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/64.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd3: prog = null
thenact1: prog := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
whengrd1: prog = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd3: prog = null
thenact1: prog := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
whengrd1: prog = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
whengrd1: basal suspend = TRUE
grd2: prog = null
thenact1: prog := call basal resume
act2: par basal resume t := timemodc
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd1: prog = return basal update
then
23.01.2018 12:37 Page 64 of 196
![Page 65: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/65.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
control5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: prog = null
grd5: t basal ∈ dom(rate setting2 B− {−1})then
act1: prog := call basal update
act2: par basal update rate t := t basal
end
Event control5.timer 〈ordinary〉 =̂
extends control6.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
NormalBolus.grd4: normal bolus suspend = FALSE
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
end
23.01.2018 12:37 Page 65 of 196
![Page 66: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/66.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
whenNormalBolus.grd4: normal add = 3
NormalBolus.grd5: normal bolus suspend = FALSE
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
whenNormalBolus.grd4: normal bolus suspend = FALSE
NormalBolus·grd3: normal add = 3
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
end
Event NormalBolus·normal bolus resume 〈ordinary〉 =̂
whenNormalBolus.grd1: normal bolus suspend = TRUE
NormalBolus.grd2: normal add = 0
thenNormalBolus.act1: normal bolus suspend := FALSE
act1: normal delivering rate := 0
end
Event Basal6.basal suspend 〈ordinary〉 =̂
extends Basal6.basal suspend
whengrd1: prog = call basal suspend
Basal6.grd3: prog basal = null
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act1: prog := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
23.01.2018 12:37 Page 66 of 196
![Page 67: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/67.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act1: prog := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whengrd1: prog = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
Basal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
23.01.2018 12:37 Page 67 of 196
![Page 68: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/68.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act5: prog := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whengrd1: prog = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
Basal6.grd3: add update = 0
Basal6.grd2: prog basal = null
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act5: prog := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whengrd1: prog = call basal start
Basal6.grd3: add start = 0
Basal6.grd4: 〈theorem〉 basal mode = stop
Basal6.grd2: prog basal = null
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
23.01.2018 12:37 Page 68 of 196
![Page 69: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/69.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
extends Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd1: prog = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act1: prog := return basal stop
end
Event Basal6.get min value 1 〈ordinary〉 =̂
extends Basal6.get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
23.01.2018 12:37 Page 69 of 196
![Page 70: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/70.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6.get max value 1 〈ordinary〉 =̂
extends Basal6.get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 70 of 196
![Page 71: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/71.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
MACHINE control Basal6 NormalBolus 2
REFINES control Basal6 NormalBolus
SEES c normalbolus,c prog
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
prog1
dmodule
d update time
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
par t max
prog basal
par get t
add resume
add update
add start
prog
INVARIANTS
inv1: prog1 ∈ PROGinv2: prog1 = return normal finish⇒ normal delivering rate = 0
23.01.2018 12:37 Page 71 of 196
![Page 72: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/72.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
inv3: prog1 = return normal suspend⇒ normal delivering rate = 0
inv4: prog1 = return normal resume⇒ normal delivering rate = 0
inv5: prog1 = return normal start⇒ normal bolus work = FALSE ∧ normal suspend = FALSE ∧normal add = 3
inv6: prog1 = return normal finish⇒ normal suspend = FALSE ∧ time = t normal
∧ normal bolus work = TRUE
inv7: prog1 = return normal suspend⇒ normal suspend = FALSE ∧ normal bolus work = TRUE
inv8: prog1 = return normal resume⇒ normal suspend = TRUE
inv9: prog1 = call normal finish⇒ normal suspend = FALSE ∧ time = t normal
∧ normal bolus work = TRUE
inv10: prog1 = call normal suspend⇒ normal suspend = FALSE ∧ normal bolus work = TRUE
inv11: prog1 = call normal resume⇒ normal suspend = TRUE
inv12: prog1 = call normal start⇒normal bolus work = FALSE∧normal bolus suspend = FALSE
inv19: normal add = 1 ∨ normal add = 2⇒ prog1 = call normal start
inv13: prog1 = call normal suspend⇒ normal add = 3 ∧ normal bolus suspend = FALSE
inv14: prog1 = call normal finish⇒ normal bolus suspend = FALSE ∧ normal add = 3
inv15: prog1 = call normal resume⇒ normal bolus suspend = TRUE ∧ normal add = 0
inv20: prog1 = call normal suspend ∧ normal suspend = FALSE ∧ normal bolus work = TRUE⇒normal add = 3
inv21: prog1 ∈ {null, call basal start, return basal start, call basal stop, return basal stop,call basal suspend, return basal suspend, call basal resume, return basal resume, call basal update,
return basal update} ∧ normal suspend = FALSE ∧ normal bolus work = TRUE
⇒ normal add = 3
inv22: prog1 ∈ {null, call basal start, return basal start, call basal stop, return basal stop,call basal suspend, return basal suspend, call basal resume, return basal resume, call basal update,
return basal update}⇒ normal bolus suspend = normal suspend
inv23: prog1 = return normal suspend⇒ normal bolus suspend = TRUE
inv24: prog1 = return normal resume⇒ normal bolus suspend = FALSE
inv25: prog1 = return normal finish⇒ normal bolus suspend = FALSE
inv26: prog1 ∈ {call basal start, return basal start, call basal stop, return basal stop, call basal suspend,return basal suspend, call basal resume, return basal resume, call basal update, return basal update}⇒ prog = prog1
inv27: prog1 = null⇒ prog = null
inv28: prog1 ∈ {call normal start, return normal start, call normal suspend, return normal suspend,call normal finish, return normal finish, call normal resume, return normal resume}⇒ prog = null
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
23.01.2018 12:37 Page 72 of 196
![Page 73: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/73.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act21: prog := null
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
act31: prog1 := null
end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
refines control5.normal bolus start 1
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd1: prog1 = return normal start
grd8: dmodule = FALSE⇒ t2 = 0
witht: t = normal delivering time
r: r = normal delivering rate
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act1: prog1 := null
end
Event control5·normal bolus start 1 call 〈ordinary〉 =̂
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
23.01.2018 12:37 Page 73 of 196
![Page 74: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/74.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
thenact1: prog1 := call normal start
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
refines control5.normal bolus start 2
whencontrol5.grd2: sd bolus work = FALSE
grd1: prog1 = return normal start
witht: t = normal delivering time
r: r = normal delivering rate
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act1: prog1 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
thenact1: prog1 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
refines control5.normal bolus finish
whengrd1: prog1 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
whengrd1: prog1 = null
grd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
thenact1: prog1 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
refines control5.normal suspend
whengrd1: prog1 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
23.01.2018 12:37 Page 74 of 196
![Page 75: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/75.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
control5.act3: pump rate := basal rate
act1: prog1 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
whengrd1: prog1 = null
grd2: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: prog1 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
refines control5.normal resume
whengrd1: prog1 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act1: prog1 := null
act2: normal bolus work := FALSE
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
whengrd1: prog1 = null
grd2: normal suspend = TRUE
thenact1: prog1 := call normal resume
end
Event control5·square or dual bolus start s 〈ordinary〉 =̂
extends control5·square or dual bolus start s
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := FALSE
end
Event control5·square or dual bolus start d 〈ordinary〉 =̂
extends control5·square or dual bolus start d
anyr
t
t0 t: both bolus, t0:for normal bolus
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
23.01.2018 12:37 Page 75 of 196
![Page 76: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/76.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
grd4: r ∈ N1
grd5: t ∈ N1
grd6: t0 ∈ N1
grd7: t > t0
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := TRUE
act6: d update time := time+ t0
end
Event control5.square or dual bolus finish 〈ordinary〉 =̂
extends control5.square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
act5: dmodule := FALSE
end
Event control5.square or dual bolus resume from normal 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal
anyr
t2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE⇒ t2 = time+ d update time
grd7: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t sd
act5: d update time := t2
end
Event control5.sd suspend 〈ordinary〉 =̂
extends control5.sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
23.01.2018 12:37 Page 76 of 196
![Page 77: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/77.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
act6: d update time := 0
end
Event control5.square or dual update rate 〈ordinary〉 =̂
extends control5.square or dual update rate
anyr
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE
grd7: time = d update time
thenact1: sd rate := r
act2: pump rate := r + basal rate
act3: dmodule := FALSE
act4: d update time := 0
end
Event control5.sd resume 〈ordinary〉 =̂
extends control5.sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
whengrd1: prog = return basal start
grd2: prog1 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
thenact1: prog := call basal start
act2: par basal start t := timemodc
act3: prog1 := call basal start
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
23.01.2018 12:37 Page 77 of 196
![Page 78: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/78.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
whengrd1: prog = return basal stop
grd2: prog1 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
thenact1: prog := call basal stop
act2: prog1 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
whengrd1: prog = return basal suspend
grd2: prog1 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd3: prog = null
grd5: prog1 = null
thenact1: prog := call basal suspend
act2: prog1 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
whengrd1: prog = return basal resume
grd2: prog1 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
23.01.2018 12:37 Page 78 of 196
![Page 79: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/79.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
act1: prog := null
act2: prog1 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
whengrd1: basal suspend = TRUE
grd2: prog = null
grd3: prog1 = null
thenact1: prog := call basal resume
act2: par basal resume t := timemodc
act3: prog1 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd1: prog = return basal update
grd2: prog1 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: prog = null
grd5: t basal ∈ dom(rate setting2 B− {−1})grd6: prog1 = null
thenact1: prog := call basal update
act2: par basal update rate t := t basal
act3: prog1 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
refines NormalBolus.normal bolus start calculate insulin needed
23.01.2018 12:37 Page 79 of 196
![Page 80: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/80.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd1: prog1 = call normal start
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
extends NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act1: prog1 := return normal start
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
refines NormalBolus.normal bolus suspend
whengrd1: prog1 = call normal suspend
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act1: prog1 := return normal suspend
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
refines NormalBolus.normal bolus finish
whengrd1: prog1 = call normal finish
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act1: prog1 := return normal finish
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
refines NormalBolus ·normal bolus resume
whengrd1: prog1 = call normal resume
thenNormalBolus.act1: normal bolus suspend := FALSE
act1: normal delivering rate := 0
act2: prog1 := return normal resume
end
23.01.2018 12:37 Page 80 of 196
![Page 81: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/81.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
Event Basal6·basal suspend 〈ordinary〉 =̂
extends Basal6.basal suspend
whengrd1: prog = call basal suspend
Basal6.grd3: prog basal = null
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
grd2: prog1 = call basal suspend
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act1: prog := return basal suspend
act2: prog1 := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
23.01.2018 12:37 Page 81 of 196
![Page 82: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/82.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
Basal6.grd9: add resume = 2
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act1: prog := return basal resume
act2: prog1 := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whengrd1: prog = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
Basal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd2: prog1 = call basal resume
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act5: prog := return basal update
act6: prog1 := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whengrd1: prog = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
Basal6.grd3: add update = 0
Basal6.grd2: prog basal = null
grd2: prog1 = call basal update
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
23.01.2018 12:37 Page 82 of 196
![Page 83: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/83.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act5: prog := return basal start
act6: prog1 := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whengrd1: prog = call basal start
Basal6.grd3: add start = 0
Basal6.grd4: 〈theorem〉 basal mode = stop
Basal6.grd2: prog basal = null
grd2: prog1 = call basal start
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
extends Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd1: prog = call basal stop
grd2: prog1 = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act1: prog := return basal stop
act2: prog1 := return basal stop
end
Event Basal6.get min value 1 〈ordinary〉 =̂
extends Basal6.get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
then
23.01.2018 12:37 Page 83 of 196
![Page 84: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/84.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
Basal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
23.01.2018 12:37 Page 84 of 196
![Page 85: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/85.jpg)
An Event-B Specification of Insulin pump whole 7 MACHINE control Basal6 NormalBolus 2
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6.get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 85 of 196
![Page 86: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/86.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
REFINES control Basal6 NormalBolus 2
SEES c normalbolus,c prog,c sd bolus
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
prog1
state
s r
s t
d deliver time
d deliver rate
d t
sd module
sd flag
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
par t max
prog basal
23.01.2018 12:37 Page 86 of 196
![Page 87: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/87.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
par get t
add resume
add update
add start
prog
INVARIANTS
Square Dual bolus2.inv1: d deliver time ∈ NSquare Dual bolus2.inv2: d deliver rate ∈ NSquare Dual bolus2.inv3: d t ∈ Ninv1: s r ∈ Ninv2: s t ∈ NSquare Dual bolus2.inv4: sd module ∈ SDFSquare Dual bolus2.inv5: sd flag ∈ SDFSquare Dual bolus2.inv6: state = off ∨ state = suspend⇒ d deliver time = 0 ∧ d deliver rate = 0
Square Dual bolus2.inv7: state = deliver⇒ d deliver time ≥ 0 ∧ d deliver rate > 0
Square Dual bolus2.inv8: state = off ∨ state = suspend⇒ d t = 0
Square Dual bolus2.inv9: state = deliver ∨ state = preempt⇒ s r > 0
Square Dual bolus2.inv10: state = preempt⇒ d deliver time ≥ 0 ∧ d deliver rate = 0
Square Dual bolus2.inv11: sd module = d ∧ sd flag = s ∧ state = deliver⇒ d deliver rate = s r
Square Dual bolus2.inv12: sd module = d ∧ sd flag = d ∧ state = deliver ⇒ d deliver rate =
normal bolus rate
Square Dual bolus2.inv13: sd module = s ∧ state = deliver⇒ d deliver rate = s r
Square Dual bolus2.inv14: state = off ∨ state = suspend⇒ sd flag = d
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
23.01.2018 12:37 Page 87 of 196
![Page 88: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/88.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act21: prog := null
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
act31: prog1 := null
Square Dual bolus2.act1: state := off
Square Dual bolus2.act2: s r := 0
Square Dual bolus2.act3: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd module := s
Square Dual bolus2.act10: sd flag := d
end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
extends control5·normal bolus start 1 return
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd1: prog1 = return normal start
grd8: dmodule = FALSE⇒ t2 = 0
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act1: prog1 := null
end
Event control5·normal bolus start 1 call 〈ordinary〉 =̂
extends control5·normal bolus start 1 call
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
thenact1: prog1 := call normal start
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
23.01.2018 12:37 Page 88 of 196
![Page 89: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/89.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
extends control5.normal bolus start 2 return
whencontrol5.grd2: sd bolus work = FALSE
grd1: prog1 = return normal start
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act1: prog1 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
extends control5·normal bolus start 2 call
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
thenact1: prog1 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
extends control5·normal bolus finish return
whengrd1: prog1 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
extends control5 ·normal bolus finish call
whengrd1: prog1 = null
grd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
thenact1: prog1 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
extends control5·normal suspend return
whengrd1: prog1 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
extends control5·normal bolus suspend call
whengrd1: prog1 = null
23.01.2018 12:37 Page 89 of 196
![Page 90: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/90.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
grd2: normal bolus work = TRUE
grd3: normal suspend = FALSE
thenact1: prog1 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
extends control5·normal resume return
whengrd1: prog1 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act1: prog1 := null
act2: normal bolus work := FALSE
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
extends control5 ·normal bolus resume call
whengrd1: prog1 = null
grd2: normal suspend = TRUE
thenact1: prog1 := call normal resume
end
Event control5·square or dual bolus start s 〈ordinary〉 =̂
extends control5·square or dual bolus start s
anyr
t
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
thenact1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := FALSE
end
Event control5·square or dual bolus start d 〈ordinary〉 =̂
extends control5·square or dual bolus start d
anyr
t
t0 t: both bolus, t0:for normal bolus
wheregrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd4: r ∈ N1
grd5: t ∈ N1
grd6: t0 ∈ N1
grd7: t > t0
then
23.01.2018 12:37 Page 90 of 196
![Page 91: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/91.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
act1: sd bolus work := TRUE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t
act5: dmodule := TRUE
act6: d update time := time+ t0
end
Event control5.square or dual bolus finish 〈ordinary〉 =̂
extends control5.square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: sd bolus work := FALSE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := 0
act5: dmodule := FALSE
end
Event control5.square or dual bolus resume from normal 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal
anyr
t2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE⇒ t2 = time+ d update time
grd7: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := r
act3: pump rate := r + basal rate
act4: t sd := time+ t sd
act5: d update time := t2
end
Event control5.sd suspend 〈ordinary〉 =̂
extends control5.sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: sd suspend := TRUE
act2: sd rate := 0
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: d update time := 0
end
Event control5.square or dual update rate 〈ordinary〉 =̂
extends control5.square or dual update rate
any
23.01.2018 12:37 Page 91 of 196
![Page 92: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/92.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
r
wheregrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: r ∈ N1
grd6: dmodule = TRUE
grd7: time = d update time
thenact1: sd rate := r
act2: pump rate := r + basal rate
act3: dmodule := FALSE
act4: d update time := 0
end
Event control5.sd resume 〈ordinary〉 =̂
extends control5.sd resume
whengrd1: sd suspend = TRUE
thenact1: sd bolus work := FALSE
act2: sd suspend := FALSE
act3: sd rate := 0
act4: pump rate := basal rate
act5: t sd := 0
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
whengrd1: prog = return basal start
grd2: prog1 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
thenact1: prog := call basal start
act2: par basal start t := timemodc
act3: prog1 := call basal start
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
whengrd1: prog = return basal stop
grd2: prog1 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
23.01.2018 12:37 Page 92 of 196
![Page 93: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/93.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
thenact1: prog := call basal stop
act2: prog1 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
whengrd1: prog = return basal suspend
grd2: prog1 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd3: prog = null
grd5: prog1 = null
thenact1: prog := call basal suspend
act2: prog1 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
whengrd1: prog = return basal resume
grd2: prog1 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
23.01.2018 12:37 Page 93 of 196
![Page 94: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/94.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
whengrd1: basal suspend = TRUE
grd2: prog = null
grd3: prog1 = null
thenact1: prog := call basal resume
act2: par basal resume t := timemodc
act3: prog1 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd1: prog = return basal update
grd2: prog1 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: prog = null
grd5: t basal ∈ dom(rate setting2 B− {−1})grd6: prog1 = null
thenact1: prog := call basal update
act2: par basal update rate t := t basal
act3: prog1 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate insulin needed
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd1: prog1 = call normal start
23.01.2018 12:37 Page 94 of 196
![Page 95: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/95.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
extends NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act1: prog1 := return normal start
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
extends NormalBolus.normal bolus suspend
whengrd1: prog1 = call normal suspend
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act1: prog1 := return normal suspend
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
extends NormalBolus.normal bolus finish
whengrd1: prog1 = call normal finish
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act1: prog1 := return normal finish
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
extends NormalBolus.normal bolus resume
whengrd1: prog1 = call normal resume
thenNormalBolus.act1: normal bolus suspend := FALSE
act1: normal delivering rate := 0
act2: prog1 := return normal resume
end
Event Square Dual bolus2.start 〈ordinary〉 =̂
anyt
r
where
23.01.2018 12:37 Page 95 of 196
![Page 96: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/96.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
Square Dual bolus2.grd1: state = off
Square Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: sd module := s
Square Dual bolus2.act7: d deliver time := t
Square Dual bolus2.act8: d deliver rate := r
end
Event Square Dual bolus2.start dual 〈ordinary〉 =̂
anyt
r
td
whereSquare Dual bolus2.grd1: state = off
Square Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
Square Dual bolus2.grd4: td ∈ N1
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: d deliver time := t+ td
Square Dual bolus2.act7: d deliver rate := normal bolus rate
Square Dual bolus2.act8: d t := td
Square Dual bolus2.act9: sd module := d
end
Event Square Dual bolus2.update to dual 〈ordinary〉 =̂
whenSquare Dual bolus2.grd2: state = deliver
Square Dual bolus2.grd3: sd module = d
Square Dual bolus2.grd4: sd flag = d
thenSquare Dual bolus2.act2: d deliver rate := s r
Square Dual bolus2.act3: sd flag := s
end
Event Square Dual bolus2.finish 〈ordinary〉 =̂
whenSquare Dual bolus2.grd1: state = deliver
Square Dual bolus2.grd2: sd module = d⇒ sd flag = s
thenSquare Dual bolus2.act1: state := off
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
end
Event Square Dual bolus2.suspend 〈ordinary〉 =̂
whenSquare Dual bolus2.grd1: state = deliver
thenSquare Dual bolus2.act1: state := suspend
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
23.01.2018 12:37 Page 96 of 196
![Page 97: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/97.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
end
Event Square Dual bolus2.resume 〈ordinary〉 =̂
whenSquare Dual bolus2.grd1: state = suspend
thenSquare Dual bolus2.act1: state := off
end
Event Square Dual bolus2.preempted 〈ordinary〉 =̂
anyt time left for square bolus
whereSquare Dual bolus2.grd1: state = deliver
Square Dual bolus2.grd2: t ∈ 0 .. d deliver time
thenSquare Dual bolus2.act1: state := preempt
Square Dual bolus2.act4: d deliver time := t
Square Dual bolus2.act5: d deliver rate := 0
end
Event Square Dual bolus2.resume from preempt 〈ordinary〉 =̂
anyr
whereSquare Dual bolus2.grd1: state = preempt
Square Dual bolus2.grd2: sd module = s⇒ r = s r
Square Dual bolus2.grd3: sd module = d ∧ sd flag = d⇒ r = normal bolus rate
Square Dual bolus2.grd4: sd module = d ∧ sd flag = s⇒ r = s r
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act4: d deliver rate := r
end
Event Basal6·basal suspend 〈ordinary〉 =̂
extends Basal6·basal suspend
whengrd1: prog = call basal suspend
Basal6.grd3: prog basal = null
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
grd2: prog1 = call basal suspend
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act1: prog := return basal suspend
act2: prog1 := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
23.01.2018 12:37 Page 97 of 196
![Page 98: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/98.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act1: prog := return basal resume
act2: prog1 := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whengrd1: prog = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
Basal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd2: prog1 = call basal resume
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
23.01.2018 12:37 Page 98 of 196
![Page 99: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/99.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act5: prog := return basal update
act6: prog1 := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whengrd1: prog = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
Basal6.grd3: add update = 0
Basal6.grd2: prog basal = null
grd2: prog1 = call basal update
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act5: prog := return basal start
act6: prog1 := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whengrd1: prog = call basal start
Basal6.grd3: add start = 0
Basal6.grd4: 〈theorem〉 basal mode = stop
Basal6.grd2: prog basal = null
grd2: prog1 = call basal start
23.01.2018 12:37 Page 99 of 196
![Page 100: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/100.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
extends Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd1: prog = call basal stop
grd2: prog1 = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act1: prog := return basal stop
act2: prog1 := return basal stop
end
Event Basal6.get min value 1 〈ordinary〉 =̂
extends Basal6.get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
23.01.2018 12:37 Page 100 of 196
![Page 101: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/101.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6·get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 101 of 196
![Page 102: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/102.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
REFINES control Basal6 NormalBolus 2 Square Dual bolus2
SEES c normalbolus,c prog2,c sd bolus
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
state
s r
s t
d deliver time
d deliver rate
d t
sd module
sd flag
prog2
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
par t max
prog basal
23.01.2018 12:37 Page 102 of 196
![Page 103: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/103.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
par get t
add resume
add update
add start
prog
prog1
INVARIANTS
inv1: prog2 ∈ PROG0
inv2: prog2 = return sd resume⇒ d deliver rate = 0
inv3: prog2 = return sd update⇒ d deliver rate ∈ N1
inv4: prog2 = return sd suspend⇒ d deliver rate = 0
inv5: prog2 = return sd resume preempt⇒ d deliver rate ∈ N1
inv6: prog2 = return sd start d⇒ d deliver rate ∈ N1 ∧ d deliver time ∈ N1 ∧ d t ∈ N1
inv7: prog2 = return sd start d⇒ d deliver time > d t
inv8: prog2 = return sd start s⇒ d deliver rate ∈ N1 ∧ d deliver time ∈ N1
inv15: prog2 = return sd finish⇒ d deliver time = 0
inv14: prog2 = return sd finish⇒ d deliver rate = 0
inv16: prog2 = return sd start s ∨ prog2 = call sd start s⇒ sd bolus work = FALSE
∧ normal bolus work = FALSE ∧ sd suspend = FALSE
inv17: prog2 = return sd start d ∨ prog2 = call sd start d⇒ sd bolus work = FALSE
∧ normal bolus work = FALSE ∧ sd suspend = FALSE
inv9: prog2 = return sd finish ∨ prog2 = call sd finish⇒ sd bolus work = TRUE ∧sd preempted by normal = FALSE ∧ sd suspend = FALSE ∧ time = t sd
inv10: prog2 = return sd resume preempt ∨ prog2 = call sd resume preempt ⇒ sd bolus work =
TRUE∧sd preempted by normal = TRUE∧normal bolus work = FALSE∧sd suspend = FALSE
inv11: prog2 = return sd suspend ∨ prog2 = call sd suspend⇒ sd bolus work = TRUE ∧sd preempted by normal = FALSE ∧ sd suspend = FALSE
inv12: prog2 = return sd update∨ prog2 = call sd update⇒ sd suspend = FALSE ∧ sd bolus work =
TRUE ∧ sd preempted by normal = FALSE ∧ dmodule = TRUE ∧ time = d update time
inv13: prog2 = return sd resume ∨ prog2 = call sd resume⇒ sd suspend = TRUE
inv47: prog2 = return sd preempt ∨ prog2 = call sd preempt
⇒ sd bolus work = TRUE ∧ sd preempted by normal = FALSE ∧normal bolus work = FALSE ∧sd suspend = FALSE
inv18: prog2 ∈ PROG \ {null}⇒ prog1 = prog2
inv19: prog2 = null⇒ prog1 = null
inv20: prog2 ∈ pg2⇒ prog1 = null
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
23.01.2018 12:37 Page 103 of 196
![Page 104: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/104.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act21: prog := null
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
act31: prog1 := null
Square Dual bolus2.act1: state := off
Square Dual bolus2.act2: s r := 0
Square Dual bolus2.act3: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd module := s
Square Dual bolus2.act10: sd flag := d
act32: prog2 := null
end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
extends control5·normal bolus start 1 return
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd1: prog1 = return normal start
grd8: dmodule = FALSE⇒ t2 = 0
grd9: prog2 = return normal start
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
23.01.2018 12:37 Page 104 of 196
![Page 105: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/105.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act1: prog1 := null
act2: prog2 := null
end
Event control5·normal bolus start 1 call 2 〈ordinary〉 =̂
extends control5·normal bolus start 1 call
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: prog2 = return sd preempt
thenact1: prog1 := call normal start
act2: prog2 := call normal start
end
Event control5·normal bolus start 1 call sd preempt 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: dmodule = TRUE⇒ time 6= d update time
thenact1: prog2 := call sd preempt
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
extends control5.normal bolus start 2 return
whencontrol5.grd2: sd bolus work = FALSE
grd1: prog1 = return normal start
grd2: prog2 = return normal start
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act1: prog1 := null
act2: prog2 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
extends control5·normal bolus start 2 call
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact1: prog1 := call normal start
act2: prog2 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
extends control5·normal bolus finish return
when
23.01.2018 12:37 Page 105 of 196
![Page 106: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/106.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
grd1: prog1 = return normal finish
grd2: prog2 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
act2: prog2 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
extends control5 ·normal bolus finish call
whengrd1: prog1 = null
grd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact1: prog1 := call normal finish
act2: prog2 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
extends control5·normal suspend return
whengrd1: prog1 = return normal suspend
grd2: prog2 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
act3: prog2 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
extends control5·normal bolus suspend call
whengrd1: prog1 = null
grd2: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: prog2 = null
thenact1: prog1 := call normal suspend
act2: prog2 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
extends control5·normal resume return
whengrd1: prog1 = return normal resume
grd2: prog2 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act1: prog1 := null
act2: normal bolus work := FALSE
23.01.2018 12:37 Page 106 of 196
![Page 107: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/107.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
act3: prog2 := null
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
extends control5 ·normal bolus resume call
whengrd1: prog1 = null
grd2: normal suspend = TRUE
grd3: prog2 = null
thenact1: prog1 := call normal resume
act2: prog2 := call normal resume
end
Event control5·square or dual bolus start s return 〈ordinary〉 =̂
refines control5 ·square or dual bolus start s
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd6: prog2 = return sd start s
withr: r = d deliver rate
t: t = d deliver time
thenact1: sd bolus work := TRUE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5square or dual bolus start s call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start s
end
Event control5·square or dual bolus start d return 〈ordinary〉 =̂
refines control5 ·square or dual bolus start d
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd8: prog2 = return sd start d
withr: r = d deliver rate
t: t = d deliver time
t0: t0 = d t
thenact1: sd bolus work := TRUE
act5: dmodule := TRUE
act6: d update time := time+ d t
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act7: prog2 := null
23.01.2018 12:37 Page 107 of 196
![Page 108: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/108.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
end
Event control5·square or dual bolus start d call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start d
end
Event control5.square or dual bolus finish return 〈ordinary〉 =̂
refines control5.square or dual bolus finish
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
grd6: prog2 = return sd finish
thenact1: sd bolus work := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5.square or dual bolus finish call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: prog2 := call sd finish
end
Event control5.square or dual bolus resume from normal return 〈ordinary〉 =̂
refines control5.square or dual bolus resume from normal
anyt2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd6: prog2 = return sd resume preempt
grd7: dmodule = TRUE⇒ t2 = time+ d update time
grd8: dmodule = FALSE⇒ t2 = 0
withr: r = d deliver rate
thenact1: sd preempted by normal := FALSE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ t sd
act5: prog2 := null
act6: d update time := t2
end
23.01.2018 12:37 Page 108 of 196
![Page 109: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/109.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
Event control5.square or dual bolus resume from normal call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = TRUE
grd4: normal bolus work = FALSE
grd5: sd suspend = FALSE
thenact1: prog2 := call sd resume preempt
end
Event control5.sd suspend return 〈ordinary〉 =̂
refines control5.sd suspend
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: prog2 = return sd suspend
thenact1: sd suspend := TRUE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: prog2 := null
act7: d update time := 0
end
Event control5.sd suspend call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd suspend
end
Event control5.square or dual update rate return 〈ordinary〉 =̂
refines control5.square or dual update rate
whengrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd6: dmodule = TRUE
grd7: time = d update time
grd8: prog2 = return sd update
withr: r = d deliver rate
thenact1: sd rate := d deliver rate
act2: pump rate := d deliver rate+ basal rate
act3: dmodule := FALSE
act4: prog2 := null
act5: d update time := 0
end
Event control5·square or dual update rate call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
23.01.2018 12:37 Page 109 of 196
![Page 110: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/110.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
grd4: sd preempted by normal = FALSE
grd5: dmodule = TRUE
grd6: time = d update time
thenact1: prog2 := call sd update
end
Event control5.sd resume return 〈ordinary〉 =̂
refines control5.sd resume
whengrd1: sd suspend = TRUE
grd3: prog2 = return sd resume
thenact1: sd suspend := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := 0
act5: prog2 := null
act6: sd bolus work := FALSE
end
Event control5.sd resume call 〈ordinary〉 =̂
whengrd1: prog2 = null
grd2: sd suspend = TRUE
thenact1: prog2 := call sd resume
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
whengrd1: prog = return basal start
grd2: prog1 = return basal start
grd3: prog2 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
grd5: prog2 = null
thenact1: prog := call basal start
act2: par basal start t := timemodc
act3: prog1 := call basal start
act4: prog2 := call basal start
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
when
23.01.2018 12:37 Page 110 of 196
![Page 111: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/111.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
grd1: prog = return basal stop
grd2: prog1 = return basal stop
grd3: prog2 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
grd5: prog2 = null
thenact1: prog := call basal stop
act2: prog1 := call basal stop
act3: prog2 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
whengrd1: prog = return basal suspend
grd2: prog1 = return basal suspend
grd3: prog2 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd3: prog = null
grd5: prog1 = null
grd6: prog2 = null
thenact1: prog := call basal suspend
act2: prog1 := call basal suspend
act3: prog2 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
when
23.01.2018 12:37 Page 111 of 196
![Page 112: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/112.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
grd1: prog = return basal resume
grd2: prog1 = return basal resume
grd3: prog2 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
whengrd1: basal suspend = TRUE
grd2: prog = null
grd3: prog1 = null
grd4: prog2 = null
thenact1: prog := call basal resume
act2: par basal resume t := timemodc
act3: prog1 := call basal resume
act4: prog2 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd1: prog = return basal update
grd2: prog1 = return basal update
grd3: prog2 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: prog = null
grd5: t basal ∈ dom(rate setting2 B− {−1})grd6: prog1 = null
grd7: prog2 = null
thenact1: prog := call basal update
act2: par basal update rate t := t basal
act3: prog1 := call basal update
act4: prog2 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
when
23.01.2018 12:37 Page 112 of 196
![Page 113: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/113.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
grd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate insulin needed
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd1: prog1 = call normal start
grd2: prog2 = call normal start
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
extends NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act1: prog1 := return normal start
act2: prog2 := return normal start
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
extends NormalBolus.normal bolus suspend
whengrd1: prog1 = call normal suspend
grd2: prog2 = call normal suspend
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act1: prog1 := return normal suspend
act2: prog2 := return normal suspend
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
23.01.2018 12:37 Page 113 of 196
![Page 114: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/114.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
extends NormalBolus.normal bolus finish
whengrd1: prog1 = call normal finish
grd2: prog2 = call normal finish
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act1: prog1 := return normal finish
act2: prog2 := return normal finish
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
extends NormalBolus.normal bolus resume
whengrd1: prog1 = call normal resume
grd2: prog2 = call normal resume
thenNormalBolus.act1: normal bolus suspend := FALSE
act1: normal delivering rate := 0
act2: prog1 := return normal resume
act3: prog2 := return normal resume
end
Event Square Dual bolus2.start 〈ordinary〉 =̂
extends Square Dual bolus2.start
anyt
r
whereSquare Dual bolus2.grd1: state = off
Square Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
grd2: prog2 = call sd start s
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: sd module := s
Square Dual bolus2.act7: d deliver time := t
Square Dual bolus2.act8: d deliver rate := r
act2: prog2 := return sd start s
end
Event Square Dual bolus2.start dual 〈ordinary〉 =̂
extends Square Dual bolus2.start dual
anyt
r
td
whereSquare Dual bolus2.grd1: state = off
Square Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
Square Dual bolus2.grd4: td ∈ N1
grd2: prog2 = call sd start d
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: d deliver time := t+ td
23.01.2018 12:37 Page 114 of 196
![Page 115: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/115.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
Square Dual bolus2.act7: d deliver rate := normal bolus rate
Square Dual bolus2.act8: d t := td
Square Dual bolus2.act9: sd module := d
act2: prog2 := return sd start d
end
Event Square Dual bolus2.update to dual 〈ordinary〉 =̂
extends Square Dual bolus2.update to dual
whenSquare Dual bolus2.grd2: state = deliver
Square Dual bolus2.grd3: sd module = d
Square Dual bolus2.grd4: sd flag = d
grd2: prog2 = call sd update
thenSquare Dual bolus2.act2: d deliver rate := s r
Square Dual bolus2.act3: sd flag := s
act2: prog2 := return sd update
end
Event Square Dual bolus2.finish 〈ordinary〉 =̂
extends Square Dual bolus2.finish
whenSquare Dual bolus2.grd1: state = deliver
Square Dual bolus2.grd2: sd module = d⇒ sd flag = s
grd1: prog2 = call sd finish
thenSquare Dual bolus2.act1: state := off
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd finish
end
Event Square Dual bolus2.suspend 〈ordinary〉 =̂
extends Square Dual bolus2.suspend
whenSquare Dual bolus2.grd1: state = deliver
grd1: prog2 = call sd suspend
thenSquare Dual bolus2.act1: state := suspend
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd suspend
end
Event Square Dual bolus2.resume 〈ordinary〉 =̂
extends Square Dual bolus2.resume
whenSquare Dual bolus2.grd1: state = suspend
grd1: prog2 = call sd resume
thenSquare Dual bolus2.act1: state := off
act1: prog2 := return sd resume
end
Event Square Dual bolus2.preempted 〈ordinary〉 =̂
23.01.2018 12:37 Page 115 of 196
![Page 116: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/116.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
extends Square Dual bolus2.preempted
anyt time left for square bolus
whereSquare Dual bolus2.grd1: state = deliver
Square Dual bolus2.grd2: t ∈ 0 .. d deliver time
grd1: prog2 = call sd preempt
thenSquare Dual bolus2.act1: state := preempt
Square Dual bolus2.act4: d deliver time := t
Square Dual bolus2.act5: d deliver rate := 0
act1: prog2 := return sd preempt
end
Event Square Dual bolus2.resume from preempt 〈ordinary〉 =̂
extends Square Dual bolus2.resume from preempt
anyr
whereSquare Dual bolus2.grd1: state = preempt
Square Dual bolus2.grd2: sd module = s⇒ r = s r
Square Dual bolus2.grd3: sd module = d ∧ sd flag = d⇒ r = normal bolus rate
Square Dual bolus2.grd4: sd module = d ∧ sd flag = s⇒ r = s r
grd1: prog2 = call sd resume preempt
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act4: d deliver rate := r
act1: prog2 := return sd resume preempt
end
Event Basal6·basal suspend 〈ordinary〉 =̂
extends Basal6·basal suspend
whengrd1: prog = call basal suspend
Basal6.grd3: prog basal = null
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
grd2: prog1 = call basal suspend
grd3: prog2 = call basal suspend
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act1: prog := return basal suspend
act2: prog1 := return basal suspend
act3: prog2 := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
23.01.2018 12:37 Page 116 of 196
![Page 117: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/117.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act1: prog := return basal resume
act2: prog1 := return basal resume
act3: prog2 := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whengrd1: prog = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
Basal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd2: prog1 = call basal resume
grd3: prog2 = call basal resume
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
23.01.2018 12:37 Page 117 of 196
![Page 118: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/118.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act5: prog := return basal update
act6: prog1 := return basal update
act7: prog2 := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whengrd1: prog = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
Basal6.grd3: add update = 0
Basal6.grd2: prog basal = null
grd2: prog1 = call basal update
grd3: prog2 = call basal update
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act5: prog := return basal start
act6: prog1 := return basal start
act7: prog2 := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whengrd1: prog = call basal start
Basal6.grd3: add start = 0
Basal6.grd4: 〈theorem〉 basal mode = stop
Basal6.grd2: prog basal = null
23.01.2018 12:37 Page 118 of 196
![Page 119: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/119.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
grd2: prog1 = call basal start
grd3: prog2 = call basal start
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
extends Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd1: prog = call basal stop
grd2: prog1 = call basal stop
grd3: prog2 = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act1: prog := return basal stop
act2: prog1 := return basal stop
act3: prog2 := return basal stop
end
Event Basal6.get min value 1 〈ordinary〉 =̂
extends Basal6.get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
23.01.2018 12:37 Page 119 of 196
![Page 120: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/120.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6·get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
23.01.2018 12:37 Page 120 of 196
![Page 121: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/121.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 3
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 121 of 196
![Page 122: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/122.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
REFINES control Basal6 NormalBolus 2 Square Dual bolus2 3
SEES c normalbolus anim,c prog2 anim,c basal anim,c sd bolus
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
state
s r
s t
d deliver time
d deliver rate
d t
sd module
sd flag
prog2
par sd preempt t
sdp add
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
23.01.2018 12:37 Page 122 of 196
![Page 123: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/123.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
par t max
prog basal
par get t
add resume
add update
add start
prog
prog1
INVARIANTS
inv22: prog2 = call sd start s⇒ state = off
inv23: prog2 = call sd start d⇒ state = off
inv24: prog2 = call sd update⇒ state = deliver ∧ sd module = d ∧ sd flag = d
inv25: prog2 = call sd finish⇒ state = deliver ∧ (sd module = d⇒ sd flag = s)
inv26: prog2 = call sd suspend⇒ state = deliver
inv28: prog2 = call sd preempt⇒ state = deliver
inv32: prog2 = return sd resume ∨ prog2 = return sd finish⇒ state = off
inv33: prog2 ∈ PROG ∧ sd bolus work = FALSE⇒ state = off
inv35: prog2 ∈ PROG\{call normal start, return normal start}∧sd suspend = FALSE∧sd bolus work =
TRUE ∧ sd preempted by normal = FALSE⇒ state = deliver
inv39: normal add ∈ {1, 2}⇒ prog2 = call normal start
inv38: prog2 = return sd preempt⇒ state = preempt
inv37: prog2 ∈ PROG ∧ dmodule = TRUE ∧ time ≤ d update time ∧ sd suspend = FALSE ∧sd bolus work = TRUE ∧ sd preempted by normal = FALSE⇒ sd module = d ∧ sd flag = d
inv42: prog2 ∈ PROG∪{call sd resume preempt, return sd resume preempt, return sd preempt, call sd preempt}∧dmodule = TRUE⇒ sd module = d ∧ sd flag = d
inv43: prog2 = return sd start d⇒ sd module = d ∧ sd flag = d
inv40: prog2 ∈ PROG∧sd bolus work = TRUE∧sd preempted by normal = FALSE∧sd suspend =
FALSE ∧ time = t sd⇒ dmodule = FALSE
(sd module=d ⇒ sd flag=s)
inv41: prog2 ∈ PROG∪{call sd resume preempt, return sd resume preempt, return sd preempt, call sd preempt,call normal start, return normal start} ∧ sd bolus work = TRUE ∧ sd preempted by normal =
FALSE ∧ sd suspend = FALSE ∧ dmodule = FALSE⇒ (sd module = d⇒ sd flag = s)
inv44: prog2 ∈ {return sd update, return sd start s}⇒ (sd module = d⇒ sd flag = s)
inv45: prog2 = return sd finish⇒ sd flag = d
inv46: sd bolus work = TRUE ∧ sd preempted by normal = TRUE ∧ sd suspend = FALSE ∧dmodule = FALSE⇒ (sd module = d⇒ sd flag = s)
inv1: prog2 ∈ PROG ∧ sd suspend = TRUE⇒ state = suspend
inv2: prog2 ∈ PROG ∧ sd bolus work = TRUE ∧ sd preempted by normal = TRUE ∧ sd suspend =
FALSE⇒ state = preempt
inv3: prog2 = return sd suspend⇒ state = suspend
inv4: prog2 ∈ {call normal start, return normal start}∧sd bolus work = TRUE∧sd preempted by normal =
FALSE ∧ normal bolus work = FALSE ∧ sd suspend = FALSE⇒ state = preempt
inv5: prog2 = return sd preempt⇒ state = preempt
inv6: prog2 = call sd resume⇒ state = suspend
inv7: prog2 = call sd resume preempt⇒ state = preempt
inv47: par sd preempt t ∈ Ninv48: prog2 = call sd preempt⇒ par sd preempt t ∈ 0 .. d deliver time
inv49: prog2 = call sd preempt⇒ t sd− time ≥ 0
inv51: prog2 ∈ PROG ∪ {call sd preempt, call sd update, return sd update} ∧ normal bolus work =
FALSE∧sd bolus work = TRUE∧sd preempted by normal = FALSE∧sd suspend = FALSE⇒t sd− time ≤ d deliver time
inv53: prog2 ∈ {return sd start s, return sd start d} ∧ sd bolus work = FALSE ∧ sd suspend =
FALSE⇒ t sd− time ≤ d deliver time
23.01.2018 12:37 Page 123 of 196
![Page 124: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/124.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
inv54: prog2 ∈ {call sd resume preempt, return sd resume preempt}⇒ t sd ≤ d deliver timeinv55: sd preempted by normal = TRUE⇒ t sd ≤ d deliver timeinv56: prog2 ∈ {return sd preempt}⇒ d deliver time = par sd preempt t∧ par sd preempt t = t sd−
time
inv57: prog2 ∈ {call normal start, return normal start}∧sd bolus work = TRUE⇒d deliver time =
par sd preempt t ∧ par sd preempt t = t sd− timeinv58: prog2 = call sd preempt⇒ par sd preempt t = t sd− timeinv59: sdp add ∈ 0 .. 1
inv60: prog2 ∈ {return sd preempt, call sd preempt}∨(prog2 ∈ {call normal start, return normal start}∧sd bolus work = TRUE)⇒ sdp add = 1
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act21: prog := null
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
act31: prog1 := null
23.01.2018 12:37 Page 124 of 196
![Page 125: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/125.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
Square Dual bolus2.act1: state := off
Square Dual bolus2.act2: s r := 0
Square Dual bolus2.act3: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd module := s
Square Dual bolus2.act10: sd flag := d
act32: prog2 := null
act33: par sd preempt t := 0
act34: sdp add := 0
end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
extends control5·normal bolus start 1 return
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd1: prog1 = return normal start
grd8: dmodule = FALSE⇒ t2 = 0
grd9: prog2 = return normal start
grd4: 〈theorem〉 sdp add = 1
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act1: prog1 := null
act2: prog2 := null
act3: sdp add := 0
end
Event control5·normal bolus start 1 call 2 〈ordinary〉 =̂
extends control5·normal bolus start 1 call 2
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: prog2 = return sd preempt
grd8: 〈theorem〉 sdp add = 1
thenact1: prog1 := call normal start
act2: prog2 := call normal start
end
Event control5·normal bolus start 1 call sd preempt 〈ordinary〉 =̂
extends control5 ·normal bolus start 1 call sd preempt
whengrd1: prog2 = null
grd2: normal bolus work = FALSE
23.01.2018 12:37 Page 125 of 196
![Page 126: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/126.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: dmodule = TRUE⇒ time 6= d update time
grd7: sdp add = 0
thenact1: prog2 := call sd preempt
act2: par sd preempt t := t sd− timeact3: sdp add := 1
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
extends control5.normal bolus start 2 return
whencontrol5.grd2: sd bolus work = FALSE
grd1: prog1 = return normal start
grd2: prog2 = return normal start
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act1: prog1 := null
act2: prog2 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
extends control5·normal bolus start 2 call
whengrd1: prog1 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact1: prog1 := call normal start
act2: prog2 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
extends control5·normal bolus finish return
whengrd1: prog1 = return normal finish
grd2: prog2 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
act2: prog2 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
extends control5 ·normal bolus finish call
whengrd1: prog1 = null
grd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
grd5: prog2 = null
then
23.01.2018 12:37 Page 126 of 196
![Page 127: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/127.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act1: prog1 := call normal finish
act2: prog2 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
extends control5·normal suspend return
whengrd1: prog1 = return normal suspend
grd2: prog2 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act1: prog1 := null
act3: prog2 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
extends control5·normal bolus suspend call
whengrd1: prog1 = null
grd2: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: prog2 = null
thenact1: prog1 := call normal suspend
act2: prog2 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
extends control5·normal resume return
whengrd1: prog1 = return normal resume
grd2: prog2 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act1: prog1 := null
act2: normal bolus work := FALSE
act3: prog2 := null
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
extends control5 ·normal bolus resume call
whengrd1: prog1 = null
grd2: normal suspend = TRUE
grd3: prog2 = null
thenact1: prog1 := call normal resume
act2: prog2 := call normal resume
end
Event control5·square or dual bolus start s return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start s return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
23.01.2018 12:37 Page 127 of 196
![Page 128: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/128.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
grd6: prog2 = return sd start s
thenact1: sd bolus work := TRUE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5square or dual bolus start s call 〈ordinary〉 =̂
extends control5square or dual bolus start s call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start s
end
Event control5·square or dual bolus start d return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start d return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd8: prog2 = return sd start d
thenact1: sd bolus work := TRUE
act5: dmodule := TRUE
act6: d update time := time+ d t
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act7: prog2 := null
end
Event control5·square or dual bolus start d call 〈ordinary〉 =̂
extends control5·square or dual bolus start d call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start d
end
Event control5.square or dual bolus finish return 〈ordinary〉 =̂
extends control5.square or dual bolus finish return
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
grd6: prog2 = return sd finish
thenact1: sd bolus work := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := d deliver time
23.01.2018 12:37 Page 128 of 196
![Page 129: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/129.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5.square or dual bolus finish call 〈ordinary〉 =̂
extends control5.square or dual bolus finish call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: prog2 := call sd finish
end
Event control5.square or dual bolus resume from normal return 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal return
anyt2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd6: prog2 = return sd resume preempt
grd7: dmodule = TRUE⇒ t2 = time+ d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ t sd
act5: prog2 := null
act6: d update time := t2
end
Event control5.square or dual bolus resume from normal call 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = TRUE
grd4: normal bolus work = FALSE
grd5: sd suspend = FALSE
thenact1: prog2 := call sd resume preempt
end
Event control5.sd suspend return 〈ordinary〉 =̂
extends control5.sd suspend return
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: prog2 = return sd suspend
thenact1: sd suspend := TRUE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
23.01.2018 12:37 Page 129 of 196
![Page 130: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/130.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act6: prog2 := null
act7: d update time := 0
end
Event control5.sd suspend call 〈ordinary〉 =̂
extends control5.sd suspend call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd suspend
end
Event control5.square or dual update rate return 〈ordinary〉 =̂
extends control5.square or dual update rate return
whengrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd6: dmodule = TRUE
grd7: time = d update time
grd8: prog2 = return sd update
thenact1: sd rate := d deliver rate
act2: pump rate := d deliver rate+ basal rate
act3: dmodule := FALSE
act4: prog2 := null
act5: d update time := 0
end
Event control5·square or dual update rate call 〈ordinary〉 =̂
extends control5·square or dual update rate call
whengrd1: prog2 = null
grd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: dmodule = TRUE
grd6: time = d update time
thenact1: prog2 := call sd update
end
Event control5.sd resume return 〈ordinary〉 =̂
extends control5.sd resume return
whengrd1: sd suspend = TRUE
grd3: prog2 = return sd resume
thenact1: sd suspend := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := 0
act5: prog2 := null
act6: sd bolus work := FALSE
end
Event control5.sd resume call 〈ordinary〉 =̂
extends control5.sd resume call
when
23.01.2018 12:37 Page 130 of 196
![Page 131: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/131.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
grd1: prog2 = null
grd2: sd suspend = TRUE
thenact1: prog2 := call sd resume
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
whengrd1: prog = return basal start
grd2: prog1 = return basal start
grd3: prog2 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
grd5: prog2 = null
thenact1: prog := call basal start
act2: par basal start t := timemodc
act3: prog1 := call basal start
act4: prog2 := call basal start
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
whengrd1: prog = return basal stop
grd2: prog1 = return basal stop
grd3: prog2 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd3: prog = null
grd4: prog1 = null
grd5: prog2 = null
then
23.01.2018 12:37 Page 131 of 196
![Page 132: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/132.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act1: prog := call basal stop
act2: prog1 := call basal stop
act3: prog2 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
whengrd1: prog = return basal suspend
grd2: prog1 = return basal suspend
grd3: prog2 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd3: prog = null
grd5: prog1 = null
grd6: prog2 = null
thenact1: prog := call basal suspend
act2: prog1 := call basal suspend
act3: prog2 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
whengrd1: prog = return basal resume
grd2: prog1 = return basal resume
grd3: prog2 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
whengrd1: basal suspend = TRUE
grd2: prog = null
grd3: prog1 = null
grd4: prog2 = null
thenact1: prog := call basal resume
23.01.2018 12:37 Page 132 of 196
![Page 133: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/133.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act2: par basal resume t := timemodc
act3: prog1 := call basal resume
act4: prog2 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd1: prog = return basal update
grd2: prog1 = return basal update
grd3: prog2 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act1: prog := null
act2: prog1 := null
act3: prog2 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd4: prog = null
grd5: t basal ∈ dom(rate setting2 B− {−1})grd6: prog1 = null
grd7: prog2 = null
thenact1: prog := call basal update
act2: par basal update rate t := t basal
act3: prog1 := call basal update
act4: prog2 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
grd2: sdp add 6= 1
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate insulin needed
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd1: prog1 = call normal start
23.01.2018 12:37 Page 133 of 196
![Page 134: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/134.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
grd2: prog2 = call normal start
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
extends NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act1: prog1 := return normal start
act2: prog2 := return normal start
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
extends NormalBolus.normal bolus suspend
whengrd1: prog1 = call normal suspend
grd2: prog2 = call normal suspend
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act1: prog1 := return normal suspend
act2: prog2 := return normal suspend
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
extends NormalBolus.normal bolus finish
whengrd1: prog1 = call normal finish
grd2: prog2 = call normal finish
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act1: prog1 := return normal finish
act2: prog2 := return normal finish
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
extends NormalBolus.normal bolus resume
whengrd1: prog1 = call normal resume
grd2: prog2 = call normal resume
thenNormalBolus.act1: normal bolus suspend := FALSE
act1: normal delivering rate := 0
23.01.2018 12:37 Page 134 of 196
![Page 135: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/135.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act2: prog1 := return normal resume
act3: prog2 := return normal resume
end
Event Square Dual bolus2.start 〈ordinary〉 =̂
refines Square Dual bolus2.start
anyt
r
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
grd2: prog2 = call sd start s
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: sd module := s
Square Dual bolus2.act7: d deliver time := t
Square Dual bolus2.act8: d deliver rate := r
act2: prog2 := return sd start s
end
Event Square Dual bolus2.start dual 〈ordinary〉 =̂
refines Square Dual bolus2.start dual
anyt
r
td
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
Square Dual bolus2.grd4: td ∈ N1
grd1: prog2 = call sd start d
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: d deliver time := t+ td
Square Dual bolus2.act7: d deliver rate := normal bolus rate
Square Dual bolus2.act8: d t := td
Square Dual bolus2.act9: sd module := d
act1: prog2 := return sd start d
end
Event Square Dual bolus2.update to dual 〈ordinary〉 =̂
refines Square Dual bolus2.update to dual
whengrd1: prog2 = call sd update
thenSquare Dual bolus2.act2: d deliver rate := s r
Square Dual bolus2.act3: sd flag := s
act1: prog2 := return sd update
end
Event Square Dual bolus2.finish 〈ordinary〉 =̂
refines Square Dual bolus2.finish
whengrd1: prog2 = call sd finish
thenSquare Dual bolus2.act1: state := off
Square Dual bolus2.act4: s r := 0
23.01.2018 12:37 Page 135 of 196
![Page 136: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/136.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd finish
end
Event Square Dual bolus2.suspend 〈ordinary〉 =̂
refines Square Dual bolus2.suspend
whengrd1: prog2 = call sd suspend
thenSquare Dual bolus2.act1: state := suspend
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd suspend
end
Event Square Dual bolus2.resume 〈ordinary〉 =̂
refines Square Dual bolus2.resume
whengrd1: prog2 = call sd resume
thenSquare Dual bolus2.act1: state := off
act1: prog2 := return sd resume
end
Event Square Dual bolus2.preempted 〈ordinary〉 =̂
refines Square Dual bolus2.preempted
whengrd1: prog2 = call sd preempt
witht: t = par sd preempt t
thenSquare Dual bolus2.act1: state := preempt
Square Dual bolus2.act4: d deliver time := par sd preempt t
Square Dual bolus2.act5: d deliver rate := 0
act1: prog2 := return sd preempt
end
Event Square Dual bolus2.resume from preempt 〈ordinary〉 =̂
extends Square Dual bolus2.resume from preempt
anyr
whereSquare Dual bolus2.grd1: state = preempt
Square Dual bolus2.grd2: sd module = s⇒ r = s r
Square Dual bolus2.grd3: sd module = d ∧ sd flag = d⇒ r = normal bolus rate
Square Dual bolus2.grd4: sd module = d ∧ sd flag = s⇒ r = s r
grd1: prog2 = call sd resume preempt
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act4: d deliver rate := r
act1: prog2 := return sd resume preempt
end
Event Basal6·basal suspend 〈ordinary〉 =̂
extends Basal6·basal suspend
23.01.2018 12:37 Page 136 of 196
![Page 137: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/137.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
whengrd1: prog = call basal suspend
Basal6.grd3: prog basal = null
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
grd2: prog1 = call basal suspend
grd3: prog2 = call basal suspend
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act1: prog := return basal suspend
act2: prog1 := return basal suspend
act3: prog2 := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
23.01.2018 12:37 Page 137 of 196
![Page 138: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/138.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
Basal6.grd9: add resume = 2
grd1: prog2 = call basal resume
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act1: prog := return basal resume
act2: prog1 := return basal resume
act3: prog2 := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whengrd1: prog = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
Basal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd2: prog1 = call basal resume
grd3: prog2 = call basal resume
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
grd1: prog2 = call basal update
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act5: prog := return basal update
act6: prog1 := return basal update
act7: prog2 := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whengrd1: prog = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
Basal6.grd3: add update = 0
23.01.2018 12:37 Page 138 of 196
![Page 139: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/139.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
Basal6.grd2: prog basal = null
grd2: prog1 = call basal update
grd3: prog2 = call basal update
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
grd1: prog2 = call basal start
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act5: prog := return basal start
act6: prog1 := return basal start
act7: prog2 := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whengrd1: prog = call basal start
Basal6.grd3: add start = 0
Basal6.grd4: 〈theorem〉 basal mode = stop
Basal6.grd2: prog basal = null
grd2: prog1 = call basal start
grd3: prog2 = call basal start
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
extends Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd1: prog = call basal stop
grd2: prog1 = call basal stop
grd3: prog2 = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
23.01.2018 12:37 Page 139 of 196
![Page 140: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/140.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
act1: prog := return basal stop
act2: prog1 := return basal stop
act3: prog2 := return basal stop
end
Event Basal6·get min value 1 〈ordinary〉 =̂
extends Basal6.get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
23.01.2018 12:37 Page 140 of 196
![Page 141: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/141.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 4
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6·get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 141 of 196
![Page 142: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/142.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
REFINES control Basal6 NormalBolus 2 Square Dual bolus2 4
SEES c normalbolus anim,c prog2 anim,c basal anim,c sd bolus
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
state
s r
s t
d deliver time
d deliver rate
d t
sd module
sd flag
prog2
par sd preempt t
sdp add
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
23.01.2018 12:37 Page 142 of 196
![Page 143: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/143.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
par t max
prog basal
par get t
add resume
add update
add start
EVENTS
Initialisation
beginact1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
Square Dual bolus2.act1: state := off
Square Dual bolus2.act2: s r := 0
Square Dual bolus2.act3: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd module := s
23.01.2018 12:37 Page 143 of 196
![Page 144: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/144.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Square Dual bolus2.act10: sd flag := d
act32: prog2 := null
act33: par sd preempt t := 0
act34: sdp add := 0
end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
refines control5·normal bolus start 1 return
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd8: dmodule = FALSE⇒ t2 = 0
grd9: prog2 = return normal start
grd4: 〈theorem〉 sdp add = 1
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act2: prog2 := null
act3: sdp add := 0
end
Event control5·normal bolus start 1 call 2 〈ordinary〉 =̂
refines control5·normal bolus start 1 call 2
whengrd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: prog2 = return sd preempt
grd8: 〈theorem〉 sdp add = 1
thenact2: prog2 := call normal start
end
Event control5·normal bolus start 1 call sd preempt 〈ordinary〉 =̂
extends control5 ·normal bolus start 1 call sd preempt
whengrd1: prog2 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: dmodule = TRUE⇒ time 6= d update time
grd7: sdp add = 0
thenact1: prog2 := call sd preempt
act2: par sd preempt t := t sd− timeact3: sdp add := 1
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
23.01.2018 12:37 Page 144 of 196
![Page 145: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/145.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
refines control5.normal bolus start 2 return
whencontrol5.grd2: sd bolus work = FALSE
grd2: prog2 = return normal start
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act2: prog2 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
refines control5·normal bolus start 2 call
whengrd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact2: prog2 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
refines control5·normal bolus finish return
whengrd2: prog2 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act2: prog2 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
refines control5·normal bolus finish call
whengrd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact2: prog2 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
refines control5·normal suspend return
whengrd2: prog2 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act3: prog2 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
refines control5·normal bolus suspend call
whengrd2: normal bolus work = TRUE
23.01.2018 12:37 Page 145 of 196
![Page 146: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/146.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
grd3: normal suspend = FALSE
grd4: prog2 = null
thenact2: prog2 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
refines control5·normal resume return
whengrd2: prog2 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act2: normal bolus work := FALSE
act3: prog2 := null
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
refines control5·normal bolus resume call
whengrd2: normal suspend = TRUE
grd3: prog2 = null
thenact2: prog2 := call normal resume
end
Event control5·square or dual bolus start s return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start s return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd6: prog2 = return sd start s
thenact1: sd bolus work := TRUE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5square or dual bolus start s call 〈ordinary〉 =̂
extends control5square or dual bolus start s call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start s
end
Event control5·square or dual bolus start d return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start d return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd8: prog2 = return sd start d
23.01.2018 12:37 Page 146 of 196
![Page 147: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/147.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
thenact1: sd bolus work := TRUE
act5: dmodule := TRUE
act6: d update time := time+ d t
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act7: prog2 := null
end
Event control5·square or dual bolus start d call 〈ordinary〉 =̂
extends control5·square or dual bolus start d call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start d
end
Event control5.square or dual bolus finish return 〈ordinary〉 =̂
extends control5.square or dual bolus finish return
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
grd6: prog2 = return sd finish
thenact1: sd bolus work := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5.square or dual bolus finish call 〈ordinary〉 =̂
extends control5.square or dual bolus finish call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: prog2 := call sd finish
end
Event control5.square or dual bolus resume from normal return 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal return
anyt2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd6: prog2 = return sd resume preempt
grd7: dmodule = TRUE⇒ t2 = time+ d update time
grd8: dmodule = FALSE⇒ t2 = 0
23.01.2018 12:37 Page 147 of 196
![Page 148: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/148.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
thenact1: sd preempted by normal := FALSE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ t sd
act5: prog2 := null
act6: d update time := t2
end
Event control5.square or dual bolus resume from normal call 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = TRUE
grd4: normal bolus work = FALSE
grd5: sd suspend = FALSE
thenact1: prog2 := call sd resume preempt
end
Event control5.sd suspend return 〈ordinary〉 =̂
extends control5.sd suspend return
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: prog2 = return sd suspend
thenact1: sd suspend := TRUE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: prog2 := null
act7: d update time := 0
end
Event control5.sd suspend call 〈ordinary〉 =̂
extends control5.sd suspend call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd suspend
end
Event control5.square or dual update rate return 〈ordinary〉 =̂
extends control5.square or dual update rate return
whengrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd6: dmodule = TRUE
grd7: time = d update time
grd8: prog2 = return sd update
thenact1: sd rate := d deliver rate
act2: pump rate := d deliver rate+ basal rate
act3: dmodule := FALSE
23.01.2018 12:37 Page 148 of 196
![Page 149: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/149.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
act4: prog2 := null
act5: d update time := 0
end
Event control5·square or dual update rate call 〈ordinary〉 =̂
extends control5·square or dual update rate call
whengrd1: prog2 = null
grd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: dmodule = TRUE
grd6: time = d update time
thenact1: prog2 := call sd update
end
Event control5.sd resume return 〈ordinary〉 =̂
extends control5.sd resume return
whengrd1: sd suspend = TRUE
grd3: prog2 = return sd resume
thenact1: sd suspend := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := 0
act5: prog2 := null
act6: sd bolus work := FALSE
end
Event control5.sd resume call 〈ordinary〉 =̂
extends control5.sd resume call
whengrd1: prog2 = null
grd2: sd suspend = TRUE
thenact1: prog2 := call sd resume
end
Event control5·basal start return 〈ordinary〉 =̂
refines control5·basal start return
whengrd3: prog2 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal start call 〈ordinary〉 =̂
refines control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd5: prog2 = null
thenact2: par basal start t := timemodc
act4: prog2 := call basal start
end
23.01.2018 12:37 Page 149 of 196
![Page 150: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/150.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Event control5·basal stop return 〈ordinary〉 =̂
refines control5·basal stop return
whengrd3: prog2 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
refines control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd5: prog2 = null
thenact3: prog2 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
refines control5·basal suspend return
whengrd3: prog2 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
refines control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd6: prog2 = null
thenact3: prog2 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
refines control5·basal resume return
whengrd3: prog2 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
refines control5·basal resume call
whengrd1: basal suspend = TRUE
23.01.2018 12:37 Page 150 of 196
![Page 151: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/151.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
grd4: prog2 = null
thenact2: par basal resume t := timemodc
act4: prog2 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
refines control5·basal update rate return
whengrd3: prog2 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
refines control5 ·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd5: t basal ∈ dom(rate setting2 B− {−1})grd7: prog2 = null
thenact2: par basal update rate t := t basal
act4: prog2 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
grd2: sdp add 6= 1
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
refines NormalBolus.normal bolus start calculate insulin needed
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd2: prog2 = call normal start
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
23.01.2018 12:37 Page 151 of 196
![Page 152: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/152.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
refines NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act2: prog2 := return normal start
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
refines NormalBolus.normal bolus suspend
whengrd2: prog2 = call normal suspend
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act2: prog2 := return normal suspend
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
refines NormalBolus.normal bolus finish
whengrd2: prog2 = call normal finish
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act2: prog2 := return normal finish
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
refines NormalBolus.normal bolus resume
whengrd2: prog2 = call normal resume
thenNormalBolus.act1: normal bolus suspend := FALSE
act2: prog2 := return normal resume
act3: normal delivering rate := 0
end
Event Square Dual bolus2.start 〈ordinary〉 =̂
extends Square Dual bolus2.start
anyt
r
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
grd2: prog2 = call sd start s
thenSquare Dual bolus2.act1: state := deliver
23.01.2018 12:37 Page 152 of 196
![Page 153: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/153.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: sd module := s
Square Dual bolus2.act7: d deliver time := t
Square Dual bolus2.act8: d deliver rate := r
act2: prog2 := return sd start s
end
Event Square Dual bolus2.start dual 〈ordinary〉 =̂
extends Square Dual bolus2.start dual
anyt
r
td
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
Square Dual bolus2.grd4: td ∈ N1
grd1: prog2 = call sd start d
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: d deliver time := t+ td
Square Dual bolus2.act7: d deliver rate := normal bolus rate
Square Dual bolus2.act8: d t := td
Square Dual bolus2.act9: sd module := d
act1: prog2 := return sd start d
end
Event Square Dual bolus2.update to dual 〈ordinary〉 =̂
extends Square Dual bolus2.update to dual
whengrd1: prog2 = call sd update
thenSquare Dual bolus2.act2: d deliver rate := s r
Square Dual bolus2.act3: sd flag := s
act1: prog2 := return sd update
end
Event Square Dual bolus2.finish 〈ordinary〉 =̂
extends Square Dual bolus2.finish
whengrd1: prog2 = call sd finish
thenSquare Dual bolus2.act1: state := off
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd finish
end
Event Square Dual bolus2.suspend 〈ordinary〉 =̂
extends Square Dual bolus2.suspend
whengrd1: prog2 = call sd suspend
thenSquare Dual bolus2.act1: state := suspend
Square Dual bolus2.act4: s r := 0
23.01.2018 12:37 Page 153 of 196
![Page 154: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/154.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd suspend
end
Event Square Dual bolus2.resume 〈ordinary〉 =̂
extends Square Dual bolus2.resume
whengrd1: prog2 = call sd resume
thenSquare Dual bolus2.act1: state := off
act1: prog2 := return sd resume
end
Event Square Dual bolus2.preempted 〈ordinary〉 =̂
extends Square Dual bolus2.preempted
whengrd1: prog2 = call sd preempt
thenSquare Dual bolus2.act1: state := preempt
Square Dual bolus2.act4: d deliver time := par sd preempt t
Square Dual bolus2.act5: d deliver rate := 0
act1: prog2 := return sd preempt
end
Event Square Dual bolus2.resume from preempt 〈ordinary〉 =̂
extends Square Dual bolus2.resume from preempt
anyr
whereSquare Dual bolus2.grd1: state = preempt
Square Dual bolus2.grd2: sd module = s⇒ r = s r
Square Dual bolus2.grd3: sd module = d ∧ sd flag = d⇒ r = normal bolus rate
Square Dual bolus2.grd4: sd module = d ∧ sd flag = s⇒ r = s r
grd1: prog2 = call sd resume preempt
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act4: d deliver rate := r
act1: prog2 := return sd resume preempt
end
Event Basal6·basal suspend 〈ordinary〉 =̂
refines Basal6·basal suspend
whenBasal6.grd3: prog basal = null
grd3: prog2 = call basal suspend
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act3: prog2 := return basal suspend
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
23.01.2018 12:37 Page 154 of 196
![Page 155: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/155.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
refines Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
grd1: prog2 = call basal resume
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act3: prog2 := return basal resume
end
Event Basal6.basal resume call 〈ordinary〉 =̂
refines Basal6.basal resume call
whenBasal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd3: prog2 = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
then
23.01.2018 12:37 Page 155 of 196
![Page 156: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/156.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Basal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
refines Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
grd1: prog2 = call basal update
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act7: prog2 := return basal update
end
Event Basal6.rate update call 〈ordinary〉 =̂
refines Basal6.rate update call
whenBasal6.grd3: add update = 0
Basal6.grd2: prog basal = null
grd3: prog2 = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
refines Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
grd1: prog2 = call basal start
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act7: prog2 := return basal start
end
Event Basal6.start call 〈ordinary〉 =̂
refines Basal6.start call
whenBasal6.grd3: add start = 0
23.01.2018 12:37 Page 156 of 196
![Page 157: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/157.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Basal6.grd2: prog basal = null
grd3: prog2 = call basal start
Basal6.grd4: 〈theorem〉 basal mode = stop
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
refines Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd3: prog2 = call basal stop
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act3: prog2 := return basal stop
end
Event Basal6·get min value 1 〈ordinary〉 =̂
extends Basal6·get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
23.01.2018 12:37 Page 157 of 196
![Page 158: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/158.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6·get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 158 of 196
![Page 159: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/159.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
REFINES control Basal6 NormalBolus 2 Square Dual bolus2 5
SEES c normalbolus anim,c prog2 anim,c basal anim,c sd bolus
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
state
s r
s t
d deliver time
d deliver rate
d t
sd module
sd flag
prog2
par sd preempt t
sdp add
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
23.01.2018 12:37 Page 159 of 196
![Page 160: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/160.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
par t max
prog basal
par get t
add resume
add update
add start
fbegin
fend
rate basal c
normal delivering rate c
nb now
nb new now
sd now
sd new now
sd rate c
INVARIANTS
inv11: sd rate c ∈ N 7→ Ninv12: sd now ∈ dom(sd rate c)
inv13: sd new now ∈ Ninv14: d deliver rate = sd rate c(sd now)
inv10: state ∈ {deliver, preempt} ∧ sd module = d ∧ sd flag = d⇒ d deliver time > s t
inv7: normal delivering rate c ∈ N 7→ 0 .. normal bolus rate
inv8: nb new now ∈ Ninv9: nb now ∈ dom(normal delivering rate c)
inv1: normal delivering rate c(nb now) = normal delivering rate
inv2: rate basal c ∈ N 7→ 0 .. basal max
inv3: fbegin ∈ dom(rate basal c)
inv4: fend ∈ 0 .. c
inv5: rate basal c(fbegin) = basal rate in
inv6: basal mode = delivering⇒ fend > fbegin
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
23.01.2018 12:37 Page 160 of 196
![Page 161: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/161.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
Square Dual bolus2.act1: state := off
Square Dual bolus2.act2: s r := 0
Square Dual bolus2.act3: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd module := s
Square Dual bolus2.act10: sd flag := d
act32: prog2 := null
act33: par sd preempt t := 0
act34: sdp add := 0
act35: fbegin := 0
act36: fend := 0
act37: rate basal c := {0 7→ 0}act38: normal delivering rate c := {0 7→ 0}act39: nb now := 0
act40: nb new now := 0
act41: sd now := 0
act42: sd new now := 0
act43: sd rate c := {0 7→ 0}end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
extends control5·normal bolus start 1 return
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd8: dmodule = FALSE⇒ t2 = 0
grd9: prog2 = return normal start
grd4: 〈theorem〉 sdp add = 1
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
23.01.2018 12:37 Page 161 of 196
![Page 162: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/162.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act2: prog2 := null
act3: sdp add := 0
end
Event control5·normal bolus start 1 call 2 〈ordinary〉 =̂
extends control5·normal bolus start 1 call 2
whengrd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: prog2 = return sd preempt
grd8: 〈theorem〉 sdp add = 1
thenact2: prog2 := call normal start
end
Event control5·normal bolus start 1 call sd preempt 〈ordinary〉 =̂
extends control5 ·normal bolus start 1 call sd preempt
whengrd1: prog2 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: dmodule = TRUE⇒ time 6= d update time
grd7: sdp add = 0
thenact1: prog2 := call sd preempt
act2: par sd preempt t := t sd− timeact3: sdp add := 1
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
extends control5.normal bolus start 2 return
whencontrol5.grd2: sd bolus work = FALSE
grd2: prog2 = return normal start
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act2: prog2 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
extends control5·normal bolus start 2 call
whengrd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact2: prog2 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
23.01.2018 12:37 Page 162 of 196
![Page 163: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/163.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
extends control5·normal bolus finish return
whengrd2: prog2 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act2: prog2 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
extends control5 ·normal bolus finish call
whengrd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact2: prog2 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
extends control5·normal suspend return
whengrd2: prog2 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act3: prog2 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
extends control5·normal bolus suspend call
whengrd2: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: prog2 = null
thenact2: prog2 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
extends control5·normal resume return
whengrd2: prog2 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act2: normal bolus work := FALSE
act3: prog2 := null
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
extends control5 ·normal bolus resume call
whengrd2: normal suspend = TRUE
grd3: prog2 = null
23.01.2018 12:37 Page 163 of 196
![Page 164: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/164.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
thenact2: prog2 := call normal resume
end
Event control5·square or dual bolus start s return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start s return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd6: prog2 = return sd start s
thenact1: sd bolus work := TRUE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5square or dual bolus start s call 〈ordinary〉 =̂
extends control5square or dual bolus start s call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start s
end
Event control5·square or dual bolus start d return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start d return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd8: prog2 = return sd start d
thenact1: sd bolus work := TRUE
act5: dmodule := TRUE
act6: d update time := time+ d t
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act7: prog2 := null
end
Event control5·square or dual bolus start d call 〈ordinary〉 =̂
extends control5·square or dual bolus start d call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start d
end
Event control5.square or dual bolus finish return 〈ordinary〉 =̂
extends control5.square or dual bolus finish return
when
23.01.2018 12:37 Page 164 of 196
![Page 165: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/165.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
grd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
grd6: prog2 = return sd finish
thenact1: sd bolus work := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5.square or dual bolus finish call 〈ordinary〉 =̂
extends control5.square or dual bolus finish call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: prog2 := call sd finish
end
Event control5.square or dual bolus resume from normal return 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal return
anyt2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd6: prog2 = return sd resume preempt
grd7: dmodule = TRUE⇒ t2 = time+ d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ t sd
act5: prog2 := null
act6: d update time := t2
end
Event control5.square or dual bolus resume from normal call 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = TRUE
grd4: normal bolus work = FALSE
grd5: sd suspend = FALSE
thenact1: prog2 := call sd resume preempt
end
Event control5.sd suspend return 〈ordinary〉 =̂
extends control5.sd suspend return
when
23.01.2018 12:37 Page 165 of 196
![Page 166: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/166.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
grd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: prog2 = return sd suspend
thenact1: sd suspend := TRUE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: prog2 := null
act7: d update time := 0
end
Event control5.sd suspend call 〈ordinary〉 =̂
extends control5.sd suspend call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd suspend
end
Event control5.square or dual update rate return 〈ordinary〉 =̂
extends control5.square or dual update rate return
whengrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd6: dmodule = TRUE
grd7: time = d update time
grd8: prog2 = return sd update
thenact1: sd rate := d deliver rate
act2: pump rate := d deliver rate+ basal rate
act3: dmodule := FALSE
act4: prog2 := null
act5: d update time := 0
end
Event control5·square or dual update rate call 〈ordinary〉 =̂
extends control5·square or dual update rate call
whengrd1: prog2 = null
grd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: dmodule = TRUE
grd6: time = d update time
thenact1: prog2 := call sd update
end
Event control5.sd resume return 〈ordinary〉 =̂
extends control5.sd resume return
whengrd1: sd suspend = TRUE
grd3: prog2 = return sd resume
thenact1: sd suspend := FALSE
23.01.2018 12:37 Page 166 of 196
![Page 167: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/167.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := 0
act5: prog2 := null
act6: sd bolus work := FALSE
end
Event control5.sd resume call 〈ordinary〉 =̂
extends control5.sd resume call
whengrd1: prog2 = null
grd2: sd suspend = TRUE
thenact1: prog2 := call sd resume
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
whengrd3: prog2 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd5: prog2 = null
thenact2: par basal start t := timemodc
act4: prog2 := call basal start
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
whengrd3: prog2 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd5: prog2 = null
thenact3: prog2 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
23.01.2018 12:37 Page 167 of 196
![Page 168: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/168.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
whengrd3: prog2 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
grd6: prog2 = null
thenact3: prog2 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
whengrd3: prog2 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
whengrd1: basal suspend = TRUE
grd4: prog2 = null
thenact2: par basal resume t := timemodc
act4: prog2 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd3: prog2 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd5: t basal ∈ dom(rate setting2 B− {−1})
23.01.2018 12:37 Page 168 of 196
![Page 169: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/169.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
grd7: prog2 = null
thenact2: par basal update rate t := t basal
act4: prog2 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
grd2: sdp add 6= 1
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate insulin needed
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd2: prog2 = call normal start
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
extends NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act2: prog2 := return normal start
act3: normal delivering rate c := λt·t ∈ nb now..nb now+normal delivering time|normal bolus rate
act5: nb new now := nb now + normal delivering time
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
extends NormalBolus.normal bolus suspend
any
23.01.2018 12:37 Page 169 of 196
![Page 170: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/170.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
ta
wheregrd2: prog2 = call normal suspend
grd7: ta ∈ nb now .. nb new now
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act2: prog2 := return normal suspend
act6: normal delivering rate c := λt·t ≥ ta|0act5: nb now := ta
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
extends NormalBolus.normal bolus finish
anyta
wheregrd2: prog2 = call normal finish
grd5: ta = nb new now
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act2: prog2 := return normal finish
act4: normal delivering rate c := λt·t ≥ ta|0act5: nb now := ta
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
extends NormalBolus.normal bolus resume
anyta
wheregrd2: prog2 = call normal resume
grd3: ta ≥ nb nowthen
NormalBolus.act1: normal bolus suspend := FALSE
act2: prog2 := return normal resume
act3: normal delivering rate := 0
act4: nb now := ta
act5: normal delivering rate c := λt·t ≥ ta|0end
Event Square Dual bolus2.start 〈ordinary〉 =̂
extends Square Dual bolus2.start
anyt
r
ctime
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
grd2: prog2 = call sd start s
grd4: ctime ≥ sd nowthen
Square Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: sd module := s
23.01.2018 12:37 Page 170 of 196
![Page 171: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/171.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
Square Dual bolus2.act7: d deliver time := t
Square Dual bolus2.act8: d deliver rate := r
act2: prog2 := return sd start s
act9: sd rate c := λx·x ∈ ctime .. ctime+ t|ract10: sd now := ctime
act11: sd new now := ctime+ t
end
Event Square Dual bolus2.start dual 〈ordinary〉 =̂
extends Square Dual bolus2.start dual
anyt
r
td
ctime
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
Square Dual bolus2.grd4: td ∈ N1
grd1: prog2 = call sd start d
grd5: ctime ≥ sd nowthen
Square Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: d deliver time := t+ td
Square Dual bolus2.act7: d deliver rate := normal bolus rate
Square Dual bolus2.act8: d t := td
Square Dual bolus2.act9: sd module := d
act1: prog2 := return sd start d
act11: sd rate c := λx·x ∈ ctime .. ctime+ td|normal bolus rateact12: sd now := ctime
act10: sd new now := ctime+ td
end
Event Square Dual bolus2.update to dual 〈ordinary〉 =̂
extends Square Dual bolus2.update to dual
anyctime
wheregrd1: prog2 = call sd update
grd5: ctime = sd new now
thenSquare Dual bolus2.act2: d deliver rate := s r
Square Dual bolus2.act3: sd flag := s
act1: prog2 := return sd update
act4: sd now := ctime
act5: sd new now := ctime+ s t
act6: sd rate c := λx·x ∈ ctime .. ctime+ s t|s rend
Event Square Dual bolus2.finish 〈ordinary〉 =̂
extends Square Dual bolus2.finish
anyctime
wheregrd1: prog2 = call sd finish
grd3: ctime = sd new now
thenSquare Dual bolus2.act1: state := off
Square Dual bolus2.act4: s r := 0
23.01.2018 12:37 Page 171 of 196
![Page 172: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/172.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd finish
act10: sd rate c := λx·x ≥ ctime|0act11: sd now := ctime
end
Event Square Dual bolus2.suspend 〈ordinary〉 =̂
extends Square Dual bolus2.suspend
anyctime
wheregrd1: prog2 = call sd suspend
grd2: ctime ∈ sd now .. sd new now
thenSquare Dual bolus2.act1: state := suspend
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd suspend
act10: sd now := ctime
act11: sd rate c := λx·x ≥ ctime|0end
Event Square Dual bolus2.resume 〈ordinary〉 =̂
extends Square Dual bolus2.resume
anyctime
wheregrd1: prog2 = call sd resume
grd2: ctime > sd now
thenSquare Dual bolus2.act1: state := off
act1: prog2 := return sd resume
act2: sd now := ctime
act3: sd rate c := λx·x ≥ ctime|0end
Event Square Dual bolus2.preempted 〈ordinary〉 =̂
refines Square Dual bolus2.preempted
anyctime
wheregrd1: prog2 = call sd preempt
grd3: ctime ∈ sd now .. sd new now
grd4: sd module = d ∧ sd flag = d⇒ par sd preempt t ∈ s t+ 1 .. d deliver time
grd5: sd module = d ∧ sd flag = s⇒ par sd preempt t ∈ 0 .. s t
thenSquare Dual bolus2.act1: state := preempt
Square Dual bolus2.act4: d deliver time := par sd preempt t
Square Dual bolus2.act5: d deliver rate := 0
act1: prog2 := return sd preempt
act6: sd now := ctime
act7: sd rate c := λx·x ≥ ctime|0end
23.01.2018 12:37 Page 172 of 196
![Page 173: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/173.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
Event Square Dual bolus2.resume from preempt 〈ordinary〉 =̂
extends Square Dual bolus2.resume from preempt
anyr
ctime
t2
whereSquare Dual bolus2.grd1: state = preempt
Square Dual bolus2.grd2: sd module = s⇒ r = s r
Square Dual bolus2.grd3: sd module = d ∧ sd flag = d⇒ r = normal bolus rate
Square Dual bolus2.grd4: sd module = d ∧ sd flag = s⇒ r = s r
grd1: prog2 = call sd resume preempt
grd5: ctime > sd now
grd6: sd module = s⇒ t2 = ctime+ d deliver time
grd7: sd module = d ∧ sd flag = d⇒ t2 = ctime+ d deliver time− s tgrd8: sd module = d ∧ sd flag = s⇒ t2 = ctime+ d deliver time
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act4: d deliver rate := r
act1: prog2 := return sd resume preempt
act5: sd now := ctime
act6: sd rate c := λx·x ∈ ctime .. t2|ract7: sd new now := t2
end
Event Basal6·basal suspend 〈ordinary〉 =̂
extends Basal6·basal suspend
anyt
whereBasal6.grd3: prog basal = null
grd3: prog2 = call basal suspend
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
grd4: t ∈ fbegin .. fendthen
Basal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act3: prog2 := return basal suspend
act4: rate basal c := λx·x ≥ t|0act5: fbegin := t
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
23.01.2018 12:37 Page 173 of 196
![Page 174: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/174.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
grd1: prog2 = call basal resume
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act3: prog2 := return basal resume
act6: rate basal c := λx·x ∈ par get t .. min value|max valueact7: fbegin := par get t
act8: fend := min value
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whenBasal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd3: prog2 = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
23.01.2018 12:37 Page 174 of 196
![Page 175: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/175.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
grd1: prog2 = call basal update
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get tBasal6.act3: add update := 0
act4: prog basal := null
act7: prog2 := return basal update
act8: fbegin := par get t
act5: fend := min value
act6: rate basal c := λx·x ∈ par get t .. min value|rate setting2(par get t)
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whenBasal6.grd3: add update = 0
Basal6.grd2: prog basal = null
grd3: prog2 = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
grd1: prog2 = call basal start
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act7: prog2 := return basal start
act8: fbegin := par get t
act6: fend := min value
act5: rate basal c := λx·x ∈ par get t .. min value|max valueend
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whenBasal6.grd3: add start = 0
Basal6.grd2: prog basal = null
grd3: prog2 = call basal start
Basal6.grd4: 〈theorem〉 basal mode = stop
then
23.01.2018 12:37 Page 175 of 196
![Page 176: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/176.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
Basal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
Event Basal6.stop 〈ordinary〉 =̂
extends Basal6.stop
anyt
whereBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd3: prog2 = call basal stop
grd4: t ∈ fbegin .. fendthen
Basal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act3: prog2 := return basal stop
act5: fbegin := t
act4: rate basal c := λx·x ≥ t|0end
Event Basal6·get min value 1 〈ordinary〉 =̂
extends Basal6·get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
23.01.2018 12:37 Page 176 of 196
![Page 177: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/177.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1then
Basal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1then
Basal6.act1: temp min := par t
Basal6.act2: get min value add := 3end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get maxthen
Basal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get tend
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6·get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1then
Basal6.act1: par t max := par t max− 1end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1then
Basal6.act1: get max value add := 2end
END
23.01.2018 12:37 Page 177 of 196
![Page 178: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/178.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
REFINES control Basal6 NormalBolus 2 Square Dual bolus2 5 c
SEES c normalbolus anim,c prog2 anim,c basal anim,c sd bolus
VARIABLES
rate setting2
normal bolus work
sd preempted by normal
sd bolus work
sd suspend
normal suspend
basal work
basal suspend
pump rate
basal rate
normal rate
sd rate
time
t basal
t normal
t sd
basal rate in
basal mode
btime
par basal start t
par basal resume t
par basal update rate t
insulin needed
normal add
normal delivering time
normal delivering rate
normal bolus suspend
dmodule
d update time
state
s r
s t
d deliver time
d deliver rate
d t
sd module
sd flag
prog2
par sd preempt t
sdp add
min value
get min value add
par t
temp min
get min start t
max value
get max start t
get max value add
23.01.2018 12:37 Page 178 of 196
![Page 179: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/179.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
par t max
prog basal
par get t
add resume
add update
add start
fbegin
fend
rate basal c
normal delivering rate c
nb now
nb new now
sd now
sd new now
sd rate c
EVENTS
Initialisation 〈extended〉begin
act1: normal bolus work := FALSE
act2: sd bolus work := FALSE
act3: sd preempted by normal := FALSE
act7: sd suspend := FALSE
act8: normal suspend := FALSE
act9: basal work := FALSE
act10: basal suspend := FALSE
act11: pump rate := 0
act12: basal rate := 0
act13: normal rate := 0
act14: sd rate := 0
act15: time := 0
act16: t basal := 0
act17: t normal := 0
act18: t sd := 0
act19: dmodule := FALSE
act20: d update time := 0
Basal1.act4: btime := c
Basal1.act2: basal rate in := 0
Basal1.act3: basal mode := stop
Basal6.act15: prog basal := null
Basal6.act16: par get t := 0
Basal6.act17: add resume := 0
Basal6.act18: add update := 0
Basal6.act19: add start := 0
Basal6.act5: rate setting2 := (1 .. c− 1× {−1}) ∪ {0 7→ 0}Basal6.act6: min value := 0
Basal6.act7: max value := 0
Basal6.act11: get min value add := 0
Basal6.act8: par t := 0
Basal6.act9: temp min := 0
Basal6.act10: get min start t := 0
Basal6.act12: get max start t := 0
Basal6.act13: get max value add := 0
Basal6.act14: par t max := 0
act22: par basal start t := 0
act23: par basal resume t := 0
act24: par basal update rate t := 0
NormalBolus.act1: insulin needed := 0
23.01.2018 12:37 Page 179 of 196
![Page 180: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/180.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal delivering rate := 0
NormalBolus.act4: normal add := 0
NormalBolus.act5: normal bolus suspend := FALSE
Square Dual bolus2.act1: state := off
Square Dual bolus2.act2: s r := 0
Square Dual bolus2.act3: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd module := s
Square Dual bolus2.act10: sd flag := d
act32: prog2 := null
act33: par sd preempt t := 0
act34: sdp add := 0
act35: fbegin := 0
act36: fend := 0
act37: rate basal c := {0 7→ 0}act38: normal delivering rate c := {0 7→ 0}act39: nb now := 0
act40: nb new now := 0
act41: sd now := 0
act42: sd new now := 0
act43: sd rate c := {0 7→ 0}end
Event control5·normal bolus start 1 return 〈ordinary〉 =̂
extends control5·normal bolus start 1 return
anyt2
wheregrd6: normal bolus work = FALSE
grd7: dmodule = TRUE⇒ t2 = d update time− time ∧ time 6= d update time
control5.grd2: sd bolus work = TRUE
control5.grd3: sd preempted by normal = FALSE
control5.grd4: sd suspend = FALSE
grd8: dmodule = FALSE⇒ t2 = 0
grd9: prog2 = return normal start
grd4: 〈theorem〉 sdp add = 1
thencontrol5.act6: t normal := time+ normal delivering time
control5.act7: t sd := t sd− timecontrol5.act1: normal bolus work := TRUE
control5.act2: sd preempted by normal := TRUE
control5.act3: normal rate := normal delivering rate
control5.act4: sd rate := 0
control5.act5: pump rate := normal delivering rate+ basal rate
act8: d update time := t2
act2: prog2 := null
act3: sdp add := 0
end
Event control5·normal bolus start 1 call 2 〈ordinary〉 =̂
extends control5·normal bolus start 1 call 2
whengrd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: prog2 = return sd preempt
grd8: 〈theorem〉 sdp add = 1
23.01.2018 12:37 Page 180 of 196
![Page 181: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/181.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
thenact2: prog2 := call normal start
end
Event control5·normal bolus start 1 call sd preempt 〈ordinary〉 =̂
extends control5 ·normal bolus start 1 call sd preempt
whengrd1: prog2 = null
grd2: normal bolus work = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: sd suspend = FALSE
grd6: dmodule = TRUE⇒ time 6= d update time
grd7: sdp add = 0
thenact1: prog2 := call sd preempt
act2: par sd preempt t := t sd− timeact3: sdp add := 1
end
Event control5.normal bolus start 2 return 〈ordinary〉 =̂
extends control5.normal bolus start 2 return
whencontrol5.grd2: sd bolus work = FALSE
grd2: prog2 = return normal start
thencontrol5·act4: t normal := time+ normal delivering time
control5.act1: normal bolus work := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := normal delivering rate+ basal rate
act2: prog2 := null
end
Event control5·normal bolus start 2 call 〈ordinary〉 =̂
extends control5·normal bolus start 2 call
whengrd2: normal bolus work = FALSE
grd3: sd bolus work = FALSE
grd4: normal suspend = FALSE
grd5: prog2 = null
thenact2: prog2 := call normal start
end
Event control5·normal bolus finish return 〈ordinary〉 =̂
extends control5·normal bolus finish return
whengrd2: prog2 = return normal finish
thencontrol5.act4: t normal := 0
control5.act1: normal bolus work := FALSE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act2: prog2 := null
end
Event control5·normal bolus finish call 〈ordinary〉 =̂
extends control5 ·normal bolus finish call
whengrd2: time = t normal
grd3: normal bolus work = TRUE
grd4: normal suspend = FALSE
23.01.2018 12:37 Page 181 of 196
![Page 182: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/182.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd5: prog2 = null
thenact2: prog2 := call normal finish
end
Event control5·normal suspend return 〈ordinary〉 =̂
extends control5·normal suspend return
whengrd2: prog2 = return normal suspend
thencontrol5.act4: t normal := t normal − timecontrol5.act1: normal suspend := TRUE
control5.act2: normal rate := normal delivering rate
control5.act3: pump rate := basal rate
act3: prog2 := null
end
Event control5·normal bolus suspend call 〈ordinary〉 =̂
extends control5·normal bolus suspend call
whengrd2: normal bolus work = TRUE
grd3: normal suspend = FALSE
grd4: prog2 = null
thenact2: prog2 := call normal suspend
end
Event control5·normal resume return 〈ordinary〉 =̂
extends control5·normal resume return
whengrd2: prog2 = return normal resume
thencontrol5.act4: t normal := 0
control5.act1: normal suspend := FALSE
control5.act2: normal rate := 0
control5.act3: pump rate := basal rate
act2: normal bolus work := FALSE
act3: prog2 := null
end
Event control5·normal bolus resume call 〈ordinary〉 =̂
extends control5 ·normal bolus resume call
whengrd2: normal suspend = TRUE
grd3: prog2 = null
thenact2: prog2 := call normal resume
end
Event control5·square or dual bolus start s return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start s return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd6: prog2 = return sd start s
thenact1: sd bolus work := TRUE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act5: dmodule := FALSE
23.01.2018 12:37 Page 182 of 196
![Page 183: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/183.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
act6: prog2 := null
end
Event control5square or dual bolus start s call 〈ordinary〉 =̂
extends control5square or dual bolus start s call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start s
end
Event control5·square or dual bolus start d return 〈ordinary〉 =̂
extends control5 ·square or dual bolus start d return
whengrd1: sd bolus work = FALSE
grd2: normal bolus work = FALSE
grd3: sd suspend = FALSE
grd8: prog2 = return sd start d
thenact1: sd bolus work := TRUE
act5: dmodule := TRUE
act6: d update time := time+ d t
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ d deliver time
act7: prog2 := null
end
Event control5·square or dual bolus start d call 〈ordinary〉 =̂
extends control5·square or dual bolus start d call
whengrd1: prog2 = null
grd2: sd bolus work = FALSE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd start d
end
Event control5.square or dual bolus finish return 〈ordinary〉 =̂
extends control5.square or dual bolus finish return
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
grd6: prog2 = return sd finish
thenact1: sd bolus work := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := d deliver time
act5: dmodule := FALSE
act6: prog2 := null
end
Event control5.square or dual bolus finish call 〈ordinary〉 =̂
extends control5.square or dual bolus finish call
when
23.01.2018 12:37 Page 183 of 196
![Page 184: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/184.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: time = t sd
thenact1: prog2 := call sd finish
end
Event control5.square or dual bolus resume from normal return 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal return
anyt2
wheregrd1: sd bolus work = TRUE
grd2: sd preempted by normal = TRUE
grd3: normal bolus work = FALSE
grd4: sd suspend = FALSE
grd6: prog2 = return sd resume preempt
grd7: dmodule = TRUE⇒ t2 = time+ d update time
grd8: dmodule = FALSE⇒ t2 = 0
thenact1: sd preempted by normal := FALSE
act2: sd rate := d deliver rate
act3: pump rate := d deliver rate+ basal rate
act4: t sd := time+ t sd
act5: prog2 := null
act6: d update time := t2
end
Event control5.square or dual bolus resume from normal call 〈ordinary〉 =̂
extends control5.square or dual bolus resume from normal call
whengrd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = TRUE
grd4: normal bolus work = FALSE
grd5: sd suspend = FALSE
thenact1: prog2 := call sd resume preempt
end
Event control5.sd suspend return 〈ordinary〉 =̂
extends control5.sd suspend return
whengrd1: sd bolus work = TRUE
grd2: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
grd5: prog2 = return sd suspend
thenact1: sd suspend := TRUE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := t sd− timeact5: dmodule := FALSE
act6: prog2 := null
act7: d update time := 0
end
Event control5.sd suspend call 〈ordinary〉 =̂
extends control5.sd suspend call
when
23.01.2018 12:37 Page 184 of 196
![Page 185: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/185.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd1: prog2 = null
grd2: sd bolus work = TRUE
grd3: sd preempted by normal = FALSE
grd4: sd suspend = FALSE
thenact1: prog2 := call sd suspend
end
Event control5.square or dual update rate return 〈ordinary〉 =̂
extends control5.square or dual update rate return
whengrd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd6: dmodule = TRUE
grd7: time = d update time
grd8: prog2 = return sd update
thenact1: sd rate := d deliver rate
act2: pump rate := d deliver rate+ basal rate
act3: dmodule := FALSE
act4: prog2 := null
act5: d update time := 0
end
Event control5·square or dual update rate call 〈ordinary〉 =̂
extends control5·square or dual update rate call
whengrd1: prog2 = null
grd2: sd suspend = FALSE
grd3: sd bolus work = TRUE
grd4: sd preempted by normal = FALSE
grd5: dmodule = TRUE
grd6: time = d update time
thenact1: prog2 := call sd update
end
Event control5.sd resume return 〈ordinary〉 =̂
extends control5.sd resume return
whengrd1: sd suspend = TRUE
grd3: prog2 = return sd resume
thenact1: sd suspend := FALSE
act2: sd rate := d deliver rate
act3: pump rate := basal rate
act4: t sd := 0
act5: prog2 := null
act6: sd bolus work := FALSE
end
Event control5.sd resume call 〈ordinary〉 =̂
extends control5.sd resume call
whengrd1: prog2 = null
grd2: sd suspend = TRUE
thenact1: prog2 := call sd resume
end
Event control5·basal start return 〈ordinary〉 =̂
extends control5·basal start return
23.01.2018 12:37 Page 185 of 196
![Page 186: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/186.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
whengrd3: prog2 = return basal start
thencontrol5.act4: t basal := time+ btime
control5.act1: basal work := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal start call 〈ordinary〉 =̂
extends control5·basal start call
whengrd1: basal work = FALSE
grd2: basal suspend = FALSE
grd5: prog2 = null
thenact2: par basal start t := timemodc
act4: prog2 := call basal start
end
Event control5·basal stop return 〈ordinary〉 =̂
extends control5·basal stop return
whengrd3: prog2 = return basal stop
thencontrol5.act4: t basal := 0
control5.act1: basal work := FALSE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal stop call 〈ordinary〉 =̂
extends control5·basal stop call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd5: prog2 = null
thenact3: prog2 := call basal stop
end
Event control5·basal suspend return 〈ordinary〉 =̂
extends control5·basal suspend return
whengrd3: prog2 = return basal suspend
thencontrol5.act4: t basal := 0
control5.act1: basal suspend := TRUE
control5.act2: basal rate := basal rate in
control5.act3: pump rate := normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal suspend call 〈ordinary〉 =̂
extends control5·basal suspend call
whengrd1: basal work = TRUE
grd2: basal suspend = FALSE
grd4: basal rate 6= 0
23.01.2018 12:37 Page 186 of 196
![Page 187: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/187.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd6: prog2 = null
thenact3: prog2 := call basal suspend
end
Event control5·basal resume return 〈ordinary〉 =̂
extends control5·basal resume return
whengrd3: prog2 = return basal resume
thencontrol5.act1: basal suspend := FALSE
control5.act4: t basal := btime+ time
control5.act2: basal rate := basal rate in
control5.act3: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal resume call 〈ordinary〉 =̂
extends control5·basal resume call
whengrd1: basal suspend = TRUE
grd4: prog2 = null
thenact2: par basal resume t := timemodc
act4: prog2 := call basal resume
end
Event control5·basal update rate return 〈ordinary〉 =̂
extends control5 ·basal update rate return
whengrd3: prog2 = return basal update
thencontrol5.act3: t basal := time+ btime
control5.act1: basal rate := basal rate in
control5.act2: pump rate := basal rate in+ normal rate+ sd rate
act3: prog2 := null
end
Event control5·basal update rate call 〈ordinary〉 =̂
extends control5·basal update rate call
whengrd1: t basal = time
grd2: basal suspend = FALSE
grd3: basal work = TRUE
grd5: t basal ∈ dom(rate setting2 B− {−1})grd7: prog2 = null
thenact2: par basal update rate t := t basal
act4: prog2 := call basal update
end
Event control5.timer 〈ordinary〉 =̂
extends control5.timer
whengrd1:¬(
((normal bolus work = TRUE) ∧ (normal suspend = FALSE) ∧ (time = t normal)) ∨((sd bolus work = TRUE)∧ (sd preempted by normal = FALSE)∧ (sd suspend = FALSE)∧(time = t sd)) ∨(((sd suspend = FALSE)∧(sd bolus work = TRUE)∧(sd preempted by normal = FALSE)∧(dmodule = TRUE) ∧ (time = d update time))) ∨(((basal suspend = FALSE) ∧ (basal work = TRUE) ∧ (t basal = time)))
)
23.01.2018 12:37 Page 187 of 196
![Page 188: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/188.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd2: sdp add 6= 1
thenact1: time := time+ 1
end
Event NormalBolus.normal bolus start calculate insulin needed 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate insulin needed
anyinsulin
whereNormalBolus.grd1: insulin > 0
NormalBolus.grd3: normal add = 0
grd2: prog2 = call normal start
thenNormalBolus.act1: insulin needed := insulin
NormalBolus.act2: normal add := 1
end
Event NormalBolus.normal bolus start calculate lasting time 〈ordinary〉 =̂
extends NormalBolus.normal bolus start calculate lasting time
whenNormalBolus.grd1: normal add = 1
thenNormalBolus.act1: normal delivering time := insulin needed/normal bolus rate
NormalBolus.act2: insulin needed := 0
NormalBolus.act3: normal add := 2
end
Event NormalBolus.normal bolus delivery 〈ordinary〉 =̂
refines NormalBolus.normal bolus delivery
whenNormalBolus.grd2: normal add = 2
thenNormalBolus.act1: normal delivering rate := normal bolus rate
NormalBolus.act2: normal add := 3
act2: prog2 := return normal start
act3: normal delivering rate c := λt·t ∈ nb now..nb now+normal delivering time|normal bolus rate
act5: nb new now := nb now + normal delivering time
end
Event NormalBolus.normal bolus suspend 〈ordinary〉 =̂
refines NormalBolus.normal bolus suspend
whengrd2: prog2 = call normal suspend
grd7: time ∈ nb now .. nb new now
withta: ta = time
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
NormalBolus.act4: normal bolus suspend := TRUE
act2: prog2 := return normal suspend
act6: normal delivering rate c := λt·t ≥ time|0act5: nb now := time
end
Event NormalBolus.normal bolus finish 〈ordinary〉 =̂
refines NormalBolus.normal bolus finish
whengrd2: prog2 = call normal finish
23.01.2018 12:37 Page 188 of 196
![Page 189: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/189.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd5: time = nb new now
grd6: t normal = time
withta: ta = time
thenNormalBolus.act1: normal delivering rate := 0
NormalBolus.act2: normal delivering time := 0
NormalBolus.act3: normal add := 0
act2: prog2 := return normal finish
act4: normal delivering rate c := λt·t ≥ time|0act5: nb now := time
end
Event NormalBolus.normal bolus resume 〈ordinary〉 =̂
refines NormalBolus.normal bolus resume
whengrd2: prog2 = call normal resume
grd3: time ≥ nb nowwith
ta: ta = time
thenNormalBolus.act1: normal bolus suspend := FALSE
act2: prog2 := return normal resume
act3: normal delivering rate := 0
act4: nb now := time
act5: normal delivering rate c := λt·t ≥ time|0end
Event Square Dual bolus2.start 〈ordinary〉 =̂
refines Square Dual bolus2.start
anyt
r
whereSquare Dual bolus2.grd2: t ∈ N1
Square Dual bolus2.grd3: r ∈ N1
grd2: prog2 = call sd start s
grd4: time ≥ sd nowwith
ctime: ctime = time
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: sd module := s
Square Dual bolus2.act7: d deliver time := t
Square Dual bolus2.act8: d deliver rate := r
act2: prog2 := return sd start s
act9: sd rate c := λx·x ∈ time .. time+ t|ract10: sd now := time
act11: sd new now := time+ t
end
Event Square Dual bolus2.start dual 〈ordinary〉 =̂
refines Square Dual bolus2.start dual
anyt
r
td
whereSquare Dual bolus2.grd2: t ∈ N1
23.01.2018 12:37 Page 189 of 196
![Page 190: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/190.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
Square Dual bolus2.grd3: r ∈ N1
Square Dual bolus2.grd4: td ∈ N1
grd1: prog2 = call sd start d
grd5: time ≥ sd nowwith
ctime: ctime = time
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act2: s r := r
Square Dual bolus2.act3: s t := t
Square Dual bolus2.act6: d deliver time := t+ td
Square Dual bolus2.act7: d deliver rate := normal bolus rate
Square Dual bolus2.act8: d t := td
Square Dual bolus2.act9: sd module := d
act1: prog2 := return sd start d
act11: sd rate c := λx·x ∈ time .. time+ td|normal bolus rateact12: sd now := time
act10: sd new now := time+ td
end
Event Square Dual bolus2.update to dual 〈ordinary〉 =̂
refines Square Dual bolus2.update to dual
whengrd1: prog2 = call sd update
grd5: time = sd new now
withctime: ctime = time
thenSquare Dual bolus2.act2: d deliver rate := s r
Square Dual bolus2.act3: sd flag := s
act1: prog2 := return sd update
act4: sd now := time
act5: sd new now := time+ s t
act6: sd rate c := λx·x ∈ time .. time+ s t|s rend
Event Square Dual bolus2.finish 〈ordinary〉 =̂
refines Square Dual bolus2.finish
whengrd1: prog2 = call sd finish
grd3: time = sd new now
withctime: ctime = time
thenSquare Dual bolus2.act1: state := off
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd finish
act10: sd rate c := λx·x ≥ time|0act11: sd now := time
end
Event Square Dual bolus2.suspend 〈ordinary〉 =̂
refines Square Dual bolus2.suspend
whengrd1: prog2 = call sd suspend
grd2: time ∈ sd now .. sd new now
23.01.2018 12:37 Page 190 of 196
![Page 191: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/191.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
withctime: ctime = time
thenSquare Dual bolus2.act1: state := suspend
Square Dual bolus2.act4: s r := 0
Square Dual bolus2.act5: s t := 0
Square Dual bolus2.act6: d deliver time := 0
Square Dual bolus2.act7: d deliver rate := 0
Square Dual bolus2.act8: d t := 0
Square Dual bolus2.act9: sd flag := d
act1: prog2 := return sd suspend
act10: sd now := time
act11: sd rate c := λx·x ≥ time|0end
Event Square Dual bolus2.resume 〈ordinary〉 =̂
refines Square Dual bolus2.resume
whengrd1: prog2 = call sd resume
grd2: time > sd now
withctime: ctime = time
thenSquare Dual bolus2.act1: state := off
act1: prog2 := return sd resume
act2: sd now := time
act3: sd rate c := λx·x ≥ time|0end
Event Square Dual bolus2.preempted 〈ordinary〉 =̂
refines Square Dual bolus2.preempted
whengrd1: prog2 = call sd preempt
grd3: time ∈ sd now .. sd new now
grd4: sd module = d ∧ sd flag = d⇒ par sd preempt t ∈ s t+ 1 .. d deliver time
grd5: sd module = d ∧ sd flag = s⇒ par sd preempt t ∈ 0 .. s t
withctime: ctime = time
thenSquare Dual bolus2.act1: state := preempt
Square Dual bolus2.act4: d deliver time := par sd preempt t
Square Dual bolus2.act5: d deliver rate := 0
act1: prog2 := return sd preempt
act6: sd now := time
act7: sd rate c := λx·x ≥ time|0end
Event Square Dual bolus2.resume from preempt 〈ordinary〉 =̂
refines Square Dual bolus2.resume from preempt
anyr
t2
whereSquare Dual bolus2.grd1: state = preempt
Square Dual bolus2.grd2: sd module = s⇒ r = s r
Square Dual bolus2.grd3: sd module = d ∧ sd flag = d⇒ r = normal bolus rate
Square Dual bolus2.grd4: sd module = d ∧ sd flag = s⇒ r = s r
grd1: prog2 = call sd resume preempt
grd5: time > sd now
grd6: sd module = s⇒ t2 = time+ d deliver time
grd7: sd module = d ∧ sd flag = d⇒ t2 = time+ d deliver time− s t
23.01.2018 12:37 Page 191 of 196
![Page 192: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/192.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
grd8: sd module = d ∧ sd flag = s⇒ t2 = time+ d deliver time
withctime: ctime = time
thenSquare Dual bolus2.act1: state := deliver
Square Dual bolus2.act4: d deliver rate := r
act1: prog2 := return sd resume preempt
act5: sd now := time
act6: sd rate c := λx·x ∈ time .. t2|ract7: sd new now := t2
end
Event Basal6·basal suspend 〈ordinary〉 =̂
refines Basal6·basal suspend
whenBasal6.grd3: prog basal = null
grd3: prog2 = call basal suspend
Basal6.grd1: 〈theorem〉 basal rate in 6= 0
Basal6.grd2: 〈theorem〉 basal mode = delivering
grd4: time ∈ fbegin .. fendwith
t: t = time
thenBasal6.act1: basal rate in := 0
Basal6.act2: basal mode := suspended
act3: prog2 := return basal suspend
act4: rate basal c := λx·x ≥ time|0act5: fbegin := time
end
Event Basal6·change setting 〈ordinary〉 =̂
extends Basal6·change setting
anyt
r
whereBasal6.grd5: prog basal = null
Basal6.grd6: t ∈ 0 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
Basal6.grd2: r ∈ 0 .. basal max
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.delete setting 〈ordinary〉 =̂
extends Basal6.delete setting
anyt
whereBasal6.grd5: prog basal = null
Basal6.grd2: basal mode 6= suspended
Basal6.grd6: t ∈ 1 .. c− 1
Basal6.grd7: rate setting2(t) 6= − 1
grd1: t 6= par basal update rate t
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ − 1}
end
Event Basal6.add setting 〈ordinary〉 =̂
extends Basal6.add setting
anyt
23.01.2018 12:37 Page 192 of 196
![Page 193: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/193.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
r
whereBasal6.grd9: prog basal = null
Basal6.grd3: r ∈ 0 .. basal max
Basal6.grd4: basal mode 6= suspended
Basal6.grd5: t ∈ 0 .. c− 1
Basal6.grd6: rate setting2(t) = −1
thenBasal6.act2: rate setting2 := rate setting2 C− {t 7→ r}
end
Event Basal6.basal resume return 〈ordinary〉 =̂
extends Basal6.basal resume return
whenBasal6.grd8: prog basal = return get max
Basal6.grd9: add resume = 2
grd1: prog2 = call basal resume
thenBasal6.act1: basal rate in := max value
Basal6.act2: basal mode := delivering
Basal6.act3: btime := min value− par get tBasal6.act4: prog basal := null
Basal6.act5: add resume := 0
act3: prog2 := return basal resume
act6: rate basal c := λx·x ∈ par get t .. min value|max valueact7: fbegin := par get t
act8: fend := min value
end
Event Basal6.basal resume call 〈ordinary〉 =̂
extends Basal6.basal resume call
whenBasal6.grd6: add resume = 0
Basal6.grd5: prog basal = null
grd3: prog2 = call basal resume
Basal6.grd1: 〈theorem〉 basal rate in = 0
Basal6.grd3: 〈theorem〉 basal mode = suspended
thenBasal6.act1: par get t := par basal resume t
Basal6.act2: prog basal := call get min
Basal6.act3: add resume := 1
end
Event Basal6.basal resume call 2 〈ordinary〉 =̂
extends Basal6.basal resume call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add resume = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add resume := 2
end
Event Basal6·rate update return 〈ordinary〉 =̂
extends Basal6·rate update return
whenBasal6.grd12: add update = 1
Basal6.grd4: prog basal = return get min
grd1: prog2 = call basal update
thenBasal6.act1: basal rate in := rate setting2(par get t)
Basal6.act2: btime := min value− par get t
23.01.2018 12:37 Page 193 of 196
![Page 194: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/194.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
Basal6.act3: add update := 0
act4: prog basal := null
act7: prog2 := return basal update
act8: fbegin := par get t
act5: fend := min value
act6: rate basal c := λx·x ∈ par get t .. min value|rate setting2(par get t)
end
Event Basal6.rate update call 〈ordinary〉 =̂
extends Basal6.rate update call
whenBasal6.grd3: add update = 0
Basal6.grd2: prog basal = null
grd3: prog2 = call basal update
Basal6.grd5: 〈theorem〉 basal mode = delivering
Basal6.grd7: 〈theorem〉 rate setting2(par basal update rate t) 6= − 1
thenBasal6.act1: par get t := par basal update rate t
Basal6.act2: prog basal := call get min
Basal6.act3: add update := 1
end
Event Basal6.start return 〈ordinary〉 =̂
extends Basal6.start return
whenBasal6.grd8: add start = 2
Basal6.grd9: prog basal = return get max
grd1: prog2 = call basal start
thenBasal6.act1: basal mode := delivering
Basal6.act2: basal rate in := max value
Basal6.act3: btime := min value− par get tBasal6.act4: add start := 0
act4: prog basal := null
act7: prog2 := return basal start
act8: fbegin := par get t
act6: fend := min value
act5: rate basal c := λx·x ∈ par get t .. min value|max valueend
Event Basal6.start call 〈ordinary〉 =̂
extends Basal6.start call
whenBasal6.grd3: add start = 0
Basal6.grd2: prog basal = null
grd3: prog2 = call basal start
Basal6.grd4: 〈theorem〉 basal mode = stop
thenBasal6.act1: par get t := par basal start t
Basal6.act2: prog basal := call get min
Basal6.act3: add start := 1
end
Event Basal6.start call 2 〈ordinary〉 =̂
extends Basal6.start call 2
whenBasal6.grd1: prog basal = return get min
Basal6.grd2: add start = 1
thenBasal6.act1: prog basal := call get max
Basal6.act2: add start := 2
end
23.01.2018 12:37 Page 194 of 196
![Page 195: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/195.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
Event Basal6.stop 〈ordinary〉 =̂
refines Basal6.stop
whenBasal6.grd2: prog basal = null
Basal6.grd1: basal mode = delivering
grd3: prog2 = call basal stop
grd4: time ∈ fbegin .. fendwith
t: t = time
thenBasal6.act1: basal mode := stop
Basal6.act2: basal rate in := 0
act3: prog2 := return basal stop
act5: fbegin := time
act4: rate basal c := λx·x ≥ time|0end
Event Basal6·get min value 1 〈ordinary〉 =̂
extends Basal6·get min value 1
whenBasal6.grd4: get min value add = 2
Basal6.grd5: par t = c
thenBasal6.act1: min value := c
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value 2 〈ordinary〉 =̂
extends Basal6.get min value 2
whenBasal6.grd5: get min value add = 3
thenBasal6.act1: min value := temp min
Basal6.act2: get min value add := 0
Basal6.act3: prog basal := return get min
end
Event Basal6.get min value start 〈ordinary〉 =̂
extends Basal6.get min value start
whenBasal6.grd2: get min value add = 0
Basal6.grd3: prog basal = call get min
thenBasal6.act1: par t := par get t+ 1
Basal6.act2: get min value add := 1
Basal6.act3: get min start t := par get t
end
Event Basal6.find min value 〈ordinary〉 =̂
extends Basal6.find min value
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) = −1
thenBasal6.act1: par t := par t+ 1
Basal6.act2: get min value add := 2
end
Event Basal6.find min value 2 〈ordinary〉 =̂
extends Basal6.find min value 2
23.01.2018 12:37 Page 195 of 196
![Page 196: Contents...23.01.2018 12:37 Page 1 of 196 An Event-B Speci cation of Insulin pump whole 7 CONTEXT c basal CONTEXT c basal SETS BASALMODE CONSTANTS basal max c suspended delivering](https://reader033.vdocument.in/reader033/viewer/2022050419/5f8eb9762ea2be70651f755f/html5/thumbnails/196.jpg)
An Event-B Specification of Insulin pump whole 7MACHINE control Basal6 NormalBolus 2 Square Dual bolus2 5 c 2
whenBasal6.grd1: par t < c
Basal6.grd2: get min value add = 1 ∨ get min value add = 2
Basal6.grd3: rate setting2(par t) 6= − 1
thenBasal6.act1: temp min := par t
Basal6.act2: get min value add := 3
end
Event Basal6.get max value 〈ordinary〉 =̂
extends Basal6.get max value
whenBasal6.grd2: get max value add = 2
thenBasal6.act3: prog basal := return get max
Basal6.act1: max value := rate setting2(par t max)
Basal6.act2: get max value add := 0
end
Event Basal6.get max value start 〈ordinary〉 =̂
extends Basal6.get max value start
whenBasal6.grd2: get max value add = 0
Basal6.grd3: prog basal = call get max
thenBasal6.act1: get max start t := par get t
Basal6.act2: get max value add := 1
Basal6.act3: par t max := par get t
end
Event Basal6·get max value 1 〈ordinary〉 =̂
extends Basal6·get max value 1
whenBasal6.grd1: get max value add = 1
Basal6.grd3: par t max ≥ 0
Basal6.grd2: rate setting2(par t max) = −1
thenBasal6.act1: par t max := par t max− 1
end
Event Basal6.get max value 2 〈ordinary〉 =̂
extends Basal6.get max value 2
whenBasal6.grd1: get max value add = 1
Basal6.grd2: par t max ≥ 0
Basal6.grd3: rate setting2(par t max) 6= − 1
thenBasal6.act1: get max value add := 2
end
END
23.01.2018 12:37 Page 196 of 196