Sets for system modelling. At the end of this lecture you should be able to: Identify when it is appropriate to use a set for system modelling Define.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

C) between 18 and 27. D) between 27 and 50.
Homework Answers 4. 2t – 8 = (m + n) = 7n 6. A = 1/2bh
Homework Answers 1. {3} 2. {1, 3} 5. {3, 4, 6} 6. {} 10. {2, 3, 4}
Mathematical Preliminaries
Art Foundations Exam 1.What are the Elements of Art? List & write a COMPLETE definition; you may supplement your written definition with Illustrations.
Slide 1 Insert your own content. Slide 2 Insert your own content.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Chapter 1 The Study of Body Function Image PowerPoint
Combining Like Terms. Only combine terms that are exactly the same!! Whats the same mean? –If numbers have a variable, then you can combine only ones.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 11: Structure and Union Types Problem Solving & Program Design.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
2 pt 3 pt 4 pt 5pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt 2pt 3 pt 4pt 5 pt 1pt 2pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4pt 5 pt 1pt Simplify All mixed up Misc. AddingSubtract.
ALGEBRAIC EXPRESSIONS
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING Think Distributive property backwards Work down, Show all steps ax + ay = a(x + y)
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Empty Box Problems Subtraction = 3 If you start on 6 and jump back 3 spaces you land on
Lecture 15 Linked Lists part 2
Learning Objectives for Section 7.2 Sets
CSI 1306 ALGORITHMS - PART 4 LIST PROCESSING. Lists Sometimes a problem deals with a list of values We represent such a list with a single name, and use.
Evaluate the numerical expression 52 – 2 ∙ 4 + (7 – 2)
© S Haughton more than 3?
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
1 Chapter 4 The while loop and boolean operators Samuel Marateck ©2010.
Lesson 1.3 Unit 1, Lesson 3. Set:A collection of distinct objects Elements:All of the objects that make up a set.
Properties of Exponents
Chapter 5 Test Review Sections 5-1 through 5-4.
1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)
Addition 1’s to 20.
25 seconds left…...
Equal or Not. Equal or Not
Test B, 100 Subtraction Facts
Week 1.
Types of selection structures
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
1 Chapter 3:Operators and Expressions| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2006 | Last Updated: July 2006 Slide 1 Operators and Expressions.
FIND THE AREA ( ROUND TO THE NEAREST TENTHS) 2.7 in 15 in in.
PSSA Preparation.
© 2007 BST. All rights reserved. Confidential Information. SLU – 1 PDS_139 (0503) L2 Applying Problem- Solving Tools.
Equivalence Relations
Discrete Structures Chapter 6: Set Theory
Vienna Development Method SIM5104. one of the longest-established Formal Methods for the development of computer- based systemsFormal Methods Originating.
Sequences for system modelling. At the end of this lecture you should be able to: provide a definition of a VDM sequence; identify situations in which.
Sequences At the end of this lecture you should be able to: provide a definition of a VDM sequence; utilize and interpret sequence notation; make appropriate.
Sequences At the end of this lecture you should be able to: provide a definition of a VDM sequence; utilize and interpret sequence notation; make appropriate.
Sets Learning Outcomes At the end of this lecture you should be able to: Identify when it is appropriate to use a set for system modelling Define a set.
An introduction to specification in VDM-SL At the end of this lecture you should be able to: write a formal specification of a system in VDM-SL; correlate.
VDM-SL Case Study Learning Outcomes At the end of this lecture you should be able to: Analyse and informally specify a complete system using UML class.
Introduction to Z Copyright, 2002 © Jerzy R. Nawrocki Models and Analysis of Software.
TIVDM1Modelling unordered collections1 Peter Gorm Larsen.
Composite Objects Learning Outcomes At the end of this lecture you should be able to: Identify when it is appropriate to use a composite object type Use.
An introduction to specification in VDM-SL At the end of this lecture you should be able to: write a formal specification of a system in VDM-SL; correlate.
ELEMENTARY SET THEORY.
8. The set types The set types are one of the compound types available in SOFL, and usually used for the abstraction of data items that have a collection.
Basic Definitions of Set Theory Lecture 23 Section 5.1 Wed, Mar 8, 2006.
Basic Definitions of Set Theory Lecture 24 Section 5.1 Fri, Mar 2, 2007.
Basic Definitions of Set Theory Lecture 23 Section 5.1 Mon, Feb 21, 2005.
VDM: Vienna Development Method
books WARM-uP Lesson 1 Independent work Exit card
Presentation transcript:

Sets for system modelling

At the end of this lecture you should be able to: Identify when it is appropriate to use a set for system modelling Define a set using enumeration, number ranges and comprehension Use the set operators (union, intersection, difference, subset and cardinality) Apply the set type to model systems in VDM-SL

A set is an unordered collection of objects in which repetition is not significant. Collection of patients registered on the books of a doctor's surgery? When to use a set? The queue of patients waiting for a doctor?

Declaring sets in VDM-SL

To indicate a variable to be of the set type: variableName: ElementType For example Day = <MON> | <TUE> | <WED> | <THU> | <FRI> | <SAT> | <SUN> aNumber: aDay : Day someNumbers: -set someOtherNumbers: -set importantDays : Day-set -set

Defining sets in VDM-SL Three ways to initialise the values of a set: by enumeration; by number ranges; by comprehension.

