1 Why using formal methods (FM)? 4 When there is nothing better to - - PDF document

1
SMART_READER_LITE
LIVE PREVIEW

1 Why using formal methods (FM)? 4 When there is nothing better to - - PDF document

1 Last update: 2 June 2004 Programming in the large Bertrand Meyer Chair of Softw are Engineering Programming in the large - Lecture 17 2 Lecture 17: Introducing Formal Methods (with an example) By Jean-Raymond Abrial Chair of Softw are


slide-1
SLIDE 1

1

Programming in the large - Lecture 17 1 Chair of Softw are Engineering

Programming in the large

Bertrand Meyer

Last update: 2 June 2004

Programming in the large - Lecture 17 2 Chair of Softw are Engineering

Lecture 17: Introducing Formal Methods (with an example)

By Jean-Raymond Abrial

Programming in the large - Lecture 17 3 Chair of Softw are Engineering

Definition of Formal Methods

Not given yet Many very different definitions Give your own at the end of this lecture!

slide-2
SLIDE 2

2

Programming in the large - Lecture 17 4 Chair of Softw are Engineering

Why using formal methods (FM)?

When there is nothing better to do. When the risk is too high. When people have already suffered enough. When people question their development process. Decision of using FM is always strategic.

Programming in the large - Lecture 17 5 Chair of Softw are Engineering

Which formal method?

This is a difficult question. Today many formal methods vendors. FM has becom e a meaningless buzz word. “Formal” alone does not mean anything.

Programming in the large - Lecture 17 6 Chair of Softw are Engineering

Questions to be asked to FM vendors

Is there a theory behind your FM? What kind of language is your FM using? Does there exist any REFINEMENT mechanism in your FM? Do you PROVE anything when using your FM? Have you got an efficient automatic prover?

slide-3
SLIDE 3

3

Programming in the large - Lecture 17 7 Chair of Softw are Engineering

Claimed difficulties in using FM

You have to be a mathematician. Formalism is hard to master. Not visual enough (no boxes, arrows, etc.). People will not be able to do formal proofs.

Programming in the large - Lecture 17 8 Chair of Softw are Engineering

Genuine difficulties (my own view)

You have to think a lot before final coding. Incorporation in development process. Model building is an elaborate activity. Prover technology has to improve. Making proofs a design criterium. Poor quality of requirement documents.

Programming in the large - Lecture 17 9 Chair of Softw are Engineering

Application areas

Train system s Car systems Avionics and Space Power station control Telecom Defense Complex databases Large business network SmartCard applications Machine tools …

slide-4
SLIDE 4

4

Programming in the large - Lecture 17 10 Chair of Softw are Engineering

Complex systems (1/ 2)

QUESTION: What is common to an electronic circuit a file transfer protocol an airline booking system a PC operating system a nuclear plant control system a SmartCard electronic purse a launch vehicle flight controller ANSWER: They are all complex.

Programming in the large - Lecture 17 11 Chair of Softw are Engineering

Complex systems (2/ 2)

They are made of many parts. They interact with a possibly hostile environment. They involve several executing agents. They require a high degree of correctness. Their construction spreads over several years. Their specifications are subjected to many changes. Their construction process requires a talented team.

Programming in the large - Lecture 17 12 Chair of Softw are Engineering

Discrete systems

These system s operate in an discrete fashion. Their dynam ical behavior can be abstracted by: A succession of steady states Interm ixed with sudden jumps. The possibility of state changes is enormous. The change frequency is unthinkable. Such systems are called transition systems.

slide-5
SLIDE 5

5

Programming in the large - Lecture 17 13 Chair of Softw are Engineering

Reasoning about (discrete) systems

Two broad categories: Test reasoning (98% ) Blue Print reasoning (10% )

Programming in the large - Lecture 17 14 Chair of Softw are Engineering

Test reasoning

Based on laboratory execution. Obvious incompleteness. The oracle is usually m issing. Often implies postponing serious thinking. Re-adapting and re-shaping after testing. Reveals an imm ature technology.

Programming in the large - Lecture 17 15 Chair of Softw are Engineering

“Blue Print” reasoning

Based on a model: the “blue print”. Describing the system with the required precision. Completeness can be approached. Serious thinking made on the m odel, not on the final system. This is validated by proofs. Reveals a mature technology.

slide-6
SLIDE 6

6

Programming in the large - Lecture 17 16 Chair of Softw are Engineering

Incorporation within the development process

Carefully rewriting the requirem ent document. Develop models by successive refinement. Prove each refinement step. Use efficient tools for: Analyzing formal texts. Generating proof statem ents. Proving (as much as possible automatically).

