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

Slides:



Advertisements
Similar presentations
Intermediate Code Generation
Advertisements

Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
Macro Processor.
Axiomatic Semantics The meaning of a program is defined by a formal system that allows one to deduce true properties of that program. No specific meaning.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Simple Example {i = 0} j := i * i {j < 100} Can we ‘verify’ this triple? Only if we know the semantics of assignment.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
Weakest pre-conditions and towards machine consistency Saima Zareen.
CS 355 – Programming Languages
Shaoying Liu Department of Computer Science
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der Humboldt.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
Detailed Design Kenneth M. Anderson Lecture 21
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
Describing Syntax and Semantics
Floyd Hoare Logic. Semantics A programming language specification consists of a syntactic description and a semantic description. Syntactic description:symbols.
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Fundamentals of Python: From First Programs Through Data Structures
Test coverage Tor Stålhane. What is test coverage Let c denote the unit type that is considered – e.g. requirements or statements. We then have C c =
Timed UML State Machines Ognyana Hristova Tutor: Priv.-Doz. Dr. Thomas Noll June, 2007.
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Verification of behavioural elements of UML models using B Truong, Ninh-Thuan and Souquieres, Jeanine In Proceedings of the 2005 ACM Symposium on.
1. 2 IMPLEMENTATION FragileStackI REFINES FragileStack IMPORTS FragStack_Vseq(ITEM, dep) INVARIANT FragStack_Vseq = items OPERATIONS putin(ii) = FragStack_PSH_SEQ(ii);
CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.
Chapter 3 Part II Describing Syntax and Semantics.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
Error Example - 65/4; ! Toplevel input: ! 65/4; ! ^^ ! Type clash: expression of type ! int ! cannot have type ! real.
1 Assertions. 2 A boolean expression or predicate that evaluates to true or false in every state In a program they express constraints on the state that.
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 26.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Course: Software Engineering – Design I IntroductionSlide Number 1 What is a specification Description of a (computer) system, which:  is precise;  defines.

Procedure Activations Programming Language. Exploration Name ocurrenceDeclarationLocationValue scopeactivationstate a.From names to their declarations.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
Propositional Logic. Assignment Write any five rules each from two games which you like by using propositional logic notations.
The B-Method of Formal Specification By: Marshall Leitem.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Recursion,
Chapter 3 of Programming Languages by Ravi Sethi
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Formal Methods in Software Engineering
Stacks Chapter 4.
B (The language of B-Method )
In-Class Exercises: Sample Spaces and Events
Mathematical Structures for Computer Science Chapter 1
Programming Languages 2nd edition Tucker and Noonan
Semantics In Text: Chapter 3.
Axiomatic Verification II
An algebraic expression that defines a function is a function rule.
Department of Computer Science Abdul Wali Khan University Mardan
Output Variables {true} S {i = j} i := j; or j := i;
M248: Analyzing data Block A UNIT A3 Modeling Variation.
CSE S. Tanimoto Lambda Calculus
Programming Languages and Compilers (CS 421)
Programming Languages 2nd edition Tucker and Noonan
Unit III – Chapter 3 Path Testing.
Presentation transcript:

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

2

3

4

5

6 B4free

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29 Exercise 1.7 A 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.

30 MACHINE CarPark VARIABLES contents INVARIANT contents : NAT & contents <= 640 INITIALIZATION contents := 0 OPERATIONS enter = PRE contents < 640 THEN contents := contents + 1 END; leave = PRE contents > 0 THEN contents := contents – 1 END; nn <-- query = PRE true THEN nn := contents END

31

32

33

34

35

36

37

38

39

40

41

42

43 houseset, magazine := {}, {}

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

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

92

93 Renaming bound variables to avoid variable capture If the variable being substituted does not occur free anywhere in the predicate then it is left unchanged.

94

95 Self test

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114 The set of all possible states a machine can be in.

115

116 See Page 26 of the B-method.

117

118

119

120

121

122 P is a predicate which describes a set of states that may be reached after 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 of any initial state from which is guaranteed to achieve P.

123

124 See Page 27 of the B-method.

125

126

127

128

129

130

131

132

133

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

135

136

137

138

139

140

141

142

143

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

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)

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-3<7)) = (x =5) & (x<10))

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169 MACHINE Info(ITEM, sample, num) CONSTRAINTSsample:ITEM & num : NAT & num > card(ITEM) CONSTANTSstorage PROPERTIESstorage : NAT1 & storage <= num VARIABLEScurrent, next, previous INVARIANTcurrent <: 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?

170 # ITEM, sample, num.( ITEM /= {} & sample : ITEM & num : NAT & num > card(ITEM) ) Proof obligation associated with the constraints:

171 (ITEM /={} & sample:ITEM & num:NAT & num > card(ITEM)) => # storage. (storage : NAT1 & storage <= num) Proof obligation: It must be possible to find appropriate SETS and CONSTANTS.

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 be possible for the machine to have variables that satisfy the invariant. What if ITEM={a}?

173 Summary of Proof Obligations:

174

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

176 Completing the Laws of [S]P

177

178

179

180 Non-determinism:

181

182

183

184 Sequences