Software Engineering: A Practitioner s s Approach, 6/e Roger Pressman. Chapter 28 Formal Methods

Similar documents
SOFTWARE ENGINEERING REQUIREMENTS ANALYSIS AND SPECIFICATION. Saulius Ragaišis.

Programming Languages Third Edition

Chapter 3. Describing Syntax and Semantics

LOGIC AND DISCRETE MATHEMATICS

Contents. Chapter 1 SPECIFYING SYNTAX 1

Formal Methods. CITS5501 Software Testing and Quality Assurance

Metamodeling with Metamodels. Using. UML/MOF including OCL

An Annotated Language

Semantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics

LECTURE 8: SETS. Software Engineering Mike Wooldridge

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Formal Methods in Software Design. Markus Roggenbach

This book is licensed under a Creative Commons Attribution 3.0 License

Agenda. More on the Unified Modeling Language. UML diagram types. Packages

Chapter 3. Describing Syntax and Semantics ISBN

Formal Specification: Z Notation. CITS5501 Software Testing and Quality Assurance

CSC 501 Semantics of Programming Languages

Chapter 3. Describing Syntax and Semantics ISBN

Introductory logic and sets for Computer scientists

Chapter 3 (part 3) Describing Syntax and Semantics

An Evolution of Mathematical Tools

LECTURE 17. Expressions and Assignment

FreePascal changes: user documentation

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Chapter 7:: Data Types. Mid-Term Test. Mid-Term Test (cont.) Administrative Notes

Chapter 3. Describing Syntax and Semantics

Axiomatic Specification. Al-Said, Apcar, Jerejian

CS 242. Fundamentals. Reading: See last slide

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

CSC Discrete Math I, Spring Sets

In Our Last Exciting Episode

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs?

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CITS5501 Software Testing and Quality Assurance Formal methods

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor

! Use of formal notations. ! in software system descriptions. ! for a broad range of effects. ! and varying levels of use. !

1 Lexical Considerations

Com S 541. Programming Languages I

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Lexical Considerations

Research Collection. Reusable mathematical models. Master Thesis. ETH Library. Author(s): Widmer, Tobias K. Publication Date: 2004

Solving the TTC 2011 Model Migration Case with UML-RSDS

Programming Languages

SOFTWARE ENGINEERING DESIGN I

Chapter 8, Object Design: Object Constraint Language

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

JOURNAL OF OBJECT TECHNOLOGY

A Small Permutation Group Engine by: Gregory Kip. COMS W4115 Programming Languages and Translators Prof. Stephen Edwards

From OCL to Typed First-order Logic

Lexical Considerations

Formal Foundations of Software Engineering

From OCL to Propositional and First-order Logic: Part I

FUZZY SPECIFICATION IN SOFTWARE ENGINEERING

Relational Databases

MIDTERM EXAMINATION. CSE 130: Principles of Programming Languages. Professor Goguen. February 16, points total

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

TIME-BASED CONSTRAINTS IN THE OBJECT CONSTRAINT LANGUAGE OCL

Summary of Course Coverage

Lambda Calculus. Gunnar Gotshalks LC-1

22c:111 Programming Language Concepts. Fall Types I

Virtual World Development

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

Introduction to Axiomatic Semantics

Runtime Checking for Program Verification Systems

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Models versus Ontologies - What's the Difference and where does it Matter?

CSE 307: Principles of Programming Languages

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

Formal Systems and their Applications

Chapter 4 Fuzzy Logic

COMPUTATIONAL SEMANTICS WITH FUNCTIONAL PROGRAMMING JAN VAN EIJCK AND CHRISTINA UNGER. lg Cambridge UNIVERSITY PRESS

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

Chapter 3: Syntax and Semantics. Syntax and Semantics. Syntax Definitions. Matt Evett Dept. Computer Science Eastern Michigan University 1999

Relational Database: The Relational Data Model; Operations on Database Relations

CMSC 330: Organization of Programming Languages

Ingegneria del Software Corso di Laurea in Informatica per il Management. Introduction to UML

Ian Kenny. November 28, 2017

Formal languages and computation models

