unit unit 04 relations it disiciplineitd1111 discrete mathematics & statistics stdtlp1 unit 4...

24
IT Disicipline IT Disicipline ITD1111 Discrete Mathematics & Statistics ITD1111 Discrete Mathematics & Statistics STDTLP STDTLP 1 Unit Unit 04 Relations Unit 4 Relations

Upload: maud-williams

Post on 01-Jan-2016

223 views

Category:

Documents


1 download

TRANSCRIPT

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 11

UnitUnit 04 Relations

Unit 4 Relations

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 22

UnitUnit 04 Relations

4.1 Introduction to Relations

Relationships between elements of sets

occur in many contexts. We have many

examples in everyday life such as those

between companies, schools and their

telephone numbers, a person and a relative,

a student and his/her student number.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 33

UnitUnit 04 Relations

Introduction to Relations

Relations can be used to solve problems such

as determining which pairs of cities are linked

by airline flights in a network, or producing a

useful way to store information in computer

databases.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 44

UnitUnit 04 Relations

Introduction to Relations

Definition: Let A and B be sets. The

Cartesian product of A and B, is defined by

E.g. If A={1,2} and B={a,b,c}, then

B}b and Aa :b){(a, BA c)}(2,b),(2,a),(2,c),(1,b),(1,a),{(1, BA

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 55

UnitUnit 04 Relations

Introduction to Relations

Relationships between elements of sets are

represented using a structure called relation.

Definition: Let A and B be sets. A relation R

from A to B (a binary relation) is a subset of BA

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 66

UnitUnit 04 Relations

4.2 Relations and Their Properties

Use ordered pairs (a, b) to represent the relationship between elements of two sets.

Example 4.2-1

Let A be the set of students in the ICT department,

Let B be the set of courses,

Let R be the relation that consists of those pairs (a, b) where a is a student enrolled in course b.

Then we may have

(Raymond, 41300), (John, 41983) belonging to R.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 77

UnitUnit 04 Relations

Example 4.2-2

Let A={0,1,2} and B={a,b}.

If R={(0,a), (0,b), (1,a), (2,b)}, then

0 is related to a

but 1 is not related to b.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 88

UnitUnit 04 Relations

Relations can be represented graphically and in tabular form

Graphical method Tabular form

R={(0,a), (0,b), (1,a), (2,b)}

0

1

2

a

b

R a b

0 X X

1 X

2 X

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 99

UnitUnit 04 Relations

4.3 Relations on a Set

Relations from a set A to itself are of special interest. • Definition: A relation on a set A is a relation from

A to A.

Example 4.3-1

Let A = {1, 2, 3, 4 }. Which ordered pairs are in

the relation ?

R ={(a, b) AA : a divides b } ?R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4,4)}

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1010

UnitUnit 04 Relations

Example 4.3-2Which of the following relations contain the ordered pairs (1, 1), (1, 2), (2, 1), (1, -1) or (2, 2) ?

SolutionR1 = {(a, b) : a < b } {(1, 1), (1, 2), (2, 2)}

R2 = {(a, b) : a > b } {(2, 1), (1, -1)}

R3 = {(a, b) : a = b or a = -b} {(1, 1), (1, -1), (2, 2)}

R4 = {(a, b) : a = b } {(1, 1), (2, 2)}

R5 = {(a, b) : a = b + 1 } {(2, 1)}

R6 = {(a, b) : a + b < 3 }. {(1, 1), (1, 2), (2, 1), (1,-1)}

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1111

UnitUnit 04 Relations

4.4 Combining Relations

Two relations from A to B can be combined

using the set operations of union ,

intersection and difference \. Consider

the following examples.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1212

UnitUnit 04 Relations

Example 4.4-1

Let R1 = {(1, 1), (2, 2), (3, 3)} and

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

then :

R1 R2 = {(1, 1), (1, 2), (1, 3), (1,4), (2, 2), (3, 3)}

