+ All Categories
Home > Documents > Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control An Example in Z Formalisation

Date post: 02-Feb-2022
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
46
Formal Specification of Software Steam Boiler Control An Example in Z Formalisation Bernhard Beckert U NIVERSITÄT KOBLENZ -L ANDAU B. Beckert: Formal Specification of Software – p.1
Transcript
Page 1: Steam Boiler Control An Example in Z Formalisation

Formal Specification of Software

Steam Boiler ControlAn Example in Z Formalisation

Bernhard Beckert

UNIVERSITÄT KOBLENZ-LANDAU

B. Beckert: Formal Specification of Software – p.1

Page 2: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control: Scenario

4

w

w

d

w

/ k

/ k

k k

l/ δ

δ

p1 / . . . / p4v

a

z

p1 p4/ ... /

d

w

min

max

p

d System Components

steam boiler

water level measuring device

four pumps

four pump controlers

steam quantity measuring device

valve for emptying the boiler

B. Beckert: Formal Specification of Software – p.2

Page 3: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control: Scenario

4

w

w

d

w

/ k

/ k

k k

l/ δ

δ

p1 / . . . / p4v

a

z

p1 p4/ ... /

d

w

min

max

p

d

Physical constants

wmin minimal water level

wmax maximal water level

l water amount per pump

dmax maximal quantity of steam

exiting the boiler

δp error in the value of l

δd error in steam

measurement

B. Beckert: Formal Specification of Software – p.3

Page 4: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control: Scenario

4

w

w

d

w

/ k

/ k

k k

l/ δ

δ

p1 / . . . / p4v

a

z

p1 p4/ ... /

d

w

min

max

p

d

Measured values

w water level

d amount of steam exiting

the boiler

kp,i pump i works/broken

kw water level measuring device

works/broken

kd steam amount measuring

device works/broken

B. Beckert: Formal Specification of Software – p.4

Page 5: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control: Scenario

4

w

w

d

w

/ k

/ k

k k

l/ δ

δ

p1 / . . . / p4v

a

z

p1 p4/ ... /

d

w

min

max

p

d

Control values

pi pump i on/off

v valve open/closed

a boiler on/off

z state init/norm/broken/stop

B. Beckert: Formal Specification of Software – p.5

Page 6: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control

Types

State ::= init | norm | broken | stop

OnOff ::= on | off

OpenClosed ::= open | closed

B. Beckert: Formal Specification of Software – p.6

Page 7: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control

Physical constants

wmin : N

wmax : N

l : N

dmax : N

δp : N

δd : N

wmin < wmax

Measured values

Inputw? : N

d? : N

B. Beckert: Formal Specification of Software – p.7

Page 8: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control

Physical constants

wmin : N

wmax : N

l : N

dmax : N

δp : N

δd : N

wmin < wmax

Measured values

Inputw? : N

d? : N

B. Beckert: Formal Specification of Software – p.7

Page 9: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Control

Control values

Pumpsp1, p2, p3, p4 : OnOff

SteamBoiler0Pumpsv : OpenCloseda : OnOffz : State

B. Beckert: Formal Specification of Software – p.8

Page 10: Steam Boiler Control An Example in Z Formalisation

Auxiliary Schemata

Auxiliary Schemata

PumpsOffPumps′

p′1 = off ∧ p′2 = off ∧ p′3 = off ∧ p′4 = off

PumpsOnPumps′

p′1 = on ∧ p′2 = on ∧ p′3 = on ∧ p′4 = on

B. Beckert: Formal Specification of Software – p.9

Page 11: Steam Boiler Control An Example in Z Formalisation

Steam Boiler Initial State

SteamBoilerInit0SteamBoiler0′

a′ = offz′ = init

B. Beckert: Formal Specification of Software – p.10

Page 12: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitNormal0∆SteamBoiler0Input

z = initd? = 0w? ≥ wmin + dmaxw? ≤ wmax

PumpsOffz′ = normv′ = closeda′ = on

B. Beckert: Formal Specification of Software – p.11

Page 13: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitStop0∆SteamBoiler0Input

z = initd? > 0z′ = stop

B. Beckert: Formal Specification of Software – p.12

Page 14: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitFill0∆SteamBoiler0Input

z = initd? = 0w? < wmin + dmax

PumpsOnz′ = zv′ = closeda′ = off

B. Beckert: Formal Specification of Software – p.13

Page 15: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitEmpty0∆SteamBoiler0Input

z = initd? = 0w? > wmax

PumpsOffz′ = zv′ = opena′ = off

B. Beckert: Formal Specification of Software – p.14

Page 16: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

ControlInit0 =̂ SInitNormal0∨ SInitStop0∨ SInitFill0∨ SInitEmpty0

B. Beckert: Formal Specification of Software – p.15

Page 17: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalFill0∆SteamBoiler0Input

z = normw? ≥ wminw? ≤ wopt − 3lPumpsOnv′ = closed ∧ a′ = on ∧ z′ = z

Note:Simplified version where all four pumps are switched simultaneously

B. Beckert: Formal Specification of Software – p.16

