Top Banner
1 Relations Relations
19

1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Dec 17, 2015

Download

Documents

Austen Lewis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

1

RelationsRelations

Page 2: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

2

RelationsRelationsIf we want to describe a relationship between If we want to describe a relationship between elements of two sets A and B, we can use elements of two sets A and B, we can use ordered pairsordered pairs with their first element taken with their first element taken from A and their second element taken from B. from A and their second element taken from B.

Since this is a relation between Since this is a relation between two setstwo sets, it is , it is called a called a binary relationbinary relation..

Definition:Definition: Let A and B be sets. A binary Let A and B be sets. A binary relation from A to B is a subset of Arelation from A to B is a subset of AB.B.

In other words, for a binary relation R we have In other words, for a binary relation R we have R R A AB. We use the notation aRb to denote B. We use the notation aRb to denote that (a, b)that (a, b)R and aR and aRb to denote that (a, b)b to denote that (a, b)R.R.

Page 3: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

3

RelationsRelationsWhen (a, b) belongs to R, a is said to be When (a, b) belongs to R, a is said to be relatedrelated to b by R. to b by R.Example:Example: Let P be a set of people, C be a set Let P be a set of people, C be a set of cars, and D be the relation describing which of cars, and D be the relation describing which person drives which car(s).person drives which car(s).P = {Carl, Suzanne, Peter, Carla}, P = {Carl, Suzanne, Peter, Carla}, C = {Mercedes, BMW, tricycle}C = {Mercedes, BMW, tricycle}D = {(Carl, Mercedes), (Suzanne, Mercedes),D = {(Carl, Mercedes), (Suzanne, Mercedes), (Suzanne, BMW), (Peter, tricycle)} (Suzanne, BMW), (Peter, tricycle)}This means that Carl drives a Mercedes, This means that Carl drives a Mercedes, Suzanne drives a Mercedes and a BMW, Peter Suzanne drives a Mercedes and a BMW, Peter drives a tricycle, and Carla does not drive any drives a tricycle, and Carla does not drive any of these vehicles.of these vehicles.

Page 4: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

4

Functions as RelationsFunctions as Relations

You might remember that a You might remember that a functionfunction f from a f from a set A to a set B assigns a unique element of B set A to a set B assigns a unique element of B to each element of A.to each element of A.

The The graphgraph of f is the set of ordered pairs (a, b) of f is the set of ordered pairs (a, b) such that b = f(a).such that b = f(a).

Since the graph of f is a subset of ASince the graph of f is a subset of AB, it is a B, it is a relationrelation from A to B. from A to B.

Moreover, for each element Moreover, for each element aa of A, there is of A, there is exactly one ordered pair in the graph that has exactly one ordered pair in the graph that has aa as its first element. as its first element.

Page 5: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

5

Functions as RelationsFunctions as Relations

Conversely, if R is a relation from A to B such Conversely, if R is a relation from A to B such that every element in A is the first element of that every element in A is the first element of exactly one ordered pair of R, then a function exactly one ordered pair of R, then a function can be defined with R as its graph.can be defined with R as its graph.

This is done by assigning to an element aThis is done by assigning to an element aA A the unique element bthe unique element bB such that (a, b)B such that (a, b)R.R.

Page 6: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

6

Relations on a SetRelations on a Set

Definition:Definition: A relation on the set A is a relation A relation on the set A is a relation from A to A.from A to A.

In other words, a relation on the set A is a In other words, a relation on the set A is a subset of Asubset of AA.A.

Example:Example: Let A = {1, 2, 3, 4}. Which ordered Let A = {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a < b} ?pairs are in the relation R = {(a, b) | a < b} ?

Page 7: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

7

Relations on a SetRelations on a Set

Solution:Solution: R = { R = {(1, 2),(1, 2),(1, 3),(1, 3),(1, 4),(1, 4),(2, 3),(2, 3),(2, 4),(2, 4),(3, 4)}(3, 4)}

RR 11 22 33 44

11

22

33

44

11 11

22

33

44

22

33

44

XX XX XX

XX XX

XX

Page 8: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

8

Relations on a SetRelations on a SetHow many different relations can we How many different relations can we define on a set A with n elements?define on a set A with n elements?

A relation on a set A is a subset of AA relation on a set A is a subset of AA.A.How many elements are in AHow many elements are in AA ?A ?