Lecture 11 Lecture 11 Nov 5, 2014

Architectural Models and Styles Component-Based Software Engineering ECE493-Topic 5 Winter 2007 Lecture 12 The Object Constraint Language (Part A)

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

Language Reference Manual simplicity

Formal Methods in Software Engineering 1

Lecture 5. Logic I. Statement Logic

Fortgeschrittene objektorientierte Programmierung (Advanced Object-Oriented Programming)

6. Discuss how producer-consumer problem and Dining philosophers problem are solved using concurrency in ADA. [16]

Programming Languages Third Edition. Chapter 7 Basic Semantics

Specification-based Testing of Embedded Systems H. Schlingloff, SEFM 2008

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement

CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T

SCHOOL OF COMPUTING, MATHEMATICAL AND INFORMATION SCIENCES Semester 2 Examinations 2008/2009. CI311 Specification and Refinement

Computing Fundamentals 2 Introduction to CafeOBJ

1.1 Software Life Cycle

Syntax. A. Bellaachia Page: 1

3. DESCRIBING SYNTAX AND SEMANTICS

Transcription:

Software Engineering: A Practitioner s s Approach, 6/e Roger Pressman Chapter 28 Formal Methods 1

Problems with Conventional Specification contradictions ambiguities vagueness incompleteness mixed levels of abstraction 2

Formal Specification Desired properties - consistency, completeness,, and lack of ambiguity - are the objectives of all specification methods The formal syntax of a specification language enables requirements or design to be interpreted in only one way, eliminating ambiguity that often occurs when a natural language (e.g., English) or a graphical notation must be interpreted The descriptive facilities of set theory and logic notation enable clear statement of facts (requirements). Consistency is ensured by mathematically proving that initial facts can be formally mapped (using inference rules) into later statements ents within the specification. 3

Formal Methods Concepts data invariant a a condition that is true throughout the execution of the system that contains a collection of data state Many formal languages, such as Object Constraint Language (OCL), use the notion of states, that is, a system can be in one of several states, each representing an externally observable mode of behavior. The Z language defines a state as the stored data which a system accesses and alters operation - an action that takes place in a system and reads or writes data to a state precondition defines the circumstances in which a particular operation is valid postcondition defines what happens when an operation has completed its action 4

An Example Print Spooler Device queues LP1 LP2 LAS1 LAS2 files awaiting printing ftax newdata exres persons Limits Size LP1 -> 750 LP2 -> 500 LAS1 -> 300 LAS2 -> 200 newdata -> 450 ftax -> 650 exres -> 50 persons -> 700 5

States and Data Invariant The state of the spooler is represented by the four components Queues, OutputDevices, Limits, and Sizes. The data invariants are: Each output device is associated with an upper limit of print lines Each output device is associated with a possibly nonempty queue of files awaiting printing Each file is associated with a size Each queue associated with an output device contains files that each have a size less than the upper limit of the output device There will be no more than MaxDevs output devices administered by the spooler 6

Operations An operation which adds a new output device to the spooler together with its associated print limit An operation which removes a file from the queue associated with a particular output device An operation which adds a file to the queue associated with a particular output device An operation which alters the upper limit of print lines for a particular output device An operation which moves a file from a queue associated with an output device to another queue associated with a second output device 7

Pre- & Postconditions For the first operation (adds a new output device to the spooler together with its associated print limit): Precondition: the output device name does not already exist and that there are currently less than MaxDevs output devices known to the spooler Postcondition: the name of the new device is added to the collection of existing device names, a new entry is formed for the device with no files being associated with its queue, and the device is associated with its print limit. 8

Mathematical Concepts sets and constructive set specification set operators logic operators e.g., i, j: i > j i 2 => j 2 which states that, for every pair of values in the set of natural numbers, if i is greater than j, then i 2 is greater than j 2. sequences 9

Sets and Constructive Specification A set is a collection of objects or elements and is used as a cornerstone of formal methods. Enumeration {C++, Pascal, Ada,, COBOL, Java} #{C++, Pascal, Ada,, COBOL, Java} implies cardinality = 5 Constructive set specification is preferable to enumeration because it enables a succinct definition of large sets. {x, y : N x + y = 10} 10