Page 18: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalContinue0ΞSteamBoiler0Input

z = normw? > wopt − 3lw? ≤ wopt

B. Beckert: Formal Specification of Software – p.17

Page 19: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalNotFill0∆SteamBoiler0Input

z = normw? > woptw? ≤ wmax

PumpsOffv′ = closed ∧ a′ = on ∧ z′ = z

B. Beckert: Formal Specification of Software – p.18

Page 20: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalStop0∆SteamBoiler0Input

z = normw? < wmin ∨ w? > wmax

a′ = off ∧ z′ = stop

B. Beckert: Formal Specification of Software – p.19

Page 21: Steam Boiler Control An Example in Z Formalisation

Complete Operation

ControlNormal0 =̂ SNormalFill0∨ SNormalContinue0

∨ SNormalNotFill0∨ SNormalStop0

Control0 =̂ ControlInit0∨ ControlNormal0

B. Beckert: Formal Specification of Software – p.20

Page 22: Steam Boiler Control An Example in Z Formalisation

Extended Solution

Additional Type

WorksBroken ::= works | broken

Additional measured values

ControlInputkw? : WorksBrokenkd? : WorksBrokenkp1? : WorksBrokenkp2? : WorksBrokenkp3? : WorksBrokenkp4? : WorksBroken

B. Beckert: Formal Specification of Software – p.21

Page 23: Steam Boiler Control An Example in Z Formalisation

Extended Solution

Additional Type

WorksBroken ::= works | broken

Additional measured values

ControlInputkw? : WorksBrokenkd? : WorksBrokenkp1? : WorksBrokenkp2? : WorksBrokenkp3? : WorksBrokenkp4? : WorksBroken

B. Beckert: Formal Specification of Software – p.21

Page 24: Steam Boiler Control An Example in Z Formalisation

Extended Solution

Control values

SteamBoiler1SteamBoiler0s : N

δ : N

Initial State

SteamBoilerInit1SteamBoiler1′

a′ = offz′ = init

B. Beckert: Formal Specification of Software – p.22

Page 25: Steam Boiler Control An Example in Z Formalisation

Extended Solution

Control values

SteamBoiler1SteamBoiler0s : N

δ : N

Initial State

SteamBoilerInit1SteamBoiler1′

a′ = offz′ = init

B. Beckert: Formal Specification of Software – p.22

Page 26: Steam Boiler Control An Example in Z Formalisation

Extended Auxiliary Schemata

Auxiliary Functions

pswitch : (OnOff × WorksBroken) → OnOff

pswitch(on, works) = onpswitch(on, broken) = offpswitch(off , works) = offpswitch(off , broken) = off

pamount : (OnOff ×WorksBroken) → N

∀x : OnOff , y : WorksBroken| x = off ∨ y = broken • pamount(x, y) = 0

pamount(on, works) = 1

B. Beckert: Formal Specification of Software – p.23

Page 27: Steam Boiler Control An Example in Z Formalisation

Extended Auxiliary Schemata

Auxiliary Schemata

PumpsControlledOnPumps′ControlInput

p′1 = pswitch(on, kp1?) ∧ p′2 = pswitch(on, kp2?)p′3 = pswitch(on, kp3?) ∧ p′4 = pswitch(on, kp4?)

PumpsControlledOffPumps′ControlInput

p′1 = pswitch(off , kp1?) ∧ p′2 = pswitch(off , kp2?)p′3 = pswitch(off , kp3?) ∧ p′4 = pswitch(off , kp4?)

B. Beckert: Formal Specification of Software – p.24

Page 28: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitNormal1∆SteamBoiler1InputControlInput

z = initd? = 0kw = works ∧ kd = worksw? ≥ wmin + dmaxw? ≤ wmax

z′ = normv′ = closeda′ = ons′ = w?PumpsOff

B. Beckert: Formal Specification of Software – p.25

Page 29: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitFill1∆SteamBoiler1InputControlInput

z = initd? = 0kw = works ∧ kd = worksw? < wmin + dmax

z′ = zv′ = closeda′ = offPumpsOn

B. Beckert: Formal Specification of Software – p.26

Page 30: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitEmpty1∆SteamBoiler1InputControlInput

z = initd? = 0w? > wmax

z′ = zv′ = opena′ = offPumpsOff

B. Beckert: Formal Specification of Software – p.27

Page 31: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

SInitStop1∆SteamBoiler1InputControlInput

z = initd? > 0 ∨ kw = broken ∨ kd = brokenz′ = stop

B. Beckert: Formal Specification of Software – p.28

Page 32: Steam Boiler Control An Example in Z Formalisation

Operations for Initialisation

ControlInit1 =̂ SInitNormal1∨ SInitFill1∨ SInitEmpty1

∨ SInitStop1

B. Beckert: Formal Specification of Software – p.29

Page 33: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalFill1∆SteamBoiler1InputControlInput

z = normkw = worksw? ≥ wminw? ≤ wopt − 3ls′ = w?PumpsControlledOnv′ = closed ∧ a′ = on ∧ z′ = z

B. Beckert: Formal Specification of Software – p.30

