18 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 1.
Advertisements

Formal Models of Computation Part II The Logic Model
Database Design: ER Modelling (Continued)
Restricted Machines Presented by Muhannad Harrim.
0 PROGRAMMING IN HASKELL Chapter 5 - List Comprehensions.
CSC211 Data Structures Lecture 9 Linked Lists Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
Chapter 24 Lists, Stacks, and Queues
Chapter 3: Lists, Operators, Arithmetic Part 1. Outline Representation of lists Some operations in lists Operator notation Arithmetic.
Modern Programming Languages, 2nd ed.
Software Testing and Quality Assurance
18 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
Container Classes A container class is a data type that is capable of holding a collection of items. In C++, container classes can be implemented as.
Introduction to Set Theory
5.4 Basis And Dimension.
What You Should Learn • Represent and classify real numbers.
Mathematics1 Mathematics 1 Applied Informatics Štefan BEREŽNÝ.
Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Topic 16 Sorting Using ADTs to Implement Sorting Algorithms.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Software Systems.
Chapter 6 Languages: finite state machines
Chapter 5 Relations and Functions
1 MAC 2313 CALC III Chapter 12 VECTORS and the GEOMETRY of SPACE THOMAS’ CALCULUS – EARLY TRANSCENDENTALS, 11 TH ED. Commentary by Doug Jones Revised Aug.
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction.
Chapter Three: Lists, Operators, Arithmetic 1. Chapter three: 3.1Representation of lists 3.2Some operations on lists 2.
22 March 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction.
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
© 2006 Pearson Addison-Wesley. All rights reserved8-1 Chapter 8 Queues CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2008.
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
Sequences. What is sequence? A sequence is an ordered collection of objects. We use sequences to model collections in which order or multiplicity is important.
13 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
10 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
Function: Definition A function is a correspondence from a first set, called the domain, to a second set, called the range, such that each element in the.
Vocabulary word (put this word on the back of the card.) THIS WILL BE THE DEFINITION – FILL IN THE BLANKS ON THE VOCABULARY CARDS PROVIDED.
The Z Notation: relations and functions Compiled By Tariq R. Soomro, Ph.D. Reference: Text Book Week-7.
22 March 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
P.1 Set Notation Intersections of Sets Unions of Sets Negative Properties and Algebraic Expressions Modeling Real Data with Algebraic Formulas Pg. 14 #
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
6  Sets and Set Operations  The Number of Elements in a Finite Set  The Multiplication Principle  Permutations and Combinations Sets and Counting.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
PRESENTED BY: RAJKRISHNADEEPAK.VUYYURU SWAMYCHANDAN.DONDAPATI VINESHKUMARREDDY.LANKA RAJSEKHARTIRUMALA KANDURI ALAN.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
MTH 231 Section 2.1 Sets and Operations on Sets. Overview The notion of a set (a collection of objects) is introduced in this chapter as the primary way.
University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction to computer vision Chapter 2: Image.
Data Structures Using C++ 2E Chapter 8 Queues. Data Structures Using C++ 2E2 Objectives Learn about queues Examine various queue operations Learn how.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues (part 3)
Chapter 6, Counting and Probability
17 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
08 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
Equations, Inequalities, and Mathematical Models 1.2 Linear Equations
1 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
 A Collection class is a data type that is capable of holding a group of items.  In Java, Collection classes can be implemented as a class, along with.
