Formal Methods in Software Engineering

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Design by Contract.
Looking inside classes Fields, Constructors & Methods Week 3.
Programming with Microsoft Visual Basic 2008 Fourth Edition
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.
Weakest pre-conditions and towards machine consistency Saima Zareen.
1.2 Row Reduction and Echelon Forms
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Drawing System Sequence Diagrams
CS 582 / CMPE 481 Distributed Systems Fault Tolerance.
An Introduction to Input/Output Automata Qihua Wang.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Automating Tasks With Macros
Fall 2007CS 225 Introduction to Software Design Chapter 1.
Axiomatic Semantics Dr. M Al-Mulhem ICS
Using Objects and Properties
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
CS 201 Functions Debzani Deb.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
Lesson 6. Refinement of the Operator Model This page describes formally how we refine Figure 2.5 into a more detailed model so that we can connect it.
Describing Syntax and Semantics
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Understanding class definitions Looking inside classes.
Spring 2009CS 225 Introduction to Software Design Chapter 1.
Winter 2012SEG Chapter 11 Chapter 1 (Part 2) Introduction to Requirements Modeling.
SE-565 Software System Requirements More UML Diagrams.
Systems Analysis I Data Flow Diagrams
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
Interaction Modeling. Introduction (1) Third leg of the modeling tripod. It describes interaction within a system. The class model describes the objects.
Introduction to Software Design Chapter 1. Chapter Objectives  To become familiar with the software challenge and the software life cycle  To understand.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
1 Lecture 6: Operation Contracts. 2 Overview  What is contract ?  The guidelines for writing contracts for the system operations.  Use Case realizations.
An Ontological Framework for Web Service Processes By Claus Pahl and Ronan Barrett.
Chapter 10 Analysis and Design Discipline. 2 Purpose The purpose is to translate the requirements into a specification that describes how to implement.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
A Use Case Primer 1. The Benefits of Use Cases  Compared to traditional methods, use cases are easy to write and to read.  Use cases force the developers.
Unit 2 Architectural Styles and Case Studies | Website for Students | VTU NOTES | QUESTION PAPERS | NEWS | RESULTS 1.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Covenant College November 27, Laura Broussard, Ph.D. Professor COS 131: Computing for Engineers Chapter 5: Functions.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Structure Programming Lecture 8 Chapter 5&6 - Function – part I 12 December 2015.
ECSE Software Engineering 1I HO 4 © HY 2012 Lecture 4 Formal Methods A Library System Specification (Continued) From Specification to Design.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering 2 -Prakash Shrestha.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Interface specifications At the core of each Larch interface language is a model of the state manipulated by the associated programming language. Each.
1 Object Oriented Analysis and Design System Events & Contracts.
1 Team Skill 3 Defining the System Part 1: Use Case Modeling Noureddine Abbadeni Al-Ain University of Science and Technology College of Engineering and.
COMPONENT & DEPLOYMENT DIAGRAMS
About the Presentations
Formal Methods in Software Engineering
Structural testing, Path Testing
B (The language of B-Method )
Sequence Diagrams Lecture 6.
Abstract Class As per dictionary, abstraction is the quality of dealing with ideas rather than events. For example, when you consider the case of ,
Output Variables {true} S {i = j} i := j; or j := i;
Presentation transcript:

Formal Methods in Software Engineering Saima Zareen

Formal Specification of a System Formal Specification describes the System behavior Operations of system Problem with formal specification is large amount of detailed information which is required for accurate system specification. A structured approach is required. The basic building block of a specification is abstract machine. Large specification can be constructed from smaller ones. AMN (abstract Machine Notation ) is used.

Compositional structuring Abstract Machines The combination of abstract machine is also an abstract machine permitting hierarchical specification. Abstract Machines It is the specification of a system. It contains pieces of information, that describes various aspects of the specification. Specification must describe what the component should do?(Operations,Functions). Operations/Functions Take inputs from the user Supply outputs to the user. Affect any change within the component.

Components/parts of Abstract machines Interface Collection of operations by which machine interacts with environment. Components/parts of Abstract machines It is required by the machine to maintain or process information. For this a local state is required. State is mentioned by the local variables. State variables are listed under VARIABLES heading. INVARIANT Their types and any other information are listed. The information which must be true of the state. For example type of variable must not be changed during the execution.

INITIALISATION Machine Name Represents initial state Machine must have a name ,so that other machines can refer to it. The name is given under the heading MACHINE. Machine It is not like an object in object oriented sense. It has a name, internal state, and set of operations as do objects. It may be considered as a black box with buttons on the side corresponding to the operations, and a set of state variables inside.

Abstract machine Interaction must be through these buttons.

Example of abstract machine Consider the example of ticket dispenser, which is used in shop to order the queue. On entry to the shop customer takes a numbered ticket from the dispenser. When a sales assistant is ready to serve, a display indicates the number of the customer who is to be served next. Customers wait until it is their turn to be served. The system is pictured in figure

A ticketing System

The behavior of ticket system can be represented using abstract machine. First of all name the machine as MACHINE Ticket

