+ All Categories
Home > Documents > Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC...

Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC...

Date post: 21-Aug-2020
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
16
Relations & Functions CSC 1300 – Discrete Structures Villanova University
Transcript
Page 1: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Relations & Functions

CSC 1300 – Discrete StructuresVillanova University

Page 2: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Relations: Basic terminologyRelations between elements of set A and set B can be expressed as sets of ordered pairs.

R : A® B

Example: The “hates” relationA = { anne, bart, cal, dave } B = { arugula, broccoli, cauliflower, dill, escarole}

R = {(anne, broccoli), (anne, cauliflower), (bart, arugula), (bart, broccoli), (bart, cauliflower), (bart, escarole), (dave, broccoli), (dave, cauliflower)}

A anne arugula Bbart broccoli cal cauliflowerdave dill

escaroledomain co-domain

R

Villanova CSC 1300 - Dr Papalaskari

• A relation R from a set A to a set B is a subset of A x B• Notation: x R y means (x,y) is in R,

i.e., x is related to y by the relation R• Examples: anne R broccoli, anne R arugula/

Page 3: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Relation on a setA relation between elements of a set A is referred to as a relation on A

R : A® A

• A relation R on the set A is a subset of A x A

Example: The “likes” relationA = { anne, bart, cal, dave }

R = {(anne, bart), (anne, cal), (bart, cal), (cal, bart), (dave, anne), (dave,dave)}

A anne

bartcal

davedomain co-domain (SAME)

Villanova CSC 1300 - Dr Papalaskari

Page 4: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Another example

Relation on set A = {1,2,3,4}(x,y) Î R if y / x has remainder 0

(i.e., x divides y) R = { (1,1), (2,2), (3,3), (4,4), (1,2), (1,3), (1,4), (2,4)}

2

1

3

4

Page 5: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Properties of Relations

• Reflexive – for all a Î A (a, a) Î R

• Symmetric– for all a, b Î A, if (a, b) Î R, then (b, a) Î R

• Antisymmetric– for all a, b Î A, if (a, b) Î R and a ≠ b, then (b, a) Ï R

• Transitive– for all a, b, c Î A, if (a, b) Î R and (b, c) Î R, then

(a,c) Î R

Given:the relation Rthe set A

Page 6: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Additional Properties

• A relation is called a partial order if it is reflexive, antisymmetric and transitive.– Partial orders represent relations that use ordered

elements– Example: Í (subset relation)

• A relation is called an equivalence relation if it is reflexive, symmetric and transitive.– Formalizes the notion of “equivalence” or “sameness”.– Example: logical equivalence

Page 7: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Equivalence Relations

Villanova CSC 1300 - Dr Papalaskari

A relation on a set A is called an equivalence relation if it is(i) reflexive,(ii) symmetric,(iii) transitive.

Formalizes the notion of “equivalence” or “sameness”.

More Examples of equivalence relations:• “to be equal” (for numbers or sets)• “to have the same number of elements” (for sets)• “to have the same age”• “to have the same remainder after division by 2” (i.e., parity)• “to have the same first 3 bits” (for bit strings)• “to have the same truth table” (for propositions)

Page 8: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Equivalence classes

Villanova CSC 1300 - Dr Papalaskari

Let R be an equivalence relation on a set X, and let a be an element of X. The set of all elements of X that are related to a by R is called the equivalence class for a and is denoted by [a].Any element b Î [a], b is called a representative of [a].

Example: Let R be a relation defined on ℤ by a R b if a + b = 0 or a - b = 0 . Equivalence classes?

Example: Let X be the set of all bit strings of length at least 3, and R be the relation “agree in the first three bits”. Find • [001]• [1101101]• [0011]

Page 9: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Partitions

Villanova CSC 1300 - Dr Papalaskari

A partition of a set X is a collection of disjoint nonempty subsets of X that have X as their union.

XX1

The collectionX1, X2, X3, X4 X2 X4is a partition of X

X3