Built-in Data Structures in Python An Introduction.
03 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Introduction.
Formal Methods in SE Lecture 16 Formal Methods in SE Qaisar Javaid Assistant Professor.
Container Classes  A container class is a data type that is capable of holding a collection of items.  In C++, container classes can be implemented as.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Module #10: Proof Strategies Rosen 5 th ed., §3.1 (already covered)
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Notions & Notations (2) - 1ICOM 4075 (Spring 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez Spring.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Data Structures Using C++ 2E
Chapter 2 Sets and Functions.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Set-Builder Notation.
Advanced Algorithms Analysis and Design
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Algebra 4-6 Functions Functions
Presentation transcript:

18 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Sequences

18 April 2009Instructor: Tasneem Darwish2 Outlines Sequence notation A model for sequences Functions on sequences Bags

18 April 2009Instructor: Tasneem Darwish3 Sequence notation A sequence is an ordered collection of objects If there are no objects in the collection, the sequence is the empty sequence, and it is written as The expression denotes the sequence containing objects a, b, and c, in that order Concatenation is when two sequences are combined in such a way that the elements of one follow the elements of the other, and order is maintained Example: If s and t are sequences, we write s ̑ t to denote the concatenation of s and t

18 April 2009Instructor: Tasneem Darwish4 Sequence notation Example 9.1 The ticket office in a railway station has a choice of two counters at which tickets may be purchased. There are two queues of people, one at each counter; these may be modelled as sequences To restrict elements of a sequence we can use the filter operator if s is a sequence, then is the largest subsequence of s containing only those objects that are elements of the set A Note: The order and multiplicity of elements must be preserved

18 April 2009Instructor: Tasneem Darwish5 Sequence notation Example 9.2 In the station, there is a destination board displaying a list of trains, arranged in order of departure. This may be modelled as a sequence of pairs, each recording a time and a destination Sally is interested only in those trains that are going to London;

18 April 2009Instructor: Tasneem Darwish6 Sequence notation To refer to the first element of a sequence, or to the part of the sequence that follows the first element; these are called the head and tail, respectively Notice that the head of a sequence is an element, while the tail is another sequence. If s is any non-empty sequence

18 April 2009Instructor: Tasneem Darwish7 Sequence notation Example 9.3 Sally wants to take the first train to London. From the list of trains on the destination board Tim is still waiting to buy a ticket, and the first train is about to leave, then the list of available trains is given by `tail trains', the sequence

18 April 2009Instructor: Tasneem Darwish8 Sequence notation if s is a sequence, then we write `#s' to denote the length of s. For example Example 9.4 The total number of trains on the destination board is given by and the total number of trains to London is given by flattening is to map a sequence of sequences to a single sequence; For example,

18 April 2009Instructor: Tasneem Darwish9 A model for sequences A sequence may be regarded as a function from the natural numbers to a collection of objects. If X is a set, then the set of all finite sequences of objects from X is defined by the following abbreviation: is used to denote the set of all finite functions from N to X a finite function is a function with a finite set as a domain If s is a sequence of at least n objects, then the expression `s n' denotes the n th object in s

18 April 2009Instructor: Tasneem Darwish10 A model for sequences Example 9.6 The second person in the queue at Counter b is Wilson: Queue_b 2 = wilson If s and t are sequences and i is a number in the range 1 … #s, Then: The i th element of s ̑ t is the i th element of s: if j is a number in the range 1 …. #t, then the (j + #s) th element of s ̑ t is the j th element of t :

18 April 2009Instructor: Tasneem Darwish11 A model for sequences

18 April 2009Instructor: Tasneem Darwish12 A model for sequences The function squash takes a finite function defined upon the natural numbers and returns a sequence.

18 April 2009Instructor: Tasneem Darwish13 A model for sequences The head operator definition is: The tail operator is defined as:

18 April 2009Instructor: Tasneem Darwish14 A model for sequences The set of all non-empty sequences over X Another special set of sequences is the set of all injective sequences: (sequences in which no element appears more than once.)

18 April 2009Instructor: Tasneem Darwish15 Functions on sequences We can introduce an operation f by describing its effect upon the empty sequence, and also its effect upon a sequence starting with an arbitrary element Example 9.7 The function `reverse' returns a sequence in which the elements appear in reverse order.

18 April 2009Instructor: Tasneem Darwish16 Functions on sequences For the restriction operator A common property of functions on sequences is distributivity. We say that a function f is distributive if Example 9.9 The function add one is defined on sequences of numbers by the following pair of equations: The effect of applying add one is to increase each number in the sequence by precisely one: for example, This function is distributive

18 April 2009Instructor: Tasneem Darwish17 Bags A sequence stores information about the multiplicity and ordering of its elements If we wish to record multiplicities, but not ordering, then we may represent a collection of objects as a bag write to denote the bag containing two copies of a, two copies of b, and two copies of c Example 9.12 Four friends Alice, Bill, Claire, and David are sitting in a café, waiting for their drinks to arrive. Alice and Claire have asked for espresso, Bill has asked for fruit tea, and David has asked for grape juice. Their requests can be represented by a bag: The order in which these drinks are to be delivered is unspecified

18 April 2009Instructor: Tasneem Darwish18 Bags If B is a bag of elements from set X, then B may be regarded as a partial function from X to N For example, the bag contains the same information as the function which associates each element with the number 2. the set of all bags of elements from X may be defined by the following generic abbreviation: If we wish to know how many instances of an object there are in a given bag, we can use the function count which is defined as:

18 April 2009Instructor: Tasneem Darwish19 Bags is the number of occurrences of x in B: The number of occurrences of a in the bag could be written asor Example 9.13 If drinks denotes the collection of drinks requested by the four friends, then count drinks espresso = 2 count drinks decaffeinated coffee = 0

18 April 2009Instructor: Tasneem Darwish20 Bags We define bag membership and sub-bag relations, similar to the set membership and subset relations introduced in Chapter 5: An element x is a member of bag B if it appears in the domain of B, considered as a function. A bag B is a sub-bag of another bag C of the same type if each element occurs no more often in B than it does in C.

18 April 2009Instructor: Tasneem Darwish21 Bags Example 9.14 At least one grape juice has been requested, and two of the group have asked for espresso, If B and C are bags of the same type, then their union contains as many copies of each element as B and C put together: If there are m copies of some element in bag B, and n copies of the same element in bag C, then the bag difference contains m n copies, provided that m n. If there are more copies in C than in B, then the count of this element is zero in the difference.

18 April 2009Instructor: Tasneem Darwish22 Bags Example 9.15 No sooner have the drinks been asked for than two more friends arrive Edward and Fleur, and take their places at the table. Edward asks for a cappuccino; Fleur asks for a mineral water. If we definethen: A few minutes later, a tray of drinks is brought over. It holds a mineral water, a grape juice, a decaffeinated coffee, and an espresso

18 April 2009Instructor: Tasneem Darwish23 Bags If s is a sequence, then we may extract the multiplicity information from s using the function items, which turns sequences into bags Example 9.16 Another tray is brought over with the remaining drinks; these are placed on the table in front of our friends. The order in which the drinks are placed upon the table is recorded in the following sequence, but only the count of each drink is important. The group at the table will be content, as items arrive = drinks