VARIABLES To maintain the state of a system we define variables, a variable should be of the type which is suitable to express kind of value it can store. How the systems are understood rather than implemented. In terms of values, sets, relations, sequences . A variable can be of the type N, natural numbers set(0,1,2,…..). In the example we have two kind of tickets Ticket number being served Number of Next ticket to be dispensed. We can model with variables: next serve

VARIABLES serve, next INVARIANT Provides information about the variables of the machine It gives type of values of variable Restrictions on their possible values Relationships to each other Values of variables may change but it describes the properties of the variables which must be true during execution process. Type of variable is expressed as: Either an element of a set var € TYPE Subset of a set var⊑ TYPE. Var=expression

INVARIANT serve € N ⋀ next € N ⋀ serve ≤ next At least one invariant clause should be defined for each variable. Listed Next € N Sreve € N Furthure restrictions imposed by the operation can also be added In Ticket machine number being served must be less than the number of the ticket to be given out. server≤next INVARIANT serve € N ⋀ next € N ⋀ serve ≤ next

OPERATIONS It has following parts The name of the operation Input parameters Output parameters What the operation requires.(restrictions, conditions) What the operation modifies (variables that are modified) The effects or behavior of the operation(what the operation does). In B, operation is described in a structured way Name, input, output parameters of an operation are given by an operation header Outputs⃖ name(inputs) Where name refers to operation name, outputs is a list of output and inputs is a list of inputs

Inputs and outputs are optional parameters. Name must be given Inputs and outputs are optional parameters. Ticket machine will offer two operations One to serve customer and update the indicator board To provide the customer with the next ticket. Ss⃖serve_next tt ⃖ take_ticket Operation has precondition, It states that what the operation requires in order to behave correctly. Information of all input variables. Assumptions/state of the inputs

The requirements on the user to ensure that the requirements are met whenever the operation is called. For example, the serve_next operation will be called when the sales assistant has finished serving a customer. In this case serve must be less than next. If the shop is empty, then the value of serve will be the same as next. Thus the precondition will be serve ≤next Body of the operation, describes what the operation achieves. It must assign some value to one of the outputs. Output should be in terms of initial state and input values. Update the state of the variable

In AMN assignment is written as x:=E (pronounced x becomes E) In case of serve_next, Serve should be incremented Output should be incremented to show state serve. In AMN assignment is written as x:=E (pronounced x becomes E) Serve:= serve+1 Output of this operation is assigned the same value Ss, serve:=serve+1,serve+1. Body shows the states, there is no intermediate statement in the operation, therefore multiple assignments must be shown in simultaneous assignment, rather than a sequence of assignments one after the other.

The complete specification of the operation serve_next is as follows

Type of the output variable ss is given by the assignment, there is no need to declare its type. It is determined from the operation. After the execution of operation it must guarantee that the invariant is still true on the updated state. Then the operation is consistent. Is the operation serve_next consistent with the inavriant? If the precondition is weaker then there will be the chance of inconsistency with its variant.

Strengthening the precondition of serve_next to serve<next imposes more constraints on the user. Then the operation becomes consistent. Operation take_ticket

If a precondition is true, it may be dropped from the specification

Is consistent with the invariant of the Ticket machine?

INITIALISATION serve, next:=0,0 Describes possible initial state of the machine. All variables listed must be initialised. The Ticket machine should start with 0 on the display board, 0 is the number of the first ticket to be taken. INITIALISATION serve, next:=0,0 INITILISATION can only be consistent if initial states are correct with respect to the invariant.

complete Specification of Ticket machine

Set Theory The B method makes use of the language of set theory and logic with in AMN in order to express these requirements in a formal and precise way. Set Collection of entities of some sort. Notation for set membership is e € S, pronounced e is a member of S for a set S and element e. Finite set Naming Convention of set in B Names of given sets are in upper case SMALLSQUARE={4, 16, 0, 1,9}

Empty set Set comprehension {} Set can be defined as a collection of elements of some type which meet a particular property. SMALLSQUARE

Segment of the natural numbers can be expressed using the notation m…n, which defines the set of numbers between m and n Subset If all the members S are also the members of another set then S is said to be a subset of T S ⊑T

Set combinations If S and T are both sets ,then their union S⊔ T is another set which contains elements that appear in either S or T.. Generalized union ⊔ SS over set of SS. Elements that appear in any set S€ SS. Intersection The intersection of S∩T of two sets is the set of elements that are in both S and T. Generalized intersection ∩SS over a set of sets SS. The set of elements that appear in every set S€ SS. If S∩T={} then S and T are said to be disjoint

Set Subtraction Subset S-T is used to obtain the set of members of S which are not members of T. For example CHESS_GO is the set of all chess players who do not play GO. Subset Sets which contain only elements from S. Empty set {} is always one such set. SET={alice,bob} {} {alice} {bob} {alice, bob}

Power set Cartesian Product The collection of subsets of S is called power set and written as Cartesian Product S x T of two sets S and T will be the set of ordered pairs of elements (s, t) In which s€ S for the first element of the pair, and T€ T for the second element.

The Cartesian product is the set of all possible pairings of such elements. For example {alice, bob} and {home, work} {alice, home} {alice, work} {bob, home} {bob, work} The Cartesian product of two sets is given by

Set theoretic notation

The size or cardinality of set s is written card(S). It is the number of elements it contains. For example Card({alice, bob}) = 2 Task