Programming in the large - Lecture 17 17 Chair of Softw are Engineering

Example: a mechanical press

Presenting the rewritten requirement document. Partial development of models by successive refinem ent.

Programming in the large - Lecture 17 18 Chair of Softw are Engineering

Mechanical press schema

MOTOR ROD SLI DE PART TOOL

slide-7
SLIDE 7

7

Programming in the large - Lecture 17 19 Chair of Softw are Engineering

Basic equipment

A vertical slide with a tool at its lower extrem ity. An electrical rotating motor. A connecting rod transform ing rotary movem ent to vertical movem ent of slide. A clutch engaging or disengaging the m otor on the rod. When the clutch is disengaged, the slide stops “immediately”.

Programming in the large - Lecture 17 20 Chair of Softw are Engineering

Initial situation

Programming in the large - Lecture 17 21 Chair of Softw are Engineering

Starting the motor

slide-8
SLIDE 8

8

Programming in the large - Lecture 17 22 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 23 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 24 Chair of Softw are Engineering

The motor works

slide-9
SLIDE 9

9

Programming in the large - Lecture 17 25 Chair of Softw are Engineering

Adding a tool

Programming in the large - Lecture 17 26 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 27 Chair of Softw are Engineering

The motor works

slide-10
SLIDE 10

10

Programming in the large - Lecture 17 28 Chair of Softw are Engineering

Putting a part

Programming in the large - Lecture 17 29 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 30 Chair of Softw are Engineering

The motor works

slide-11
SLIDE 11

11

Programming in the large - Lecture 17 31 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 32 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 33 Chair of Softw are Engineering

The motor works

slide-12
SLIDE 12

12

Programming in the large - Lecture 17 34 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 35 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 36 Chair of Softw are Engineering

The motor works

slide-13
SLIDE 13

13

Programming in the large - Lecture 17 37 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 38 Chair of Softw are Engineering

Engaging the clutch

Programming in the large - Lecture 17 39 Chair of Softw are Engineering

The press works

slide-14
SLIDE 14

14

Programming in the large - Lecture 17 40 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 41 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 42 Chair of Softw are Engineering

The press works

slide-15
SLIDE 15

15

Programming in the large - Lecture 17 43 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 44 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 45 Chair of Softw are Engineering

The press works

slide-16
SLIDE 16

16

Programming in the large - Lecture 17 46 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 47 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 48 Chair of Softw are Engineering

The press works

slide-17
SLIDE 17

17

Programming in the large - Lecture 17 49 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 50 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 51 Chair of Softw are Engineering

The press works

slide-18
SLIDE 18

18

Programming in the large - Lecture 17 52 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 53 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 54 Chair of Softw are Engineering

The press works

slide-19
SLIDE 19

19

Programming in the large - Lecture 17 55 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 56 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 57 Chair of Softw are Engineering

The press works

slide-20
SLIDE 20

20

Programming in the large - Lecture 17 58 Chair of Softw are Engineering

Disengaging the clutch

Programming in the large - Lecture 17 59 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 60 Chair of Softw are Engineering

The motor works

slide-21
SLIDE 21

21

Programming in the large - Lecture 17 61 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 62 Chair of Softw are Engineering

Removing the part

Programming in the large - Lecture 17 63 Chair of Softw are Engineering

The motor works

slide-22
SLIDE 22

22

Programming in the large - Lecture 17 64 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 65 Chair of Softw are Engineering

Adding a new part

Programming in the large - Lecture 17 66 Chair of Softw are Engineering

Engaging the clutch

slide-23
SLIDE 23

23

Programming in the large - Lecture 17 67 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 68 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 69 Chair of Softw are Engineering

The press works

slide-24
SLIDE 24

24

Programming in the large - Lecture 17 70 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 71 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 72 Chair of Softw are Engineering

The press works

slide-25
SLIDE 25

25

Programming in the large - Lecture 17 73 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 74 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 75 Chair of Softw are Engineering

The press works

slide-26
SLIDE 26

26

Programming in the large - Lecture 17 76 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 77 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 78 Chair of Softw are Engineering

The press works

slide-27
SLIDE 27

27

Programming in the large - Lecture 17 79 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 80 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 81 Chair of Softw are Engineering

The press works

slide-28
SLIDE 28

28

Programming in the large - Lecture 17 82 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 83 Chair of Softw are Engineering

The press works

Programming in the large - Lecture 17 84 Chair of Softw are Engineering

The press works

