Binary Relations

(Donny, Mary)

(cousins, brother and sister, or whatever) Section 4.1 Relations - to distinguish certain ordered pairs of objects from other ordered pairs because the components of the distinguished pairs satisfy some relationship that the components of the other pairs do not.

1 2

The of a S with itself, S x S or S2, is the set e.g. Let S = {1, 2, 4}. of all ordered pairs of elements of S. On the set S x S = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), Let S = {1, 2, 3}; then (2, 4), (4, 1), (4, 2), (4, 4)} S x S = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2) , (3, 3)}

For relationship of , then (1, 1), (2, 2), (3, 3) would be the A binary  can be defined by: distinguished elements of S x S, that is, the only ordered pairs whose components are equal. x  y x = y 1. Describing the relation x  y if and only if x = y/2 x  y x < y/2 For relationship of one number being less than another, we Thus (1, 2) and (2, 4) satisfy . would choose (1, 2), (1, 3), and (2, 3) as the distinguished ordered pairs of S x S. x  y x < y 2. Specifying a subset of S x S {(1, 2), (2, 4)} is the set of ordered pairs satisfying  The notation x  y indicates that the (x, y) satisfies a relation .

3 4

Binary Relations e.g.

Definition: on a Set S Let S={1, 2}. Then S x S = {(1, 1), (1, 2), (2, 1), (2, 2)}. Given a set S, a binary relation on S is a of S x S(a set of ordered pairs of elements of S). Let  on S be given by the description x  y x + y is odd. Now that we know that a binary relation  is a subset, we see that Then (1, 2) , and (2, 1) .

x  y (x, y) 

5 6

1 For each of the following binary relations  on N, Definition: Relations on Multiple Sets decide which of the given ordered pairs belong to .

a. x  y x = y +1; (2, 2), (2, 3), (3, 3), (3,2) Given two sets S and T, a binary (3, 2)   relation from S to T is a subset of S x T. b. x  y x > y2; (1,2),(2,1),(5,2),(6,4),(4,3) Given n sets S1, S2, …Sn, n > 2, an n-ary (2, 1)  , and (5, 2)   relation on S1 x S2 x … x Sn is a subset of S1 x S2 x … x Sn.

7 8

If  is a binary relation on S, then  will consist of •Many-to-one:some second component S2 is paired with more than one first component. a set of ordered pairs of the form (S1, S2). A given first component S1 or second component S2 can be paired in various ways in the relation. •One-to-one:each first component and each second component appears only once in the relation.

•Many-to-many:at least one S1 is paired with more than one second

component and at least one S2 is paired with more than one first component.

•One-to-many:some first component S1 is paired with more than one second component.

9 10

Properties of Relations e.g. Identify each of these relations on S, where S = {2, 5, 7, 9}, as one-to-one, Definition: Reflexive, Symmetric, and Transitive Relations one-to-many, many-to-one, or many-to-many. Let  be a binary relation on a set S. Then  is reflexive means a. {(5,2), (7,5), (9,2)} (x) (xS (x, x) ) Many-to-one Every x is related to itself.  is symmetric means (x)(y) (xS  yS  (x, y)(y, x) ) b. {(2, 5), (5, 7), (7, 2), (9, 9)} If x is related to y, then y is related to x. one-to-one  is transitive means (x)(y)(z) (xS  yS  zS  (x, y) c. {(7, 9), (2, 5), (9, 9), (2, 7)}  (y, z)(x, z)) many-to-many If x is related to y and y is related to z, then x is 11 related to z. 12

2 Definition: e.g. Test each binary relation on the given set S for reflexivity, , antisymmetry, and Let  be a binary relation on a set S. Then  is antisymmetric transitivity. means: a. S = set of natural numbers N; (x)(y)(xS  yS  (x, y)(y, x)x=y) the relation  ( x  y x  y ) Reflexive  ; Symmetric X ; Antisymmetric  ; Transitive  If x is related to y and y is related to x, then x = y. b. S = {x|x is a student in CS130}; x  y x sits in the same row as y Reflexive, Symmetric, and Transitive

c. S = {1,2,3};  = {(1, 1), (2, 2), (3, 3),(1,2),(2,1)} 13 Reflexive, Symmetric, and Transitive 14

Closures of Relations e. g. Let S = {1,2,3} and  ={(1,1),(1,2),(1,3),(3,1),(2,3)} Definition: of a Relation  is not Reflexive, not Symmetric, and not Transitive. A binary relation * on a set S is the closure of a (closure of  with respect to reflexivity) relation  on S with respect to property P if {(1,1),(1,2),(1,3),(3,1),(2,3),(2,2),(3,3)} 1. * has property P. This is reflexive and contains . (Any containing  must have the relation above as 2. * . subset.) 3. * is a subset of any other relation on S that includes  Symmetric closure (closure of  with respect to symmetry) and has property P. {(1,1),(1,2),(1,3),(3,1),(2,3),(2,1),(3,2)} (closure of  with respect to transitivity) (related to “reachability in a ”, section 6.1)

15 {(1,1),(1,2),(1,3),(3,1),(2,3),(3,2),(3,3),(2,1),(2,2)} 16

Type of Binary Relation – Partial Ordering Type of Binary Relation –

Definition: Partial Ordering Definitions: Equivalence Relation A binary relation on a set S that is reflexive, antisymmetric, A binary relation on a set S that is reflexive, symmetric, and transitive is called a partial ordering on S. and transitive is called an equivalence relation on S. e.g e.g. a. On {1,2,3};  = {(1,1),(2,2),(3,3),(1,2),(2,1)} b. On S = {x|x is a student in CS130}; a. On N, set of natural numbers; x  y x  y x  y x sits in the same row as y b. On {0,1}; x  y x = y2

Row 2 Row 1 Row 5 Row 4 Row 3

17 18

3 Definition: Partial Orderings and A partition of a set S is a collection of nonempty disjoint of S whose equals S. Equivalence Relations

For  an equivalence relation on a set S and x  S, we let [x] denote Type of the set of all members of S to which x is related, called the Binary Reflexive Symmetric Anti- Transitive equivalence of x. Thus Relation Symmetric [x] = {y|y  S  x  y} Partial Yes No Yes Yes e. g. x  y “ x sits in the same row as y” Ordering Suppose that Michael, James, Anita, and Jose all sit in row 3. Then [Michael] = {Michael, James, Anita, Jose}. Equivalence Yes Yes No Yes Also [Michael] = [James] = [Anita]. Relation They are not distinct classes, but the same class with multiple names. An can take its name from any of the elements in it. 19 20

4