170 likes | 564 Views
Relations. A binary relation R from a set A to a set B is a subset of A B. Domain of R = { a A | (a,b) R for some b B} Range of R = {b B | (a,b) R for some a A} Student Course Adam CS271 Adam CS301 Bill Phy101 Bill CS271
E N D
Relations • A binary relation R from a set A to a set B is a subset of • AB. • Domain of R = { a A | (a,b) R for some b B} • Range of R = {b B | (a,b) R for some a A} • Student Course • Adam CS271 • Adam CS301 • Bill Phy101 • Bill CS271 • Beth Bio101 • Beth CS271 Adam CS271 Beth CS301 Bill Phy101 Bio101
Relation on a set A relation R on a set A is a relation from A to A. Example: A = { 1, 2, 3, ,4} R = { (x,y) | x,y A, x is no greater than y and xy is a square} R= { (1,1), (1,4), ( 2,2), (4,4)} Also write xRy if (x,y) R.
Properties of a relation • A relation R on a set A is • reflextive: (x,x) R for all x A. • symmetric: for all x,y A, if (x,y) R then (y,x) R. • antisymmetric: all x,y A, if (x,y) R and x y, then (y,x) R. • transitive: for all x,y,z A, if (x,y) R and (y,z) R, then (x,z) R.
Examples N = the set of natural numbers. (1) R= { (x,y) | x,y N, x > y } antisymm, trans. (2) R={ (x,y) | x,y N, x is no less than y} reflexive, antisymm, trans. (3) R = { (x,y) | x,y N, xy is even} reflexive, symm, trans.
Transitivity: for all x,y,z N, suppose (x,y) R and (y,z) R. Then
A relation that is symmetric and antisymmetric? R = { (x,x) | xN} Every relation on N that is both symmetric and antisymmetric must be a subset of R. Enough to show that such a relation cannot contain (x,y) for xy. Otherwise, R being symmetric implies (y,x) also in R, but since xy, antisymmerty is violated.
Partial order A relation on a set which is reflexive, antisymmetric and transitive. Total order: a partial order with respect to which every pair of elements is comparable. Eg. Divide | : partial : total
Application: task scheduling Given a set of partially ordered tasks. To schedule the tasks without violating the partial order. Eg. (1,2), (2,4), (3,5), (3,1) 3,1,2,5,4
Equivalence A relation R on a set A is an equivalence relation if R is reflexive, symmetric and transitive. A partition on a set A is a collection of nonempty subsets of A such that every element of A belongs to exactly one member of . Example: ={O,E} where E is the set of even integers and O the set odd integers is a partition of the set of integers. Example: = { { 1,2,3}, {a,b,c}} is a partition of {1,a,2,b,3,c}.
Theorem: Let be a partition of a set A. Define a relation R on A such that for every pair x,yA, xRy if and only if x,y belong to the same member of . Then R is an equivalence relation.Proof: For all xA, let S(x) be the member of which contains x. Reflexive: xRx for all xA, since S(x)=S(x). Symmetric: xRy means S(x)=S(y). So S(y)=S(x), so yRx. Transitive: if xRy and yRz, then S(x)=S(y) and S(y)=S(z), so S(x)=S(z), so xRz.
Theorem Let R be an equivalence relation on a set A. Define [a] = { xA | xRa} (the equivalence class of a). Then = {[a] | aA} is a partition of A. Proof Since R is reflexive aRa for all aA, hence [a] is nonempty for all aA.
Next show that every xA belong s to exactly one member of . That is, if x [a] and x[b], then [a]=[b]. Claim: aRb (and similarly bRa). Pf: So suppose x [a] and x[b]. Then xRa and xRb. Since R is symmetric, xRa implies aRx. Now aRx and xRb, and since R is transitive, it follows that aRb.
Claim: [a] [b] Pf: For all y [a] we have yRa. Since aRb, and R is transitive, it follows that yRb, hence y[b]. Therefore [a] [b]. Similarly, [b] [a]. Therefore [a] = [b].
Example R is the relation on the set of integers so that for integers x and y, xRy iff x-y is even. Reflexive: For every integer x, xRx since x-x = 0. Symmetric: For integers x and y, if xRy, then x-y is even, since x-y= -(y-x), y-x is also even, hence yRx.
Transitive: For integers x,y and z, if xRy and yRz, then x-y and y-z are even, hence x-z = (x-y)+(y-z) is also even hence xRz. Therefore R is an equivalence. How many equivalence classes are there? [0] = the set of even integers [1] = the set of odd integers
Example: R is the relation on the set of integers so that for integers x and y, xRy iff 5 | x-y. Reflexive: 5 | x-x for all integers x. Symmetric: 5 | x-y implies 5 | y-x = -(x-y) for all integers x,y. Transitive: for all integers x,y,z, if 5 | x-y and 5 | y-z then 5 | (x-y)+(y-z) = x-z. equivalence classes: [0], [1], [2], [3], [4]