0% found this document useful (0 votes)
2 views40 pages

L05 - Function

The document outlines a lecture on Discrete Structures at the University of Dar es Salaam, covering topics such as functions, relations, proof techniques, and counting. It explains the definitions and properties of functions, including injections, surjections, bijections, and inverse functions, along with examples. Additionally, it discusses sequences, summations, and cardinality, emphasizing the concept of countable and uncountable sets.

Uploaded by

japharyjaphet46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views40 pages

L05 - Function

The document outlines a lecture on Discrete Structures at the University of Dar es Salaam, covering topics such as functions, relations, proof techniques, and counting. It explains the definitions and properties of functions, including injections, surjections, bijections, and inverse functions, along with examples. Additionally, it discusses sequences, summations, and cardinality, emphasizing the concept of countable and uncountable sets.

Uploaded by

japharyjaphet46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

UNIVERSITY OF DAR ES SALAAM

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

 Proposition, Sets, Relations and Functions

 Algorithm and Basic Logics

 Proof Techniques

 Basics Of Counting (Mathematical Reasoning)

 Graphs And Trees

 Discrete Probability
Functions
 Definition:

Let A and B be sets. A function (mapping, map) f from A


to B, denoted f :AB, is a subset of A * B such that

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

 Note: there may be more than one pre-image of y but


there is only one image of x.

 The range of f is the set of all images of points in A under f. We


denote it by f(A).
Functions (cont.)
o If S is a subset of A then
f(S) = {f(s) | s in S}.
 Example:

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.

o Definition: f is one-to-one (denoted 1-1) or injective if pre-images are


unique.
Note: this means that if a  b then f(a)  f(b).

o Definition: f is onto or surjective if every y in B has a pre-image.


Note: this means that for every y in B there must be an x in
A such that f(x) = y.

o Definition: f is bijective if it is surjective and injective (one-to-one


and onto).
Functions (cont.)
o Examples:

The previous example function is neither an injection nor a


surjection. Hence it is not a bijection.

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

Injection but not a surjection


Functions (cont.)
o Note: Whenever there is a bijection from A to B, the two
sets must have the same number of elements or the same
cardinality.

o That will become our definition, especially for infinite sets.


Functions (cont.)
o Examples:

Let A = B = R, the reals. Determine which are injections, surjections,


bijections:

 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, . . . .}.

Then there is a bijection f from N to E , the even nonnegative


integers, defined by
f(x) = 2x.

Hence, the set of even integers has the same cardinality as the set of
natural numbers.
Functions (cont.)
 Inverse Functions

 Definition:

Let f be a bijection from A to B. Then the inverse of f,


denoted f-1, is the function from B to A defined as

f-1(y) = x iff f(x) = y


Functions (cont.)
 Example: Let f be defined by the diagram:

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}

Note: f need not be a bijection for this definition to hold.


 Example: Let f be the following function, what is f -1(X),
f -1(Y), f -1(Z):
A B
a
X f-1({Z}) = {c, d}
b f-1({X, Y}) = {a, b}
Y
c
Z
d
Functions (cont.)
 Composition

 Definition:

Let f: B C, g: A B. The composition of f with g, denoted fg,


is the function from A to C defined by

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:

o The floor function, denoted f ( x) = x or


f(x) = floor(x), is the largest integer less than or equal to x.

o The ceiling function, denoted f ( x) = x or f(x) = ceiling(x), is


the smallest integer greater than or equal to x.
Functions (cont.)
 Examples: 3.5 = 3, 3.5 = 4.
Note: the floor function is equivalent to truncation for positive numbers.

 Example:
Suppose f: B  C, g: A  B and f  g is injective.
What can we say about f and g?

o If the composition is injective then a  b thus f(g(a))  f(g(b)).


o Since f is a function, it cannot be the case that g(a) = g(b) since then f
would have two different images for the same point.
o Hence, g(a)  g(b)

 It follows that g must be an injection; however, f need not be an injection


(you show).
Sequences and Summations
 Definition: A sequence is a function from a subset of the
