You are on page 1of 6

INCOM'2006: 12th IFAC/IFIP/IFORS/IEEE/IMS Symposium

Information Control Problems in Manufacturing


May 17-19 2006, Saint-Etienne, France

FORMAL SPECIFICATION OF SAFE MANUFACTURING MACHINES USING THE B METHOD:


APPLICATION TO A MECHANICAL PRESS

Dominique EVROT1+3, Jean-François PETIN1, Dominique MERY2

(1) Université Henri Poincaré, CRAN, UMR 7039 CNRS-INPL-UHP


(2) Université Henri Poincaré, LORIA, UMR 7503 CNRS-INPL-UHP-INRIA-Nancy II
Campus Scientifique, BP 239, 54506 Vandoeuvre lès Nancy
{dominique.evrot}{jean-francois.petin}@cran.uhp-nancy.fr, dominique.mery@loria.fr
(3) INRS, BP 27 54501 Vandoeuvre lès Nancy cedex

Abstract: This paper deals with the development of manufacturing machinery subjected
to strong dependability and safety properties. In this context, IEC 61508 standard
recommends the use of formal methods to control the complexity of software intensive
applications. This paper focuses on model refinement to ensure safety requirements
traceability. A mechanical press case study illustrates a way to bridge the gap for using
the B method within such an automation-oriented context. Copyright © 2006 IFAC

Keywords: Formal specification, safety analysis, requirements refinement, machinery


control design

1. INTRODUCTION In this context, INRS is waging a study about the


conceptual and practical approaches related to
Manufacturing machines are increasingly being safety/reliability, computer sciences and automatic
equipped with programmable logic controllers control. More precisely, verification using model
(PLCs) which ensure not only their strictly functional checking (Clarke et al, 2000)(Craigen et al,
part but also operator safety functions. They have 1995)(Feldman et al, 1999) or theorem proving
long been ensured by electromechanical technology, (Abrial et al, 1991)(Roussel and Faure, 2002) have
the application of which is relatively well mastered been tackled. However, in spite of the consensus that
both from the design and production points of view. early phases of a system definition are the most
Integration of safety functions into the software parts important ones to ensure that the system will satisfy
of programmable systems can be envisaged only if the user’s requirements, most of these models and
the safety level of “PLC and software” set is at least tools address the design and implementation phases.
equal to the electromechanical circuit’s one. Over these later stages, many systems engineering
and automation engineering practitioners (Shell,
One role of Institut National de Recherche et de 2001)(Johnson, 2004) are considering that time is
Sécurité (INRS) in France is to study methods for the ripe to formalise the earlier stages of specification.
development of safety machines and to deliver safety This means providing a set of guidelines, generic
certification for some equipments (presses, wood constructs, and formal verification tools to establish a
machines and electro-sensitive protective devices) non-ambiguous, correct, consistent and complete
listed in the annex IV of the machinery directive model of understanding of what a system has to do
(Blaise et al., 2003). It could be based on normative according to the users’ requirements before designing
recommendations such as the IEC 61508 standard its behaviour according to the multiple engineers’
defining four Safety Integrity Levels (SILs) practices and techniques (Lhote et al, 1999).
according to an estimation of the risk for the
operator, the probability of failure of each Among candidate formalisms, INRS has studied on
component, and the method used to develop the the B method (Abrial, 1996) and ordered a case study
system. In particular, the higher level SIL 4 development using this method1 (Lamy and Bello,
recommends the use of formal methods to control the
quality of software intensive applications. 1
Atelier B is a product of ClearSy, http://www.clearsy.com.

281
2004)(Abrial et al, 2005). This study has clearly when in up position. Moreover, if the operator
shown the benefit of using B for proved code releases the hand command during the falling phase,
generation. Nevertheless, applying this approach or if emergency stop occurs, the press is stopped.
within an industrial automation engineering
framework requires the definition of a system formal Mechanical press environment
engineering rationale:
- to better detail how the safety requirements are O
p
taken into account all along the development e Clutch side
Motor
C
o
r
process and to ensure their traceability, a Brake side steering wheel n
t
t
- to enlarge software engineering to system i Mobile
Disc
r
o
engineering including software, hardware, man- n
g
l