R1 R2 = {(1, 1)}

R1 \ R2 = {(2, 2), (3, 3)}

R2 \ R1 = {(1, 2), (1, 3), (1,4)}

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1313

UnitUnit 04 Relations

4.5 Representing Relations

– List its ordered pairs

– Graphical method

– Tabular form

– Use zero-one matrices

– Use directed graphs

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1414

UnitUnit 04 Relations

4.5.1 Representing relations using matricesExample 4.5-1Suppose that A = {1, 2, 3} and B ={1, 2}. Let R be the relation from A to B such that it contains (a, b) if

a A, b B, and a > b.What is the matrix representing R ?Since R = {(2, 1), (3, 1), (3, 2)}, the matrix for R is :

11

01

00

RM

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1515

UnitUnit 04 Relations

4.5.2 Representing relations using directed graphs

Example 4.5-2

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

(4,1), (4,3)}

1

3

2

4

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1616

UnitUnit 04 Relations

4.6 Properties of Binary Relations

The most direct way to express a relationship

between two sets was to use ordered pairs. For

this reason, sets of ordered pairs are called

binary relations.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1717

UnitUnit 04 Relations

4.6.1 Reflexive Property of a Binary Relation

Definition:

A relation R on a set A is called reflexive if (a,

a) R for every element a A.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1818

UnitUnit 04 Relations

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

Not reflexive because 3 A but (3,3) R1

R2 = {(1, 1), (1, 2), (2, 1)}Not reflexive because, say, 4 A but (4, 4) R2

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

Reflexive

Example 4.6-1 Consider the following relations on A={1,2,3,4}. Which of these relations are reflexive?

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 1919

UnitUnit 04 Relations

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

Not reflexive - (1, 1) ?

R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3),

(2, 4),(3, 3), (3, 4), (4, 4)}

Reflexive - Why ?

R6 = {(3, 4)}

Not Reflexive - Why ?

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 2020

UnitUnit 04 Relations

4.6.2 Symmetric Property of a Binary Relation

A relation R on a set A is called symmetric if

for all a, b A, (a, b) R implies (b, a) R .

Definitions:

A relation R on a set A is called antisymmetric

if for all a, b A,

(a, b) R and (b, a) R implies a = b.

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 2121

UnitUnit 04 Relations

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

Not symmetric - (3, 4) but there is no (4, 3)

Not antisymmetric - (1, 2) & (2, 1) but 12

R2 = {(1, 1), (1, 2), (2, 1)}

Symmetric

Not antisymmetric - (1, 2) & (2, 1) but 12

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

Symmetric

Not antisymmetric - (1, 4) & (4, 1) but 14

Example 4.6-2 Which of the relations are symmetric and which are antisymmetric?

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 2222

UnitUnit 04 Relations

R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}Not symmetric - (2, 1) but no (1, 2)Antisymmetric

R5 = { (1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4),

(3, 3), (3, 4), (4, 4) }Not symmetric - (1, 3) but no (3, 1)Antisymmetric

R6 = {(3, 4)}

Not symmetric - (3, 4) but no (4, 3)Antisymmetric

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 2323

UnitUnit 04 Relations

4.6.3 Transitive Property of a Binary RelationDefinition:A relation R on a set A is called transitive if whenever (a, b) R and (b, c) R then(a, c) R, for a, b, c A.

Example 4.6-3 Which of the following relations are transitive?R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}

Not transitive because- (3, 4) & (4, 1) R1 but (3, 1) R1

IT DisiciplineIT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLPITD1111 Discrete Mathematics & Statistics STDTLP 2424

UnitUnit 04 Relations

R2 = {(1, 1), (1, 2), (2, 1)}Not transitive because

- (2, 1) & (1, 2) R2 but (2, 2) R2

R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}Not transitive - (4, 1) & (1, 2) R3 but (4, 2) R3

R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}Transitive

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

Transitive