natural numbers (usually of the form {0, 1, 2, . . . } to a set S.
Note: the sets
{0, 1, 2, 3, . . . , k} and {1, 2, 3, 4, . . . , k}
are called initial segments of N.

Notation: if f is a function from {0, 1, 2, . . .} to S we usually


denote f(i) by ai and we write a0 , a1 , a 2 ,...  ai ki 0  ai 0k
where k is the upper limit (usually ).
Sequences and Summations (cont.)
Examples:

Using zero-origin indexing, if f(i) = 1/(i + 1). then the


Sequence

f = {1, 1/'2,1/3,1/4, . . . } = {a0, a1, a2, a3, . . }

Using one-origin indexing the sequence f becomes

{1/2, 1/3, . . .} = {a1, a2, a3, . . .}


Sequences and Summations (cont.)
 Summation Notation

Given a sequence a i 0k we can add together a subset of the


sequence by using the summation and function notation

n
a g ( m )  a g ( m  1 )  ...  a g ( n )   a g( j )
j m

or more generally

aj
jS
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

if S  {2,5,7,10} then  a j  a 2  a5  a7  a10


jS

Similarity for the product notation:


n
 a j  a m a m  1 ...a n
j m
Sequences and Summations (cont.)
 Cardinality

 Definition:

The cardinality of a set A is equal to the cardinality of a set B,


denoted
| A | = | B |,

if there exists a bijection from A to B.


Sequences and Summations
 Definition:

If a set has the same cardinality as a subset of the natural


numbers N, then the set is called countable.

If |A| = |N|, the set A is countably infinite.

The (transfinite) cardinal number of the set N is

aleph null = 0.

If a set is not countable we say it is uncountable.


Sequences and Summations
 Examples:

The following sets are uncountable (we show later)

 The real numbers in [0, 1]


 P(N), the power set of N

 Note: With infinite sets proper subsets can have the same
cardinality. This cannot happen with finite sets.

Countability carries with it the implication that there is a listing


of the elements of the set.
Sequences and Summations
 Definition: | A |  | B | if there is an injection from A to B.

Note: as you would hope,

 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

 This is difficult to prove but is an example of demonstrating existence without


construction.
 It is often easier to build the injections and then conclude the bijection exists.
Sequences and Summations
 Example:

Theorem: If A is a subset of B then | A |  | B |.


Proof: the function f(x) = x is an injection from A to B.

 Example: {0, 2, 5}|  0


The injection f: {0, 2, 5}  N defined by f(x) = x is shown
below:

0 1 2 3 4 5 6…

0 2 5
Sequences and Summations
 Some Countably Infinite Sets

 The set of even integers E ( 0 is considered even) is countably


infinite. Note that E is a proper subset of N,

Proof: Let f(x) = 2x. Then f is a bijection from N to E


0 1 2 3 4 5 6…

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.

Proof: Z+ is a subset of Q+ so |Z+| = 0  |Q+|.


Now we have to show that |Q+|  0.

To do this we show that the positive rational numbers with


repetitions, QR, is countably infinite.

Then, since Q+ is a subset of QR, it follows that


|Q+|  0 and hence |Q+| = 0.
Sequences and Summations
Sequences and Summations

 The position on the path (listing) indicates the image of the


bijective function f from N to QR:

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).

Hence, |N| = |QR| = 0. Q. E. D

 The set of all rational numbers Q, positive and negative, is


countably infinite.
Sequences and Summations
 The set of (finite length) strings S over a finite alphabet A is countably
infinite.

To show this we assume that


 A is nonvoid
 There is an “alphabetical” ordering of the symbols in A

Proof: List the strings in lexicographic order:


 all the strings of zero length,
 then all the strings of length 1 in alphabetical order,
 then all the strings of length 2 in alphabetical order,
etc.

This implies a bijection from N to the list of strings and hence it is a


countably infinite set.
Sequences and Summations
 For example:
Let A = {a, b, c}.

Then the lexicographic ordering of A is

{ , 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.

Proof: Let S be the set of legitimate characters which can appear in a C


program.

 A C compiler will determine if an input program is a syntactically correct C


program (the program doesn't have to do anything useful).
 Use the lexicographic ordering of S and feed the strings into the compiler.

 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.

 In this way we construct a list or an implied bijection from N to the set


of C programs.

 Hence, the set of C programs is countable.


Sequences and Summations
 Cantor Diagonalization

 An important technique used to construct an object which is not a


member of a countable set of objects with (possibly) infinite descriptions

Theorem: The set of real numbers between 0 and 1 is uncountable.


Proof:We assume that it is countable and derive a contradiction.

If it is countable we can list them (i.e., there is a bijection from a subset


of N to the set).

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.

o Represent each real number in the list using its decimal


expansion.

e.g., 1/3 = .3333333........


1/2 = .5000000........
= .4999999........

o If there is more than one expansion for a number, it doesn't


matter as long as our construction takes this into account.
Sequences and Summations
o THE LIST....
r1 = .d11d12d13d14d15d16. . . . .
r2 = .d21d22d23d24d25d26 . . . .
r3 = .d31d32d33d34d35d36 . . . .
...

o Now construct the number x = .x1x2x3x4x5x6x7. . . .


xi = 3 if dii  3
xi = 4 if dii = 3

(Note: choosing 0 and 9 is not a good idea because of the non uniqueness of
decimal expansions.)

o Then x is not equal to any number in the list.


Hence, no such list can exist and hence the interval (0,1) is uncountable.
Sequences and Summations
 An extra goody:

Definition: a number x between 0 and 1 is computable if there


is a C program which when given the input i, will produce the
ith digit in the decimal expansion of x.

 Example:

The number 1/3 is computable.

The C program which always outputs the digit 3, regardless if


the input, computes the number.
Sequences and Summations
Theorem: There is exists a number x between 0 and 1 which
is not computable.

There does not exist a C program (or a program in any other


language) which will compute it!

Why? Because there are more numbers between 0 and 1 than


there are C programs to compute them.

(in fact there are c such numbers!)

Our second example of the nonexistence of programs to


compute things!

You might also like