machine interface and physical systems as S


Springs S
y
required by automation projects. y
s Crankshaft
s
t
t
e
e
This paper presents a mechanical press case study m
m

that illustrates a way to bridge the gap for using the B Clutching-braking system

method within an automation-oriented context. Our Mechanical press system

proposal is based on: Fig. 1. Mechanical press case study


- a refinement mechanism that is rather used to
progressively detail abstract safety properties Two main safety properties have to be guaranteed in
into more concrete ones related to each sub- this operating mode:
systems than to only simplify proof tasks, - S1: falling movement is enabled if and only if
- the Fusaoka’s automation assertion (Fusaoka et operator’s hands are on the two hands command
al, 1983), which postulates that the design of and emergency stop is not engaged.
automation systems consists in defining the - S2: rising movement is enabled if and only if the
control rules of the dynamics of a physical emergency stop is not engaged.
system, starting from the behavioural goals to be Note that in rising movement, no constraint about the
met: Control Rules ∧ Dynamics ⊃ Goal (1). two hands command is required.
Note that this decomposition is close to the
structure of a machine given by ISO 121002 in This set of mode specification and safety properties
terms of control and operative parts. is the foundation of the B first formalisation.
The two first sections introduce respectively the 3. THE B METHOD
mechanical press case study and the B formalism.
Third section details the refinement mechanism Introduced by Abrial, the B Method is a formal
based on the Fusaoka’s assertion. Fourth section method for the specification, design, and
discusses about the verification issues due to the implementation of software/system applications that
properties decomposition introduced by our supports invariance and safety properties proofs. The
modelling framework. Last section gives some B language is based on:
conclusions and prospects. - set theory with classical set operators (S U T, S
I T, S c T, x e S, #S), function and relationship
2. MECHANICAL PRESS CASE STUDY
(A j B Í P A x B);
In this paper, we consider a mechanical press that - first order logic with classical operators of a 2-
aims at stamping metal products with a tool in valued proposal logic (! P, P v Q, P ¶ Q, P fi
vertical movement. A crankshaft equipped with two Q, P ¤ Q) and quantifiers (A X • p, E X • p).
sensors for top and bottom dead centres gives this
vertical movement. A clutch, which is actuated by a A B model is defined by the structure shown in Fig 2.
pneumatic valve, ensures the transmission between
motor and crankshaft. Operator protection is supplied MODEL m
thanks to a two hands command. An emergency stop SETS s
enable or not the stamping action. CONSTANTS c
PROPERTIES p
We focus on the press function that is in charge of VARIABLES x
clutching and braking the press motor in the normal INVARIANT I(x)
operating mode (motor is considered as always INITIALISATION init(x)
working). In this mode, the press is initially stopped EVENTS
O1= Select P1(x) Then S1(x)
in up position and waits for a two hands command. …
Then, the tool is falling until the bottom dead centre On = Select Pn(x) Then Sn(x)
is reached, then is rising back, and finally stopped END

2 Fig. 2. B formal model


ISO 12100, Safety of machinery – basic concept, general
principles for design, January 2004

282
A model has a name m; the clause SETS contains physical variables). It means that specification does
definitions of sets of the problem; the clause not differentiate cause (such as input action by
CONSTANTS allows the designer to introduce human operator) from consequence (such as press
information related to the mathematical structure of movement). As an example, a first situation of the
the problem to be solved; and the clause press can be characterised by two system variables:
PROPERTIES contains the effective definitions of press stopped and no operator’s action. These two
the constants. The second section of the model variables are observed in a next situation as
defines the dynamic aspects of the state variables and following: the press is now moving and the two hand
properties of variables using the invariant. Events command is pushed.
O1…On are used to describe state variable
modifications due to generalized substitutions; Si(x) Consequently, variables of the first specification
contains the new value of variable x after the level are the following: state1 represent the press
occurrence of Oi. The substitution of a variable is abstract state which is considered as stopped1,
feasible with respect to its guard. The invariant I(x) falling1, rising1; start and emergency model the
states that variable x is always in a given set of Boolean operator’s actions. This gives rise to the
possible values, which is assumed to be initialized declaration section of the first B machine:
with respect to the initial conditions and which is
preserved by any event of the list of events. MODEL Press_System 1
Conditions of verification, called proof obligations SETS STATES1= {stopped1, falling1, rising1};
are generated from the text of the model, and they PIN= {on, off}
express underlying hypotheses required for the VARIABLES state1, start, emergency
preservation of invariant properties: INITIALISATION
state1= stopped1 || start = off || emergency = off
(INV1) Init(x) fi I(x)
(INV2) I(x) ¶ P(x) fi I( S(x)) Invariant is related to the type of each variable and
(INV1) states the initial condition that should express also S1 and S2 properties.
establish the invariant. (INV2) should be checked for INVARIANT
every event Oi of the model; it states that starting start ∈ PIN ∧ emergency ∈ PIN ∧ state1 ∈ STATES1 ∧
from a situation where the guard of event Oi and the (state1= rising1 ⇒ emergency= off) ∧ (S1)
invariant are verified, the variable transformation (state1= falling1 ⇒ start= on ∧ emergency= off) (S2)
leads to a new value of x where the invariant is still
preserved. The B proof mechanism is founded on The press behaviour is described using three events
rule-bases using an inference engine supported by the that define a cyclic sequence:
Atelier B tool. - when the operator pushes the start button, the
The refinement calculus is used to relate models at press is going down,
varying levels of abstraction by enriching variables - when the press reaches its bottom point, the
and event descriptions while preserving the already movement direction is changing and the press
proven invariants. We summarize the approach as begins to rise,
follows: - when the press reaches its top point, it is
(M1,G1) refined by (M2,G2) refined by … (Mn,Gn) stopped.
Mi is the ith model iteration that satisfies the goal Gi EVENTS
and the goals of lower iteration number. The refined
by relationship ensures the preservation of goals, but Starting =
the proof of refinement must be given. This means Select state1= stopped1 ∧ start= off
that if a new model is derived from (Mn, Gn), we Then state1:= falling1 || start:= on || emergency:= off
should prove that the new model refines the previous End;
model and preserves the new properties. Consider a Direction_shift =
refinement of the machine shown in Fig.2 given by Select state1= falling1
variable y, invariant J(x,y), event Oi(y) Í Select Then state1:= rising1
End;
Qi(y) then Ti(y), where J represents the formal link
between the abstract variable x and the refined Stop_up =
variable y and some local properties over y. Select state1= rising1
Then state1:= stopped1 || start ∈ PIN
4. PRESS SPECIFICATION End;