slide-29
SLIDE 29

29

Programming in the large - Lecture 17 85 Chair of Softw are Engineering

Disengaging the clutch

Programming in the large - Lecture 17 86 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 87 Chair of Softw are Engineering

The motor works

slide-30
SLIDE 30

30

Programming in the large - Lecture 17 88 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 89 Chair of Softw are Engineering

Removing the part

Programming in the large - Lecture 17 90 Chair of Softw are Engineering

The motor works

slide-31
SLIDE 31

31

Programming in the large - Lecture 17 91 Chair of Softw are Engineering

The motor works

Programming in the large - Lecture 17 92 Chair of Softw are Engineering

Removing the tool

Programming in the large - Lecture 17 93 Chair of Softw are Engineering

Stopping the motor

slide-32
SLIDE 32

32

Programming in the large - Lecture 17 94 Chair of Softw are Engineering

Final situation

Programming in the large - Lecture 17 95 Chair of Softw are Engineering

Basic commands

Command 1: Start motor. Command 2: Engage clutch. Command 3: Disengage clutch. Command 4: Stop motor.

Programming in the large - Lecture 17 96 Chair of Softw are Engineering

Basic user actions

Action 1: Change the tool at the lower extrem ity of the slide. Action 2: Put a part to be treated under the slide. Action 3: Remove the part.

slide-33
SLIDE 33

33

Programming in the large - Lecture 17 97 Chair of Softw are Engineering

First schematic view

COMMANDS EQUI PMENT

Programming in the large - Lecture 17 98 Chair of Softw are Engineering

A typical user session

1: Start the motor (command 1), 2: Change the tool (action 1), 3: Put a part (action 2), 4: Engage the clutch (command 2): the press now works, 5: Disengage the clutch (comm and 3): the press does not work, 6: Rem ove the part (action 3), 7: Repeat zero or more tim es actions 3 to 6, 8: Repeat zero or more tim es actions 2 to 7, 9: Stop the motor (command4).

Programming in the large - Lecture 17 99 Chair of Softw are Engineering

Danger: Necessity of a controller

Action 2 (change the tool), Action 3 (put a part), Action 6 (rem ove the part) are all DANGEROUS.

slide-34
SLIDE 34

34

Programming in the large - Lecture 17 100 Chair of Softw are Engineering

Second schematic view

CONTROLLER EQUI PMENT COMMANDS

Programming in the large - Lecture 17 101 Chair of Softw are Engineering

More elaborate commands for protecting the user Controlling the way the clutch is engaged or disengaged. Protection by m eans of the bi-manual device. Protection by m eans of a front door. The pedal.

Programming in the large - Lecture 17 102 Chair of Softw are Engineering

The bi-manual device

slide-35
SLIDE 35

35

Programming in the large - Lecture 17 103 Chair of Softw are Engineering

The bi-manual device: assumptions

A single user. A single user only has two hands. The user has both hands either

  • n the bi-manual device or (exclusively)

within the press. Distance between the device and the press is long enough (more below).

Programming in the large - Lecture 17 104 Chair of Softw are Engineering

The bi-manual device: behavior

When both hands are put simultaneously on the device The clutch is engaged. As soon as the user removes at least one hand from the device The clutch is disengaged. Before putting one’s hands on the device Hands must be both removed from the device. Sim ultaneously means that the delay between both hands is bounded: delay D5 (more on delays below).

Programming in the large - Lecture 17 105 Chair of Softw are Engineering

The bi-manual device: consequence

Maintaining the clutch engaged and having at the same tim e one’s hands in the press is impossible.

slide-36
SLIDE 36

36

Programming in the large - Lecture 17 106 Chair of Softw are Engineering

The front door

Programming in the large - Lecture 17 107 Chair of Softw are Engineering

The front door: Assumptions

User can have hands within the press only when door is open. Distance between door and inside of the press is long enough (m ore below).

Programming in the large - Lecture 17 108 Chair of Softw are Engineering

The front door: behavior

When front door is closed, the user can engage the clutch (with the bi-manual device). He can then freely remove both hands from the device (clutch is not disengaged). As soon as he opens the front door, the clutch is disengaged. As soon as he closes the front door, the clutch is engaged again. Pressing a special button B6 stops this procedure.

slide-37
SLIDE 37

37

Programming in the large - Lecture 17 109 Chair of Softw are Engineering

The front door: consequence

Having the clutch engaged and at the same time one’s hands in the press is impossible.

Programming in the large - Lecture 17 110 Chair of Softw are Engineering

The distance problem

