Specification Calculus 1. Contents Abstract data types Subtype relation Type specification Type reduct Most common reduct Type refinement Type meet Type.

Slides:



Advertisements
Similar presentations
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Advertisements

The Substitution Principle SWE 332 – Fall Liskov Substitution Principle In any client code, if subtype object is substituted for supertype object,
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Pre and Post Condition Rules Definition : If R and S are two assertions, then R is said to be stronger than S if R -> S (R implies S). –Example : the assertion.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
August Moscow meeting1August Moscow meeting1August Moscow meeting11 Deductive tools in insertion modeling verification A.Letichevsky.
ISBN Chapter 3 Describing Syntax and Semantics.
Program Proving Notes Ellen L. Walker.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CS 355 – Programming Languages
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Discrete Mathematics Lecture 4 Harper Langston New York University.
1 Advanced Material The following slides contain advanced material and are optional.
Principles of Object-Oriented Software Development Behavioral refinement.
Object-Oriented Analysis and Design Lecture 8 State Space, Behavior, and Type Conformance.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Congruence Classes Z n = {[0] n, [1] n, [2] n, …, [n - 1] n } = the set of congruence classes modulo n.
Harvey SiyPrinciples of Object-Oriented Software Development by Eliens Slide 1 Behavioral Refinement Principles of Object-Oriented Software Development.
Describing Syntax and Semantics
Floyd Hoare Logic. Semantics A programming language specification consists of a syntactic description and a semantic description. Syntactic description:symbols.
Proving Program Correctness The Axiomatic Approach.
1 COSC 4406 Software Engineering COSC 4406 Software Engineering Haibin Zhu, Ph.D. Dept. of Computer Science and mathematics, Nipissing University, 100.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Model-Based Specification CIS 376 Bruce R. Maxim UM-Dearborn.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Nikolay A. Skvortsov Institute for Informatics Problems Russian Academy of Sciences RCDL’2008 Dubna Application.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.5 Application: Correctness of Algorithms 1 [P]rogramming reliability – must be an activity.
CompSci 102 Discrete Math for Computer Science
Chapter 3 Part II Describing Syntax and Semantics.
Formal Methods in Software Engineering “And they made their lives bitter with hard bondage … all their service … was with rigour.” Ex 1:14.
Type Abstraction SWE Spring October 05Kaushik, Ammann Substitution Principle “In any client code, if supertype object is substituted.
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
ISP RAS Java Specification Extension for Automated Test Development Igor B. Bourdonov, Alexei V. Demakov, Andrei A. Jarov, Alexander S. Kossatchev, Victor.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
L13: Design by Contract Definition Reliability Correctness Pre- and post-condition Asserts and Exceptions Weak & Strong Conditions Class invariants Conditions.
Slide 7- 1 Copyright © 2012 Pearson Education, Inc.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
D. WijesekeraSWE 699/IT 823: Precise Modeling1 Typing A Behavioral Notion of Subtyping By Barbara Liskov and Jeannette M. Wing in ACM Trans. Of Prog. Languages.
Cs2220: Engineering Software Class 12: Substitution Principle Fall 2010 University of Virginia David Evans.
6-1 Type Conformance and Closed Behavior Constructing class hierarchiesConstructing class hierarchies –need to be careful –two helpful principles: type.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
DBC NOTES. Design By Contract l A contract carries mutual obligations and benefits. l The client should only call a routine when the routine’s pre-condition.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
A UML-Based Pattern Specification Technique Presented by Chin-Yi Tsai IEEE TRANSACTION ON SOFTWARE ENGINEERING, VOL. 30, NO. 3, MARCH 2004 Robert B. France,
Logics for Data and Knowledge Representation ClassL (part 1): syntax and semantics.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Laurea Triennale in Informatica – Corso di Ingegneria del Software I – A.A. 2006/2007 Andrea Polini IX. System Models (III)
11/22/2016IT 3271 A formal system:Axioms and Rules, for inferring valid specification x := m; y := n; while ¬(x=y) do if x>y then x := x-y else y := y-x.
Formal Methods in SE Lecture 21.
Язык СИНТЕЗ как ядро канонической информационной модели
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Type Abstraction SWE Spring 2009.
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
Type Abstraction Liskov, Chapter 7.
Semantics In Text: Chapter 3.
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
Predicate Transformers
Binary Search and Loop invariants
Respectful Type Converters
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Algebraic Trace Theory
Type Abstraction SWE Spring 2013.
Presentation transcript:

Specification Calculus 1

Contents Abstract data types Subtype relation Type specification Type reduct Most common reduct Type refinement Type meet Type join Type lattice 2

Abstract Data Type 3 ADT definition includes a specification defining a behavior of the type values by means of the operation signatures and of their abstract descriptions

