formal engineering methods for software development --an introduction to sofl-- shaoying liu...

31
Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information S ciences Hosei University Email: [email protected] URL: http://cis.k.hosei.ac.jp/~sliu/

Upload: david-patterson

Post on 18-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Formal Engineering Methodsfor Software Development--An Introduction to SOFL--

Shaoying Liu

Department of Computer Science

Faculty of Computer and Information Sciences

Hosei University

Email: [email protected]

URL: http://cis.k.hosei.ac.jp/~sliu/

Page 2: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

2006年4月9日の朝日新聞

Page 3: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Textbook and References

The textbook:

“Formal Engineering for

Industrial Software

Development Using the SOFL Method”,

by Shaoying Liu,

Springer-Verlag, 2004,

ISBN 3-540-20602-7

Page 4: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

1. Introduction

• Problems in software development

• Formal methods for the problems

• Challenges to formal methods

• Formal engineering methods for the challenges

• SOFL: a specific formal engineering method

Page 5: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

1.1 Problems in software development

S P Construct

Specification Program

How to ensure that S is not ambiguous so that it can be correctly understood by all the people involved?

How can S be effectively used for inspecting and testing P?

How can software tools effectively support the analysis of S, transformation from S to P, and verification of P against S?

What to do How to do it

Page 6: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

An example of informal specification:

“A software system for an Automated Teller Machine (ATM) needs to provide services on various accounts. The services include operations on current account, operations on savings account, transferring money between accounts, managing foreign currency account, and change password. The operations on a current or savings account include deposit, withdraw, show balance, and print out transaction records.”

Page 7: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

A better way to write the same specification:

“A software system for an automated teller machine (ATM) needs to provide services on various accounts.

The services include ① operations on current account② operations on savings account③ transferring money between accounts④ managing foreign currency account, ⑤ change password.

The operations on a current or savings account include ① deposit② withdraw③ show balance④ print out transaction records.”

Page 8: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

The major problems with informal specifications:

Informal specifications are likely to be ambiguous, which is likely to cause misinterpretations.

Informal specifications are difficult to be used for inspection and testing of programs because of the big gap between the functional descriptions in the specifications and the program structures.

Informal specifications are difficult to be analyzed for their consistency and validity.

Information specifications are difficult to be supported by software tools in their analysis, transformation, and management (e.g., search, change, reuse).

Page 9: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

A possible solution to these problems:

Formal Methods!!!

Page 10: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

1.2 Formal methods for the problems

What is formal methods?

Formal methods = Formal Specification

+

Refinement

+

Formal Verification

Set theory, logics, algebra, etc.

Shaoying Liu
形式的手法
Shaoying Liu
形式的手法
Page 11: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Formal methods can also be understood as the following three

components:

• Formal notation (or language) for writing specifications.

• Logical calculus for formal verification (or proof)

• Method for developing software systems.

Page 12: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

SpecificationImplementation

Refinement

Verification

What to do How to do it

From the abstract to the concrete

Check the correctness

Page 13: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Testing

Requirements analysis

Design

Coding

Formal Specification

Validation

Verification

Verification

Page 14: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

The question of our interest is:

How to write a formal specification?

Many formal notations have been

developed for writing formal specifications

and the most commonly used ones

include VDM, Z, and B.

Page 15: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

The most commonly used formal methods

(1) VDM-SL (Vienna Development Method – Specification Language), IBM Research Laboratory in Vienna References:

(1) “Systematic Software Development Using VDM’’, by Cliff B. Jones, 2nd edition, Prentice Hall,1990.

(2) “Modelling Systems”, by John Fitzgerald and Peter Gorm Larsen, Cambridge University Press,1998.

Page 16: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Operation specification:

OperationName(input)output

ext State variables

pre preconiditon

post postcondition

Example:

Add(x : nat) y : nat

ext rd z : nat /*z is an external variable */

pre true

post y > x + z

Page 17: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Operations are organized into modules:

module A