Distance between the device and the press is long enough. Distance between door and inside of the press is long enough. These distances must be carefully calculated so that the press is effectively stopped before the user can put hands within the press. Consequence: carefully checking the stopping time

  • f the press after disengaging the clutch (more

below).

Programming in the large - Lecture 17 111 Chair of Softw are Engineering

The pedal: assumptions and behavior

The user is m oving the m otor m anually (no danger thus). The clutch is engaged by pressing the pedal (with the foot).

slide-38
SLIDE 38

38

Programming in the large - Lecture 17 112 Chair of Softw are Engineering

Buttons and commands so far at the disposal of the user

B1: void B2: void B3: void B4: start motor B5: stop motor B6: continuous cycle stop (when using front door) B7: void BM: bi-manual device FD: front door PL: pedal

Programming in the large - Lecture 17 113 Chair of Softw are Engineering

The concept of modes of operation

Using the bi-manual device. Using the front door. Using the pedal. Also normal and maintenance m odes.

Programming in the large - Lecture 17 114 Chair of Softw are Engineering

Summary of modes (more below)

M1: Maintenance mode without motor and pedal M2: Maintenance mode with motor and bi-manual device M3: Normal mode with motor and bi-manual device M4: Normal mode with motor and front door M5: Stop mode

slide-39
SLIDE 39

39

Programming in the large - Lecture 17 115 Chair of Softw are Engineering

Changing modes (1/ 2)

A rotation button B1 is used for changing mode. When using B1, the clutch must be automatically disengaged. Five wires (on/ off) are installed between B1 and the controller. Only one wire should be “on” at a time: emergency otherwise (more on emergency below).

Programming in the large - Lecture 17 116 Chair of Softw are Engineering

Changing modes (2/ 2)

A small delay D1 should be awaited after turning button (for electrical stabilization). To enter the new mode, user m ust push an “arm ing” button B2. B2 tests for some special conditions depending on the mode (m ore below).

Programming in the large - Lecture 17 117 Chair of Softw are Engineering

Buttons and commands so far at the disposal of the user

B1: mode selection (5 positions) B2: arm ing B3: void B4: start motor B5: stop motor B6: continuous cycle stop B7: void BM: bi-manual device FD: front door PL: pedal

slide-40
SLIDE 40

40

Programming in the large - Lecture 17 118 Chair of Softw are Engineering

Summary of delays so far

D1: when changing mode D2: void D3: void D4: void D5: when using the bi-manual device

Programming in the large - Lecture 17 119 Chair of Softw are Engineering

Upper and lower positions of the vertical slide In M2, clutch automatically disengaged at upper point. In M3, clutch automatically disengaged at upper point. In M3, clutch disengaged when removing hands while going down. In M4, clutch disengaged at upper point after pressing button B6. Upper and lower positions determined by cams (next slide).

Programming in the large - Lecture 17 120 Chair of Softw are Engineering

Upper and lower cams

lower cam “on” 170° 340° 15° 350° upper cam “on”

slide-41
SLIDE 41

41

Programming in the large - Lecture 17 121 Chair of Softw are Engineering

More on motor and clutch

Controller sends commands (start/ stop) to motor and clutch. After a change is received, they must send an acknowledgm ent. Acknowledgment must be received before certain delays D2 and D3 (em ergency otherwise).

Programming in the large - Lecture 17 122 Chair of Softw are Engineering

Summary of delays so far

D1: when changing mode D2: when starting or stopping the m otor D3: when engaging or disengaging the clutch D4: void D5: when using the bi-manual device

Programming in the large - Lecture 17 123 Chair of Softw are Engineering

Braking

In mode M3 or M4, clutch automatically disengaged at upper point. If acknowledgment from clutch received after 15 degrees (upper cam) an em ergency is raised.

slide-42
SLIDE 42

42

Programming in the large - Lecture 17 124 Chair of Softw are Engineering

Emergency stop

Can be raised m anually (button B7). Can also be raised by specific conditions depending on the mode. Lit an emergency lamp. Emergency state: no normal command can be used. Press arming button B2 to resume normal mode (turn off lamp).

Programming in the large - Lecture 17 125 Chair of Softw are Engineering

Buttons and commands so far at the disposal of the user

B1: mode selection (5 positions) B2: arm ing B3: void B4: start motor B5: stop motor B6: continuous cycle stop B7: emergency BM: bi-manual device FD: front door PL: pedal SD: side door

Programming in the large - Lecture 17 126 Chair of Softw are Engineering

Environment actuators

MR: motor CL: clutch LP: lamp