There are nThere are n22 elements in A elements in AA, so how many A, so how many subsets (= relations on A) does Asubsets (= relations on A) does AA have?A have?

The number of subsets that we can form out of The number of subsets that we can form out of a set with m elements is 2a set with m elements is 2mm. Therefore, 2. Therefore, 2nn22 subsets can be formed out of Asubsets can be formed out of AA.A.

Answer:Answer: We can define 2 We can define 2nn22 different relations different relations on A.on A.

Page 9: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

9

Properties of RelationsProperties of RelationsWe will now look at some useful ways to We will now look at some useful ways to classify relations.classify relations.

Definition:Definition: A relation R on a set A is called A relation R on a set A is called reflexivereflexive if (a, a) if (a, a)R for every element aR for every element aA.A.

Are the following relations on {1, 2, 3, 4} Are the following relations on {1, 2, 3, 4} reflexive?reflexive?R = {(1, 1), (1, 2), (2, 3), (3, 3), R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)}(4, 4)}

NoNo..R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, R = {(1, 1), (2, 2), (2, 3), (3, 3), (4,

4)}4)}Yes.Yes.

R = {(1, 1), (2, 2), (3, 3)}R = {(1, 1), (2, 2), (3, 3)} NoNo..

Definition:Definition: A relation on a set A is called A relation on a set A is called irreflexiveirreflexive if (a, a) if (a, a)R for every element aR for every element aA.A.

Page 10: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

10

Properties of RelationsProperties of Relations

Definitions:Definitions:

A relation R on a set A is called A relation R on a set A is called symmetricsymmetric if if (b, a)(b, a)R whenever (a, b)R whenever (a, b)R for all a, bR for all a, bA. A.

A relation R on a set A is called A relation R on a set A is called antisymmetricantisymmetric if if a = b whenever (a, b)a = b whenever (a, b)R and (b, a)R and (b, a)R.R.

A relation R on a set A is called A relation R on a set A is called asymmetricasymmetric if if (a, b)(a, b)R implies that (b, a)R implies that (b, a)R for all a, bR for all a, bA. A.

Page 11: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

11

Properties of RelationsProperties of RelationsAre the following relations on {1, 2, 3, 4} Are the following relations on {1, 2, 3, 4} symmetric, antisymmetric, or asymmetric?symmetric, antisymmetric, or asymmetric?

R = {(1, 1), (1, 2), (2, 1), (3, 3), R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)}(4, 4)}

symmetrisymmetriccR = {(1, 1)}R = {(1, 1)} sym. sym. and and antisymantisym..R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} antisym. antisym. and and asym.asym.

R = {(4, 4), (3, 3), (1, 4)}R = {(4, 4), (3, 3), (1, 4)} antisym.antisym.

Page 12: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

12

Properties of RelationsProperties of Relations

Definition:Definition: A relation R on a set A is called A relation R on a set A is called transitivetransitive if whenever (a, b) if whenever (a, b)R and (b, c)R and (b, c)R, R, then (a, c)then (a, c)R for a, b, cR for a, b, cA. A.

Are the following relations on {1, 2, 3, 4} Are the following relations on {1, 2, 3, 4} transitive?transitive?

R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)}3)}

Yes.Yes.

R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} No.No.

R = {(2, 4), (4, 3), (2, 3), (4, 1)}R = {(2, 4), (4, 3), (2, 3), (4, 1)} No.No.

Page 13: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 13

Equivalence Relations Equivalence Relations

Equivalence relationsEquivalence relations are used to relate are used to relate objects that are similar in some way.objects that are similar in some way.

Definition:Definition: A relation on a set A is called an A relation on a set A is called an equivalence relation if it is reflexive, equivalence relation if it is reflexive, symmetric, and transitive.symmetric, and transitive.

Two elements that are related by an Two elements that are related by an equivalence relation R are called equivalence relation R are called equivalentequivalent..

Page 14: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 14

Equivalence Relations Equivalence Relations

Since R is Since R is symmetricsymmetric, a is equivalent to b , a is equivalent to b whenever b is equivalent to a.whenever b is equivalent to a.

Since R is Since R is reflexivereflexive, every element is , every element is equivalent to itself.equivalent to itself.

Since R is Since R is transitivetransitive, if a and b are equivalent , if a and b are equivalent and b and c are equivalent, then a and c are and b and c are equivalent, then a and c are equivalent.equivalent.

Obviously, these three properties are necessary Obviously, these three properties are necessary for a reasonable definition of equivalence.for a reasonable definition of equivalence.

