1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book,...

184
1 “B is a method for specifying, designing, and coding software systems.” J.R. Abrial, The B-Book, Cambridge University Press

description

3

Transcript of 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book,...

Page 1: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

1

“B is a method for specifying, designing, and coding software systems.”J.R. Abrial, The B-Book, Cambridge University Press

Page 2: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

2

Page 3: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

3

Page 4: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

4

Page 5: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

5

Page 6: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

6

B4free

Page 7: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

7

Page 8: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

8

Page 9: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

9

Page 10: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

10

Page 11: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

11

Page 12: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

12

Page 13: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

13

Page 14: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

14

Page 15: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

15

Page 16: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

16

Page 17: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

17

Page 18: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

18

Page 19: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

19

Page 20: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

20

Page 21: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

21

Page 22: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

22

Page 23: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

23

Page 24: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

24

Page 25: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

25

Page 26: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

26

Page 27: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

27

Page 28: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

28

Page 29: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

29

Exercise 1.7A car park has 640 parking spaces. Give an abstract machine which specifies a system to control cars entering the car park. It should keep track of the cars currently in the car park, and should provide 3 operations:– Enter, which recorders the entry of a new car.

This should occur only when the car park is not full;

– Leave, which records the exit of a car from the car park;

– Query, which outputs the number of cars currently in the car park.

Page 30: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

30

MACHINE CarParkVARIABLES contentsINVARIANT contents : NAT & contents <= 640INITIALIZATION contents := 0OPERATIONSenter =

PRE contents < 640THEN contents := contents + 1END;

leave =PRE contents > 0THEN contents := contents – 1END;

nn <-- query =PRE trueTHEN nn := contentsEND

END

Page 31: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

31

Page 32: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

32

Page 33: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

33

Page 34: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

34

Page 35: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

35

Page 36: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

36

Page 37: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

37

Page 38: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

38

Page 39: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

39

Page 40: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

40

Page 41: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

41

Page 42: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

42

Page 43: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

43houseset, magazine := {}, {}

Page 44: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

44

Page 45: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

45

Page 46: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

46

Page 47: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

47

Page 48: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

48

Page 49: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

49

Page 50: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

50

Page 51: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

51

Page 52: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

52

Page 53: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

53

Page 54: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

54

Page 55: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

55

Page 56: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

56

Page 57: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

57

Page 58: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

58

Page 59: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

59

Page 60: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

60

Page 61: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

61

Page 62: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

62

Page 63: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

63

Page 64: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

64

Page 65: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

65

Page 66: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

66

Page 67: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

67

Page 68: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

68

t parentancestor

parentyzparentzx

PERSONzzyxparentancestor

,,.,

Page 69: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

69

Page 70: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

70

Page 71: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

71

Page 72: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

72

Page 73: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

73

Page 74: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

74

Page 75: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

75

Page 76: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

76

Page 77: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

77

Page 78: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

78

Page 79: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

79

Page 80: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

80

Page 81: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

81

Page 82: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

82

Page 83: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

83

Page 84: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

84

Page 85: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

85

Page 86: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

86

Page 87: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

87

Page 88: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

88

Page 89: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

89

Page 90: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

90

Page 91: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

91

Substitutions

xEP /

Expression E is substituted for a free variable x byreplacing all occurrences of x by E.Read as P with E for x.

GOaliceCHESSalice

xaliceGOxCHESSx

/

Page 92: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

92

zyxxyzyxyx /