slide-43
SLIDE 43

43

Programming in the large - Lecture 17 127 Chair of Softw are Engineering

Wires (1/ 2)

Bi-manual: 2 input wires per hand (when different: emergency) Front door: 2 input wires (when different: emergency) Pedal: 2 input wires (when different: em ergency) Clutch: 2 output wires, 2 input wires (when different: emergency) Motor: 1 output wire, 1 input wire Lamp: 1 output wire

Programming in the large - Lecture 17 128 Chair of Softw are Engineering

Wires (2/ 2)

Upper cam: 1 input wire Lower cam: 2 input wires (when different: emergency) Button B1: 5 input wires (when inconsistent: emergency) Other buttons: 1 input wire per button Side door for m aintenance: 1 input wire

Programming in the large - Lecture 17 129 Chair of Softw are Engineering

Controller input wires (26 wires)

CONTROLLER

B1 B2 B3 B4 B5 B6 BM PL MR CL UC LC B7 SD FD

slide-44
SLIDE 44

44

Programming in the large - Lecture 17 130 Chair of Softw are Engineering

Controller output wires (4 wires)

CONTROLLER

MR LP CL

Programming in the large - Lecture 17 131 Chair of Softw are Engineering

Summary of emergency stop

Emergency button, Brake, Cam (bad redundancy), Front door (bad redundancy), Motor (elapsed delay), Clutch (bad redundancy and elapsed delay), Modes (inconsistency), Foot (bad redundancy), Left hand (bad redundancy), Right hand (bad redundancy)

Programming in the large - Lecture 17 132 Chair of Softw are Engineering

Mode analysis: M1

Initial condition: Motor should not work (done by controller; delay D4) Emergencies: m otor, clutch, pedal Mode selection button: Yes Arm ing button: Yes Motor starting button: No Motor stopping button: No Stopping continuous cycle button: No Emergency button: Yes Bi-manual device: No Pedal: Yes

slide-45
SLIDE 45

45

Programming in the large - Lecture 17 133 Chair of Softw are Engineering

M1: Clutch disengagement

When removing foot from pedal.

Programming in the large - Lecture 17 134 Chair of Softw are Engineering

Mode analysis: M2

Initial condition: Motor should work (press B4) Emergencies: m otor, clutch, bi-manual device Mode selection button: Yes Arm ing button: Yes Motor starting button: Yes Motor stopping button: Yes Stopping continuous cycle button: No Emergency button: Yes Bi-manual device: Yes Pedal: No

Programming in the large - Lecture 17 135 Chair of Softw are Engineering

M2: Clutch disengagement

When removing hands from bi-manual device. At upper point.

slide-46
SLIDE 46

46

Programming in the large - Lecture 17 136 Chair of Softw are Engineering

Mode analysis: M3

Initial condition: Motor should work (press B4), side door closed Emergencies: m otor, clutch, bi-manual device, brake, cam Mode selection button: Yes Arm ing button: Yes Motor starting button: Yes Motor stopping button: Yes Stopping continuous cycle button: No Emergency button: Yes Bi-manual device: Yes Pedal: No

Programming in the large - Lecture 17 137 Chair of Softw are Engineering

M3: Clutch disengagement

When removing hands from bi-manual device if press is going down and after it has stopped at upper point. When opening side door. At upper point.

Programming in the large - Lecture 17 138 Chair of Softw are Engineering

Mode analysis: M4

Initial condition: Motor should work (press B4), side door closed, front door closed Emergencies: m otor, clutch, bi-manual device, brake, front door, cam Mode selection button: Yes Arm ing button: Yes Motor starting button: Yes Motor stopping button: Yes Stopping continuous cycle button: Yes Emergency button: Yes Bi-manual device: Yes Pedal: No

slide-47
SLIDE 47

47

Programming in the large - Lecture 17 139 Chair of Softw are Engineering

M4: Clutch disengagement

When opening front door. When opening side door. At upper point after pressing button B6.

Programming in the large - Lecture 17 140 Chair of Softw are Engineering

Mode analysis: M5

Initial condition: Motor should not work (done by controller) Emergencies: m otor Mode selection button: Yes Arm ing button: No Motor starting button: No Motor stopping button: No Stopping continuous cycle button: No Emergency button: No Bi-manual device: No Pedal: No

Programming in the large - Lecture 17 141 Chair of Softw are Engineering

Summary of delays

D1: when changing mode D2: when starting or stopping the m otor D3: when engaging or disengaging the clutch D4: before entering mode M1 D5: when using the bi-manual device

slide-48
SLIDE 48

