70 likes | 313 Views
Relations. Generalization of function Any set of ordered pairs Examples & properties. 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
E N D
Relations • Generalization of function • Any set of ordered pairs • Examples & properties
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.
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
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
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.
Try these For the relational operators, let’s assume that the underlying set of objects is some subset of the integers, e.g. { 1, 2, 3 }.
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. However, most are not useful.