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.
© Copyright 2026 Paperzz