48

Programming in the large - Lecture 17 142 Chair of Softw are Engineering

Characterizing the model

It is a closed model of: the environm ent (equipm ent and commands), the controller. This model is developed by means of successive refinem ents. When it will be complete, it could be used to: perform a simulation (environm ent and controller). program a m icro-computer (controller).

Programming in the large - Lecture 17 143 Chair of Softw are Engineering

The first three models

These first models are devoted to the environm ent

  • nly.

They refine each others. 1st model: I ntroducing the free movements of the press. 2nd model: Introducing the behavior and safety laws. 3rd model: Introducing the motor and the clutch.

Programming in the large - Lecture 17 144 Chair of Softw are Engineering

The five next models: treating equipment

4th model: Simplified clutch com mands. 5th model: Simplified model of movements. 6th model: The front door. 7th model: The side door. 8th model: Starting and stopping motor.

slide-49
SLIDE 49

49

Programming in the large - Lecture 17 145 Chair of Softw are Engineering

The next two models: refining treatments

9th model: Refining movement (the cam s). 10th model: Refining the clutch command (bi- manual device).

Programming in the large - Lecture 17 146 Chair of Softw are Engineering

The last models

11th model: Changing modes and emergencies. 12th model: Delays and wire redundancies. 13th model: Refining the clocks. 14th model: Refining the mode changing.

Programming in the large - Lecture 17 147 Chair of Softw are Engineering

Model structure: discrete systems

A model is made of a number of variables a number of transitions on these variables (called events). Variables are typed. An event is made of a guard (necessary enabling conditions) an action (variable modifications). A model has no control mechanism besides the events.

slide-50
SLIDE 50

50

Programming in the large - Lecture 17 148 Chair of Softw are Engineering

Structure of final model

Environment and controller events. Environment and controller variables. Sensor and actuator variables (correspond to the wires).

Programming in the large - Lecture 17 149 Chair of Softw are Engineering

Decomposing the final model: environment

The environment events. The environment variables modified by environment events. The sensor variables modified by environment events. The actuator variables read by environment events. The controller variables not seen by environment events.

Programming in the large - Lecture 17 150 Chair of Softw are Engineering

Decomposing the final model: controller

The controller events. The controller variables modified by controller events. The sensor variables read by controller events. The actuator variables modified by controller events. The environment variables not seen by controller events.

slide-51
SLIDE 51

51

Programming in the large - Lecture 17 151 Chair of Softw are Engineering

Back to the first three models

The controller does not exist: thus no sensors, no actuators. The equipment just “knows” the various modes. These models describe what an external observer can “see”. They also describe the invariant laws of the various m odes. These models are gradually refined.

Programming in the large - Lecture 17 152 Chair of Softw are Engineering

1st model: the environment variables

Such variables are defined without constraints to begin with: PRESS ∈ {stopped, working} HANDS ∈ {free, busy} FRONT_DOOR ∈ {open, closed} SIDE_DOOR ∈ {open, closed} DIRECTION ∈ {up, down} STOP_UPPER_POINT ∈ {yes, no}

Programming in the large - Lecture 17 153 Chair of Softw are Engineering

1st model: starting the press

The press is stopped: one observes that it can be started. start_press ≘ w hen PRESS = stopped then PRESS := working end

slide-52
SLIDE 52

52

Programming in the large - Lecture 17 154 Chair of Softw are Engineering

1st model: stopping the press

The press works: one observes that it can be stopped. stop_press ≘ w hen PRESS = working then PRESS := stopped end

Programming in the large - Lecture 17 155 Chair of Softw are Engineering

1st model: freeing the hands (case 1)

Press is working and hands are busy: one can

  • bserve that hands are freed and press still works.

free_hands ≘ w hen PRESS = working ∧ HANDS = busy then HANDS := free end

Programming in the large - Lecture 17 156 Chair of Softw are Engineering

1st model: freeing the hands (case 2)

Press is working and hands are busy: one can

  • bserve that hands are freed and press is stopped.

stop_press_free_hands ≘ w hen PRESS = working ∧ HANDS = busy then PRESS, HANDS := stopped, free end

slide-53
SLIDE 53

53

Programming in the large - Lecture 17 157 Chair of Softw are Engineering

1st model: other events

busy_hands press_up close_front_door

  • pen_front_door

close_side_door

  • pen_side_door

stop_press_down press_down stop_press_open_front_door stop_press_open_side_door

Programming in the large - Lecture 17 158 Chair of Softw are Engineering

More on model structure: invariant and refinement