Research Project Specification 4 { RProject; in: type; supertype: Project; coordinator: Organization; leader: Professor; priority_theme: string; cooperate_with: {set; type_of_element: RProject; }; candidate_proj: {in: function; params: { j/RProject, -c/Project}; {{ this.area = j.area & this.priority_theme = j.priority_theme & c' = j }}}; area_constr: {in: predicate, invariant; {{ all p/RProject (p.area = 'comp-sci' => p.grade = 5 & (p.priority_theme = 'open systems' | p.priority_theme = 'interoperability')) }}}; leader_constr: {in: predicate, invariant; {{ all p/RProject (p.leader.degree = 'PhD') }}} }

Industrial Project Specification 5 {IProject; in: type; supertype: Project; coordinator: Company; cooperate_with: {set; type_of_element: Project; }; sponsor: Company; candidate_proj: {in: function; params: {+j/Project, -c/Project}; {{ this.area = j.area & c' = j }}}; area_constr: {in: predicate, invariant; {{ all p/IProject (p.area = 'comp-sci' => p.grade >= 3 )}}} }

Subtype relation informally 6 a value of a subtype can be used in all cases where a supertype value is expected correspondence of type operations supertype’s invariant should be implied by subtype’s invariant supertype’s operations should be refined by subtype’s operations multiple subtyping is allowed (for a subtype a set of supertypes can be defined) operations of a subtype to which operations of a supertype correspond can be renamed in case of multiple subtyping

Type Specification 7 Type specification is a triplet V T – extension the type (carrier of the type) - set of admissible instances of the type O T – operation symbols, indicating operation arguments and result types I T – invariant symbols Conjunction of all invariants in I T constitutes the type invariant Inv T Every instance must satisfy the invariant Inv T

Type Specification - Example 8 V RProject = {, … } O RProject = { candidateProj(+j/Rproject, -c/Project) } I RProject = { areaConstr, leaderConstr } Inv RProject = all p/RProject (p.area = 'comp-sci' => p.grade = 5 & (p.priority_theme = 'open systems' | p.priority_theme = 'interoperability')) & all p/RProject (p.leader.degree = 'PhD')

Subtype relation formally 9 Invariant rule:  v: V sub (I sub (v)  I sup (Abs(v))) Precondition rule: subtype operation should terminate whenever a supertype operation is guaranteed to terminate  v s : V sub, x?: X (preO sup (v t, x?)[v t / Abs(v s )]  preO sub (v s, x?)) Postcondition rule: the state after the subtype operation (marked by ‘) represents one of those abstract states in which an operation of a supertype could terminate  v s : V sub, v’ s : V sub, x?: X, y?: Y ( preO sup (v t, x?)[v t / Abs(v s )]  postO sub (v s, v’ s, x?, y?)  postO sup (v t, v’ t, x?, y?) [v t / Abs(v s ), v’ t / Abs(v’ s )] ) Type specification (ex. T sup ) is correct if it has a model  v t : V sup (I sup (v t )) type operations preserve type invariants  v t : V sup, v’ t : V sup, x?: X, y?: Y ( preO sup (v t, x?)  postO sup (v s, v’ s, x?, y?)  I sup (v’ t ) )

Subtype relation example (I) 10 Organization is a supertype of Company RProject.candidateProj is refined by IProject.candidateProj

Subtype relation example (II) 11 Iproject.areaConstr is implied by Rproject.areaConstr

Overdefined and Least Informative Types 12 Taval is least informative type, any type is a subtype of Taval Tnone is overdefined type, any type is a supertype of Tnone predefined none value is of type Tnone and may be returned by a function as an empty result of any type

Type Reduct 13 Reduct R T = of type T = is a subspecification of type T: V R = V T O R  O T I R  I T

Most Common Reduct 14

Type Refinement 15 Type U is a refinement of type T iff there exists an injective mapping Ops: O T  O U ; there exists an abstraction function Abs: V U  V T that maps each admissible state of U into the respective state of T;  x  V T, y  V U ( Abs(x, y)  I U (y)  I T (x) ) for every operation o  O T the operation Ops(o) = o'  O U is a refinement of o pre(o)  pre(o') post(o')  post(o).

MCR(RProject, IProject) 16

MCR(IProject, RProject) 17

Type MEET 18 The meet operation T 1 & T 2 of produces a type T as an "intersection” of specifications of the operand types Common elements of the types are defined by most common reducts MCR(T 1, T 2 ) and MCR(T 2, T 1 ) O T1 & T2 = O MCR(T1,T2)  O MCR(T2,T1) Type invariant of T is defined as a disjunction of operand types invariants Inv MCR(T1,T2) | Inv MCR(T2,T1) T 1 & T 2 is a supertype of both T 1 and T 2

Type Meet Example 19

Type JOIN 20 The join operation T 1 | T 2 produces a type T as a "join" of specifications of the operand types, common elements are included only once Common elements of the types are defined by most common reducts MCR(T 1, T 2 ) and MCR(T 2, T 1 ) O T1 | T2 = (O T1 \O MCR(T1,T2) )  (O T2 \O MCR(T2,T1) )  (O MCR(T1,T2)  O MCR(T2,T1) ) Type invariant of T is defined as a conjunction of operand types invariants Inv T1 & Inv T2 T 1 | T 2 is a subtype of both T 1 and T 2

Type Join Example 21

Type Lattice 22 Set V of types is a lattice over meet and join operations commutativity T 1 & T 2 = T 2 & T 1 T 1 | T 2 = T 2 | T 1 associativity T 1 | (T 2 | T 3 ) = (T 1 | T 2 ) | T 3 T 1 & (T 2 & T 3 ) = (T 1 & T 2 ) & T 3 idempotence T & T = T T | T = T absorption T 1 & (T 1 | T 2 ) = T 1 T 1 | (T 1 & T 2 ) = T 1