Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relations Compare with function – Function: Set of ordered pairs where x’s don’t repeat x’s come from domain; y’s come from co-domain Purpose: to transform.

Similar presentations


Presentation on theme: "Relations Compare with function – Function: Set of ordered pairs where x’s don’t repeat x’s come from domain; y’s come from co-domain Purpose: to transform."— Presentation transcript:

1 Relations Compare with function – Function: Set of ordered pairs where x’s don’t repeat x’s come from domain; y’s come from co-domain Purpose: to transform input into output – Relation: Any set of ordered pairs: the x’s may repeat x and y must be drawn from the same set. Purpose: to exhibit relationships among data in a set. Examples & properties

2 Relations Within some set, the elements may have some relationship Can be depicted by – A formula – List/set of ordered pairs – Directed graph – Adjacency matrix Example: the “<“ relation on the set { 1, 2, 3, 4 } – 1 points to 2, 3, 4 – etc. Standard notation: xRy means “x is related to y” where R is the name of the relation.

3 Examples Let S = { 1, 2, 3, 4, 5 }. Relations will be over this set. xRy if y = x + 1 – A special case of a relation is a function. All functions are relations, but not all relations are functions! xRy if y = x  1 R = S  S – This is called the complete relation. xRy if x mod 3 = y mod 3 – What if we had more numbers in S? xRy = x | y

4 Properties of relations Reflexive  x: xRx Symmetric  x,y: xRy  yRx Antisymmetric  x,y: (x  y  xRy)  ~ yRx Transitive  x,y,z: (xRy  yRz)  xRz Definite  x,y: xRy  yRx Type of relation Reflexive?Symmetric?Antisym- metric? Transitive?Definite? Equivalence relation YYY Partial orderYYY Total orderYYYY

5 Adjacency matrix Relation properties are sometimes easier to discern if you look at an adjacency matrix. Reflexive: All 1’s along main diagonal Symmetric Anti-symmetric: Away from main diagonal, all 1’s have a 0 across the main diagonal (mirror image). Transitive – not much help Definite: Main diagonal is all 1’s, and for each other cell, either it or its mirror image is a 1. 101 011 100

6 Try these =<≤  Same suit Reflexive? Symmetric? Antisymmetric? Transitive? Definite? Equiv. rel. ? Partial order? Total order? For the relational operators, let’s assume that the underlying set of objects is some subset of the integers, e.g. { 1, 2, 3 }.

7 Properties cont’d Equivalence relation = a relation that is reflexive, symmetric, and transitive. – Useful when you want a collection of objects to be grouped into some partitions What are some examples? Partial/total order: – Useful when the set of objects need to be ranked Many relations are possible. For example, for a set of 3 elements, you can have 512 possible relations. (Do you know why?) However, most are not useful.

8 Examples of equiv. rel. On the set of (positive) integers: – Same remainder when divided by 6 – End in same digit – Start with same digit – Same number of digits – Same number of divisors On the set of people: – Live in same ZIP code – Same sign of the zodiac – Alumni of the same college – Same blood type – Same native language In each case, how many equivalence classes are there?


Download ppt "Relations Compare with function – Function: Set of ordered pairs where x’s don’t repeat x’s come from domain; y’s come from co-domain Purpose: to transform."

Similar presentations


Ads by Google