The Z Notation: relations and functions Compiled By Tariq R. Soomro, Ph.D. Reference: Text Book Week-7.

Slides:



Advertisements
Similar presentations
Copyright © Cengage Learning. All rights reserved.
Advertisements

Mathematics as a Second Language Mathematics as a Second Language Mathematics as a Second Language Developed by Herb I. Gross and Richard A. Medeiros ©
The Engineering Design of Systems: Models and Methods
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
FUNCTIONS AND MODELS Chapter 1. Preparation for calculus :  The basic ideas concerning functions  Their graphs  Ways of transforming and combining.
Relations. Ipoh Kota Bharu Alor Star Seremban Pasir Mas Perak Kelantan Kedah Neg. Sembilan citiesstates isin.
Relations. Ipoh Kota Bharu Alor Star Seremban Pasir Mas Perak Kelantan Kedah Neg. Sembilan citiesstates isin.
LIMITS 2. LIMITS 2.4 The Precise Definition of a Limit In this section, we will: Define a limit precisely.
7 INVERSE FUNCTIONS. The common theme that links the functions of this chapter is:  They occur as pairs of inverse functions. INVERSE FUNCTIONS.
Copyright © Cengage Learning. All rights reserved.
Functions. A function between two sets is a relation between those sets that has a special property, namely that each member of the from-set is related.
LIAL HORNSBY SCHNEIDER
VECTORS AND THE GEOMETRY OF SPACE Vectors VECTORS AND THE GEOMETRY OF SPACE In this section, we will learn about: Vectors and their applications.
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Adding Vectors, Rules When two vectors are added, the sum is independent of the order of the addition. This is the Commutative Law of Addition.
 We noticed in Section 2.3 that the limit of a function as x approaches a can often be found simply by calculating the value of the function at a.  Functions.
The importance of sequences and infinite series in calculus stems from Newton’s idea of representing functions as sums of infinite series.  For instance,
Vectors and the Geometry of Space 9. Vectors 9.2.
Copyright © Cengage Learning. All rights reserved. 12 Vectors and the Geometry of Space.
Copyright © Cengage Learning. All rights reserved. CHAPTER 3 THE LOGIC OF QUANTIFIED STATEMENTS THE LOGIC OF QUANTIFIED STATEMENTS.
Copyright © Cengage Learning. All rights reserved. 1 Functions and Models.
Common Fractions © Math As A Second Language All Rights Reserved next #6 Taking the Fear out of Math 1 3 ×1 3 Multiplying.
Copyright © Cengage Learning. All rights reserved. 11 Infinite Sequences and Series.
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved. 6 Inverse Functions.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 17 part 2 By Herbert I. Gross and Richard A. Medeiros next.
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Infinite Sequences and Series 8. Sequences Sequences A sequence can be thought of as a list of numbers written in a definite order: a 1, a 2, a.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 4 Inverse, Exponential, and Logarithmic Functions Copyright © 2013, 2009, 2005 Pearson Education,
Chapter 1 Logic and Proof.
Vectors and the Geometry
Copyright © Cengage Learning. All rights reserved.
Chapter 2 Sets and Functions.
The Language of Sets If S is a set, then
Relations and Functions
2.7 Combining Functions.
Copyright © Cengage Learning. All rights reserved.
Chapter 2 Sets and Functions.
7 INVERSE FUNCTIONS.
Chapter 2 Sets and Functions.
Discrete Structure II: Introduction
Transformations of Functions
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Section 8.2 Functions.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
College Algebra Fifth Edition
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Section 11.2 Inverse Functions.
VECTORS.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

The Z Notation: relations and functions Compiled By Tariq R. Soomro, Ph.D. Reference: Text Book Week-7

Relations Example from Text Book: –Jim plays piano –John plays guitar Here, the first element is taken from the set of people and the second from the set of instruments A person is related to instrument if he or she plays that instrument –Jim is brother of John –Janny is mother of Jim –Janny is mother of John In this case, pairs of people are related so the two sets concerned are in fact the same. We borrow the familiar term ‘relation’, used to describe kinship of people, to refer to any interesting connection between the element of sets.