Page 15: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 15

Equivalence Relations Equivalence Relations Example:Example: Suppose that R is the relation on the set Suppose that R is the relation on the set of strings that consist of English letters such that of strings that consist of English letters such that aRb if and only if l(a) = l(b), where l(x) is the length aRb if and only if l(a) = l(b), where l(x) is the length of the string x. Is R an equivalence relation?of the string x. Is R an equivalence relation?

Solution:Solution: • R is reflexive, because l(a) = l(a) and therefore R is reflexive, because l(a) = l(a) and therefore aRa for any string a. aRa for any string a.• R is symmetric, because if l(a) = l(b) then l(b) = R is symmetric, because if l(a) = l(b) then l(b) = l(a), so if aRb then bRa. l(a), so if aRb then bRa.• R is transitive, because if l(a) = l(b) and l(b) = l(c), R is transitive, because if l(a) = l(b) and l(b) = l(c), then l(a) = l(c), so aRb and bRc implies aRc. then l(a) = l(c), so aRb and bRc implies aRc.

R is an equivalence relation.R is an equivalence relation.

Page 16: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 16

Equivalence Classes Equivalence Classes Definition: Definition: Let R be an equivalence relation on Let R be an equivalence relation on a set A. The set of all elements that are related a set A. The set of all elements that are related to an element a of A is called the to an element a of A is called the equivalence equivalence classclass of a. of a.

The equivalence class of a with respect to R is The equivalence class of a with respect to R is denoted by denoted by [a][a]RR..

When only one relation is under consideration, When only one relation is under consideration, we will delete the subscript R and write we will delete the subscript R and write [a][a] for for this equivalence class.this equivalence class.

If bIf b[a][a]RR, b is called a , b is called a representativerepresentative of this of this equivalence class.equivalence class.

Page 17: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 17

Equivalence Classes Equivalence Classes

Example: Example: In the previous example (strings of In the previous example (strings of identical length), what is the equivalence class identical length), what is the equivalence class of the word mouse, denoted by [mouse] ?of the word mouse, denoted by [mouse] ?

Solution:Solution: [mouse] is the set of all English [mouse] is the set of all English words containing five letters.words containing five letters.

For example, ‘horse’ would be a representative For example, ‘horse’ would be a representative of this equivalence class.of this equivalence class.

Page 18: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 18

Equivalence Classes Equivalence Classes Theorem: Theorem: Let R be an equivalence relation on a Let R be an equivalence relation on a set A. The following statements are equivalent:set A. The following statements are equivalent:• aRbaRb• [a] = [b][a] = [b]• [a] [a] [b] [b]

Definition:Definition: A A partition partition of a set S is a collection of of a set S is a collection of disjoint nonempty subsets of S that have S as their disjoint nonempty subsets of S that have S as their union. In other words, the collection of subsets Aunion. In other words, the collection of subsets A ii, , iiI, forms a partition of S if and only if I, forms a partition of S if and only if (i) A(i) Aii for i for iII

• AAii A Ajj = = , if i , if i j j

• iiII A Aii = S = S

Page 19: 1 Relations. 2Relations If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element.

Fall 2002 CMSC 203 - Discrete Structures 19

Equivalence Classes Equivalence Classes Examples: Examples: Let S be the set {u, m, b, r, o, c, k, s}.Let S be the set {u, m, b, r, o, c, k, s}.Do the following collections of sets partition S ?Do the following collections of sets partition S ?

{{m, o, c, k}, {r, u, b, {{m, o, c, k}, {r, u, b, s}}s}}

yes.yes.

{{c, o, m, b}, {u, s}, {{c, o, m, b}, {u, s}, {r}}{r}}

no (k is missing).no (k is missing).

{{b, r, o, c, k}, {m, u, s, {{b, r, o, c, k}, {m, u, s, t}}t}}

no (t is not in S).no (t is not in S).

{{u, m, b, r, o, c, k, s}}{{u, m, b, r, o, c, k, s}} yes.yes.

{{b, o, o, k}, {r, u, m}, {{b, o, o, k}, {r, u, m}, {c, s}}{c, s}}

yes ({b,o,o,k} = yes ({b,o,o,k} = {b,o,k}).{b,o,k}).

{{u, m, b}, {r, o, c, k, s}, {{u, m, b}, {r, o, c, k, s}, }}

no (no ( not allowed). not allowed).