Defining sets by enumeration someNumbers = {2, 4, 28, 19,10 } importantDays = {<FRI>, <SAT>, <SUN>}

Defining sets by number ranges

Can be used when a set of continuous integers required: someRange = {5, …,15} equal to someRange = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} When the second number in the range is smaller than the first, the empty set is returned. {7,…,6} = { }

Defining a set by comprehension

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) }

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) }

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) }

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) } Examples: someNumbers= { x | x {2,…,6} isEven(x)} { 2, 3, 4, 5, 6 }

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) } Examples: someNumbers = { x | x {2,…,6} isEven(x)} { 2, 3, 4, 5, 6 }

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) } Examples: someOtherNumbers = { x 2 | x {2,…,6}} { 2, 3, 4, 5, 6 } 4,9,16,25,36

Allows one set to be defined by means of another: someSet = { expression (x) | x someOtherSet test(x) } Examples: someOtherNumbers = { x 2 | x {2,…,6} isEven(x)} } { 2, 3, 4, 5, 6 } 4,16,36

Set operations Set union: j k Returns a set that contains all the elements of the set j and all the elements of the set k. if j = { <MON>, <TUE>, <WED>, <SUN> } and k = { < MON >, <FRI>, < TUE > } then j k = {<MON>, <TUE>, <WED>, <SUN>, <FRI>}

Set operations…. contd Set intersection:j k Returns a set that contains all the elements that are common to both j and k. if j = { <MON>, <TUE>, <WED>, <SUN> } and k = { < MON >, <FRI>, < TUE > } thenj k = {<MON>, <TUE>}

Set operations…. contd Set difference:j \ k Returns the set that contains all the elements that belong to j but do not belong to k. if j = { <MON>, <TUE>, <WED>, <SUN> } and k = { < MON >, <FRI>, < TUE > } then j \ k = {<WED>, <SUN> }

Set operations…. contd Subset:j k Returns true if all elements that belong to j also belong to k. {a, d, e} {a, b, c, d, e, f} {a, d, e} {d, a, e} Proper subset:j k Returns true if all elements that belong to j also belong to k but false if sets j and k are equal. {a, d, e} {a, b, c, d, e, f} {a, d, e} {d, a, e}

Set operations…. contd Cardinality:card j Returns the number of elements in a given set. card { 7, 2, 12} card { 7, 2, 2, 12, 12} card { 4,…,10} card { } = 3 = 3 = 7 = 0

The PatientRegister class

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

Modelling the PatientRegister class in VDM-SL

types Patient values LIMIT state PatientRegister of reg: init mk-PatientRegister ( ) end Patient inv mk-PatientRegister (r) card r LIMIT r = { } = TOKEN : = 200 r -set There must be no more than 200 patients on the register

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

addPatient ( ) ext pre post reg = patientIn patientIn: Patient reg: Patient-setwr patientIn reg

addPatient ( ) ext pre post reg = { patientIn} patientIn regcard reg < LIMIT patientIn: Patient reg: Patient-setwr

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

removePatient ( ) ext pre post patientIn: Patient wrreg: Patient-set reg = \ { patientIn}patientIn reg patientIn reg

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

getPatients ( ) ext pre post output: Patient-set rd reg: Patient-set output = reg TRUE

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

isRegistered ( ) ext pre post patientIn: Patient query: rdreg: Patient-set query patientIn reg TRUE

PatientRegister reg: Patient [*] addPatient (Patient) removePatient (Patient) getPatients ( ): Patient [*] isRegistered (Patient): Boolean numberRegistered ( ):Integer

numberRegistered () ext pre post total: rdreg: Patient-set total = card reg TRUE

The Airport Class

" A system is to be developed that keeps track of planes that are allowed to land at a particular airport. Planes must apply for permission to land at the airport prior to landing. When a plane arrives to land at the airport it is only allowed to do so if it has previously been given permission. When a plane leaves the airport its permission to land is also removed "

A UML specification of the Airport class Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

Modelling the Airport class in VDM-SL

types state Airport of init mk-Airport ( ) end Aircraft = TOKEN permission: landed: inv mk-Airport(p,l) l p p = { } l = { } p, l Aircraft -set All landed planes must have had permission to land.

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

givePermission( ) ext pre post craftIn: Aircraft permission: Aircraft - set wr permission = {craftIn } craftIn permission

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

recordLanding ( ) ext pre post craftIn: Aircraft permission: Aircraft -set landed: Aircraft -set rd wr landed = {craftIn} craftIn permission craftIn landed

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

recordTakeOff ( ) ext pre post craftIn: Aircraft permission: Aircraft -set landed: Aircraft -set wr wr landed = \ {craftIn }permission = \ { craftIn } craftIn landed

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

getPermission( ) ext pre post out: Aircraft-set permission: Aircraft -setrd out = permission TRUE

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

getLanded( ) ext pre post out: Aircraft -set landed: Aircraft -set rd out = landed TRUE

Airport permission: Aircraft [*] landed: Aircraft [*] givePermission(Aircraft) recordLanding(Aircraft) recordTakeOff(Aircraft) getPermission( ): Aircraft [*] getLanded( ): Aircraft [*] numberWaiting(): Integer

numberWaiting( ) ext pre post total: permission: Aircraft -set landed: Aircraft -set rd rd card (permission \ landed)total =

Thats all Folks..