Relations It is sometimes helpful when thinking about relations to use pictures to gain an intuition about the idea before making a formal expression of them using mathematical notation. This can be done in the form shown below. We could capture some information about modes of transport of the Potter family from the following:

Relations In this example Kate and Tricycle have no connecting arrows, which means that Kate does not ride any of the wheeled vehicles and that none of the Potters rides a tricycle. The relation itself is completely defined by the connection between the elements of the sets Another way of recording the information contained in the picture would be to write down all the pairs of related elements. For the rides relation these are: (Alice, Bicycle) (Huw, Bicycle) (Ben, Unicycle) (Ben, Bicycle) rides == { (Alice, Bicycle), (Huw, Bicylce), (Ben, Unicycle), (Ben, Bicycle)} Also, form our knowledge of sets we can deduce that the type of rides is: P (Potters x WheeledVehicles) since this is the type of such a set of order pairs.

Relations Since the idea of a relation is so useful and occurs so often in Z specifications we introduce some special notation. A relation between sets X and Y is a member of: – P (X x Y) As a shorthand for this, and to emphasize the relational nature of a set of ordered pairs, we introduced the double-headed arrow notation: –X ↔ Y == P (X x Y) The notation can be used when declaring relations, for instance: –Rides: Potters ↔ WheeledVehicles –Plays: People ↔ Instruments

Relations A special notation may also be used for the pairs which make up a relation. Instead of writing (x, y) for a related pair we sometimes use the maplet notation: –x  y Which is read ‘x maps to y’ Using maplet notation the rides relation may be written: {Alice  Bicycle, Huw  Bicycle, Ben  Unicycle, Ben  Bicycle} And as before we can make statements about maplet: –Alice  Bicycle Є rides and –{Huw  Bicycle, Ben  Bicycle} C rides

Relations Given sets A and B, a relation R from A to B has declaration R : A ↔ B and is some subset of A × B, i.e. A ↔ B is an alternative denotation for the set P (A × B). As an example, consider the relation factor where A is the set and B the set 6.. 9, and where an element x Є is related to an element y Є if and only if x is a factor of y. The relation is formally defined by

Relations This example illustrates the use of an open schema box — a two dimensional form of schema text. The relation name is introduced and typed in the declaration part (above the horizontal dividing line). The predicate specifying precisely which ordered pairs are in the relation appears in the predicate part (below the horizontal line). In effect, the horizontal line serves the role of ‘|’ in non-boxed schema text and is also read as ‘such that’. The ‘open’ indicates that the quantities defined are accessible within the environment in which the box is placed.

Relations Domain and range The two sets used in the declaration of a relation are sometimes referred to as the source and target respectively The rides relation is an example of a relation between Potters and WheeledVehicles: in this case, Potters is the source set and WheelVehicles is a target. A relation need not relate every member of the source or of the target; in either set, only a subset might be used in the description of the relation In the rides example Kate is a member of the source but is not related to anything, and in the target set Tricycle is an element not ridden by anyone

Relations Domain and range It can be useful to give names to the subsets of the source and target whose elements really are involved in the description of the relation The subset of elements of the source which are related to at least one element of the target is known as the domain of the relation The domain of rides is: {Alice, Huw, Ben} Similarly, the range consists of all elements of the target set which are related to some elements of the source The range of rides is: {Bicycle, Unicycle}

Relations Domain and range Given a relation R : A ↔ B, the domain of R, denoted dom R, is the set of elements of A related by R to some element in B, i.e. –dom R = {a : A | b : B a  b ε R}. Similarly, the range of R, denoted ran R, is the set of elements of B which are related by R to some element in A, i.e. –ran R = {b : B | a : A a  b ε R}.

Relations Operations on relations Relational inverse Sometimes it may be useful to look at relations the other way round For example, having defined the rides relation it may be found desirable to know what is ridden by whom rather than who rides what We might call this the is isriddenby relation To obtain the new relation we would have to reverse the order of each pair in the original For instance, since: –Ben rides Unicycle Is part of rides relation, we would expect to see –Unicycle isriddenby Ben Reversing all the pairs define the new relation: –Isriddenby == {(Unicycle, Ben), (Bicycle, Ben), (Bicycle, Alice), (Bicycle, Huw)}