Page 34: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalContinue1∆SteamBoiler1InputControlInput

z = normkw = worksw? > wopt − 3lw? ≤ wopt

p′1 = pswitch(p1, kp1) ∧ p′2 = pswitch(p2, kp2)p′3 = pswitch(p3, kp3) ∧ p′4 = pswitch(p4, kp4)s′ = w?v′ = v ∧ a′ = a ∧ z′ = z

B. Beckert: Formal Specification of Software – p.31

Page 35: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalNotFill1∆SteamBoiler1InputControlInput

z = normkw = worksw? > woptw? ≤ wmax

s′ = w?PumpsControlledOffv′ = closed ∧ a′ = on ∧ z′ = z

B. Beckert: Formal Specification of Software – p.32

Page 36: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalWaterStop1∆SteamBoiler1InputControlInput

z = norm ∨ z = brokenkw = worksw? < wmin ∨ w? > wmaxa′ = off ∧ z′ = stop

B. Beckert: Formal Specification of Software – p.33

Page 37: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalControlStop1∆SteamBoiler1InputControlInput

z = normkw = broken ∧ kd = brokena′ = off ∧ z′ = stop

B. Beckert: Formal Specification of Software – p.34

Page 38: Steam Boiler Control An Example in Z Formalisation

Schema AmountComputation

AmountComputationSteamBoiler1ControlInputamount : N

δpumps : N

amount = l ∗ (pamount(p1, kp1?) + pamount(p2, kp2?) +

pamount(p3, kp3?) + pamount(p4, kp4?))δpumps = δp ∗ (pamount(p1, works) + pamount(p2, works) +

pamount(p3, works) + pamount(p4, works))

B. Beckert: Formal Specification of Software – p.35

Page 39: Steam Boiler Control An Example in Z Formalisation

Operations for Normal State

SNormalBroken1∆SteamBoiler1InputControlInputAmountComputation

z = normkw = brokenkd = workss′ = s + amount − d?δ ′ = δpumps + δds′ ≥ wmin + δ ′

s′ ≤ wmax − δ ′

s′ < (wmin + wmax)/2 → PumpsControlledOns′ ≥ (wmin + wmax)/2 → PumpsControlledOffv′ = closed ∧ a′ = onz′ = broken

Note:Simple strategy because number of workin pumps is unknown

B. Beckert: Formal Specification of Software – p.36

Page 40: Steam Boiler Control An Example in Z Formalisation

Complete Operation

ControlNormal1 =̂ SNormalFill1∨ SNormalContinue1

∨ SNormalNotFill1∨ SNormalWaterStop1

∨ SNormalControlStop1

∨ SNormalBroken1

B. Beckert: Formal Specification of Software – p.37

Page 41: Steam Boiler Control An Example in Z Formalisation

Operations for Broken State

SBrokenContinue1∆SteamBoiler1InputControlInputAmountComputation

z = brokenkw = brokenkd = workss′ = s + amount − d?δ ′ = δ + δpumps + δds′ ≥ wmin + δ ′

s′ ≤ wmax − δ ′

s′ < (wmin + wmax)/2 → PumpsControlledOns′ ≥ (wmin + wmax)/2 → PumpsControlledOffv′ = closed ∧ a′ = onz′ = broken

B. Beckert: Formal Specification of Software – p.38

Page 42: Steam Boiler Control An Example in Z Formalisation

Operations for Broken State

SBrokenNormal1∆SteamBoiler1InputControlInputAmountComputation

z = brokenkw = worksw? ≥ wminw? ≤ wmaxw? < (wmin + wmax)/2 → PumpsControlledOnw? ≥ (wmin + wmax)/2 → PumpsControlledOffs′ = w?v′ = closed ∧ a′ = onz′ = norm

B. Beckert: Formal Specification of Software – p.39

Page 43: Steam Boiler Control An Example in Z Formalisation

Operations for Broken State

SBrokenControlStop1∆SteamBoiler1InputControlInput

z = brokenkw = brokenkd = brokena′ = off ∧ z′ = stop

B. Beckert: Formal Specification of Software – p.40

Page 44: Steam Boiler Control An Example in Z Formalisation

Operations for Broken State

SBrokenWaterStop1∆SteamBoiler1InputControlInputAmountComputation

z = broken ∨ z = normkw = brokenkd = workss′ = s + amount − d?z = broken → δ ′ = δ + δpumps + δdz = norm → δ ′ = δpumps + δds′ < wmin + δ ′ ∨ s′ > wmax − δ ′

a′ = off ∧ z′ = stop

B. Beckert: Formal Specification of Software – p.41

Page 45: Steam Boiler Control An Example in Z Formalisation

Operations for Broken State

ControlBroken1 =̂ SBrokenContinue1

∨ SBrokenNormal1∨ SBrokenControlStop1

∨ SBrokenWaterStop1

B. Beckert: Formal Specification of Software – p.42

Page 46: Steam Boiler Control An Example in Z Formalisation

Complete Operation

Control1 =̂ ControlInit1∨ ControlNormal1∨ ControlBroken1

B. Beckert: Formal Specification of Software – p.43


Recommended