L05 - Function
L05 - Function
COLLEGE OF ICT
IS 143
Discrete Structure
Lecture 5
Instructor
Dr. Joseph Cosmas
Kijitonyama Campus
Block A,
Room No. A023
[email protected]
Content
Introduction to Course
Proof Techniques
Discrete Probability
Functions
Definition:
x [x A y [y B < x, y > f ]]
and
[< x, y1 > f < x, y2 > f ] y1 = y2
Functions (cont.)
Note: f associates with each x in A has one and only one y
in B.
A is called the domain and
B is called the codomain.
o If f(x) = y
y is called the image of x under f
x is called a pre-image of y
o f(a) = Z A B
o the image of d is Z a
o the domain of f is A = {a, b, c, d} X
o the codomain is B = {X,Y, Z} b
Y
o f(A) = {Y, Z} c
o the pre-image of Y is b Z
d
o the pre-images of Z are a, c and d
o f({c,d}) = {Z}
Functions (cont.)
Injections, Surjections and Bijections
o Let f be a function from A to B.
A B
a
X
b
Y
c
Z
d
Surjection but not an injection
Functions (cont.)
A B A B
a a
V V
b b
W W
c c
X X
d d
Y Y
Injection & a surjection,
Z hence a bijection
f(x) = x,
f(x) = x2,
f(x) = x3,
f(x) = | x |
Functions (cont.)
o Let E be the set of even integers {0, 2, 4, 6, . . . .}.
Hence, the set of even integers has the same cardinality as the set of
natural numbers.
Functions (cont.)
Inverse Functions
Definition:
A f B A f -1 B
a a
V V
b b
W W
c c
X X
d d
Y Y
Note: No inverse exists
unless f is a bijection
Functions (cont.)
Alternatively, inverse can exist on subset relation
Definition: Let S be a subset of B. Then
f -1(S) = {x | f(x) S}
Definition:
f g(x) = f(g(x))
Examples: A g B f C
a V h
b W i
c
X j
d
f g Y
A C
a
h
b
i
c
j
d
Functions (cont.)
If f(x) = x2 and g(x) = 2x + 1, then
o f(g(x)) = (2x+1)2
o g(f(x)) = 2x2 + 1
Definition:
Example:
Suppose f: B C, g: A B and f g is injective.
What can we say about f and g?
n
a g ( m ) a g ( m 1 ) ... a g ( n ) a g( j )
j m
or more generally
aj
jS
Sequences and Summations (cont.)
n
Examples: r r r ... r r j
0 1 2
n
0
1 1 1 1
1 ...
2 3 4 1 i
n
a 2 m a 2 ( m 1 ) ... a 2 ( n ) a2 j
j m
Definition:
Note: With infinite sets proper subsets can have the same
cardinality. This cannot happen with finite sets.
Theorem:
If | A | | B | and | B | | A | then | A | = | B |.
This implies
if there is an injection from A to B
if there is an injection from B to A
then
there must be a bijection from A to B
0 1 2 3 4 5 6…
0 2 5
Sequences and Summations
Some Countably Infinite Sets
0 2 4 6 8 10 12 …
Z+, the set of positive integers is countably infinite.
Sequences and Summations
The set of positive rational numbers Q+ is countably infinite.
f(0) = 1/1, f(1) = 1/2, f(2) = 2/1, f(3) = 3/1, and so forth.
Every rational number appears on the list at least once, some many times
(repetitions).
{ , a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc, aaa, aab,
aac, aba, ....} = {f(0), f(1), f(2), f(3), f(4), . . . .}
Sequences and Summations
The set of all C programs is countable.
If the compiler says YES, this is a syntactically correct C program, we add the
program to the list.
Else we move on to the next string.
We show that no matter what list you produce we can construct a real
number between 0 and 1 which is not in the list.
Hence, there cannot exist a list and therefore the set is not countable
Sequences and Summations
o It's actually much bigger than countable. It is said to have the
cardinality of the continuum, c.
(Note: choosing 0 and 9 is not a good idea because of the non uniqueness of
decimal expansions.)
Example: