Duminda WijesekeraSWE 623: Fall 20021 Schemas in Z Chapter 6 in Potter Sinclair and Till.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

TYPES OF BANK ACCOUNTS.
Classes and Objects CMSC 202. Version 9/122 Programming & Abstraction All programming languages provide some form of abstraction. – Also called information.
IMPLEMENTING CLASSES Chapter 3. Black Box  Something that magically does its thing!  You know what it does but not how.  You really don’t care how.
Checking Maintaining a checking account is a necessary skill to master before living independently.
The Z Specification Language
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 CS 501 Spring 2005 CS 501: Software Engineering Lecture 10 Requirements 4.
The Schema Calculus. Schemas A notation specifying both system states and operations One way: S = [ declarations | predicate ] Means: The state components.
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 Predicates and quantifiers Chapter 8 Formal Specification using Z.
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.
Nov 2002 R. McFadyen1 Statechart Diagrams - Ch 29 Example: Suppose we have a class Copy, representing copies of books. We can consider two states:
Chapter 13 Cash books.
Chapter 3, section 5 Money Market & CD Accounts. I can…  Calculate interest earned on special savings accounts  Calculate the penalty for early withdrawals.
Warm up Exercise The Perfect Check Today’s Date Tony’s Exxon for car repairs 1, dollars Who cares if you write out a check perfectly, no errors,
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
(c) University of Washington04-1 CSC 143 Java Inheritance Example (Review)
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
4 DEPOSITS IN BANKS 4.1 Deposit Accounts 4.2 Interest-Bearing Accounts
Lecture 3 [Self Study] Relational Calculus
Java Language and SW Dev’t
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
Chapter 25 Bank Reconciliation Statement. Aims To ensure that the difference between the balance in the Bank Statement and the balance in the Cash Book.
1COM6030 Systems Analysis and Design © University of Sheffield 2005 COM 6030 Software Analysis and Design Lecture 10 – Classes and operations Dr Richard.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Bank Accounts. Deposit Account: Deposit Account: An account at a banking institution which allows the account holder to deposit money into or withdraw.
2.2 Statements, Connectives, and Quantifiers
CS61B L03 Building Objects (1)Garcia / Yelick Fall 2003 © UCB  Dan Garcia ( Kathy Yelick  (
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 3.1, Slide Logic The Study of What’s True or False or Somewhere in Between.
Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 3.1, Slide Logic The Study of What’s True or False or Somewhere in Between.
P Chapter 2 introduces Object Oriented Programming. p OOP is a relatively new approach to programming which supports the creation of new data types and.
1 OCL The Role of OCL in UML. 2 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Lecture 1.2: Equivalences, and Predicate Logic* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren, Zeph.
1 Warm-Up Problem Just like with primitive data types (int, double, etc.), we can create arrays of objects. ex: bankAccount employees[100]; Problem: It’s.
Classes: Member Functions and Implementation November 22, 2002 CSE103 - Penn State University Prepared by Doug Hogan.
Introduction to Java Java Translation Program Structure
Lecture 101 CS110 Lecture 10 Thursday, February Announcements –hw4 due tonight –Exam next Tuesday (sample posted) Agenda –questions –what’s on.
Chapter 1: Object Oriented Paradigm. 1.1 Data Abstraction and Encapsulation OOP allows programmer to – separate the details that are important to the.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Thinking Mathematically
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Choosing and Balancing a Checking Account Personal Finance.
Chapter Functions 6. Modular Programming 6.1 Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
1 Assertions. 2 A boolean expression or predicate that evaluates to true or false in every state In a program they express constraints on the state that.
ACT 110 Is EASY POP! Our Confession Because ME en come to UG fuh FAIL! Yo mad or what!
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 6: Functions.
72 4/11/98 CSE 143 Abstract Data Types [Sections , ]
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
ITM 3521 ITM 352 Functions. ITM 3522 Functions  A function is a named block of code (i.e. within {}'s) that performs a specific set of statements  It.
Chapter 5.  Transaction is an exchange of goods or services between two parties at an agreed amount  An event is known in Accounting as subsequent measurement.
Relational Operator and Operations
Open, Manage, and Balance
Thinking Mathematically
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
Scope, Objects, Strings, Numbers
draw a sequence diagram
CMSC Discrete Structures
suggested reading: Java Ch. 6
Concept of a document Lesson 3.
LESSON 8-3 Preparing a Post-Closing Trial Balance
6 Chapter Functions.
(1.4) An Introduction to Logic
Binary Search Trees Chapter 9 2/22/2019 B.Ramamurthy.
ITM 352 Functions.
CS 501: Software Engineering Fall 1999
Presentation transcript:

Duminda WijesekeraSWE 623: Fall Schemas in Z Chapter 6 in Potter Sinclair and Till

Duminda WijesekeraSWE 623: Fall Schemas Z’s main representational mechanism of structure and functions. Example: initialStock: Stock # initialStock < maxlines  i :ITEM; n : N | (i,n)  initalStock /\ n<100 stockItem : P ITEM stockItems = dom initialStock

Duminda WijesekeraSWE 623: Fall Schemas Describing Abstract States Account Opened Account Overdrawn Authorized Withdrawal Account closed Account in Good Standing Overdraft Paid Off Regular Withdrawal Deposit

Duminda WijesekeraSWE 623: Fall Schemas Describing Abstract States Example 1: BankAccount 1 total, minBalance: R `total > minBalance Example 2: BankAccount 2 total, minBalance: R `inGoodStanding: BOOLEAN inGoodStanding  (total > minBalance)

Duminda WijesekeraSWE 623: Fall Schemas Describing Operations BankAccount with Operations total, minBalance: R withdraw : R BOOL overDraft: R x BOOL R total > minBalance  x?:R;out!:Bool. [total – x? out! = withdraw(x?)/\out! = TRUE /\ total’ = total-x] \/[total – x? > minBalance => out! =FALSE /\ out! = withdraw(x?)/\ total’ = total ]

Duminda WijesekeraSWE 623: Fall Schema Calculus: Operations on Schemas Schemas can be built from other schemas. Schema calculus has some operations on schemas to build new schemas from the old. Operations: –Inclusion –Decoration –Disjunction –Conjunction –Negation –composition

Duminda WijesekeraSWE 623: Fall Inclusion - 1 BankAccount with Operations Bank Account 1 Bank Overdraft Where Bank Overdraft can be defined separately

Duminda WijesekeraSWE 623: Fall Inclusion - 2 Bank Regular Withdraw total, minBalance: R withdraw : R BOOL overDraft: R x BOOL R total > minBalance  x?:R;out!:Bool. [total – x? out! = withdraw(x)/\out! = TRUE /\ minBalance’ = minBalance-x?] \/[total – x? > minBalance => out! =FALSE /\ out! = withdraw(x?)/\ total’ = total ]

Duminda WijesekeraSWE 623: Fall Decoration Adding ?, ! And ‘ to variables is referred to as decoration. Can use ‘ for schemas themselves. Example: Double Min Balance Bank Account, Bank Account’ doubleMinBalance: R R monBalance’ = 2*minBalance

Duminda WijesekeraSWE 623: Fall Full Expansion of a Decorated Schema Replace primed entities by their definitions Double Min Balance total, total’, minBalance, minBalance’ :R doubleMinBalance : RR total > minBalance /\ total’ > minBalance’

Duminda WijesekeraSWE 623: Fall Schema Disjunction Want to specify define two cases separately and state that they are two cases of the same “thing”. Example: –Bank WithdrawCash = Bank RegularWithdraw \/ Bank Overdraft –Bank Regular Withdraw defined earlier

Duminda WijesekeraSWE 623: Fall Schema Disjunction - 2 Bank Overdraft Bank Account 1, Bank Account 1’ overdraft : R x BOOLBOOL x?: R, approve?: BOOL  x?:R;out!:Bool. [approve? => (out! /\ total’=total-x?) total’ = total-x?] \/[not approve? => (not out! /\ total’=total)]

Duminda WijesekeraSWE 623: Fall Schema Conjunction When one schema can be written specified as “two specifications” Results in taking the conjunction of both constraints Example: Bank Overdraft = sendMessage/\adjustBalance

Duminda WijesekeraSWE 623: Fall Schema Conjunction - 2 send Message Bank Account 1, Bank Account 1’ overdraft : R x BOOLBOOL x?: R, approve?: BOOL  x?:R;out!:Bool. [approve? => out! /\total’=total- x?)] \/[  approve? => (  out! /\ total’=total)]

Duminda WijesekeraSWE 623: Fall Schema Conjunction - 3 Adjust Total Bank Account 1, Bank Account 1’ overdraft : R x BOOLBOOL x?: R, approve?: BOOL  x?:R;out!:Bool. [approve? => out! /\ total’ t=total-x?] \/[  approve? => (  out! /\ total’=total)]

Duminda WijesekeraSWE 623: Fall Schema Negation Example 1: BankAccount 1 total, minBalance: R `total > minBalance Bad bank Account = =  Bank Account 1 Bad BankAccount total, minBalance: R  (total > minBalance)

Duminda WijesekeraSWE 623: Fall Schema Hiding Operations Used to hide some variables and declarations of already known schemas. Use  to hide variables. Format –[Decs | Pred] \ Hidden variables –[Reduced Decs |  Hidden Decs. Predicate]

Duminda WijesekeraSWE 623: Fall Schemas Hiding Example -1 BankAccount with Operations total, minBalance: R withdraw : R BOOL overDraft: R x BOOL R total > minBalance  x?:R;  app?out!:Bool. [total – x? out! = overDraft x?, app? /\out! /\ total’ = total-x] \/[total – x? out! =FALSE /\ out! = overDraft(x?,app?)/\ total’=total]

Duminda WijesekeraSWE 623: Fall Schemas Hiding Example -2 BankAccount with Operations total, minBalance: R withdraw : R BOOL overDraft: R x BOOL R total > minBalance  x?:R;  app?out!:Bool. [total – x? out! = overDraft x?, app? /\out! /\ total’ = total-x] \/[total – x? out! =FALSE /\ out! = overDraft(x?,app?)/\ total’=total]

Duminda WijesekeraSWE 623: Fall Schema Composition Recall that function composition: –If f : S 1 -> S 2 and g: S 2 -> S 3 then –fog : S 1 -> S 3 Schema Composition imports this idea to schemas. Example: Consider overdrawn bank account –To close account: Must pay up to minimum balance Then close account from account in good standing

Duminda WijesekeraSWE 623: Fall Schema Composition Method 1.Replace primed variables (‘)in first schema with double primed variables (“) S[“/’] 2.Replace un-primed variables in second schema with double primed variables (“) T[‘/] 3.Existentially quantify variables in double primed state (“)  State”. S[“/’]/\T[“/]

Duminda WijesekeraSWE 623: Fall Schema Composition Example -1 toGoodStanding  Bank Account 1 toGoodStanding: R -> NULL total < minBalance  x?:R ( x+total > minBalance) => total’ = total + x?

Duminda WijesekeraSWE 623: Fall Schema Composition Example -2 closeInGoodStanding  Bank Account 1 close: BOOL -> R total > minBalance  x?:BOOL, return!:R ( total>minBalance) => return!=total /\ total’=0 closeFromDefault = toGoodStanding o closeFromGoodStanding

Duminda WijesekeraSWE 623: Fall Schema Composition Example -3 closeFromDefault  Bank Account 1 close: BOOL -> R  Bank Account”  x?: R toGoodStanding x /\ close true return’

Duminda WijesekeraSWE 623: Fall Schema Preconditions Applicable only to schemas representing operations Pre Op = =  State’; Out!. Op Means that the schema should be applied to those state that result in the given predicate satisfies in the post state. Here: Op is the operation

Duminda WijesekeraSWE 623: Fall Schema Precondition Example Simple x,y: N x < y NonEndPoint  Simple; Z!:N x < x’ < z! < y’ < y

Duminda WijesekeraSWE 623: Fall Constructing pre NonEndPoint preNonEndPoint Simple  x’,y’,z!: N x < x’ < z < y’ < y Can simplify the statement  x’,y’,z!: N x < x’ < z < y’ < y to x+3 < y

Duminda WijesekeraSWE 623: Fall Schema Types A way to record data types by specifying filed and their types of a structure. Example Book title, author, isbn, publisher : String Pubdate, pages: Z slength title < 80, slength author < 80, (checksum isbn) mode 11 = 0 O < pages /\ 1800 < pubdate < 2050