Discrete Maths CSM 166-1
Discrete Maths CSM 166-1
MATHEMATICS FOR
COMPUTER SCIENCEII
Yao. Elikem.Ayekple
1
Unit1
Fundamentals of Counting
The major goal of this unit is to establish several techniques for
counting large finite sets without actually listing their elements. There
are two basic counting principles used throughout. One involves
addition and the other multiplication.
Elements of Counting
Sum Rule Principle
For a set X , X denotes the number of elements of X . It is easy to
see that for any two sets A and B we have the following result known
as the Inclusion- Exclusion Principle
A B A B A B .
A B A B .
2
The first counting principle (Sum Rule Principle): Suppose some
event A can occur in m ways and a second event B can occur in n
ways, and suppose both events cannot occur simultaneously. Then A
or B can occur in m n ways.
In other words (Sum Rule Principle): Suppose A and B are disjoints
sets.
Then A B A B .
Clearly, the principle can be extended to three or more events.
Specifically, suppose an event A1 can occur in n1 ways, an event A2
can occur in n2 ways, an event A3 can occur in n3 ways, and so on,
and suppose no two of the events can occur at the same time. Then
one of the events can occur in n1 n2 n3 ways.
Solution:
Basis of induction: For n 2 the result holds by the Inclusion-
Exclusion Principle.
Induction hypothesis: Suppose that for any collection A1 , A2 ,..., An of
pairwise disjoint sets we have
A1 A2 ... An A1 A2 ... An .
3
Induction step: Let A1 , A2 ,..., An , An1 be a collection of pairwise
disjoint sets.
Since
A1 A2 ... An An1 A1 An1 A2 An1 An An1
A1 A2 An An1
Example 1.2
A total of 35 programmers interviewed for a job; 25 knew
FORTRAN, 28 knew PASCAL, and 2 knew neither language. How
many knew both languages?
Solution:
Let A be the group of programmers that knew FORTRAN, B those
Who knew PASCAL. Then A B is the group of programmers who
knew both languages. By the Inclusion-Exclusion Principle we have:
A B A B A B .
That is,
33 25 28 A B .
4
Product Rule Principle
Another important rule of counting is the multiplication rule.
The second Rule Principle (Product Rule Principle): Suppose there is
an event A which can occur in m ways and, independent of this event,
there is a second event B which can occur in n ways. Then
combinations of A and B can occur in mn ways.
In other words (Product Rule Principle): Suppose A and B are finite
sets.
Then A B A B
Clearly, the principle can be stated as: If a decision consists of k
steps, where the first step can be made in n1 different ways, the
second step in n2 ways,…, the k th step in nk ways, then the decision
itself can be made in n1 n2 nk ways.
For example,
. Tossing a coin has two possible outcomes and tossing a die has
six possible outcomes. Then the combined experiment, tossing
the coin and die together results in 2 6 = 12 possible
outcomes: H 1, H 2, H 3, H 4, H 5, H 6, T 1, T 2, T 3, T 4, T 5, T 6
. The number of different ways for a man to get dressed if he has
8 different shirts and 6 different pairs of trousers is 8 6 = 48
. The number of ways a three-figure integer be formed from the
numbers, 4, 3, 5, 6 and 7 if no number is used twice or more is
5 4 3 = 60.
5
Example 1.3
1. Suppose a college has 3 different computer science courses, 4
different mathematics courses, and 2 different actuarial courses
(with no prerequisites)
a) There are n 3 4 2 9 ways to choose 1 of the courses.
b) There are n 3 4 2 24 ways to choose one of each of
the courses.
2. Suppose Airline A has three daily flights between Kumasi and
Accra, and Airline B has two daily flights between Kumasi and
Accra
a) There are n 3 2 5 ways to fly from Kumasi to Accra.
b) There are n 3 2 6 ways to fly Airline A from Kumasi
to Accra, and then Airline B from Accra back to Kumasi.
c) There are n 5 5 25 ways to fly from Kumasi and
Accra , and then back again.
6
Solution:
3. By the multiplication rule there are 6 6 36 possible
outcomes.
4. By the multiplication rule there are
26 25 24 10 9 8 7 78,624,000 possible license plates.
Example 1.3
Let a, b, c, d be an alphabet with 4 letters. Let 2 be the set of all
words of length 2 with letters from . Find the number of all words
of length 2 where the letters are not repeated. First use the product
rule. List the words by means of a tree diagram.
Solution:
By the multiplication rule there are 4 3 12 different words.
Constructing a tree diagram:
a b c d
a c d a b d a b c
b c d
7
PERMUTATIONS
Any arrangement of a set of n object in a given order is called a
permutation of the objects (taken all at a time). Any arrangement of
any r n of those objects in a given order is called an r -permutation
of n objects or a permutation of the n objects taken r at a time. In
symbol P n, r , is an ordered selection of r objects from a given n
objects.
Example 1.4
n!
a) Use the product rule to show that P n, r
n r !
b) Find all possible 2 - permutations of the set 1, 2, 3 .
Solution:
a) We can treat a permutation as a decision with r steps. The first step
can be made in n different ways, the second in n 1 different ways,
..., the r th in n r 1 n r 1 different ways. Thus, by the
8
multiplication rule there are n n 1 · · · n r 1 r -
permutations of n objects.
n!
That is P n, r n n 1 n r 1
n r !
3!
b) P 3, 2 6
3 2 !
Example 1.5
How many license plates are there that start with three letters followed
by 4 digits (no repetitions)?
Solution:
P 26, 3 · P 10, 4 78, 624, 000
where n n1 n2 . . . nk
9
(iv) n distinct objects arranged in a circle, called circular
permutations is given by
n!
( n 1)!.
n
For example,
1. The number of possible permutations of the letters, A, B and
C is 3! 6. The required permutations are ABC, BAC, ACB,
BCA, CAB and CBA.
2. The number of permutations of 10 distinct digits taken two
at a time
10!
10 P2 10 9 90.
(10 2)!
10
Ordered Samples
When we choose one element after another from the set S containing
n elements, say r times, we call the choice an ordered sample of size
r . We consider two cases:
n n n n n r
different ordered samples with replacement of size r .
11
Example 1.6
Three cards are chosen in succession form a deck with 52
cards. Find the number of ways this can be done (a) with
replacement (b) without replacement.
Solution:
a) Since each card is replaced before the next card is chosen,
each card can be chosen in 52 ways. Thus there are
52 52 52 523 140,608
12
COMBINATIONS
Suppose we have a collection of n objects. A combination of these n
objects taken r at a time is any selection of r of the objects without
taking order in account. An r - combination of n objects, in symbol
C n, r , is an unordered selection of r of the n objects. In other
words, an r combination of a set of n objects is any subset of r
elements. But the number of different ways that r objects can be
ordered is r !. Since there are C n, r groups of r objects from a
given n objects then the number of ordered selection of r objects
from n given objects is r !C n, r P n, r .Thus
P n, r n! n
C n, r .
r! r ! n r ! r
13
Example 1.7
Find the number of combinations of four objects, a, b, c, d taken three
at a time.
Solution:
Each combination consisting of three objects determines 3! 6
permutations of the objects in the combination. Thus the number of
combination multiplied by 3! equals the number of permutations. That
is:
P 4,3
C 4,3 3! P 4,3 or C 4,3
3!
But P 4,3 4 3 2 24 and 3! 6 . Thus C 4,3 4 , which is
shown in the table below:
Combinations Permutations
abc abc, acb, bac, bca, cab, cba
abd abd , adb, bad , bda, dab, dba
acd acd , adc, cad , cda, dac, dca
bcd bcd , bdc, cbd , cdb, dbc, dcb
Example 1.8
In how many different ways can a hand of 5 cards be selected from a
deck of 52 cards? (no repetition)
Solution:
C 52,5 2, 598, 960
14
Example 1.9
Prove the following identities:
a) C n,0 C n, n 1 and C n,1 C n, n 1 n .
b) Symmetry property: C n, r C n, n r , r n .
c) Pascal’s identity: C n 1, k C n, k 1 C n, k , n k .
Solution:
a) Follows immediately from the definition of C n, r . Check
yourself.
b) Indeed, we have
n!
C n, n r
n r ! n n r !
n!
r ! n r !
C n, r
n! n!
c) C n, k 1 C n, k
k 1! n k 1! k ! n k !
n !k n! n k 1
k ! n k 1! k ! n k !
n!
k n k 1
k ! n k 1!
n 1! C n 1, k
n 1 k !
15
Example 1.10
1. Find the number m of committees of three that can be formed
from eight people. Each committee is, essentially, a combination of
the eight people take three at a time.
Solution:
8 8 7 6
m C 8,3 56
3 1 2 3
2. A farmer buys three cows, two pigs, and four hens from a man
who has six cows, five pigs, and eight hens. How many choices
does the farmer have?
Solution:
6 5
The farmer can choose the cows in ways, the pigs in 2
3
8
ways, and the hens in ways. Hence altogether he can choose
4
the animals in
6 5 8
3 2 4 20 10 70 14,000 ways
16
3. Find the number m of ways that 9 toys can be divided between 4
children if the youngest is to receive 3 toys and each of the others
2 toys.
Solution:
There are C 9,3 84 ways to first choose 3 toys for the youngest.
toys for the oldest. Next, there are C 4,2 6 ways to choose 2 of
the remaining 4 toys for the second oldest. The third oldest
receives the remaining 2 toys. Thus, by the product rule:
m 84 15 6 1 7560
Example 1.11
1.11(a) (i) In how many ways can a three-figure integer is
formed from the numbers: 4, 3, 5, 6 and 7 if any number can be used
more than once?
(ii) In a certain examination paper, students are required to answer
5 out of 10 questions from Section A another 3 out of 5 questions
from Section B and 2 out of 5 questions from Section C. In how many
ways can the students answer the examination paper?
Solution:
(i) The first, second and third numbers, each can be chosen in 5
ways. The total number of ways = 5 5 5 = 125
(ii) The number of ways of answering the questions in Section A
= 10 9 8 7 6 = 30,240
17
The number of ways of answering the questions in section B
= 5 4 3 = 60
The number of ways of answering the questions in section C
= 5 4 = 20
Hence the students can answer the questions in the three sections in
= 30,240 60 20 = 36,288,000
Solution:
(i) If we regard the 2 girls as a separate persons (B1 B2 B3 B4
G1G2), then the number of arrangements of 5 different persons, taken
all at a time = 5!
18
The 2 girls can exchange places and so the required number of ways
they can seat themselves = 5! 2! = 240
(ii) The number of ways the boys can arrange themselves = 4!
The number of ways the 2 girls can occupy the arrowed places:
B1 B2 B3 B4 = 5 P2 5 4
The required number of permutations (with the 2 girls not sitting next
to each other) = 4! 5 4 = 480
Solution:
(i) The number of ways of choosing 2 bys from 6 and 2 girls
from 5
6 5
= . = 15 10 = 150
2 2
(ii) For the committee to contain at least 1 boy and 1 girl we
have
1B3G, 2B2G or 3B1G
The required number of ways
6 5 6 5 6 5
= . . .
1 3 2 2 3 1
19
1.11(e) (i) A school Parent-Teacher committee of 5 members
is to be formed from 6 parents, 2 teachers and the principal. In how
many ways can the committee be formed in order to include
( ) The principal? ( ) Exactly four parents?
( ) Not more than four parents?
(ii) Four balls are drawn from a bag of 12 balls of which 7 are blue
and 5 are red. In how many of the possible combinations of 4
balls is at least a red?
Solution:
(i) ( ) If the principal is to be included then we select 4 people
from the remaining 8. Hence required number of ways the committee
is formed
1 8
= . 70
1 4
6
( ) The number of ways of selecting 4 parents out of 6 = . The
4
number of
ways of selecting the remaining number from the 3 (2 teachers and
3
the principal) =
1
Therefore the number of ways of selecting exactly 4 parents
6 3
= . = 15 3 = 45
4 1
12
( ) The number of ways of forming a 5-member committee =
5
20
6
The number of ways of selecting 5 parents from 6 =
5
Therefore the required number of ways of selecting a committee with
12 6
not more than 4 parents = = 126 – 6 = 120
5 5
5 7
4R, with number of combinations = = 5
4 0
Review Problems
Problem 1.1
a) How many ways can we get a sum of 4 or a sum of 8 when two
distinguishable dice are rolled?
b) Suppose a bookcase shelf has 6 mathematics texts, 3 physics texts,
4 chemistry texts, and 5 computer science texts. Find the number
n of ways a student can choose: (a) one of the texts Ans :18 , (b)
21
Problem 1.2
a) How many 4 - digit numbers can be formed using the digits,
1,2,· · · ,9 (with repetitions)? How many can be formed if no digit
can be repeated?
b) How many different license plates are there that involve 1,2, or 3
letters followed by 4 - digits (with repetitions)?
Problem 1.3
a) In how many ways can 4 cards be drawn, with replacement, from
a deck of 52 cards?
b) In how many ways can 4 cards be drawn, without replacement,
from a deck of 52 cards?
Problem 1.4
In how many ways can 7 women and 3 men be arranged in a row if
the three men must always stand next to each other.
Problem 1.5
A menu in a Chinese restaurant allows you to order exactly two of
eight main dishes as part of the dinner special. How many different
combinations of main dishes could you order?
Problem 1.6
There are 12 students in a class. Find the number n of ways that 12
students can take three different tests if four students are to take each
test. Ans : 34,650
22
Unit2
MULTINOMIAL COEFFICIENTS
INTRODUCTION
This unit extends the technique of counting as already treated under
permutations and combinations. It may be recalled that binomial expansion
is very much linked with combinations. We are going to have a short but
concise study of multinomial expansion, which is naturally linked with
multinomial coefficients.
Objectives
On completion of this unit, you should be able to:
Upgrade your knowledge on advanced techniques on
counting process
Extend knowledge of binomial expansion to
multinomials
Solve more practical problems
BINOMIAL COEFFICIENTS
Choosing a subset of size r out of a set of size n is logically equivalent to
partitioning the set of size n into two subsets, one of size r and the other of
n!
size n – k . The number of such partitions if by definition nCr .
r ! n r !
23
Suppose x, y are variable and n Z the positive integers, then
n
x y nCr x n r y r nC0 x n y 0 nC1 x n 1 y1 nC2 x n 2 y 2 ... nCn x 0 y n
n
r o
DEFINITION
n!
n
Cr (2)
r ! n r !
is a nonnegative integer.
24
Theorem 2.1 (Binomial Theorem)
Let x and y be variables, and let n be a positive integer. Then
n
x y C n, r x nr y r
n
r 0
r 0
Indeed, we have:
x y x y x y x x y y x y
n 1 n n n
n n
x C n, r x n r y r y C n, r x n r y r
r 0 r 0
n n
C n, r x n r 1
y y C n, r x n r y r 1
r
r 0 r 0
25
Example
Expand x y using the binomial theorem.
6
Solution:
By the Binomial Theorem and Pascal’s triangle we have
x y
6
x 6 6 x 5 y 15 x 4 y 2 20 x 3 y 3 15 x 2 y 4 6 xy5 y 6
Example
C n, r 2 n
n
a) Show that r 0
1 C n, r 0
n r
b) Show that r 0
Solution:
a) Letting x y 1 in the binomial theorem we find
n
2n 1 1 C n, r
n
r 0
Example
Expand 2 x 3
5
Solution:
5
2 x 3 5Cr 2 x 3
5 nr r
r 0
26
5! 5 5 5! 4 4 5! 3 3 5! 2 2
2 x 2 x 3 2 x 9 2 x 27
5!0! 4!1! 3!2! 2!3!
5! 5!
2 x 81 243
1!4! 0!5!
32 x 5 240 x 4 720 x 3 1080 x 2 81x 243
Example 2
Obtain the coefficient of a 5b 2 in the expansion of 2a 3b
7
Solution:
To obtain the coefficient of the term a 5b 2 , we notice that in (2), we set
r 2 to obtain
C2 2 -3 as the coefficient of a 5b 2
7 5 2
But
7!
C 2 2 3 2 3
7 5 2 5 2
5!2!
6048
Therefore, the coefficient of a 5 b 2 of the binomial expression is 6048
3 z 1 b 3 x 7 2 y
3 3
(iv) (v)
27
x12 y13 in x y x12 y13 in 2 x 3 y
25 25
(i) (ii)
x 9 in 2 x y 6 in 3 5 1 y
19 8
(ii) (iv)
x19 in 3 x 1 2
20
(v)
1
r n
(i) n
Cr 2 n (ii) Cr 0 .
r 0 r 0
1 1 x x 3 x5
Hence show that ln x ...
2 1 x 3 5
28
MULTINOMIAL COEFFICIENTS
Proof
We obtain the partitioning in steps: First, we choose k1 out of n elements to
form the first partition. Next, we choose k2 elements out of the remaining
n n k1 n k1 k2 n k1 k2 ... kr 2 n k1 k2 ... kr 1
... ways.
k1 k2 k3 kr 1 kr
x1 x2 ... xr
n
n
Ck1 ,k2 ...,kr x1k1 x2 k2 ...xr kr
k1 , k2 ..., kr
where k1 k2 ... kr n
29
Example 1
Expand x y z
3
Solution:
x y z
3
3C3,0,0 x 3 y 0 z 0 3C0,3,0 x 0 y 3 z 0 3C0,0,3 x 0 y 0 z 3 3C2,1,0 x 2 y1 z 0 3C2,0,1 x 2 y 0 z1
3C1,2,0 x1 y 2 z 0 3C0,2,1 x 0 y 2 z1 3C1,0,2 x1 y 0 z 2 3C0,1,2 x 0 y1 z 2 3C1,1,1 x1 y1 z1
3! 3! 3! 3 3! 2 3! 2
x3 y3 z x y x z
3!0!0! 0!3!0! 0!0!3! 2!1!0! 2!0!1!
3! 3! 3! 3! 3!
xy 2 y2 z xz 2 yz 2 xyz
1!2!0! 0!2!1! 1!0!2! 0!1!2! 1!1!1!
x3 y 3 z 3 3 x 2 y 3 x 2 z 3 xy 2 3 y 2 z 3 xz 2 3 yz 2 6 xyz
Example 2
6 5 10
Evaluate the following (a) (b) (c)
4, 2,0 3, 2 5,3,0, 2
6 6! 6 5 4 3 2 1
Solution: (a) 15
4,2,0 4!2!0! 4 3 2 1 2 1
5 5! 5 4 3 2 1
(b) 10
3, 2 3!2! 3 2 1 2 1
10 10! 10 9 8 7 6 5 4 3 2 1
(c) 2520
5,3, 0, 2 5!3!0!2! 5 4 3 2 1 3 2 1 2 1
30
n n n
1. Show that = =
n1 ,n2 n1 n2
n
3. Prove that for any n Z ,
k1 , k2 ,..., kr
n
Ck1 , k2 ,...,kr r n
i xyz 5 ii x2 y2 z3 iii x3 z 4
4
ii xyz 2 in x 2 y 3z 1
iii w3 x 2 yz 2 in 2w x 3 y 2 z
8
6
iv x11 y 4 z 2 in 2 x3 3 xy 2 z 2
v x 3 y 4 z 5 in x 2 y 3 z
12
31
(i) Use the definition of binomial coefficients as ratios of factorials.
(iii) Generalize the above formula to answer the question: In how many
ways can one choose an a -element subset from a b -element subset
from a c -element subset from a d -element subset from an n -element
set, where a b c d n ?
32
Unit3
INTRODUCTION
Welcome to this unit. Here, we shall learn more about recurrence relations,
or simply put, algorithms. This would entail one, two or three expressions
that would generate an infinite set of numbers. On the other hand, given a
set of recurrence relations, a solution would be found for such a relation.
d
Familiar properties of carry over as follows:
dx
Linearity
y v y v; y y , scalar
33
Product Rule:
y v n y n 1 v n 1 y n v n
y n 1 y n v n 1 y n v n 1 v n
y n v n 1 y n v n
Exponential:
If y n 2 n , y n y n 1 y n
2n 1 2n
2n f n
that is y y
Thus 2 n for difference equations plays the same role e x does for differential
equations.
Constants:
c 0, c constant
y is a constant.
34
Theorem
n n
v r y r y r y n 1 y m .
n 1
If y v, then m
r m r m
Proof
We have
v n y n 1 y n
v n 1 y n y n 1
v n 2 y n 1 y n 2
v m 1 y m 2 y m 1
v m y m 1 y m
......................................................
n
v r y n 1 y m
r m
Example 1
Exponentials:
a n a n1 a n a n a 1 , a constant
Hence
a n an
a by linearity
n
a 1 a 1
n
1 n a n 1 a m
a r
a a 1
r
r m a 1 r m
(This is just the usual method for summing a geometric progression).
35
Example 2
Polynomials:
We consider easier polynomials of the form
f r n n n 1 n 2 ... n r 1
Then, f r (n) yr (n 1) yr (n)
f r n n 1 n n 1 n 2 ... n r 2 n n 1 n 2 ... n r 1
n n 1 ... n r 2 n 1 n r 1
rn n 1 n 2 ... n r 2
rf r 1 n
d n
This is analogous to
dx
x nx n 1 .
n
1
We may easily deduce that f s r f n 1 f m .
s m
r 1 r r
n
1
So in particular y s r 1 y n 1 , if m 0 .
s 0
r r 1
For example,
n n
s
s 1
3
s3
s 0
n
s s 1 s 2 3s s 1 s
s 0
n
1 1
y3 s 3 y2 s y1 s y4 n 1 y3 n 1 y2 n 1
s 0 4 2
36
1 1
n 1 n n 1 n 2 n 1 n n 1 n 1 n
4 2
n 1 n n 1 n 2 4 n 1 2
4
1
n 2 n 1
2
4
Example 3
Let y n na n . [ a , constant]
a na a 1 a a 1 y n
n 1 n n 1
1 a n 1
Hence y n
y n
a 1 a 1
1 a
y n 2 a
n
a 1 a 1
1 a
y n a n
a 1 a 1
2
r m a 1
n 1 a ma m a n 2 a m 1
n 1
a 1 a 1
2
37
Example 4
Trigonometric Functions:
We study this specialized branch of mathematics using forward
differences:
so that
n sin w n 1 sin
cos wr
r 0
w
2
2sin w2
w
Setting , we have
2
n sin w n 12 sin w2
cos wr
r 0 2sin w2
n
A similar formula may be derived for sin wr .
r 0
38
2. From (1) deduce the value of
n n
a 3r 2 r 2 4r
r 0
b r r 2 r 3
r 1
10
15 N
1
c 1 d
n
n 3 n n 0 n n 2
1
From your answer to (d), deduce that n n 2
n 1
exists and find its
value.
n
n
3. Show that r 4
30
n 1 6n3 9n 2 n 1 .
r 1
39
FINITE DIFFERENCE EQUATIONS - RECURRENCE RELATIONS
Recursion
A recurrence relation for a sequence a0 , a1 ,... is a relation that
defines an in terms of a0 , a1 ,..., an1 . The formula relating an to earlier
values in the sequence is called the generating rule. The assignment
of a value to one of the a ' s is called an initial condition.
Example 2.1
The Fibonacci sequence
1,1,2,3,5,...
is a sequence in which every number after the first two is the sum of
the preceding two numbers. Find the generating rule and the initial
conditions.
Solution:
The initial conditions are a0 a1 1 and the generating rule is
an an 1 an 2 ; n 2
40
Example 2.2
Let n 0 and find the number sn of words from the alphabet
Solution:
Clearly, s0 1 (empty word) and s1 2 . We will find a recurrence
The most basic method for finding the solution of a sequence defined
recursively is by using iteration. The iteration method consists of
starting with the initial values of the sequence and then calculates
successive terms of the sequence until a pattern is observed. At that
point one guesses an explicit formula for the sequence and then uses
mathematical induction to prove its validity.
41
Example 2.3
Find a solution for the recurrence relation
a0 1
an an 1 2, n 1
Solution:
Listing the first five terms of the sequence one finds
a0 1
a1 1 2
a2 1 4
a3 1 4
a4 1 8
Hence, a guess is an 2n 1 , n 0 . It remains to show that this
formula is valid by using mathematical induction.
Example 2.4
Consider the arithmetic sequence
an an 1 d , n 1
where a0 is the initial value. Find an explicit formula for an .
42
Solution:
Listing the first four terms of the sequence after a0 we find
a1 a0 d
a2 a0 2d
a3 a0 3d
a4 a0 4d
Hence, a guess is an a0 nd . Next, we prove the validity of this
formula by induction.
Example 2.5
Consider the geometric sequence
an ran1 , n 1
Where a0 is the initial value. Find an explicit formula for an .
Solution:
Listing the first four terms of the sequence after a0 we find
a1 ra0
a2 r 2 a0
a3 r 3a0
a4 r 4 a0
43
Hence, a guess is an r n a0 . Next, we prove the validity of this
formula by induction.
Example 2.6
Find a solution to the recurrence relation
a0 0
an an 1 n 1 , n 1
Solution:
Writing the first five terms of the sequence we find
a0 0
a1 0
a2 0 +1
a3 0 +1 + 2
a4 0 +1 + 2 + 3
44
0 0 1
Basis of induction: a0 0 0.
2
n n 1
Induction hypothesis: Suppose that an .
2
n n 1
Induction step: We must show that an 1 . Indeed,
2
an1 an n
n n 1
n
2
n n 1
2
Example 2.7
Consider the recurrence relation
a0 1
an 2an1 n n 1
45
Example 2.8
Define a sequence, a1 , a2 ,... , recursively as follows:
a1 1
an 2 a n , n 2
2
an 2
log 2 n
,n 1
b. We prove the above formula by mathematical induction.
Basis of induction: For n 1 , a1 1 2 log2 1 .
46
Indeed, for n odd (i.e. n 1 even) we have:
an 1 2 a n1
2
log 2 n1
2
A similar argument holds when n is even.
NOTATION:
We write a n an , or y n yn , n
Example 2.9
Let n be the number of memory locations referenced by a certain computer
program. Suppose that the algorithm implemented by the program requires
yn bytes of the memory, where yn depends on n . Let yn be defined
inductively by
y1 3
yn 4 yn 1 if n 1
n 1 2 3 4 5 …
yn 3 12 48 192 768 …
47
Sometimes it is more convenient to start at n 0 instead of n 1 . In fact, any
integer could be used as the starting value in the inductive definition or
recursive relation.
Example 2.10
The factorial function n! is defined as follows:
0! 1
n ! n n 1 ! if n 1
Example 2.11
A function yn is defined recursively as follows:
y1 3
y2 7
y 3 y 2 y for n 3
n n 1 n 2
n 1 2 3 4 5 6 …
yn 3 7 15 31 63 127 …
48
By intuition, yn 2 n1 1. This formula clearly satisfies the initial
conditions y1 and y2 . We verify if it satisfies the recurrence relation
yn 3 yn 1 2 yn 2
But
R.H .S 3 yn1 2 yn 2
3 2n 1 2 2n 1 1
3 2n 3 2 n 2
2n 3 1 1
2n1 1
yn
L.H .S
When iteration does not apply, other methods are available for finding
explicit formulas for special classes of recursively defined.
50
Substituting these into the recurrence relation yn ayn1 byn 2 , gives
ct n act n 1 bct n 2 .
CASE I
Since yn t1n and yn t2n are solutions of the linear recurrence relation, then
another solution (the general solution) is yn At1n Bt 2n . Where A and B are
arbitrary constants.
Using the initial values y0 c0 and y1 c1 , A and B are easily determined.
CASE II
As t t0 is the repeated root of the characteristic equation, then yn t0n is a
solution of the recurrence relation. The other linearly independent solution is
yn nt 0n . So a general solution of the linear recurrence relation is
51
CASE III
Since the characteristic equation has real coefficients, the complex roots
occur in conjugate pairs. In other words, if u iv is a root of the
characteristic equation with real coefficients, then its complex conjugate
u iv is also a root with v 0 .
Then
yn A n cos n i sin n B n cos n i sin n
A B n (cos n ) i ( A B) n sin n
52
EXAMPLE 5
Solve
yn 3 yn 1 2 yn 2 for n 2
y2 7
y 3
1
SOLUTION
The characteristic equation is t 2 3t 2 0 . Factorizing the left-hand side
gives
t 1 t 2 0 so that t 1 or t 2 . The general solution is yn A 1n B 2n .
EXAMPLE 6
Solve
yn 6 yn1 9 yn 2 for n 1
y1 3
y 5
0
SOLUTION
The characteristic equation is t 2 6t 9 0 . Factorizing the left-hand side
gives t 3 0 so that t 3 repeated . The general solution is yn A 3n Bn 3n
2
.
Using the initial condition specified, A 5 and B 4 , therefore the solution is
53
yn 5 3n 4n 3n
3n 5 4n
EXAMPLE 7
Solve yn 2 yn 1 2 yn 2 0
SOLUTION
The characteristic equation is t 2 2t 2 0 . Using the quadratic formula, we
2 4 8
have the roots: t 1 i. Thus t1 1 i and t2 1 i .
2
Using the diagram,
1 i
3
4
1 i
2 sin 2
n n
2 and 34 . Hence, yn A 3 n
4 B cos 3n4 is the general
solution.
EXAMPLE 8
Solve
yn 7 yn 2 6 yn 3
y0 1, y1 2 and y2 3
SOLUTION
The characteristic equation is t 3 7t 6 0 . Factorizing the right-hand side
gives
t 1 t 2 t 3 0 so that t 1, 2 and 3.
5 4 11
Using the initial conditions, A , B and C .
4 5 20
4 5 20
EXAMPLE 9
Consider the recurrence relation:
yn yn 1 6 yn 2
y1 1
y 9
0
SOLUTION
Using the substitution g n yn transforms the recurrence relation into
55
g n g n1 6 g n 2
g1 1
g 3
0
56
NON-HOMOGENEOUS DIFFERENCE EQUATIONS
So far we have considered difference equations of the form
ak yn k ak 1 yn k 1 ... a0 yn n 1
Where n 0 for all n . For now, we consider cases where n is a
non-zero function. In the case of a homogenous difference equations, that is,
where n 0 , the general solution of (1) is obtained by adding any
particular solution of (1) to the general solution of the corresponding
homogenous equation.
THEOREM
Let n be a particular solution to
ak yn k ak 1 yn k 1 ... a0 yn n 2
and
1 g1 n 2 g 2 n ... k g k n
Then
y(n) 1 g1 n 2 g 2 n ... k g k n n 3
is the general solution to (2).
EXAMPLE 1
Use the theorem above to find the general solution to
yn 2 5 yn 1 6 yn 2n 2 4
57
SOLUTION
We observe that n n2n1 is a particular solution of (4) for if
58
THEOREM:
If
F1 n is a solution of
yn k an k 1 yn k 1 ... an yn 1 n 6
and
F2 n is a solution of
yn k an k 1 yn k 1 ... an yn 2 n 7
then F1 n F2 n is a solution of
yn k an k 1 yn k 1 ... an yn 1 n 2 n
Example
Find the general solution of
yn 2 3 yn 1 2 yn 4 2n n 2 8
Solution
The characteristic equation of the associated homogenous equation is
t 2 3t 2 t 2 t 1 0 .
Since the roots of this equation are t 1, 2 , the general solution of the
homogenous equation is 1 2 2n .
Direct substitution shows that y1 n n2n1 is a solution of the non-
homogenous difference equation
yn 2 3 yn 1 2 yn 4 2n 9
And that F2 n 12 n2 52 n is a solution of the non-homogenous difference
equation
yn 2 3 yn 1 2 yn n 2 10
59
Thence from the theorem, F1 n F2 n n2n1 12 n2 25 n is a particular solution
to (8). Adding this particular solution to the general solution of the
homogenous equation gives yn 1 2 2n n 2n 1 12 n 2 25 n as the general
solution of the non-homogenous difference equation (8).
3 yn 2 3 yn1 2 yn 3n ; n 3n , y0 1, y1 0
1
2
4 yn 2 4 yn1 4 yn 2 ; n n n 1 2n3
n
1
5 yn 2 4 yn 2n ; n n 2n , y1 3, y2 1
8
n2 4 11
6 yn 2 4 yn n2 1; n n
3 9 27
10 yn 2 5 yn 1 6 yn n; n n
1 9
14 14
60
n
11 yn 2 yn n 1; n , y0 1, y1 0
2
12 yn 2 yn1 3 yn 2n 1; n 2n 3
13 yn1 yn 1; n n, y1 1
14 yn1 3 yn 2; n 3n 1
2
15 yn 2 5 yn1 6 yn 4n1; n 4n
21
3n 2
16 yn 2 yn1 yn2 3 ; n
n 2
16
61
THE METHOD OF UNDETERMINED COEFFICIENTS
yn 1 y n 1 A2 n 1 A1 n 1 A0
2
A2 n 2 2 A2 A1 n A2 A1 A0
yn 2 A2 n 2 A1 n 2 A0
2
A2 n 2 4 A2 A1 n 4 A2 2 A1 A0
Consequently
yn 2 2 yn 1 yn A2 n 2 4 A2 A1 n 4 A2 2 A1 A0
2 A2 n 2 2 2 A2 A1 n 2 A2 A1 A0
A2 n 2 A1n A0
2 A2 n 2 8 A2 2 A1 n 6 A2 4 A1 2 A0
2 A2 n 2 8 A2 2 A1 n 6 A2 4 A1 2 A0 6n 2 24n 25 .
62
This equation is valid for all n if and only if the corresponding coefficients
are equal. Thus
2 A2 6
8 A2 2 A1 24
6 A2 4 A1 2 A0 25
From these,
7
A2 3 , A1 0 , A0
2
7
Substituting these values into yn A2 n 2 A1n A0 , we have n 3n 2 as
2
a particular solution to the non-homogenous equation (1).
To apply the method successfully, it is necessary to have the correct form for
a trial solution. The following table gives the correct form of a trial solution
to a difference equation: yn k an k 1 yn k 1 ... an yn n
Example 1
Find the general solution of
yn 3 yn 1 10 yn 2 3 2 n 2
63
Solution:
The characteristic equation of the homogenous equation is
t 2 3t 10 0 OR t 5 t 2 0 t 5, 2 .
Therefore the general solution of the homogenous equation is:
1 5n 2 2 , since n 3 2 n is of the form ck n . By the table above,
n
solution of (2).
Example 2
Find the general solution of
yn 2 yn 1 6 yn 6n 2 22n 23 4
Solution:
The characteristic solution of the associated homogenous equation is
t 2 t 6 0 or t 3 t 2 0 then t 3, 2 .
64
Therefore the general solution of the homogenous equation is
1 2 2 3n , since n 6n 2 22n 23 is of the form a1n 2 a1n a0 .
n
A2 n 2 2 A1 n 2 A0 A2 n 12 A1 n 1 A0 6 A2 n 2 A1n A0
In order for this equation to be valid for all n , the corresponding coefficients
must be equal hence,
6 A2 6, 2 A2 6 A1 22, 3 A2 A1 6 A0 23.
From these, A2 1, A1 4 and A0 5 so that
n n 2 4n 5
is a particular solution to the non-homogenous equation (4).
A slight complication arises in the use of the table whenever a term of the
selected trial solution is also a solution to the homogenous equation. If this
occurs, we multiply every term of the trial solution by n . If this new trial
solution still has a term that is a solution to the homogenous equation, we
again multiply the trial solution by n . This process continues until no term
of the trial solution is a solution of the homogenous equation.
65
homogenous equation is 1n 2 . Then both A1n and A0 are solutions of the
homogenous equation. Multiplying the original trial solution by n gives
A2 n 3 A1n 2 A0 n as a trial solution. However, since A0 n is still a solution to
Example 3
Find the general solution of
yn 4 yn 1 4 yn 2 2n 5
SOLUTION
The characteristic equation of the associated homogenous equation is
t 2 4t 4 0 or t 2 0, then t 2 repeated .
2
66
Dividing throughout by 2n2 , we obtain
4cn2 8cn2 16cn 8c 4cn2 16cn 16c 4 from which we have 8c 4 or c 12 .
Consequently, n 12 n 2 2n n 2 2n 1 is a particular solution to the non-homogenous
equation (5) and therefore the general solution of (5) is yn 1 2n 2 n22 n 2 2n 1.
Example 4
Find the general solution of
yn 2 w2 yn 2n ; y0 , y1 6
Solution
The characteristic equation is t 2 w2 0 or t iw .
The general solution of the associated homogenous equation is
1 iw 2 iw wn 1i n 2 i
n n n
wn 1e 2e since i e
n i n i i
2 2 2
wn 1 cos n2 i sin n2 2 cos n2 i sin n2
wn A cos n2 B sin n2
67
Finally we use the initial conditions y0 and y1 to find the values of A and B
in (6).
1 2
y0 A , y1 wB so that
4w 2
4 w2
1 2
A B
4w 2
w w 4 w2
2n
n 1 2 n
yn w 2
cos n
sin 2
4 w2 4 w
2
w w 4 w
2
Finally, we give an example of an important use of difference equations.
Most especially, we use difference equations to evaluate certain sums.
Example 5
n
If sn s n k 2 , find a simple expression for the summation.
k 1
Solution:
We write
sn sn 1 n 2 8
This is a non-homogenous equation. We find its general solution. The
associated homogenous equation is sn sn1 0 , whose general solution is ,
since sn sn 1 sn 2 ... s0 , a constant. Since, n n2 , we have a trial
68
However since A0 is a constant and is also a solution of the homogenous
equation, we multiply this trial solution through by n . The resulting trial
solution is A2 n 3 A1n 2 A0 n .
Substituting this into (8), we have A2n3 + A1n2 + A0n – A2(n-1)2 – A0(n-1) =
n2. Simplifying this, we select A2, A1 and A0; 3A2n2 + (2A1 – 3A2)n + (A0 – A1
+ A2) = n2 for all integers n , from which it follows that
3 A2 1, 2 A1 3 A2 0 and A0 A1 A2 0.
1 1 1
Therefore A2 , A1 and A0 , so
3 2 6
1 1 1
n n3 n 2 n is a particular solution of (8).
3 2 6
Adding this to the general solution of
the homogenous solution,
1 1 1 1 1 1
sn n3 n 2 n . Since s1 1, we have 1 ,
3 2 6 3 2 6
n
1 1 1
which gives 0, so sn k 2 n3 n 2 n 9
k 1 3 2 6
69
a. In the following problems, find the general solution if the initial
conditions are given, find the particular solution that satisfies those
conditions.
1 y y 2 y 3
n2 n 1 n
n
2 y 2 y 8 y 5
n n 1 n 2
n2
3 y 4 y 3 y 4
n n 1 n2
4 y y 2 y 2 ; y 2, y 1
n 2 n 1 n
n
0 1
5 y 2 y y 4; y 2, y 1
n2 n 1 n 1 2
6 y 3 y 10 y 36n 21
n2 n 1 n
7 y 9 y n 4n 1
n n2
2
8 y 9 y n 5n 3
n 2 n
2 n
9 y 2 y 8 y 5n 14; y 0, y
n2 n 1 n 0 1
1
10 2 y 3 y 5 y 5 4
n 1 n n 1
n 1
12 y 6 y 12 y 8 y 3
n n 1 n2 n 3
n
70
n
16 2
k 1
k
n
17 2k k
k 1
n
18 1
k
k2
k 1
71
Unit4
INTRODUCTION
We shall have an insight into the basic mathematical logic behind language
of computer usage. An understanding of this unit will ease up complex
structures in the complex language of the computer. You are encouraged to
put in some effort to follow this unit.
any elements: a, b, c B ;
B1 : commutative laws:
ab ba
a b b a
B2 : Distributive laws:
a b c a b a c
a b c a b a c
B3 : Identity Laws
72
a0 a
a 1 a
B4 : Complement Laws
a a 1
a a 0
The sextuplet is denoted by B when the operations are understood. The
element 0 is called the zero element, the element 1 is called the unit
element, and a ' is called the complement of a . The results of the operations
and are called the sum and product respectively. The following
convention, unless guided by parenthesis, is that ' has precedence over ,
and has precedence over +.
For example
a b c means a b c not a b c
a b ' means a b ' and not a b '
'
1 0
0 1
73
Then we have the following two fundamental tables:
+ 1 0
1 1 1
0 1 0
* 1 0
1 1 0
0 0 0
Example 1
Find the value of 1 0 0 1 '
Solution:
From the tables:
0 1 1
and 0 1 ' 1' 0
1 0 0 1 ' 1 0 0
00
0
74
BOOLEAN EXPRESSIONS AND BOOLEAN FUNCTIONS
Example 2
The Boolean function F x, y with the value 1 when x 1 and y 0 and the
x y F x, y
1 1 0
1 0 1
0 1 0
0 0 0
expressions.
If x1 and x2 are Boolean expressions, so are x1' , x2' , x1 x2 and x1 x2 .
75
Each Boolean expression represents a Boolean function. The values of this
function are obtained by substituting 0 and 1 for the variables in the
expression.
Example 3
Find the values of the Boolean function represented by F x, y, z xy z '
Solution:
x y z xy x y z' F x, y, z
1 1 1 1 0 1
1 1 0 1 1 1
1 0 1 0 0 0
1 0 0 0 1 1
0 1 1 0 0 0
0 1 0 0 1 1
0 0 1 0 0 0
0 0 0 0 1 1
Two different expressions that represent the same function are called
equivalent. For example, the Boolean expressions: xy , xy 0, xy 1 are
equivalent.
76
The complement of the Boolean function F is the function F ' .
77
IDENTITIES OF BOOLEAN ALGEBRA
There are many identities of Boolean algebra but we provide the most
important of them as displayed in the following table:
BOOLEAN IDENTITES
Identity Name
x ' ' x Law of double complement
x0 x
Identity laws
x0 0
x 1 1 Dominance laws
x0 0
x y yx
Commutative laws
xy yx
x y z x y z
Associative laws
x yz xy z
x yz x y ( x z )
x y z xy xz Distributive laws
78
Example 4
Show that the distributive law x y z xy xz is valid.
Solution:
The verification is shown in the following table
x y z yz xy xz x y z xy xz
1 1 1 1 1 1 1 1
1 1 0 1 1 0 1 1
1 0 1 1 0 1 1 1
1 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0
The identity holds because the last two columns of the table agree. The
basic important identities summarized in the previous table can be used to
prove further identities.
Example 5
Prove the absorption law x x y x , verify the identities of Boolean
algebra.
79
Solution:
The steps used to derive this identity and the law used in each step follows:
x x y x 0 x y Identity law for the Boolean sum
x 0 y Distributive law of the Boolean sum over the Boolean product
x y 0 Commutative law for the Boolean product
x0 Dominance law for the Boolean product
x Identity law for Boolean sum
DULITY
Observe that in the table of Boolean Identities, the identities come in pairs
(except for the double complement). To fully explain the relationship
between the two identities in each pair, we use the concept of a dual. The
dual of a Boolean expression is obtained by interchanging Boolean sums
and Boolean products and interchanging 0’s and 1’s.
Example 6
Find the duals of x y 0 and x '1 y ' z .
Solution
Interchanging * signs and + signs and interchanging 0’s and 1’s in these
expressions produces their duals. The duals are x y 1 and x ' 0 y ' z
respectively.
80
An identity between functions represented by Boolean expressions remains
valid when the duals of both sides of the identity are taken. That is, if F and
G are Boolean functions represented by Boolean expressions in n variables
and F = G, then Fd = Gd, where Fd and Gd are the Boolean functions
represented by the duals of the Boolean expressions representing F and G,
respectively. This result, called the duality principle is useful for obtaining
new identities.
Example 7
Construct an identity from the absorption law: x x y x given in example
5 by taking duals.
Solution:
Taking duals of both sides of this identity produces the identity x xy x ,
which is also called an absorption law.
81
5. Prove the absorption law x xy x using the laws in table 5.
6. Show that F x, y, z xy xz yz has the value 1 if and only if at least
Exercise 8-15 deal with the Boolean algebra defined by the Boolean sum
and Boolean product on 0,1
8. Verify the law of double complement
9. Verify the idempotent laws
10.Verify the identity laws
11.Verify the dominance laws
12.Verify the commutative laws
13.Verify the associative laws
14.Verify the first-distributive law in Table 5
15.Verify De Morgan’s laws.
(use tables)
17.Show that the following identities hold:
a x y x y xy ' b x y xy ' x ' y
18.Show that x y y x
82
19.Prove or disprove the following equalities
a x y z x y z
b x y z x y x z
c x y z x y x z
83
REPRESENTATION BOOLEAN FUNCTIONS
The second problem is: Is there a smaller set of operators that can be used to
represent all Boolean functions? This will be answered by showing that all
Boolean functions can be represented using only one operator.
Example 1
Find Boolean expressions that represent the functions F x, y, z and G x, y, z ,
which are given in Table 1.
84
TABLE 1
x y z F G
1 1 1 0 0
1 1 0 0 1
1 0 1 1 0
1 0 0 0 0
0 1 1 0 0
0 1 0 0 1
0 0 1 0 0
0 0 0 0 0
Solution
F has value 1 when x z 1 and y 0 and otherwise. Such an expression is
formed by taking the Boolean product of x, y ' and z . This product xy ' z has
value 1 if and only if x y ' z 1 , which holds if and only if
x z 1 and y 0 .
85
DEFINITION
A literal is a Boolean variable or its complement. A minterm of the
Boolean variables x1 , x2 ,..., xn is a Boolean product y1 , y2 ,..., yn where
yi xi or yi xi' . Hence, a minterm is a product of n literals with one literal
Example 2
Find a minterm that equals 1 if x1 x3 0 and x2 x4 x5 1 , and equals 0
otherwise.
Solution
The minterm x1' x2 x3' x4 x5 has the correct set of values.
86
Example 3
Find the sum of products expansion for the function F x, y, z x y z
Solution
The first step is to find the values of F . These are found in table 2. The
sum-of-products expansion of F is the Boolean sum of three minterms
corresponding to the three rows of this table that give the value 1 for the
function.
This gives F x, y, z xyz ' xy ' z ' x ' yz ' .
Table 2
x y z x y z x y z F
1 1 1 1 0 0
1 1 0 1 1 1
1 0 1 1 0 0
1 0 0 1 1 1
0 1 1 1 0 0
0 1 0 1 1 1
0 0 1 0 0 0
0 0 0 0 1 0
87
FUNCTIONAL COMPLETENESS
Every Boolean function can be expressed as a Boolean sum of minterms,
which are Boolean products of Boolean variables or their complements. This
shows that every Boolean function can be represented using the Boolean
operations , and ' . We therefore say that the set , , ' is functionally
complete.
1 1 0
1 0 1
0 1 1
88
1 0
1 0 0
0 0 1
defined by 1 1 1 0 0 1 0 and 0 0 1 .
Both of the sets {} is functionally complete. Since , ' is functionally
complete, all we need to do is show that both operators and ' can be
expressed using just operator. This is done as follows:
x' x x
xy x y x y
Exercise
1. Find a Boolean product of the Boolean variable x, y and z or their
complements, that has the value 1 if and only if
a x y 0, z 1
b x 0, y 1 z 0
c x 0, y z 1
d x y z 0
89
a F x, y x ' y
b F x, y xy '
c F x, y 1
d F x, y y '
the value 1 if and only if are odd number of w, x, y and z have the value
1
90
In question numbers 7-11, find a Boolean expression that represents a
Boolean function formed from a Boolean product of Boolean sums of
literals.
a x y 1, z 0
b x y z0
c x z 0, y 1
8. Find a Boolean product of Boolean sums of literals that has the value
0 if and only if either x y 1 and z 0, x z 0 and y 1 or x y z 0
(Hint: take the Boolean product of Boolean sums found in parts (a),
(b) and (c) in7).
91
12.Express each of the following Boolean functions using the operators
and ' .
a x y z
b x y ' x ' z
c x y ' '
d x ' x y ' z '
13.Express each of the Boolean functions in (12) using the operators
and ' .
14.Show that
a x' x x b xy x y x y
c x y x x y y
15.Show that
a x' x x b xy x x y y
c x y x y x y
92
LOGIC GATES
x x'
Input Output
II. OR gate: The inputs of this gate are two or more Boolean variables.
The output is the Boolean sum of their values. This is represented
by
x x y
y Output
Input
93
III.AND gate: The inputs to this gate are of two or more Boolean
variables. The output is the Boolean product of their values. This
is represented by
x
xy
Output
y
Input
More inputs are permitted to AND and OR gates. Such situations are shown
below
x1
x2
x1 x2 ...xn
...
xn
x1
x
x1 x2 ... xn
2
...
x n
94
2-4.1 COMBINATIONS OF GATES
x
xy
y
xy x ' y
x'
x' y
The other method is to indicate this input separately for each gate.
95
x xy
y
xy x ' y
x'
x x' y
Note also that the output from a gate may be used as input by one or more
elements as shown in the above two diagrams. Note also that the two
diagrams represent the same input and output circuiting.
EXAMPLE 1
Construct circuits that produce the following outputs:
a x y x '; b x ' y z ' ';
c x y z x ' y ' z '
96
SOLUTION
(a)
x x y
y
x y x '
x'
x
OR
x x y
y
x y x '
x'
97
(b)
x'
x
x ' y z ' '
x
x y z
y
z'
z
EXAMPLES OF CIRCUIT
We give some examples of circuits that perform some useful functions.
Example 2
A committee of three individuals decides issues for an organization. Each
individual votes either yes or no for each proposal that arises. A proposal is
98
passed if it received at least two yes votes. Design a circuit that determines
whether a proposal passes.
Solution:
Let x 1 if the first individual votes yes, and x 0 if he votes no; let y 1 if
the second votes yes and y 0 if he votes no; let z 1 if the third individual
votes yes, and z 0 if this individual votes no. Then a circuit must be
designed that produces the output 1 from the inputs x, y and z when two or
more of x, y and z are 1. The representations of the Boolean function that
have these output values are
F x, y, z xy xz yz or F x, y, z xy xz xyz yz .
x xy
x xz
xy xz yz
z
y yz
99
Example 3
Sometimes light fixtures are controlled by more than one switch. Circuits
need to be designed so that flipping any one of the switches turns the light
on when it is off and turns the light off when it is on. Design circuits that
accomplish this when there are two switches and when there are three
switches.
Solution:
I. For two switches
Let x 1 when the switch is closed and x 0 when it is opened and let y 1
when the second switch is closed and y 0 when it is opened. Let F x, y 1
the light is on when both switches are closed, so that F 1,1 1 . This
determines all the other values of F. When one of the two switches is
opened, the light goes off, so F 1, 0 F 0,1 0 . When the other switch is
opened, the light goes on, so that F 0,0 1 . The following table displays
these values.
x y F x, y
1 1 1
1 0 0
0 1 0
0 0 1
100
Then we see that F x, y xy x ' y ' with the following circuit:
x xy
xy x ' y '
x'
x x' y'
y'
y
open the light goes off, so that F 1,1, 0 F 1, 0,1 F 0,1,1 0 .
When a second switch is opened, the light goes on, so that
F 1, 0,0 F 0, 0,1 F 0,1, 0 1 . Finally, when the third switch is opened, the
light goes off again, so that F 0, 0, 0 0 . The following table and circuit
display the foregoing analysis.
101
x y z F x, y, z
1 1 1 1
1 1 0 0
1 0 1 0
1 0 0 1
0 1 1 0
0 1 0 1
0 0 1 1
0 0 0 0
x xyz
y
z
x xy ' z '
y
xyz xy ' z ' x ' yz ' x ' y ' z
z
x x ' yz '
y
z
x
x' y'z
y
Where F xyz xy ' z ' x ' yz ' x ' y ' z is the sum-of-products expansion.
102
In (1) to (5), find the output of the given circuit.
103
1 2
x
x
y
y
3 4
x x
y
y z
x
y
z
z
x
x
y
z 5
x
y
z
x
y
104
6. Construct circuits from inverters, AND gates, and OR gates to produce the
following inputs:
a x ' y; b x y ' x; c xyz x ' y ' z '; (d) x ' z y z ' '
105
Unit5
Introduction
There is the need to have a modicum knowledge of pure mathematics. This
unit does exactly that. It ushers you into an interesting area of mathematics.
This unit is a must-do
do unit.
Objectives
On completion of this unit, you would be able to:
Identify some basic theories in pure mathematics
Apply the knowledge gained to analytic courses in the
years ahead
RELATIONS IN A SET
DEFINITIONS
A binary relation (or relation) from a set of A to a set B assigns to each
pair a, b in A B exactly one
on of the following statements:
106
Observe that any relation from a set A to a set B uniquely defines a
subset of A B as follows: a, b : ab
Domain of a : a, b
Range of b : a, b
EQUIVALENCE RELATIONS
DEFINITION
A relation in a set A , that is, a subset of A A is called an equivalence
relation if and only if it satisfies the following axioms:
E1 For every a A, a, a , reflexive property
E 2 If a, b , then b, a , symmetric property
E3 If a, b , and b, c , then a, c , transition property
Accordingly, a relation is an equivalence relation if and only if it is
reflexive, symmetric and transitive.
If is an equivalence relation in A , then the equivalence class of any
element a A , denoted by a , is the set of elements to which a is related.
a x : a, x
107
THEOREM
Let be an equivalence relation in A and let a be the equivalence class of
a A . Then:
i For every a A, a a
ii a b , iff a, b
iii If a b , then a and b are disjoint
A class a of non-empty subsets of A is called a partition of A if and only if
1. each a A belongs to some member of a and
2. the members of a are pairwise disjoint.
Therefore, the theorem above implies the following fundamental theorem of
equivalence relations.
THEOREM
Let be an equivalence relation in A . Then the quotient set A / is a
partition of A .
Example 1
Let 5 be the relation in , the set of integers, defined by x y mod 5 ,
108
We observe for each integer x, x 5 p r where 0 r 5 , is a member of the
equivalence class Er , where r is the remainder when x is divided by 5.
Note that the equivalence classes are pairwise disjoint and that
Z E0 E1 E2 E3 E4
Example 2
Consider the relation 1, 2 , 1,3 , 2,3 in A 1, 2,3 . Then
Domain of 1, 2 ,
Range of 2,3
109
3. Consider the set , that is, the set of ordered pairs of positive
integers. Let be the relation in which is defined by
a, b c, d iff ad bc .
110
ORDERING OF A SET
PARTIAL ORDERING
A relation in a set A is called a partial order (or order) if and only if, for
every a, b, c A such that
(i) a a , reflexive property
(ii) a b and b a implies a b , anti-symmetric property
(iii) a b and b a implies a c , transitive property
The set A together with the partial order, that is, the pair A, is called a
partially ordered set. A partial order is a reflexive, anti-symmetric and
transitive relation.
Example 1
Set inclusion is a partial order in any class of sets since
i A A is true for any set A
ii A B and B A implies A B for any sets A, B
iii A B and B C implies A C for any sets , A, B and C
Example 2
Let A be any set of real numbers. Then the relation in A defined by x y is a
partial order and is called the natural order in A .
111
Example 3
Let X a, b, c, d , e . Then the diagram below defines a partial order in X as
follows:
x y iff x y or if one can go from x to y in the diagram, always moving in
b c
DEFINITION
If ab in an ordered set, we say, a precedes or is smaller than b and that b
follows or dominates or is larger than a . We write a b if a b but a b .
A particular ordered set A is said to be totally (or linearly) ordered if, for
every a, b A , either a b or b a .
112
Example 4
Let A and B be totally ordered. Then the product set A B can be totally
ordered as follows: a, b a ', b ' if a a ' or a a, and b b ' .
REMARKS
If a relation in a set A defines a partial order, that is, is reflexive, anti-
symmetric and transitive, then the inverse relation 1 is also a partial order,
it is called the inverse order.
113
Example 5
Consider the partial order in W a, b, c, d , e defined by the diagram
a b
d e
The sets a, c, d and b, e are totally ordered subsets, the sets
114
Example 6
Let X a, b, c, d , e be ordered by the diagram,
b c
proceed e .
Example 7
The positive integers with the natural order have 1 as a first element; there
is no last element. Similarly, the set of integers with the natural order has
no first element and no last element.
115
Example 8
Let X a, b, c, d , e be ordered by the diagram of Example 6. Then both
d and e are minimal elements. The element a is a maximal element.
Example 9
Although with the natural order is totally ordered it has no minimal and no
maximal elements.
Example 10
Let A a1 , a2 ,..., am be a finite totally ordered set. Then A contains precisely
one minimal element and precisely one maximal element, denoted
respectively by
min a1 ,..., am and max a1 ,..., am
and only if x for all x A , that is, if follows every element in A . If some
upper bound of A precedes every other upper bound of A , then it is called
the least upper bound (L.U.B) or supremum of A and is denoted by sup A .
116
A is said to be bounded above if it has an upper bound, and bounded below
if it has a lower bound. If A has both an upper and lower bounds, then it is
said to be bounded.
Example 11
Let X a, b, c, d , e, f , g be ordered as shown in the following diagram:
a b
c
B
d e
g
f
Let B c, d , e . Then a, b and c are upper bound of B , and f is the only
lower bound of B . We note that g is not a lower bound of B since g does not
precede d . Furthermore, c sup B belongs to B , while f inf B does not
belong to B .
Example 12
Let A be a bounded set of real numbers. Then, a fundamental theorem about
real numbers states that, under the natural order, inf A and sup A exist.
117
Example 13
Let be the set of rational numbers. Let B x : x , x 0, 2 x 2 3 . Then
B has an infinite number of upper and lower bounds, but inf B and sup B
do not exist, because the real numbers 2 and 3 do not belong to and
therefore cannot be considered as upper and lower bounds of B .
EXERCISE
1. Let , the positive integers, be ordered as follows: each pair of
elements a, a ' can be written uniquely in the form
a 2r 2s 1 , a ' a r ' as ' 1
Where r , r ', s, s ' 0,1, 2,3,... . Let a a ' if r r or if ' r r ' but s s ' .
Insert the correct symbol, or , between each of the following pairs
of numbers. (Note: x y iff y x ).
(i) 5……14 (ii) 6…………9
(iii) 3……..20 (iv) 14………21
2. Let A a, b, c be ordered as in the diagram below. Let be the
collection of all non-empty totally ordered subsets of A , and let be
partially ordered by set inclusion. Construct a diagram of the order of
.
b c
118
3. Let A 2,3, 4,... \ 1 and let A be ordered by " x divides y " .
(i) Determine the minimal elements of A
(ii) Determine the maximal elements of A .
1 2
4 5
6 7
6. Let A , , the positive integers with the natural order; and let
119
A B denote the lexicographical ordering of according to the
order of A and then B . Insert the correct symbol, < or >, between each
pair of elements of .
i 3,8 .......... 1,1 ii 2,1 .............. 2,8
iii 3, 3 .......... 3,1 iv 4,9 ............. 7,15
7. Let X 1, 2,3, 4,5, 6 be ordered as in the diagram below. Consider the
subset A 2,3, 4 of X .
3 4
5 6
120
8. Consider , the set of rational numbers, with the natural order, and its
subset A x : x , x 3 3
9. Let , the positive integers, be ordered by " x divides y " and let
A
(i) Does inf A exist?
ZORN’S LEMMA
Zorn’s lemma: Let X be a non-empty partially ordered set in which every
totally ordered subset has an upper bound, then X contains at least one
maximal element.
121