Theorem. Let R be an equivalence relation on a set X. Then the equivalence classes of R form a partition of X.

Page 10: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Functions: Basic terminologyf : A® B

• The range of f is the set of all images of elements of A. • y is called the image of x (under f)• The image of a subset S of A, denoted by f(S), is the subset

of B that consists of the images of the elements of S:f(S) = {f(x) | xÎS}.

A a 1 Bb 2 c 3d 4 e 5

f

Villanova CSC 1300 - Dr Papalaskari

S

Example: Let f: Z ® Z be defined as f(x) = x+1. Let E be the set of even integers. What is the image of E?

A function f from A to B assigns exactly one element of B to each element of A.

We write f(x) = y if the function f assigns y to x

domainco-domainortarget space

Page 11: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Functions: examples• x2, ex, |x|, log2x, lnx

•Floor ëxû

• n!

• n mod 5

• |S| (where S is a finite subset of Z)

• ASCII table

• Identity function

Villanova CSC 1300 - Dr Papalaskari

Page 12: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

• A function ƒ : X®Y is one-to-one (or injective) ifffor each yÎY there is at most one xÎX with ƒ(x) = y• Examples:

{(1,5), (2,3), (4,5) } ƒ(x) = x2 for x Î Z

One-to-One Functions

1 52 34 6

1 10 0

-1

one-to-one / injective Not one-to-one

Villanova CSC 1300 - Dr Papalaskari

Page 13: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

A function ƒ : X®Y is onto (or surjective) if for each yÎY there exists an xÎX with ƒ(x) = y

(co-domain = range)

Onto Functions

1 10 0

-1 2

Onto(but not one-to-

one)

Neither one-to-one nor onto

1 22 43 64

{(1,2), (2,4), (3,6), (4,6) }ƒ(x) = x2 for x Î {1,0,-1} and y Î {1,0,2}

1 10 02 4

One-to-one and onto(Bijection)

ƒ(x) = x2 for x Î {1,0,2} and y Î {1,0,4}

Villanova CSC 1300 - Dr Papalaskari

Page 14: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

• A function ƒ from X to Y is a bijection (or a one-to-one correspondence) if ƒ is both one-to-one and onto (i.e., both injective and surjective).

Bijections

1 10 02 4

ƒ(x) = x2 for x Î {1,0,2} and y Î {1,0,4}

Example. Let f (x) = x+1. Is f a bijection?

• if the domain and codomain are N? • if the domain and codomain are Z? • if the domain and codomain are R?

Villanova CSC 1300 - Dr Papalaskari

One-to-one and onto(Bijection)

Page 15: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

• If a function ƒ: A à B is a bijection, the inverse function ƒ-1: : B à A is defined and is also a bijection mapping every yÎB to a unique xÎA. Hence, ƒ-1(y) = x when ƒ(x) = y.

• Examples:– ƒ = { (a,1), (b,2), (c,3) }

– ƒ(x) = x+1, x Î Z– ƒ(x) = x2, x Î R+

Inverse Function

Villanova CSC 1300 - Dr Papalaskari

Page 16: Relations & Functionsmap/1300/s20/05relationsfunctions.pdf · Equivalence Relations Villanova CSC 1300 -Dr Papalaskari A relation on a set Ais called an equivalence relationif it

Composition of FunctionsThe composition of the functions ƒ:AàB and g:BàC, denoted by g ○ ƒ is defined by:

(g ○ f)(x) = g( f(x) )Note: the range of f must be a subset of the domain of g.

Example: Let A=B=C= R+

f(x) = 3x + 2 g(x) = 1/x

• If f and g are one-to-one, so is g ○ f• If f and g are onto, so is g ○ f• If f and g are bijections, so is g ○ f• If ƒ:AàB is bijective, then

– (f o f -1)(x) = f(f -1 (x)) = x (identity on B)– (f -1 o f )(x) = f -1 (f(x)) =x (identity on A)

Villanova CSC 1300 - Dr Papalaskari


Recommended