4.1 Goal specification After that, comes the specification of degraded


behaviour. We begin by the description of abnormal
This first model describes an external view of the stops. The press is stopped when the start button is
system behaviour. Each model evolution relaxed during the falling phase and when the
characterises a before/after transition between two emergency button is pushed whatever the press
machine situations defined by all the system movement is.
observable variables (operator’s two hand command,

283
Start_relax_stop = EVENTS
Select state1 = falling1 ∧ start = on …
Rising_restart =
Then state1 := stopped1 || start = off
Select state2= rising_stop2 ∧ emergency= on
End;
Then state2:= rising2 || start :∈ PIN || emergency:=off
End;
Emergency_stop = …
Select state1= falling1 ∧ emergency= off END
Then state1:= stopped1 || emergency= on
When state1= rising1 ∧ emergency= off 4.2 Press automated system specification
Then state1:= stopped1 || emergency= on
Next refinement aims at transforming the initial
When state1= stopped1 ∧ emergency= off system requirements (Goal) into software/hardware
Then state1:= stopped1 || emergency= on components (Control rules and dynamics) that
End; constrain the behaviour of a physical system
according to solicitations from the environment. This
At least, following operations describe restarting is done according to Fusaoka’s predicate and its B
conditions after abnormal stop. Two cases have to be formalisation (Pétin et al., 2006) where refinement is
taken into account: restarting from stop state to used to verify compliance between goal and
falling phase and restarting from stop to rising phase. automated system specifications.
Rising_restart = The B model Press_System_3 refines
Select state1= stopped1 ∧ emergency= on Press_System_2 by introducing a clear distinction
Then state1:= rising1 || start :∈ PIN || emergency:=off between events that produces stimuli, events that
End; model the dynamics of the physical part of the press
and events that control the behaviour of the press
Falling_restart = (Fig. 3). The control operations receive stimuli from
Select state1= stopped1 ∧ start= off ∧ emergency= on operator (start and emergency buttons) and from
Then state1:= falling1 || start= on || emergency:= off press physical position (top or bottom dead centres)
End; and decide to actuate or not the clutching system
(sending pressure to clutch makes move the
These two last events introduce an non deterministic crankshaft and the tool).
situation due to the possibility of having tdc
Falling_restart and Rising_restart guards bdc
simultaneously triggered. It can be explained by the
fact the movement direction when an abnormal stop start3
occurs is not memorised. pressure Physical
Physical
Operator’s
Operator’scontrol
control Command
Command part
part
This justifies the refinement of the first press Emergency3
specification to detail the STATES1 set by adding
stopped at the top, stopped when falling and stopped Fig. 3. System’s structural decomposition
when rising states. This replacement of variable
state1 by variable state2 is effective in all clauses of Modelling of environment changes (modification of
the B machine and provokes guard and event start and emergency variables) is very simple
modifications: when a value of state1 is equal to because they are assumed to be uncontrollable. It
stopped in a guard or in the effect of an event, we means that any operator command may occur
have to precise which kind of stop is concerned: whatever the system states are.
top_stopped, falling_stopped or rising_stopped. The
link between the variable state1 and its refinement Operator_actions =
state2 is defined within the invariant in a section Begin start3 :∈ PIN || emergency3 :∈ PIN
called gluing invariant. End;

REFINEMENT Press_System_2 The press physical system is modelled through B


REFINES Press_System_1 events that describe the crankshaft rotation
SETS STATES2 = {falling_stopped2, rising_stopped2, (α represent crankshaft position and crank is on
top_stopped2 , falling2, Rising2} when crankshaft is clutched) and the sensors
VARIABLES start, emergency, state2 associated to top and bottom dead centres (bdc, tdc).
INVARIANT
…….. ∧ Move =
/* gluing invariant */ If pressure = on
state2 ∈ {falling_stopped2, rising_stopped2, top_stopped2} Then
⇔ state1= stopped1 ∧ If α = 359 then α:= 0 || crank:=on
state2= falling2 ⇔ state1= falling1 ∧ Else α:= α+1 || crank:=on
state2= rising2 ⇔ state1= rising1 ∧ Else crank := off
….. End;

284
Dead_centres = - control system is able to correctly evaluate the
if α = 0 then bdc := off || tdc = on physical state of the press using top and bottom
else if α = 180 then bdc=on || tdc= off dead centres information and to compute an
else bdc=off|| tdc=off appropriate pressure order,
End; - physical system behaviour is compliant with the
control stimuli.
Introducing environment and physical part events
modify the guard of control events of These proof obligations constitute actually the
press_system_3, in order to include rising and falling intrinsic invariant properties:
edges of the operator’s stimuli. To this end, two - of the control
memory variables are created: old_emergency3 and state = rising 3 ⇒ pressure = on ∧
old_start3. After each control events, these variables 180 ≤α< 359 ⇔ state3∈ {rising3, rising_stopped3}
are updated by respectively the emergency3 and - of the physical subsystems
start3 values. For example, the guard of starting pressure = on ⇔ crank = on
event requires now the rising edge of start button
when the press is stopped as following: If the specification of control and process verify
these underlying hypotheses, then it proves that the
Starting = control and physical system events safely behave
Select state3= top_stopped3 ∧ according to the initial requirements S1 and S2.
start3= on ∧ oldstart3= off /* Start rising edge */
Then state3:= falling3 || start3:= on || emergency3:= off ||
5. VERIFICATION ISSUES
oldemergency3:=emergency3 || oldstart3:=start3 ||
pressure:= on
End; A B model is composed of a list of events.
Verification of a B model consists in proving that any
Note that state3 is an internal memory computed by event preserves the invariant. This is well adapted
the control system, which is expected to be consistent for describing software operations that always
with the press abstract state2. maintain safety invariant properties.

This structural decomposition into basic components However, B model does contain any operation
(control software, user interface, and physical scheduler that could sequence the execution of the B
system) guides designer into progressive operations. Consequently, if analysis of a safety
specification of properties. A gluing invariant links property is needed at the beginning of the sequence
the abstract state2 to the properties of control and and at the end of the sequence, the concept of B
physical variables as following: invariant must be handled carefully. This ability to
model invariant properties with the concept of
INVARIANT action/reaction is very important when modelling
State2 ∈{falling_stopped2, rising_stopped2, top_stopped2} reactive systems where B model describes control
⇔ crank = off ∧ part and its environment. Indeed, proving invariant
state3 ∈{falling_stopped3, rising_stopped3, top_stopped3} within such a machine requires playing a game where
∧ control and process operations have successively the
state2=falling2 ⇔ crank= on ∧ 0≤α<180 ∧ state3 = falling3 token. For example, if we consider an operator’s
∧ stimulus, the invariant safety properties S1 and S2
state2=rising2 ⇔ crank=on ∧ 180≤α<359 ∧ state3 = rising3 cannot be checked before having observed the
∧… associated reaction by control and process
subsystems. It means that starting from a situation
Safety properties are also projected into all the sub- where S1 and S2 invariants are true, execution of a
component of the press. The term state2 = rising2 of stimuli operation leads to a temporary situation
the predicate S1 becomes state3= rising3 (control where S1 and S2 are false until the control and
process operations are executed.
point of view) and crank = on ∧ 180 ≤α< 359
(physical system point of view). Same rational is
The way of modelling proposed to cope with this
applied for predicate S2. It completes the previous
verification problem is based on the definition of
invariant by:
flags that model the operation scheduler. Flags are
evaluated by the guard of operations and valued by
(state3= rising3) ∧ (crank= on ∧ 180 ≤α< 359) ⇒ theirs substitutions in order to define an ordered list
emergency3 = off) ∧ (S1) of operation. In this case, invariant can be specified
(state3 = falling3) ∧ (crank= on ∧ 0 ≤α< 180) ⇒ true for only a subset of flag value.
start= on ∧ emergency = off) For reactive system modelling, we propose the set of
∧… (S2) flag value to be divided into three parts, related to
stimuli, control and process operations, noted Fij
Proving this invariant is based on underlying where i denotes the type of operation (1 for stimuli, 2
hypotheses that assume: for control and 3 for process) and j the number of
operation within the sub-lists. The legal sequence of