local variables declarations

invariant declarations

operation specification1;

operation specification2;

operation specificationn;

end

Page 18: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

(2) Z, PRG (Programming Research Group), the

University of Oxford, UK

References:

(1) “The Z Notation”, by J.M. Spivey,

Prentice Hall, 1989.

(2) “Using Z: Specification, Refinement, and Proof’’, by Jim Woodcock and Jim Davies,

Prentice Hall, 1996.

Page 19: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

A Z specification is composed of a set of

schemas and possibly their sequential

compositions.

A schema can be used to define global variables,

state variables, and operations.

Axiomatic schema for defining global variables:

age: N

age > 0

declaration

predicate

Page 20: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

A schema for defining state variables:

BirthdayBook

Known: P NAME

birthday: NAME → DATE

known = dom birthday

Page 21: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

AddBirthday△BirthdayBook

name?: NAME

date?: DATE

name? ∉ known

birthday’ = birthday {name? → date?}∪

A schema for defining an operation:

Page 22: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

(3) B-Method, Jean-Raymond Abrial, France

References:

(1) “The B-Book: Assigning Programs to Meanings”, by J-R Abrial,

Cambridge University Press,1996, A B specification is composed of a set of related abstract machines. Each abstract machine is a module that contains a set of operation definitions. Each operation is defined using pre- and postconditions.

Page 23: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

1.3 Challenges to formal methods

Formal specifications of large-scale and complex software systems can be difficult to write, to read, and to understand for many engineers in industry.

Communications between clients and developers via formal specifications can be difficult.

Modifications of formal specifications for consistency during a project can be time-consuming and costly.

Formal verification is difficult to perform and is not cost-effective for the assurance of program correctness.

The tool support does not necessarily reduce the difficulty of using formal methods.

Page 24: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

1.4 Formal engineering methods for the challenges

Formal Engineering Methods (FEM) provide

a way to integrate Formal Methods into the

entire software development process to

achieve rigor (methodology),

comprehensibility (human), and tool

supportability (tool) of software process.

Page 25: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Application of Formal Methods in Software Engineering

Formal EngineeringMethods

Formal Methods

Page 26: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

The difference between FM and FEM

FM answers the question: what should we do and why?

FEM answers the question: what can we do and how?

Page 27: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

1.5 SOFL: a specific formal engineering method

SOFL stands for Structured Object-oriented

Formal Language

Started at the University of Manchester, UK

in 1989.

Completed at Hiroshima City University.

Finalized at Hosei University in 2000.

Page 28: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

SOFL = Language + Method + Process

As a language, SOFL supports proper combination of graphical and formal notations for constructability, comprehensibility, and maintainability.

As a method, SOFL adopts formal specification for developing systems, and specification-based inspection and testing for verification and validation. It also combines the structured method and object-oriented method for software development.

As a process, SOFL adopts both evolution and refinement, and emphasizes the paradigm of first specification and then incremental implementation.

Page 29: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

A general structure of a SOFL specification

const; type; var; inv;method Init;

method P1;

method P2;

method P3;

const; type; var; inv;

method Init;

method Q1;

method Q2;

method Q3;

const; type; var; inv;

const; type; var; inv;

A1 A2

B1

B2

B3

class S1;

class S2;

end_class;

end_class;

module SYSTEM;

module A2_Decom;

end_module;

end_module;

process Init;

process A1;

process A2;

process Init;

process B1;

process B2;

process B3;

Page 30: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Component

Architecture

Page 31: Formal Engineering Methods for Software Development --An Introduction to SOFL-- Shaoying Liu Department of Computer Science Faculty of Computer and Information

Exercise 1

1.Answer the following questions.

a.What is software life cycle?b.What is the problem with informal approaches to software

development?c.What are formal methods?d.What are the major features of formal engineering methods?e.What is SOFL?

2.Explain the role of specification in software development.

3.Give an example of using a method similar to formal methods to build other kinds of systems rather than software systems.