Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "08 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal."— Presentation transcript:

1 08 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Relations

2 08 April 2009Instructor: Tasneem Darwish2 Outlines Relational inverse Relational composition Closures

3 08 April 2009Instructor: Tasneem Darwish3 Relational inverse For a relation R, which is an element of the set, X is the source set and Y is the target set of R. The relational inverse (~) operator exchange the source and target. the elements of each ordered pair are exchanged. the result is an element of The relation R ~ maps y to x exactly when R maps x to y Example 7.9 The inverse of the relation drives, defined in Example 7.2, relates cars to their drivers:

4 08 April 2009Instructor: Tasneem Darwish4 Relational inverse The relation is homogeneous if the target and source are of the same type. The relation is heterogeneous if the target and source are not of the same type. An important homogeneous relation is the identity relation, defined by If a homogeneous relation contains the identity relation, then it is reflexive R is reflexive if Example 7.11 The relation ≤ upon natural numbers is reflexive; the relation < is not.

5 08 April 2009Instructor: Tasneem Darwish5 Relational inverse A homogenous relation is symmetric if whenever it relates x to y, it also relates y to x. A homogeneous relation is antisymmetric, if it is impossible for two different elements to be related in both directions. A homogeneous relation R is asymmetric if whenever it relates x to y, it doesn’t relate y to x. Example 7.14 The strict subset relation is asymmetric: it is impossible to find two sets s and t such that

6 08 April 2009Instructor: Tasneem Darwish6 Relational composition Relational composition is when the target type of one relation matches the source type of another, and they are combined to form a single relation. If R is an element of, and S is an element of, then we write to denote the relational composition of R and S which is the element of

7 08 April 2009Instructor: Tasneem Darwish7 Relational composition Example 7.16 The relation uses of type Cars↔Fuels tells us which fuel is used by each of the cars in Example 7.2: We may compose the relations drives and uses to find out which fuels a driver may purchase. The type of buys is

8 08 April 2009Instructor: Tasneem Darwish8 Relational composition A homogeneous relation R is transitive if every pair of connecting maplets and in R has a corresponding maplet in R. Example 7.17 The greater-than relation on natural numbers N is transitive: whenever a > b and b > c, we know that a > c If a homogeneous relation is reflexive, symmetric, and transitive, then it is an equivalence relation:

9 08 April 2009Instructor: Tasneem Darwish9 Closures the principle of closure involves adding maplets to a relation until some useful property is achieved The simplest form of closure is obtained by adding the identity relation to get reflexive closure Example 7.21 The reflexive closure < r is the relation. The symmetric closure is obtained by adding enough maplets to produce a symmetric relation.

10 08 April 2009Instructor: Tasneem Darwish10 Closures For any positive natural number n, we may write R n to denote the composition of n copies of R: that is: R −n is the inverse of R n and R 0 is the identity relation. The information obtained from all finite iterations of R can be combined to form the relation R +

11 08 April 2009Instructor: Tasneem Darwish11 Closures The information obtained from all finite iterations of R can be combined to form the relation R + R+ is the transitive closure of R; it is the smallest transitive relation containing R. Example 7.25 We may use a relation direct to record the availability of a direct flight between two airports. For the four airports shown this relation is given by The composition comprises all of the possibly indirect Flights that involve at most one stop en route

12 08 April 2009Instructor: Tasneem Darwish12 Closures Example 7.25 We may use a relation direct to record the availability of a direct flight between two airports. For the four airports shown this relation is given by The composition comprises all of the possibly indirect Flights that involve at most one stop in route Two step in route

13 08 April 2009Instructor: Tasneem Darwish13 Closures Example 7.25 at most one stop in route Two step in route direct 4 = direct 2 and that direct 5 = direct 3

14 08 April 2009Instructor: Tasneem Darwish14 Closures Example 7.26 The transitive closure of direct relates two airports exactly when there is a route between them consisting of some number of direct flights It is sometimes useful to consider the reflexive transitive closure of a homogeneous relation. If R is a relation of type X↔X, then we write R* to denote the smallest relation containing R that is both reflexive and transitive,

15 08 April 2009Instructor: Tasneem Darwish15 Closures Example 7.27 In the direct + relation, there is no way to travel from Perth to Perth. However, if we are planning the movement of equipment between locations, we might wish to record the fact any equipment already at Perth can be moved to Perth. In this case, we would consider the reflexive transitive closure direct of our flights relation:


Download ppt "08 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal."

Similar presentations


Ads by Google