Set Operators A specialized set of symbols is used to represent set and logic operations. Examples The operator is used to indicate membership of a set. For example, the expression x X The operators, and # take sets as their operands. The predicate A B has the value true if the members of the set A are contained in the set B and has the value false otherwise. The union operator,,, takes two sets and forms a set that contains all the elements in the set with duplicates eliminated. {File1, File2, Tax, Compiler} {NewTax,, D2, D3, File2} is the set {Filel,, File2, Tax, Compiler, NewTax,, D2, D3} 11

Logic Operators Another important component of a formal method is logic: the algebra of true and false expressions. Examples: V or not => implies Universal quantification is a way of making a statement about the elements of a set that is true for every member of the set. Universal quantification uses the symbol,. An example of its use is i, j : N i > j => i 2 > j 2 which states that for every pair of values in the set of natural numbers, if i is greater than j, then i 2 is greater than j 2. 12

Sequences Sequences are designated using angle brackets. For example, the preceding sequence would normally be written as [ Jones, Wilson, Shapiro, Estavez ] Catenation, ++,, is a binary operator that forms a sequence constructed by adding its second operand to the end of its first operand. For example, [ 2, 3, 34, 1] 1 ++ [12, 33, 34, 200 ] = [ 2, 3, 34, 1, 12, 33, 34, 200 ] Other operators that can be applied to sequences are head, tail, front, and last. head [ 2, 3, 34, 1, 99, 101 ] = 2 tail [ 2, 3, 34, 1, 99, 101 ] = [3, 34, 1,99, 101] last [ 2, 3, 34, 1, 99, 101 ] = 101 front [ 2, 3, 34, 1, 99, 101 ] = [2, 3, 34, 1, 99] 13

Formal Specification Languages A formal specification language is usually composed of three primary components: a syntax that defines the specific notation with which the specification is represented semantics to help define a "universe of objects" that will be used to describe the system a set of relations that define the rules that indicate which objects properly satisfy the specification The syntactic domain of a formal specification language is often based on a syntax that is derived from standard set theory notation and predicate calculus. The semantic domain of a specification language indicates how the language represents system requirements. 14

Object Constraint Language (OCL) a formal notation developed so that users of UML can add more precision to their specifications All of the power of logic and discrete mathematics is available in the language However the designers of OCL decided that only ASCII characters (rather than conventional mathematical notation) should be used in OCL statements. 15

OCL Overview Like an object-oriented oriented programming language, an OCL expression involves operators operating on objects. However, the result of a complete expression must always be a Boolean,, i.e. true or false. The objects can be instances of the OCL Collection class, of which Set and Sequence are two subclasses 16

BlockHandler using UML Block * elements 1 BlockSet * number * * blockqueue free * used {ordered} allblocks {subset} {subset} 1 1 1 1 BlockHandler addblock() rem oveblock() 17

BlockHandler in OCL No block will be marked as both unused and used. context BlockHandler inv: (self.used->intersection(self.free)) ->isempty() All the sets of blocks held in the queue will be subsets of the collection of currently used blocks. context BlockHandler inv: blockqueue->forall(ablockset used->includesall(ablockset )) No elements of the queue will contain the same block numbers. context BlockHandler inv: blockqueue->forall(blockset1, blockset2 blockset1 <> blockset2 implies blockset1.elements.number->excludesall(blockset2.elements.number)) The expression before implies is needed to ensure we ignore pairs where both elements are the same Block. The collection of used blocks and blocks that are unused will be the total collection of blocks that make up files. context BlockHandler inv: allblocks = used->union(free) The collection of unused blocks will have no duplicate block numbers. context BlockHandler inv: free->isunique(ablock ablock.number) The collection of used blocks will have no duplicate block numbers. context BlockHandler inv: used->isunique(ablock ablock.number) 18

The Z Language organized into schemas defines variables establishes relationships between variables the analog for a module in conventional languages 19

The Clean Language Computation organized into functional expressions Result is determined by definition and arguments No side-effects effects Semantics is determined by function evaluation substituting actual arguments in a copy of the definition Specification can be executed 20