2)(.

/2)(.

oldlimitpagePERSONpp

limitoldlimitlimitpagePERSONpp

Page 93: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

93

3.

/3./3.

nmmmlimitnlimitmmm

limitnlimitnnn

Renaming bound variables to avoid variable capture

limitmmm

nlimitmmmnlimitnnn

./50.

/50.

If the variable being substituted does not occur free anywhere inthe predicate then it is left unchanged.

Page 94: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

94

nxxxGFEP ,...,/,..., 21

zyxyx

yxzyxyxyx

,/,

Page 95: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

95

Self test

servennextnnservenn

serveservenextnnservenn

/4.)2(

/14.)1(

2

2

Page 96: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

96

Page 97: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

97

Page 98: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

98

Page 99: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

99

Page 100: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

100

Page 101: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

101

Page 102: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

102

Page 103: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

103

Page 104: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

104

Page 105: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

105

Page 106: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

106

Page 107: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

107

Page 108: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

108

Page 109: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

109

Page 110: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

110

Page 111: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

111

Page 112: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

112

Page 113: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

113

Page 114: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

114

The set of all possiblestates a machine canbe in.

Page 115: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

115

Page 116: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

116

See Page26 of theB-method.

Page 117: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

117

Page 118: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

118

Page 119: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

119

Page 120: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

120

Page 121: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

121

Page 122: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

122

P is a predicate which describes a set of states that may be reachedafter the performance of statement S.P is referred to as the post condition of S.

The notation [S]P denotes a predicate which is true ofany initial state from which is guaranteed to achieve P.

Page 123: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

123

Page 124: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

124

See Page27 of theB-method.

Page 125: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

125

Page 126: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

126

Page 127: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

127

Page 128: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

128

Page 129: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

129

Page 130: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

130

Page 131: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

131

Page 132: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

132

Page 133: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

133

Page 134: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

134

[hh := min(houseset)](!hh.(hh:houseset=> hh < 163))

Page 135: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

135

Page 136: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

136

Page 137: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

137

Page 138: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

138

Page 139: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

139

Page 140: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

140

Page 141: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

141

Page 142: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

142

Page 143: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

143

Page 144: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

144

[a(4) := 7](a : NAT1 >+> NAT)

= (a <+ {(4,7)}) : NAT1 >+> NAT

= ({4} <<| a) : NAT1 >+> NAT &7 /: ran({4} <<| a)

Page 145: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

145

Other Constructs

[IF E THEN S ELSE T END]P =(E & [S]P) or (not(E) & [T]P)

[IF E THEN S ELSE T END]P =(E => [S]P) or (not(E) => [T]P)

Page 146: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

146

[IF x<5 THEN x:=x+4 ELSE x:=x-3 END] (x<7)

= (x<5 & [x:=x+4](x<7)) or((not(x<5)) & [x:=x-3](x<7))

= (x<5 & (x+4<7)) or ((x>=5) & (x-3<7))

= (x<5 & x<3) or ((x>=5) & (x<10))

= (x<3) or ((x>=5) & (x<10))

Page 147: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

147

Page 148: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

148

Page 149: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

149

Page 150: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

150

Page 151: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

151

Page 152: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

152

Page 153: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

153

Page 154: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

154

Page 155: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

155

Page 156: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

156

Page 157: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

157

Page 158: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

158

Page 159: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

159

Page 160: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

160

Page 161: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

161

Page 162: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

162

Page 163: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

163

Page 164: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

164

Page 165: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

165

Page 166: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

166

Page 167: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

167

Page 168: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

168

Page 169: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

169

MACHINE Info(ITEM, sample, num)CONSTRAINTS sample:ITEM &

num : NAT &num > card(ITEM)

CONSTANTS storagePROPERTIES storage : NAT1 &

storage <= num

VARIABLES current, next, previous

INVARIANT current <: ITEM &next : ITEM &previous : ITEM &next /= previous

Exercise 5.1 Page 67 “the b-method”What are the proof obligations associated with the constraints below?Are they consistent?

Page 170: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

170

# ITEM, sample, num .(ITEM /= {} &sample : ITEM &num : NAT &num > card(ITEM))

Proof obligation associated with the constraints:

Page 171: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

171

(ITEM /={} & sample:ITEM & num:NAT & num > card(ITEM))

=>

# storage . (storage : NAT1 & storage <= num)

Proof obligation: It must be possible to find appropriateSETS and CONSTANTS.

Page 172: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

172

( ITEM /={} & sample:ITEM & num:NAT &num>card(ITEM) &

storage : NAT1 & storage <= num )=># current, next, previous . (

current <: ITEM &next : ITEM &previous : ITEM &next /= previous

)

Proof obligation: When all the parameters are set it must bepossible for the machine to have variables that satisfy theinvariant.

What ifITEM={a}?

Page 173: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

173

END S THEN P PRE operationeach for

][ 5.][ 4.. 3.., 2.

. 1.

ISPICBITCBIvCBBkStC

Cp

Summary of Proof Obligations:

Page 174: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

174

Page 175: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

175

• Self tests (from “the b-method”)– Exercise 5.2 page 68– Exercise 6.3 Page 89

Page 176: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

176

Completing the Laws of [S]P

nnnn xxEEPPEExx

yxFEPPFEyx

xEPPEx

,...,/,...,,...,:,...,

,/,,:,

/:

1111

Page 177: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

177

PP skip

PTEPSE

PTSE

ENDELSETHENIF

PTEPSE

PTSE

ENDELSETHENIF

?ENDTHENIF PSE

Page 178: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

178

PVeEeEeEPTeE

PTeEPTeE

P

VTe

TeTe

E

n

nnnn ...

...

ENDELSE

THENOR...OR

THENORTHENEITHER

OFCASE

21

22

11

22

11

Page 179: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

179

aEiaPPEia /,:)(

Page 180: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

180

PTQx

PTQx

.

ENDTHENWHEREANY

Non-determinism:

PTQxx

PTQxx

n

n

.,...,ENDTHENWHERE,...,ANY

1

1

xzPSzzPSx /.:

Page 181: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

181

PSExx

PSExxLET

.

ENDINBE

Page 182: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

182

PTPSPTS ENDORCHOICE

PSPSPS

PSSS

n

n

...END...ORORCHOICE

21

21

Page 183: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

183

Page 184: 1 B is a method for specifying, designing, and coding software systems. J.R. Abrial, The B-Book, Cambridge University Press.

184

• Sequences