The variables of a m odel can be constrained by some invariant laws Proving that the invariant laws are maintained by the events. A model can be refined by Transform ing the existing events Adding new events Proving that the refinement is correct. This slide is the m ost im portant one.

Programming in the large - Lecture 17 159 Chair of Softw are Engineering

2nd model: modes and rules

The rules define the constraints to be followed when the press works. In mode M2, hands m ust be busy: mode = M2 ∧ PRESS = working

HANDS = busy mode ∈ {M1, M2, M3, M4, M5}

slide-54
SLIDE 54

54

Programming in the large - Lecture 17 160 Chair of Softw are Engineering

2nd model: rules (cont’d)

In mode M3, hands m ust be busy when the press goes down and after the stop at the upper point. In mode M3, the side door must be closed. mode = M3 ∧ PRESS = working

SIDE_DOOR = closed mode = M3 ∧ PRESS = working ∧ DIRECTION = down ∧ STOP_UPPER_POINT = yes

HANDS = busy

Programming in the large - Lecture 17 161 Chair of Softw are Engineering

2nd model: rules (cont’d)

In mode M4, the front door m ust be closed. In mode M4, the side door must be closed. mode = M4 ∧ PRESS = working

FRONT_DOOR = closed mode = M4 ∧ PRESS = working

SIDE_DOOR = closed

Programming in the large - Lecture 17 162 Chair of Softw are Engineering

2nd model: rules (cont’d)

In mode M5, the press is always stopped. When the press goes up, the stop at upper point is not done. mode = M5

PRESS = stopped DIRECTION = up ⇒ STOP_UPPER_POINT = no

slide-55
SLIDE 55

55

Programming in the large - Lecture 17 163 Chair of Softw are Engineering

2nd model: starting press (refined version)

Observe the guard strengthening.

start_press ≘ w hen PRESS = stopped ∧ mode = M2 ⇒ HANDS = busy ∧ mode = M3 ∧ DIRECTION = down ∧ STOP_UPPER_POINT = yes ⇒ HANDS = busy ∧ mode = M3 ⇒ SIDE_DOOR = closed ∧ mode = M4 ⇒ SIDE_DOOR = closed ∧ mode = M4 ⇒ FRONT_DOOR = closed ∧ mode ≠ M5 then PRESS := working end

Programming in the large - Lecture 17 164 Chair of Softw are Engineering

2nd model: freeing hands (1st case) (refined version)

Hands can be freed without stop in all modes except M2 in mode M3 only if the press goes up or if stop at upper point has not happened yet.

free_hands ≘ w hen PRESS = working ∧ HANDS = busy ∧ mode ≠ M2 ∧ mode = M3 ⇒ DIRECTION = up ∨ STOP_UPPER_POINT = no then HANDS := free end

Programming in the large - Lecture 17 165 Chair of Softw are Engineering

2nd model: freeing hands (2nd case) (refined version)

Hands have to be freed with a stop in modes M2 or M3 in mode M3 if the press goes down and if stop at upper point already occurs.

stop_press_free_hands ≘ w hen PRESS = working ∧ HANDS = busy ∧ mode ∈ {M2, M3} ∧ mode = M3 ⇒ DIRECTION = down ∧ mode = M3 ⇒ STOP_UPPER_POINT = yes then PRESS, HANDS := stopped, free end

slide-56
SLIDE 56

56

Programming in the large - Lecture 17 166 Chair of Softw are Engineering

3rd model: introducing motor and clutch

Abstract variable PRESS will disappear. One is going to link PRESS with MOTOR and

CLUTCH.

MOTOR ∈ {stopped, working} CLUTCH ∈ {disengaged, engaged}

Programming in the large - Lecture 17 167 Chair of Softw are Engineering

3rd model: the linking invariant

In modes M1 and M5, the motor is stopped. In mode M5, the clutch is disengaged. When the clutch is disengaged, the press is stopped. mode = M1 ⇒ MOTOR = stopped mode = M5 ⇒ MOTOR = stopped mode = M5 ⇒ CLUTCH = disengaged CLUTCH = disengaged ⇒ PRESS = stopped

Programming in the large - Lecture 17 168 Chair of Softw are Engineering

3rd model: the linking invariant (cont’d)

In mode M1, the press works if the clutch is engaged. In other modes (except M5), the press works if motor works and clutch is engaged. mode = M1 ∧ CLUTCH = engaged

PRESS = working mode ≠ M1 ∧ MOTOR = working ∧ CLUTCH = engaged

PRESS = working

slide-57
SLIDE 57

57