285
operation execution is composed of three operations: 7. REFERENCES
one stimuli operation followed by one control
operation and then one process operation. This can be Abrial J.R., Borger E., Langmaack editors (1991). Formal
noted as following: methods for industrial applications : specifying and
programming the steam boiler control, Lecture Notes
in Computer Science, Springer Verlag.
Event ij = Abrial J.R. (1996). The B Book: Assigning Programs to
Select Flag=Fi(j-1) Meanings. Cambridge Univ. Press
Then If Gij Then Sij || Flag:=F(i+1)1 Abrial J.R (2005), Case study of a complete reactive
Else Flag:=Fi(j-1) system in Event-B: a mechanical press controller,
End; tutorial 3 of ZB’2005, Guildford, UK, 13-15/04/2005
where Gij and Sij denotes respectively the guard and Blaise, J. C., Lhoste, P., Ciccotelli, J.(2003).
substitution of the operation ij. Formalisation of normative knowledge for safe
design. In : Safety Science, 41, 241-261.
In this case, invariant will only be considered when Clarke E.M., Grunberg O., Peled D.A. (2000) Model
Flag = F10, i.e. when the flag has just been valued by Checking. The MIT Press
one process operation (sequence stimuli/control Craigen D., Gerhart S., Ralston T. (1995). Formal
reaction/physical effect has been ended). methods technology transfer: implements and
innovation. Formal Methods by Hinchey M.G.,
Bowen J.P., pp. 399-419, Prentice Hall International
6. CONCLUSION & PROSPECTS Diallo D., Vailly A., (1998) Paraphrasing of specification
written in B, Networking and Information Systems
There is a growing interest in methods and tools that Journal (NISJ), Vol. 1 n°2-3/1998.
facilitate the validation of software-intensive Feldmann K., Colombo A.W., Schnur C., Stöckel T.
automation systems. This interest is reinforced by the (1999). Specification, Design, and Implementation of
IEC 61508 safety-related standard that strongly Logic Controllers based on Coloured Petri Net
recommends the use of formal methods, but without Models and the Standard IEC 1131. In : IEEE Trans.
defining how they can be applied. on Control Systems Technology. Volume 7, N°6.
Main contribution of this paper is a system Fusaoka A., Seki H., Takahashi K. (1983). A description
and reasoning of plant controllers in temporal logic.
engineering methodology based on the use of the B International Joint Conference on Artificial
method to ensure a safer automation by checking a Intelligence. pp 405-408. Karlsruhe, 8-12 aug. 1983.
priori proved properties from the earlier phases of Johnson T. L. (2004). Improving automation software
specification. Major added value of our approach is dependability: a role for formal methods? In proc. of
related to: 11th IFAC/INCOM, Salvador-Bahia, Brazil,4-7/04/04
- the use of a system engineering rationale based Laleau R., Pollack F., (2002) Coming and going from
on the Fusaoka’s predicate to identify system UML to B: a proposal to support traceability in
safety requirements and to ensure their rigorous IS development. In Proc of ZB’2002, LNCS
traceability all along the development process, vol. 2272, pp 517–534, Grenoble, France.
Lamy P., Bello J.P., (2004). Realization of a control
- the definition of consistent relations between the software of a mechanical press using B method, in
components safety properties and the way they proc. of the 15th International Symposium on
are aggregated to satisfy the system properties, Software Reliability Engineering, St Malo, France.
- the extension of B modelling to cope with the Ledang H., (2002). Automatic translation from UML
verification of tightly coupled hardware and specifications to B, in proceedings of the Int.
software components in system engineering. Workshop on Refinement of Critical Systems:
Methods, Tools and Experience, 2nd Conf. on B and
Although these interdisciplinary experiences between Z, 23-25/01/2002, Grenoble, France.
computer and automation sciences demonstrate that Lhote F., Chazelet Ph., Dulmet M. (1999). The extension
of principles of cybernetics towards engineering and
the proposed approach may allow one to verify the manufacturing. IFAC Annual Reviews in Control.
highest levels of safety integrity of automation Volume 23 (1), pp 1-11.
systems, the lab-scale case study emphasizes the Pétin J.F., Morel G., Panetto H., (2006), Formal
efforts which should still be deployed in order to specification method for systems automation,
make the proposed engineering framework effective European Journal of Control, to be published
in practice. An important limitation for the Roussel J.-M., Faure J.-M. (2002). An algebraic
acceptance of the proposed approach into a well- approach for PLC programs verification, in
established automation engineering process is the proceedings of IFAC WODES'02, Zaragoza, Spain, 2-
mathematically oriented notation of the B language. 4 October, 2002, pp. 303-308.
Shell T. (2001) Systems functions implementation and
A means of bridging this gap at the specification behavioural modelling: system theoretic approach,
level is to propose equivalent representations of a B International Journal of Systems Engineering, 4/1.
specification using more accepted formalisms. To
this end, translations of UML diagrams into B
machines have been proposed (Ledang,
2002)(Laleau and Pollack, 2002), as well as
paraphrasing of the B model into a natural language
text to facilitate its understanding (Diallo and Vailly,
98).

286

You might also like