Relations Operations on relations Relational inverse This process of reversing a relation gives a new relation which is known as the inverse We denote the inverse operation by the suerscript, ~ So for example: –isriddenby = rides ~ –rides = isriddenby ~

Relations Operations on relations Restriction and Subtraction: Suppose that, given the rides relation, the modes of transport of Alice and Kate are found to be special interest, perhaps as part of a survey to see which cycles women ride We might want to make a smaller relation by considering only the pairs which relate Alice and Kate to some wheeled vehicle Restricting rides in this way would produce the relation: –wrides = {Alice  Bicycle} Creating a smaller relation like this, by considering only part of the original domain, is known as domain restriction The following notation is used: –wrides == {Alice, Kate} ◄ rides The domain restriction operator, ◄, appears between the set that we wish to restrict the domain to and the name of the relation being restricted

Relations Operations on relations Restriction and Subtraction: Notice that the restricting set appears on the left with one point of the triangle facing towards it There is a complementary range restriction operation which creates a smaller relation by considering only a part of the original range For instance, suppose we are interested in a relation which tells us who rides a bicycle This can be obtained by restricting the range of rides to the singleton set {Bicycle} For this we would write –rides ►{Bicycle} The range restriction the restricting set appears to the right of the range restriction symbol ►

Relations Operations on relations Restriction and Subtraction: Supposed that instead of restricting the domain (or range) to a certain set we have a particular set of elements which we would like to remove from the domain (or range) This can be done in similar way by using domain (or range) subtraction

Relations Operations on relations Restriction and Subtraction:

Relations Operations on relations Composition of relation: Given two relation such that the range type of the first is the same as the domain type of the second, it is useful to be able to put the relation ‘end to end’ and form a single relation containing all pairs joined by some common element To see how this works, let us define a new relation hasweels which relates wheeled vehicles to the number of wheels they possess: –haswheels == {Unicycle  1, Bicycle  2, Tricycle  3} We now have two relations: –rides: Potters ↔ WheeledVehicles –haswheels: WheeledVehicles ↔ N 1

Relations Operations on relations Composition of relation: The range type of rides and the domain type of haswheels are the same so we can compose rides with haswheels to produce a new relation ridesonwhools of type Potters ↔ N 1 which records how many wheels each of the Potters can ride on A picture shows how this composition is achieved

Relations Operations on relations Composition of relation:

Relations Operations on relations Composition of relation: To find which Potters are related to which numbers we must include all possible paths through this diagram from Potters to N 1 This shows that: –ridesonwheels == {Ben  1, Ben  2, Alice  2, Huw  2} The composition operation is donoted by ; and we write: –ridesonwheels == rides ; haswheels As another example, supposed we have two relations, R 1, R 2 : N ↔ N with: –R 1 = {0  1, 2  0, 2  1} –R 2 = {1  0, 1  2, 2  1} As before we draw a diagram to represent their composition:

Relations Operations on relations Composition of relation:

Relations Operations on relations Composition of relation: To obtain R 1 ; R 2 we must find all pairs of numbers where the first is in dom R 1 the second is in ran R 2 and they are connected to some common intermediate number by both R 1 and R 2 This time there are more branching paths so we must be careful to include all the possibilities We see that R 1 connects 0 to 1 and that R 2 connects 1 to both 0 and 2 So the composed relation must contain both (0,0) and (0,2). R 1 does not connect 1 to anything, so there can be no pairs with first element 1 in the composition Finally, 2 is related to both 0 and 1 by R 1

Relations Operations on relations Composition of relation: R 2 does not connect 0 to anything so that path comes to an end But again, 1 is connected to both 0 and 2 so the pairs (2,0) and (2,2) are both present in the composition Putting this together gives: –R 1 ; R 2 {0  0, 0  2, 2  0, 2  2}