Programming in the large - Lecture 17 169 Chair of Softw are Engineering

3rd model: starting the press (refined version)

start_press ≘ w hen CLUTCH = disengaged ∧ mode ≠ M1 ⇒ MOTOR = working ∧ mode = M2 ⇒ HANDS = busy ∧ mode = M3 ∧ DIRECTION = down ∧ STOP_UPPER_POINT = yes ⇒ HANDS = busy ∧ mode = M3 ⇒ SIDE_DOOR = closed ∧ mode = M4 ⇒ SIDE_DOOR = closed ∧ mode = M4 ⇒ FRONT_DOOR = closed ∧ mode ≠ M5 then CLUTCH := engaged end

Programming in the large - Lecture 17 170 Chair of Softw are Engineering

3rd model: starting motor

start_motor ≘ w hen MOTOR = stopped ∧ CLUTCH = disengaged ∧ mode ≠ M1 ∧ mode ≠ M5 then MOTOR := working end

Before starting motor clutch must be disengaged.

Programming in the large - Lecture 17 171 Chair of Softw are Engineering

The five next models: treating equipment

4th model: Simplified clutch com mands. 5th model: Simplified model of movement. 6th model: The front door. 7th model: The side door. 8th model: Starting and stopping motor.

slide-58
SLIDE 58

58

Programming in the large - Lecture 17 172 Chair of Softw are Engineering

The next two models: refining treatments

9th model: Refining movement (the cam s). 10th model: Refining the clutch command.

Programming in the large - Lecture 17 173 Chair of Softw are Engineering

The last models

11th model: Changing modes and emergencies. 12th model: Delays and wire redundancies. 13th model: Refining the clocks. 14th model: Refining the mode changing.

Programming in the large - Lecture 17 174 Chair of Softw are Engineering

Summary: 20 sensors

Clutch sensor (3rd refinement), 2nd clutch sensor (11th refinement), Motor sensor (7th refinement), Left hand sensor (9th refinement), 2nd left hand sensor (11th refinement), Right hand sensor (9th refinement), 2nd right hand sensor (11th refinement), Foot sensor (3rd refinement), 2nd foot sensor (11th refinement),

slide-59
SLIDE 59

59

Programming in the large - Lecture 17 175 Chair of Softw are Engineering

Summary: 20 sensors (cont’d)

Front door sensor (5th refinement), 2nd front door sensor (11th refinement), Side door sensor (6th refinement), Upper cam sensor (8th refinement), Lower cam sensor (8th refinement), 2nd lower cam sensor (11th refinement), M1 sensor (13th refinem ent), M2 sensor (13th refinem ent), M3 sensor (13th refinem ent), M4 sensor (13th refinem ent), M5 sensor (13th refinem ent).

Programming in the large - Lecture 17 176 Chair of Softw are Engineering

Summary: 5 clocks

Bi-manual clock (9th refinement), Motor clock (11th refinement), Clutch clock (11th refinement), Mode clock (11th refinement), M1 clock (11th refinement).

Programming in the large - Lecture 17 177 Chair of Softw are Engineering

Summary: 9 emergency stops

Button (10th refinement), Brake (11th refinement), Cam (11th refinement), Front door (11th refinement), Motor (11th refinement), Clutch (11th refinement), Modes (13th refinement), Foot (11th refinement), Left hand (11th refinement), Right hand (11th refinement).

slide-60
SLIDE 60

60

Programming in the large - Lecture 17 178 Chair of Softw are Engineering

Summary: variables of the last refinement

9 environment variables, 26 sensor variables, 4 actuator variables, 12 clock variables, 32 controller variables.

Programming in the large - Lecture 17 179 Chair of Softw are Engineering

Summary: events of the last refinement

68 environment events, 89 controller events, 329 lines for constants, variables and initialization, 745 lines for environment events, 1536 lines for controller events. 5500 lines of assembly code for the controller.

Programming in the large - Lecture 17 180 Chair of Softw are Engineering

Summary: proofs (total, interactive)

1st refinement: 56, 6 2nd refinement: 15, 2 3rd refinement: 174, 4 4th refinement: 32, 0 5th refinement: 12, 0 6th refinement: 12, 0 7th refinement: 47, 2 8th refinement: 31, 7 9th refinement: 49, 0 10th refinement: 56, 1 11th refinement: 255, 19 12th refinement: 154, 19 13th refinement: 32, 0 TOTAL: 925, 60

slide-61
SLIDE 61

61

Programming in the large - Lecture 17 181 Chair of Softw are Engineering

End of lecture 17