Model-Based Specification CIS 376 Bruce R. Maxim UM-Dearborn.

Slides:



Advertisements
Similar presentations
Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
Advertisements

1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
Discrete Mathematics Lecture 4 Harper Langston New York University.
Announcements Quiz 1 Next Week. int : Integer Range of Typically -32,768 to 32,767 (machine and compiler dependent) float : Real Number (i.e., integer.
Schema Operators. State We can use the language of schemas to describe the state of a system, and operations upon it. Different aspects of the state --
1 Z Schemas Chapter 7 Formal Specification using Z Example of Z specification Document.
Schema Operators. State We can use the language of schemas to describe the state of a system, and operations upon it. Different aspects of the state --
Correction of the Handout #include //Preprocessor using namespace std; int main (){ ………….. return 0; } A namespace is a named group of definitions. When.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
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.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.3 The Class String.
1 Z Schemas Chapter 6 Formal Specification using Z.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Basic Elements of C++ Chapter 2.
Sets.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
1 Week 12 Arrays, vectors, matrices and cubes. Introduction to Scientific & Engineering Computing 2 Array subscript expressions n Each subscript in an.
1 COSC 4406 Software Engineering COSC 4406 Software Engineering Haibin Zhu, Ph.D. Dept. of Computer Science and mathematics, Nipissing University, 100.
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
A Z Approach in Validating ORA-SS Data Models Scott Uk-Jin Lee Jing Sun Gillian Dobbie Yuan Fang Li.
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
INTRODUCTION TO THE THEORY OF COMPUTATION INTRODUCTION MICHAEL SIPSER, SECOND EDITION 1.
11 Table 2.1 defines a correspondence between a set of percent scores and a set of letter grades. For each score from 0 to 100, there corresponds only.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
Course: Software Engineering ©Alessandra RussoUnit 2: States and Operations, slide number 1 States and Operations This unit aims to:  Define: State schemas.
Week 1 Algorithmization and Programming Languages.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Copyright © Cengage Learning. All rights reserved. CHAPTER 3 THE LOGIC OF QUANTIFIED STATEMENTS THE LOGIC OF QUANTIFIED STATEMENTS.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
1 Relational Algebra and Calculas Chapter 4, Part A.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
Chapter 8: SQL. Data Definition Modification of the Database Basic Query Structure Aggregate Functions.
Copyright © 2014 Curt Hill Sets Introduction to Set Theory.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Copyright © Cengage Learning. All rights reserved.
Lecture 4: Predicates and Quantifiers; Sets.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Mathematical Preliminaries
Notes on: Is Proof More Cost- Effective Than Testing? by Steve King, Jonathan Hammond, Rob Chapman, Andy Pryor Prepared by Stephen M. Thebaut, Ph.D. University.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
Predicate Logic One step stronger than propositional logic Copyright © Curt Hill.
Java-02 Basic Concepts Review concepts and examine how java handles them.
1 An SDL Tutorial Two primary elements: –Structure –Identifies the various components of the system, and the communication paths among them. –Components:
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Set, Combinatorics, Probability & Number Theory
Basic Elements of C++.
Copyright © Cengage Learning. All rights reserved.
Revision Lecture
(State) Model-Based Approaches II Software Specification Lecture 36
Basic Elements of C++ Chapter 2.
CMSC 202 Java Primer 2.
Department of Computer Science
Chapter 2: Intro to Relational Model
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Operator King Saud University
Presentation transcript:

Model-Based Specification CIS 376 Bruce R. Maxim UM-Dearborn

Model-Based Specification Overview System model defined using well-understood mathematical entities like sets and functions System state is not hidden like it is in algebraic specification State changes are straight forward to define VDM and Z are the most widely used model- based specification languages

Z Formal Language Based on set theory and first-order predicate logic Strongly typed Declarative language Makes use of a graphical construction known as a schema –provide an effective low level structuring facility –are useful as specification building blocks –can be understood fairly easily

Schemas Include –a unique name or identifier –a signature that declares entities and their types –a predicate part that defines invariants involving these entities Schemas can be included in other schemas and act as type definitions Names are local to the schema in which they are defined

Schema: Declaration Part Contains local declarations (types and variables) Can import other types by listing their names Anonymous schemas (name omitted) are used to make global declarations Anonymous schemas usually do not contain a predicate part

Schema: Predicate Part Statements about the entities defined in the declaration part of the schema These statements must be true at all times Multiple statements are assumed to be implicitly connected by a logical and Other logical connectives (e.g. or, implies, equivalent, etc.) can be used explicitly in compound statements

Z specification examples were posted on the World Wide Web by Ken Abernathy Furman University

Example Schema The symbol P is used to indicate the power set of a type, and the symbol  is used to define a relation between two types (i.e. a set of ordered pairs from the Cartesian product of the two types). IO_Channel_Assignments Basic_Types active_instruments : P Platform_Instruments assigned_to : Communications_Channels  Platform_Instruments available, busy: P Communications_Channels range assigned_to [subset of] active_instruments available  busy = 

Z Lexical Elements Character set includes all keyboard characters and special mathematical symbols Identifiers must begin with a letter and may contain any number of digits, letters (upper and lower case), and the underscore _ Identifiers may have suffixes ? = input variable ! = output variable ` = new value for variable following a state change

Z Types and Declarations Built-in types –the integers denoted by Z –natural numbers {0, 1, 2, …} denoted by N –positive integers denoted by N 1 –the reals are not a built-in type Free types = similar to enumerated types in C++ Basic types (aka unspecified types)

Z Operators - part 1 Operator # denotes the cardinality of a finite set Operator < is used to extract ordered pairs from a relation having specified first coordinate values Example: #({channel?} < assigned_to) < 5 This statement asserts that the number of pairs from the relation assigned_to whose first coordinates equal the value of the input variable channel? is less than 5.

Z Operators - part 2 The operator > functions almost like < except it extracts pairs from a relation based on the value of the second coordinate. Example: #(assigned_to > {instrument?}) < 3 This states that the number of ordered pairs from the relation assigned_to whose second coordinates equal the value of the input variable instrument? is less than 3.

Z Operators - part 3 The notation a- > b is used to denote a specific potential pair in a relation -- instead of the more standard ordered pair notation (a,b) The following notation is used for the relational image operator | {range set} | Example:assigned_to (| {channel?} |) In this example, the relational image operator returns the image (in the range set)of the value of the variable channel? for the relation assigned_to.

Creating New Schemas from Existing Schemas The prefix  (Delta) is used to create a new schema from an existing one. –A Delta schema is obtained by combining the before and after specifications of a state. The prefix  (Xi) is also used to create a new schema from an existing one. –Similar to a Delta schema, an Xi schema is obtained by combining the before and after specifications of a state. – However, this schema is used to define specifications of operations (such as inquiries) that do not change the state of a structure.

Delta Schema Example  IO_Channel_Assignments Basic_Types active_instruments, active_instruments' : P Platform_Instruments assigned_to, assigned_to' : Communications_Channels  Platform_Instruments available, available', busy, busy' : P Communications_Channels ran assigned_to [subset of] active_instruments ran assigned_to' [subset of] active_instruments' available  busy =  available'  busy' = 

Xi Schema Example  IO_Channel_Assignments Basic_Types active_instruments, active_instruments' : P Platform_Instruments assigned_to, assigned_to' : Communications_Channels  Platform_Instruments available, available', busy, busy' : P Communications_Channels ran assigned_to [subset of] active_instruments available  busy =  active_instruments' = active_instruments assigned_to' = assigned_to available' = available busy' = busy

Operation Specification Options Operations may be specified incrementally as separate schema and then combined to produce a complete specification Define a ‘normal’ operation as a schema Define schemas for exceptional situations Combine all schemas using a disjunctive or operator

Importing Delta and Xi Schemas Importing  and  schemas into operation specifications provides a way to record the intended impact of the operations on state variables and predicate Provides a built-in check on the result of an operation

Z Specification Process

Example Problem A space platform contains a number of instruments. Several communications channels are provided allowing both input and output instrument communications. Platform instruments may be placed in active or inactive states. Only active instruments may be assigned to I/O-channels. Active instruments may be assigned to more than one I/O-channel, up to some maximum number of I/O-channels per instrument. I/O-channels may be shared by several active instruments, up to some maximum number of instruments shared per I/O-channel.

Basic Variables and Invariants IO_Channel_Assignments Basic_Types active_instruments : P Platform_Instruments assigned_to : Communications_Channels  Platform_Instruments available, busy: P Communications_Channels range assigned_to [subset of] active_instruments available  busy = 

Schema for Making an Assignment - part 1 The schema is to define the basic operator to assign a channel to an instrument The schema will later be combined using logical or’s with a number of message reporting schemas to complete the definition Schema  IO_Channel_Assignments should be imported in the declaration part of the new schema since this operator will potentially change the system state

Schema for Making an Assignment - part 2 The declaration part of the schema should also declare two variables -- one representing the instrument and one representing the channel to be included in the assignment The predicate part of the schema should consist of the conjunction (logical and’ing) of several pre-conditions assuring that the input variables satisfy conditions for a legal assignment to be made, and several post-conditions defining the state changes that will complete the assignment

Preconditions Desired pre-conditions on the input variables : instrument must be active channel must be available (i.e. not already have the maximum allowed instruments assigned to it) instrument must have assigned to it fewer than the allowed maximum number of channels the candidate assignment pair must not already exist in the relation assigned_to

Schema with Precondition Added Make_An_Assignment 0  IO_Channel_Assignments instrument? : Platform_Instruments channel? : Communications_Channels instrument?  active_instruments channel?  available #(assigned_to > {instrument?}) < Max_Channels channel? -> instrument?  assigned_to

Post-Conditions Desired post-conditions -- the operator actions : assure no change is made to the active state of the instrument (instrument remains active) add the assignment pair to the assigned_to relation (special case) if this assignment increases the number of instruments assigned to this channel to the maximum allowed, then the channel must be removed from the available channel set and placed in the busy channel set

Schema with Post-Conditions Added Make_An_Assignment 0  IO_Channel_Assignments instrument? : Platform_Instruments channel? : Communications_Channels instrument?  active_instruments channel?  available #(assigned_to > {instrument?}) < Max_Channels channel? -> instrument?  assigned_to active_instruments' = active_instruments assigned_to' = assigned_to  {channel?->instrument?} [#({channel?} < assigned_to) < Max_Instruments-1] \/ [#({channel?} < assigned_to) = Max_Instruments-1 /\ available' = available - {channel?} /\ busy' = busy  {channel?}]

Error Conditions Errors should be reported whenever one of the preconditions fail (which means the operation cannot take place) Schemas can be defined for each error condition The final schema will combine the operator schema and the error schema condition schemas using or operators

Sample Error Condition Schema Instrument_Not_Active  IO_Channel_Assignments instrument? : Platform_Instruments message! : Possible_Message instrument?  active_instruments message! = instrument_not_active

Completed Make_Assignment Schema Assuming three more error schemas are complete the definition of the Make_An_Assignment operation appears below. ( \/ = logical or) Make_An_Assignment == Make_An_Assignment 0 \/ Instrument_Not_Active \/ Channel_Not_Available \/ Maximum_Channels_Assigned \/ Assignment_Already_Made