slides - UCSD CSE

CSE 20: Discrete Mathematics
for Computer Science
Prof. Shachar Lovett
2
Todayโ€™s Topics:
1.
2.
3.
Functions
Properties of functions
Inverse
3
1. Functions
4
Definition of a function
๏‚›A
function ๐‘“: ๐‘‹ โ†’ ๐‘Œ is a mapping that maps
each element of X to an element of Y
๏‚› Each
element of X is mapped to exactly
one element of Y
๏‚› Not two
๏‚› Not none
๏‚› Exactly one!
5
What is a function?
๏‚› Is
A.
B.
the following a function from X to Y?
Yes
No
X
Y
6
What is a function?
๏‚› Is
A.
B.
the following a function from X to Y?
Yes
No
X
Y
7
What is a function?
๏‚› Is
A.
B.
the following a function from X to Y?
Yes
No
X
Y
8
What is a function?
๏‚› Is
A.
B.
the following a function from X to Y?
Yes
No
Y
X
9
What is a function?
๏‚› Is
A.
B.
the following a function from Y to X?
Yes
No
Y
X
10
What is a function
๏‚›A
function f:X๏ƒ Y maps any element of X
to an element of Y
๏‚› Every
element of X is mapped โ€“ f(x) is
always defined
๏‚› Every
element of X is mapped to just one
value in Y
11
Properties of functions
Injective, surjective, bijective
12
Injective, Surjective, Bijectiveโ€ฆ
๏‚›
๏‚›
Function f:X ๏ƒ  Y
f is injective if: f(x)=f(y) ๏ƒž x=y
๏‚›
๏‚›
f is surjective if: ๏€ ๏€ขy๏ƒŽY ๏€คx๏ƒŽX s.t. f(x)=y
๏‚›
๏‚›
๏‚›
That is, no two elements in X are mapped to the
same value
There is always an โ€œpre-imageโ€
Could be more than one x!
f is bijective if it is both injective and surjective
13
Injective, Surjective, Bijectiveโ€ฆ
๏‚› Is
A.
B.
C.
D.
the following function
Injective
Surjective
Bijective
None
X
Y
14
Injective, Surjective, Bijectiveโ€ฆ
๏‚› Is
A.
B.
C.
D.
the following function
Injective
Surjective
Bijective
None
X
Y
15
Injective, Surjective, Bijectiveโ€ฆ
๏‚› Is
A.
B.
C.
D.
the following function
Injective
Surjective
Bijective
None
X
Y
16
Injective, Surjective, Bijectiveโ€ฆ
๏‚› Which
of the following functions f:N๏‚ฎN is
not injective
A.
B.
C.
D.
E.
f(x)=x
f(x)=x2
f(x)=x+1
f(x)=2x
None/other/more than one
17
Injective, Surjective, Bijectiveโ€ฆ
๏‚› Which
of the following functions f:N๏‚ฎN is
not surjective
A.
B.
C.
D.
E.
f(x)=x
f(x)=x2
f(x)=x+1
f(x)=2x
None/other/more than one
18
Inverses
19
Inverse functions
๏‚›
๏‚›
Functions ๐‘“: ๐‘‹ โ†’ ๐‘Œ and ๐‘”: ๐‘Œ โ†’ ๐‘‹ are inverses if
โˆ€๐‘ฅ โˆˆ ๐‘‹, ๐‘” ๐‘“ ๐‘ฅ
=๐‘ฅ
โˆ€๐‘ฆ โˆˆ ๐‘Œ, ๐‘“ ๐‘” ๐‘ฆ
=๐‘ฆ
In this case we write ๐‘” = ๐‘“ โˆ’1 (and also ๐‘“ = ๐‘”โˆ’1 )
20
Inverse functions
๏‚› Does
the following function have an
inverse:
f:R ๏‚ฎ R, f(x)=2x
A.
B.
Yes
No
21
Inverse functions
๏‚› Does
the following function have an
inverse:
f:Z ๏‚ฎ Z, f(x)=2x
A.
B.
Yes
No
22
Inverse functions
๏‚› Does
the following function have an
inverse:
f:{1,2} ๏‚ฎ {1,2,3,4}, f(x)=2x
A.
B.
Yes
No
23
Functions with an inverse are
surjective
๏‚› Let
f:X๏‚ฎY, g:Y๏‚ฎX be inverse functions
๏‚› Theorem:
๏‚› Proof
f is surjective
(by contradiction):
๏‚› Assume not. That is, there is y๏ƒŽY such that
for any x๏ƒŽX, f(x)๏‚นy.
๏‚› Let xโ€™=g(y). Then, xโ€™๏ƒŽX and f(xโ€™)=y.
๏‚› Contradiction. Hence, f is surjective. QED
24
Functions with an inverse are
injective
๏‚›
Let f:X๏‚ฎY, g:Y๏‚ฎX be inverse functions
๏‚›
Theorem: f is injective
๏‚›
Proof (by contradiction):
Assume not. That is, there are distinct x1,x2๏ƒŽX
such that f(x1)=f(x2).
Then g(f(x1))=g(f(x2)).
But since f,g are inverses, g(f(x1))=x1 and
g(f(x2))=x2.
So x1=x2.
Contradiction. Hence, f is injective. QED
๏‚›
๏‚›
๏‚›
๏‚›
๏‚›
25
Functions with an inverse are
bijective
๏‚› Let
f:X๏‚ฎY, g:Y๏‚ฎX be inverse functions
๏‚› We
just showed that f must be both
surjective and injective
๏‚› Hence,
๏‚› It
bijective
turns out that the opposite is also true โ€“
any bijective function has an inverse. We
might prove it later.