All Notes
All Notes
All Notes
If the range of the random variable assumes values from a countable set, it is then a discrete random variable. The defining
characteristic of a discrete random variable is that the set of possible values in the range can all be listed, where it may be a
finite list or a countably infinite list.
𝑝 𝑥 𝑃 𝑋 𝑥 𝑥∈𝑆
Note that 𝑝 𝑥 is a function ranging over real numbers 𝑥 and that 𝑝 𝑥 can be non-zero only at the values 𝑥 ∈ 𝑆 . For
any value of 𝑥, the function 𝑝 𝑥 is the probability of the event 𝑋 𝑥 . The pmf must satisfy the following important
properties:
Note that 𝐵 is an event and the above summations have a finite or an infinite number of terms, depending on whether the
range is finite or not. All three properties are consequences of the axioms of probability.
ELEE 2110U Discrete Mathematics 3
Example
Suppose we have a fair coin. Let 𝑋 be the number of heads in three coin tosses. Find the pmf of the random variable 𝑋.
Solution
In a coin toss, there are 2 possibilities, a head and a tail. In tossing a coin 3 times, there are a total of 8 2 different
possible outcomes, as reflected below:
𝑇𝑇𝑇, 𝑇𝑇𝐻, 𝑇𝐻𝑇, 𝑇𝐻𝐻, 𝐻𝑇𝑇, 𝐻𝑇𝐻, 𝐻𝐻𝑇, 𝐻𝐻𝐻
As the coin is fair, the likelihood of a tail is the same as the likelihood of a head. The coin tosses are independent. After
tossing a fair coin three times, the probability of each of the eight outcomes is .
In short, we have
1
𝑃 𝑋 0 𝑃 𝑇𝑇𝑇
8
3
𝑃 𝑋 1 𝑃 𝑇𝑇𝐻 𝑃 𝑇𝐻𝑇 𝑃 𝐻𝑇𝑇
8
3
𝑃 𝑋 2 𝑃 𝑇𝐻𝐻 𝑃 𝐻𝐻𝑇 𝑃 𝐻𝑇𝐻
8
1
𝑃 𝑋 3 𝑃 𝐻𝐻𝐻
8
ELEE 2110U Discrete Mathematics 4
Expected Value of a Random Variable
The expected value or the mean of a random variable 𝑋 represents a real number ∞, ∞ . The expected value of a random
variable 𝑋, denoted by 𝐸 𝑋 or 𝜇 , is defined as follows:
𝐸𝑋 𝜇 𝑥 𝑃 𝑋 𝑥 𝑥𝑝 𝑥 Discrete 𝑋
∈
𝜎 𝐸𝑋 𝜇
The variance of a random variable, if it is defined, is always non-negative. The square root of the variance of 𝑋, denoted by
𝜎 , is called the standard deviation of the random variable 𝑋, and is a positive quantity with the same unit as 𝑋.
The variance of a random variable provides essentially a measure of the effective width of the pmf of the random variable.
The variance of a random variable in some sense is a measure of the variable’s randomness, as it indicates the variability of
the outcomes. For instance, a large variance indicates the random variable is quite spread out and it is thus more
unpredictable, whereas a small variance shows the random variable is concentrated around its mean and it is thus less
random.
Solution
The pmf of the discrete random variable 𝑋 is as follows:
1 4 6 4 1
𝑃 𝑋 0 𝑃 𝑋 1 𝑃 𝑋 2 𝑃 𝑋 3 𝑃 𝑋 4
16 16 16 16 16
Determine the variance of the random variable 𝑋. Show your work. Do simplify your answer to 2 decimal places.
Solution
𝐸𝑋 1 0.1 2 0.1 3 0.5 4 0.1 5 0.1 6 0.1 3.3
1 𝑝 𝑥 0
𝑝 𝑥 𝑝 𝑥 1 0 𝑝 1
0 𝑥 0, 1
The Bernoulli trial is equivalent to the tossing of a biased coin or examining if a component is defective in a system or
modelling any other process that has only two possible outcomes, such as taking a pass-fail exam.
The mean 𝜇 and variance 𝜎 of the Bernoulli random variable 𝑋, which cannot be independently set as they are both
functions of 𝑝 only, are respectively as follows:
𝜇 𝑝
𝜎 𝑝 1 𝑝
Solution
The maximum value of the variance is obtained as follow:
𝑑𝜎
1 2𝑝 0
𝑑𝑝 1
𝜎 𝑝 𝑝 → → 𝑝
2
𝑑𝜎
2 0
𝑑𝑝
Therefore, the maximum value of the variance occurs when 𝑝 , which in turn corresponds to the highest level of
uncertainty, as there are two equally likely outcomes. The variance is minimum, i.e., its value is approaching zero, when
𝑝 0 or 𝑝 1, which in turn implies there is then no uncertainty, as there is always only one possible outcome.
Applications of binomial distribution may include estimation of probabilities of the number of times hitting the target or the
number of erroneous bits when a packet of data (long sequence of bits) is transmitted over a noisy communication channel.
𝑛
𝑝 1 𝑝 𝑥 0, 1, … , 𝑛
𝑝 𝑥 𝑥 0 𝑝 1
0 otherwise
𝑛 !
where ≜ is known as the binomial coefficient. The binomial distribution is frequently used to model the number
𝑥 ! !
of successes when the sampling is performed with replacement, as the draws are independent.
The mean 𝜇 and variance 𝜎 of the binomial random variable 𝑋, which can be independently set by the appropriate
selection of 𝑝 and 𝑛, are respectively as follows:
𝜇 𝑛𝑝 & 𝜎 𝑛𝑝 1 𝑝
Solution
Noting that the bit transmission can be viewed as a Bernoulli trial, the probability of interest is as follows:
5
𝑃 𝑋 3 0.0001 0.9999 ≅ 10
𝑥
By sending the same bit five times, the bit error rate can be reduced from 10 to about 10 , a very significant reduction
in bit error rate, but of course at the heavy price of repeating a bit five times.
𝑃 𝑋 𝑘 𝑝 𝑘 𝑘 𝑚 1, … , 𝑚 𝐿 ∞ 𝑚 ∞ 𝐿 ∈ 1, 2, …
The mean 𝜇 and variance 𝜎 of the discrete uniform distribution 𝑋 are respectively as follows:
𝐿 1 𝐿 1
𝜇 𝑚 & 𝜎
2 12
The discrete random variable is used to generate random numbers in computer simulation models. Note that events that have
an equiprobable finite number of outcomes form the basis upon which counting formulas are developed.
ELEE 2110U Discrete Mathematics 16
Example
Suppose the mean and variance of a discrete uniform random variable 𝑋 are both 10. Determine the set of consecutive
integers that this discrete uniform random variable can take on.
Solution
We have:
𝐿 1
𝜎 10 → 𝐿 11
12
We can therefore have:
𝐿 1 11 1
𝜇 𝑚 10 → 𝑚 10 → 𝑚 4
2 2
Hence, 𝑋 takes on values in the set of consecutive integers 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 , each with probability .
𝑝 𝑥 1 𝑝 𝑝 𝑥 1, 2, … 0 𝑝 1.
Solution
The probability that a fan has to attempt one hundred or more times to get through is as follows:
This is simply the probability that the first ninety-nine attempts are unsuccessful.
𝑒 𝜆
𝑝 𝑥 𝑥 0, 1, 2, … 𝜆 0.
𝑥!
where 𝜆 is the parameter of the distribution reflecting the average rate of occurrence.
Solution
The probability that a computer program has no bugs is as follows:
𝑒 7
𝑃 𝑋 0 ≅ 0.0009.
0!
𝑒 7
𝑃 𝑋 3 1 𝑃 𝑋 𝑖 1 ≅ 0.0296.
𝑖!
Solution
In a four-digit integer, the first (the most significant) digit cannot be zero. There are therefore nine possible ways for the first
digit, from 1 to 9 inclusive.
The second most significant digit can be any one of the ten possible digits, from 0 to 9 inclusive.
The third digit cannot be an odd integer, that is, it must be one of the five digits 0, 2, 4, 6, and 8.
The fourth (the least significant) digit must be 0.
Using the product rule, there is then a total of 9 10 5 1 450 four-digit integers that are multiples of twenty.
Solution
There is a set of 9 two-digit integers that are divisible by 11, and there is a set of 7 two-digit integers that are divisible by 13.
These two sets are mutually exclusive, as there is no two-digit integer that is divisible by both 11 and 13.
Using the sum rule, there are therefore 9 7 16 two-digit integers that are divisible by 11 or 13.
Solution
For an integer to be a multiple of 3, the sum of its digits must be a multiple of 3.
A digit can be used only once, therefore the smallest sum of all digits in a four-digit integer can be 0 1 2 3 6, and the largest sum
of all digits can be 2 3 4 5 14. The sum that must be divisible by three can then be 6, 9, or 12.
Note that the first digit cannot be 0 as it is a four-digit integer.
We therefore have the following mutually exclusive cases:
• The sum of the integers is 6. The four integers are 0, 1, 2, and 3. Using the product rule, there are 3 3 2 1 18 integers.
• The sum of the integers is 9. The four integers are 0, 1, 3, and 5. Using the product rule, there are 3 3 2 1 18 integers.
• The sum of the integers is 9. The four integers are 0, 2, 3, and 4. Using the product rule, there are 3 3 2 1 18 integers.
• The sum of the integers is 12. The four integers are 0, 3, 4, and 5. Using the product rule, there are 3 3 2 1 18 integers.
• The sum of the integers is 12. The four integers are 1, 2, 4, and 5. Using the product rule, there are 4 3 2 1 24 integers.
By the sum rule, the total number of integers is thus 18 18 18 18 24 96.
Solution
The set of two-digit integers that are multiples of 3, the set of integers that are multiples of 4, and the set of integers that are
multiples of 5 are not mutually exclusive.
There are 30 two-digit integers that are divisible by 3, there are 22 two-digit integers that are divisible by 4, and there are 18
two-digit integers that are divisible by 5.
There are 8 two-digit integers that are divisible by both 3 and 4, there are 6 two-digit integers that are divisible by both 3 and
5, and there are 4 two-digit integers that are divisible by both 4 and 5. Also, there is one two-digit integer that is divisible by
all 3, 4, and 5.
Using the subtraction rule, there are therefore 30 22 18 8 6 4 1 53 two-digit integers that are multiples of
3, 4, or 5.
Solution
Using the inclusion-exclusion principle, we have:
Solution
Using the product rule and noting that a digit in a password cannot be repeated,
o the number of passwords consisting of four different digits is 10 9 8 7 5,040,
o the number of passwords consisting of five different digits is 10 9 8 7 6 30,240,
o the number of passwords consisting of six different digits is 10 9 8 7 6 5 151,200, and
o the number of passwords consisting of seven different digits is 10 9 8 7 6 5 4 604,800.
By the sum rule, the total number of all passwords is thus 5040 30240 151200 604800 791,280.
Solution
Using the pigeonhole principle, we have 𝑘 10, as there are ten distinct digits in the Hindu-Arabic numeral system. In
order to have at least two of the digits the same, the minimum number of the digits in the integer must then be 𝑘 1 11.
Solution
Using the generalized pigeonhole principle, we have 𝑘 2, as there are two different colors and we have 𝑛 8, as 𝑛 1
9. The minimum number of balls that she must select to be sure of having at least nine balls of the same color is thus 𝑚
𝑘𝑛 1 2 8 1 17.
In a selection without replacement, an object, once selected, is not available for future selections. In sampling without
replacement, the sample space of each selection depends on the outcomes of previous selections.
Selection with or without replacement can be both applied to both 𝑘-permutations and 𝑘-combinations, thus giving rise to
four distinct counting methods.
Permutations & Combinations, with & without Replacement
Permutations Combinations
(ordered arrangements) (unordered selections)
Without 𝒏! 𝒏!
replacement 𝒏 𝒌 ! 𝒌! 𝒏 𝒌 !
With 𝒏𝒌 𝒏 𝒌 𝟏 !
replacement
𝒌! 𝒏 𝟏 !
Example
How many different ways are there to select a gold medalist, a silver medalist, and a bronze medalist from 195 athletes with
different nationalities who have entered a world sports competition?
Solution
Since it matters which athlete wins which medal and no athlete can win more than one medal, it is a selection with ordering
!
and without replacement. Noting that 𝑛 195 and 𝑘 3, the number of ways is thus 195 194 193
!
7,301,190.
Solution
Since it matters which team wins which medal and no team can win more than one medal, it is a permutation without
!
replacement. Noting that 𝑛 32 and 𝑘 3, the number of ways is thus 32 31 30 29,760.
!
Solution
Since the order of the selection of the players is immaterial and no player can be selected more than once, it is a combination
!
without replacement. Noting that 𝑛 22 and 𝑘 11, the number of ways is thus 705,432.
! !
Solution
This is a permutation with replacement, as the order of capital letters in a password matters and a capital letter can be used in
a password more than once. Noting that 𝑛 26 and 𝑘 4, the number of words is thus 26 456,976.
Solution
This is a combination but with replacement, as the order of the selection does not matter and a food can be selected more
!
than once. With 𝑛 25 and 𝑘 4, the number of ways is thus 20,475.
! !
number is smaller than the second number, and the set 𝐶 that B
(4, 1) (4, 2) (4, 3) (4, 4) (4, 5) (4, 6)
includes 6 pairs, in each of which the first and the second
numbers are the same. We have the following four cases:
C
(5, 1) (5, 2) (5, 3) (5, 4) (5, 5) (5, 6)
A B
! !
!
15 pairs A
(6, 1) (6, 2) (6, 3) (6, 4) (6, 5) (6, 6)
!
A C B C 21 pairs
! !
!
A B 30 pairs No. of perms. with replacement 𝐴 𝐵 𝐶 36
!
𝐴 𝐵 𝐶 6 36 15 15 6 pairs No. of perms. without replacement 𝐴 𝐵 30
No. of combs. with replacement 𝐴 𝐶 𝐵 𝐶 21
No. of combs. without replacement 𝐴 𝐵 15
Example
In a bag, there are three black balls, four white balls, and five red balls. Two balls are picked from the bag. How many ways
(permutations) are there if the two balls are not of the same color?
Solution
To choose two balls of different colors, we consider three mutually exclusive cases, where each is based on the product rule:
3 4 3 5 5 4 47 ways.
𝑛 𝑛 𝑛 ! 𝑛 !
⋯ ⋯
𝑘 𝑘 𝑘 ! 𝑛 𝑘 ! 𝑘 ! 𝑛 𝑘 !
Solution
! ! !
As we have 𝑛 10, 𝑛 20, 𝑛 18, 𝑘 5, 𝑘 4, and 𝑘 6, the number of ways is thus
! ! ! ! ! !
22,665,530,160.
Solution
Note that there are ways to choose the 13 cards of the first player, ways to choose the 13 cards of the
second player, ways to choose the 13 cards of the third player, and way to choose the 13
cards of the fourth player. Using multinomial counting, the total number of possible ways is as follows:
52 39 26 13 52!
≅ 5.364 10 .
13 13 13 13 13! 13! 13! 13!
1 , ,
Assuming that once a ball is drawn, it is not put back in the device, we need to ≅ 𝟒𝟏. 𝟑𝟎𝟏𝟗%
, ,
probability 5 ≅ 𝟎. 𝟎𝟎𝟏𝟖%
, ,
6 ≅ 𝟎. 𝟎𝟎𝟎𝟎𝟎𝟕%
, ,
𝑝
! Straight It contains five cards of sequential rank, all of the same suit, but 36
2,598,960 Flush not Royal Flush. 2598960
≅ 𝟎. 𝟎𝟎𝟏𝟒%
! !
Four of It contains four cards of one rank and one other card. 624
≅ 𝟎. 𝟎𝟐𝟒%
a Kind 2598960
possible combinations in five-card
Full It contains three matching cards of one rank and two matching 3744
poker. Probability analysis can House cards of another rank. ≅ 𝟎. 𝟏𝟒𝟒%
2598960
provide the valuable knowledge Flush It contains five cards of the same suit, but not in sequence. 5108
about the probabilities of an array 2598960
≅ 𝟎. 𝟏𝟗𝟕%
of hands, a necessary but not a Straight It contains five cards of sequential rank, but in more than one
10200
suit. ≅ 𝟎. 𝟑𝟗𝟐%
sufficient requirement to win in 2598960
poker. Three of It contains three cards of the same rank, plus two unmatched
54912
a Kind (not of this rank nor the same as each other) cards. ≅ 𝟐. 𝟏𝟏%
2598960
Two It contains two cards of the same rank, plus two cards of
In poker, there are also other 123552
≅ 𝟒. 𝟕𝟓%
Pair another rank (that match each other, but not the first pair) and 2598960
important factors involved, such one unmatched (not of either rank) card.
as the betting sequence, other One It contains two cards of the same rank, plus three other
1098240
Pair unmatched (not of this rank nor the same as each other) cards. ≅ 𝟒𝟐. 𝟐𝟔%
players’ hands, and above of all 2598960
High It contains no two cards of the same rank, the five cards are not
the playing decisions made by the ≅ 𝟓𝟎. 𝟏𝟐%
Card in sequence, and the five cards are not all the same suit.
other players.
0.5
0 𝑁
1 10 50 100
Solution
• The sample space 𝑆 includes six sample points 1, 2, 3, 4, 5, and 6. Since the die is fair (unbiased), all six outcomes are equally likely.
• Some different events can be defined as follows: one with even outcomes (i.e., 2, 4, and 6), one with odd outcomes (i.e., 1, 3, and 5), and
one whose outcomes are divisible by 3 (i.e., 3 and 6).
• Two mutually exclusive events may be an event with even outcomes and an event with odd outcomes.
• The union of two events, where one is with odd outcomes and the other is with outcomes that are divisible by 3, consists of 1, 3, 5, and
6, and their intersection consists of only 3.
• A certain (sure) event consists of outcomes that are integers between 1 and 6 inclusive. A null (impossible) event consists of outcomes
that are less than 1 or greater than 6.
• The complement of the event whose outcomes are divisible by 3 is an event that contains 1, 2, 4, and 5.
Solution
For mere clarity, it is assumed that one of the two dice is red and the other is green. There are 6 possible outcomes for the red
die and 6 possible outcomes for the green die. The outcome of one die is independent of the outcome of the other die. In
other words, for a specific outcome for the red die, there can be 6 different outcomes for the green die, and for a specific
outcome for the green die, there can be 6 different outcomes for the red die. We therefore have 36 6 6 possible
outcomes in rolling a pair of dice, and as the dice are fair, we have a total of 36 equally-likely outcomes. It is thus a discrete
sample space. To have a sum of three, the outcomes must then be a 1 and a 2. But to get a sum of 3, there are two different
possible scenarios that include the red die is a 1 and the green die is a 2 or the red die is a 2 and the green die is a 1. Hence,
Axiom I: 𝑃 𝐴 0
Axiom II: 𝑃 𝑆 1
Axiom III: If 𝐴 , 𝐴 , … is a countable sequence of events such that 𝐴 ∩ 𝐴 ∅ for all 𝑖 𝑗, where ∅ is the null event,
that is they are pairwise disjoint (mutually exclusive) events, then 𝑃 𝐴 ∪ 𝐴 ∪ ⋯ 𝑃 𝐴 𝑃 𝐴 ⋯
Solution
Let 𝐴 be the event that includes prime numbers, and 𝐴 be the event that includes numbers that are multiples of 4, that is
we have:
8 2
𝐴 2, 3, 5, 7, 11, 13, 17, 19 → 𝑃 𝐴
20 5
5 1
𝐴 4, 8, 12, 16, 20 → 𝑃 𝐴
20 4
We also have:
𝐴 ∩𝐴 ∅ → 𝑃 𝐴 ∩𝐴 0
As the events 𝐴 and 𝐴 are mutually exclusive, we can use Axiom III to determine the probability that the number on a ball
chosen at random is either a prime number or a multiple of 4. We thus have:
2 1 13
𝑃 𝐴 ∪𝐴 𝑃 𝐴 𝑃 𝐴
5 4 20
III. 𝑃 𝐴 1
V. 𝐴⊂𝐵 → 𝑃 𝐴 𝑃 𝐵
VII. 𝑃 𝐴∪𝐵 𝑃 𝐴 𝑃 𝐵
Solution
There are many possibilities where at least one of the twenty bits is a zero. For instance, there may only be one zero in the
sequence, and this constitutes twenty different possibilities, such as the first one is a 0 or the second one is a 0, so on and so
forth. There may be only two zeros or three zeros or four zeros in the sequence or even more, where the locations of the
zeros could be anywhere in the sequence of twenty bits. In fact, there are quite many possibilities, in each of which there is
at least one zero in the sequence of twenty bits, and the sum of the probabilities of all these possibilities would then
determine the probability that at least one of these bits is 0.
There is an alternative strategy for finding the probability of an event when a direct approach is long and difficult. Instead of
determining the probability of an event 𝐴, the probability of its complement 𝐴 can be first found. The complement of the
event that has at least one bit being 0 is the event that all bits are 1’s. There are 2 1048576 different sequences of 20
bits, i.e., there are 1048576 sample points in the sample space. The probability of a sequence with all 1’s is thus .
Using 𝑃 𝐴 1 𝑃 𝐴 , the probability that at least one of these bits is 0 is then as follows: 1 .
Solution
The product of 7 numbers is not a multiple of 3 if none of them is a multiple of 3. The probability that a number from a bag
is not a multiple of 3 is . Therefore, the probability that the product of 7 numbers is not a multiple of 3 is . We can
then conclude that the probability that the product is a multiple of 3, using the complement law, is 1 .
Solution
Let 𝐴 be the event with balls having odd numbers and 𝐵 be the event with balls having prime numbers, we thus have:
5 1
𝐴 3, 5, 7, 9, 11 → 𝑃 𝐴
10 2
5 1
𝐵 2, 3, 5, 7, 11 → 𝑃 𝐵
10 2
4 2
𝐴∩𝐵 3, 5, 7, 11 → 𝑃 𝐴∩𝐵
10 5
6 3
𝐴∪𝐵 2, 3, 5, 7, 9, 11 → 𝑃 𝐴∪𝐵
10 5
4 2
𝐴 ∩𝐵 𝐴∪𝐵 4, 6, 8, 10 → 𝑃 𝐴 ∩𝐵
10 5
ELEE 2110U Discrete Mathematics 42
Example
Suppose for the events 𝐴 and 𝐵, we have 𝑃 𝐴 0.8 and 𝑃 𝐵 0.6. Show that 𝑃 𝐴 ∩ 𝐵 0.4.
Solution
We have:
The probability that both events 𝐴 and 𝐵 simultaneously occur is known as the joint probability of events 𝐴 and 𝐵, and is
denoted by 𝑃 𝐴 ∩ 𝐵 or 𝑃 𝐴, 𝐵 , and read as probability of 𝐴 and 𝐵.
If we assume the probability of event 𝐵 is influenced by the outcome of event 𝐴 and we also know that event 𝐴 has
occurred, then the probability that event 𝐵 will occur may be different from 𝑃 𝐵 . The probability of event 𝐵 when it is
known that event 𝐴 has occurred is defined as the conditional probability, denoted by 𝑃 𝐵|𝐴 and read as probability of 𝐵
given 𝐴. The conditional probability 𝑃 𝐵|𝐴 captures the information that the occurrence of event 𝐴 provides about event 𝐵.
The conditional probability 𝑃 𝐵|𝐴 and the conditional probability 𝑃 𝐴|𝐵 are, respectively, defined as follows:
𝑃 𝐴∩𝐵
𝑃 𝐵|𝐴 𝑃 𝐴 0
𝑃 𝐴
𝑃 𝐴∩𝐵
𝑃 𝐴|𝐵 𝑃 𝐵 0
𝑃 𝐵
If the joint probability of events 𝐴 and 𝐵 is zero, i.e., 𝑃 𝐴 ∩ 𝐵 0, these two events are then said to be mutually exclusive
or disjoint.
Solution
The four possibilities 𝐺𝐺, 𝐺𝐵, 𝐵𝐺, and 𝐵𝐵, each reflecting the order of birth, are equally likely, where 𝐺 represents a girl
and 𝐵 represents a boy. Let 𝐴 be the event that a family with two children has two girls, and let 𝐶 be the event that a family
with two children has at least one girl. We therefore have the following events and probabilities:
1
𝐴 𝐺𝐺 → 𝑃 𝐴
4
3
𝐶 𝐺𝐺, 𝐺𝐵, 𝐵𝐺 → 𝑃 𝐶
4
1
𝐴∩𝐶 𝐺𝐺 → 𝑃 𝐴∩𝐶
4
We can thus conclude:
1
𝑃 𝐴∩𝐶 4 1
𝑃 𝐴|𝐶
𝑃 𝐶 3 3
4
Solution
Let 𝐴 denote the event that the first phone tested is defective, we therefore have:
10 1
𝑃 𝐴
10000 1000
Let 𝐵 denote the event that the second phone tested is defective. Therefore, the event 𝐵|𝐴 represents that the second phone
tested is also defective, and we have:
9 1
𝑃 𝐵|𝐴
9999 1111
We can thus obtain:
1 1
𝑃 𝐴∩𝐵 𝑃 𝐵|𝐴 𝑃 𝐴 ≅ 0.9 10
1111 1000
For each of the following four cases, determine if the two events are mutually exclusive and also if they are statistically
independent: the events 𝐴 and 𝐵, the events 𝐴 and 𝐶, the events 𝐴 and 𝐷, and the events 𝐴 and 𝐸. Comment on the results.
Solution
5
𝐴 11, 13, 15, 17, 19 → 𝑃 𝐴
10
4
𝐵 11, 13, 17, 19 → 𝑃 𝐵
10
5
𝐶 12, 14, 16, 18, 20 → 𝑃 𝐶
10
2
𝐷 15, 20 → 𝑃 𝐷
10
𝐸 ∅ → 𝑃 𝐸 0
ELEE 2110U Discrete Mathematics 48
Example (2)
We then identify the four joint events of interest and their corresponding probabilities:
4
𝐴∩𝐵 11, 13, 17, 19 → 𝑃 𝐴∩𝐵
10
𝐴∩𝐶 ∅ → 𝑃 𝐴∩𝐶 0
1
𝐴∩𝐷 15 → 𝑃 𝐴∩𝐷
10
𝐴∩𝐸 ∅ → 𝑃 𝐴∩𝐸 0
We can thus conclude that any two events, no matter how they are defined, always fall into one of these four distinct cases,
i.e., whether being statistically independent or not as well as whether being mutually exclusive or not.
𝐵 … …
𝐵A 𝐵
𝐵
𝐵
𝐵
𝐵
𝐵 𝐵
In order to determine the probability of event 𝐴, it is sometimes best to separate all possible causes leading to event 𝐴. If the
events 𝐵 , 𝐵 , … , 𝐵 are all mutually exclusive events whose union forms the entire sample space 𝑆, that is we have 𝑆
𝐵 ∪ 𝐵 ∪ ⋯ ∪ 𝐵 , we then refer to these sets as a partition of 𝑆.
This divide-and-conquer approach is a practical tool used to determine the probability of event 𝐴. This is simply due to the
fact that the probability of event 𝐴 can be expressed as a combination of the probabilities of the mutually exclusive events
𝐵 , 𝐵 , … , 𝐵 that form the partition of the sample space 𝑆. The law of total probability thus highlights the probabilities of
effects given causes when causes do not deterministically select effects.
𝑃 𝐴|𝐵 0.1, 𝑃 𝐴|𝐵 0.4, 𝑃 𝐴|𝐵 0.2, 𝑃 𝐴|𝐵 0.6, 𝑃 𝐴|𝐵 0.5, 𝑃 𝐴|𝐵 0.3
the probability of interest is then as follows:
𝑃 𝐴 0.3 0.1 0.1 0.4 0.2 0.2 0.2 0.6 0.1 0.5 0.1 0.3 0.31
ELEE 2110U Discrete Mathematics 52
Bayes’ Theorem
When one conditional probability is given, but the reversed conditional probability is required, the following relation, known
as Bayes’ theorem or Bayes’ rule, which is based on the law of total probability, can be used:
𝑷 𝑨 ∩ 𝑩𝟏 𝑷 𝑨|𝑩𝟏 𝑷 𝑩𝟏
𝑷 𝑩𝟏 |𝑨
𝑷 𝑨 𝑷 𝑨|𝑩𝟏 𝑷 𝑩𝟏 𝑷 𝑨|𝑩𝟐 𝑷 𝑩𝟐 ⋯ 𝑷 𝑨|𝑩𝒏 𝑷 𝑩𝒏
where the events 𝐵 , 𝐵 , … , 𝐵 are all mutually exclusive events whose union makes the entire sample space 𝑆. Bayes’
theorem highlights inference from an observed effect, and is used to estimate probabilities based on partial evidence. It can
be used to synthesize decision rules that attempt to determine the most probable cause in light of an observation. In short, the
law of total probability is about effects from causes and Bayes’ theorem is about causes from effects.
There are three boxes 𝐴 , 𝐴 , and 𝐴 , and the probabilities of selecting them are as follows: 𝑃 𝐴 𝑃 𝐴 𝑃 𝐴 .
Let 𝑊 represent the event that the ball is white. We thus have:
1 1 3
𝑃 𝑊|𝐴 , 𝑃 𝑊𝐴 , 𝑃 𝑊|𝐴
3 2 4
1 1
𝑃 𝑊|𝐴 𝑃 𝐴 𝑃 𝑊|𝐴 𝑃 𝐴 3 3 4
𝑃 𝐴 |𝑊 ≅ 21%
𝑃 𝑊 𝑃 𝑊|𝐴 𝑃 𝐴 𝑃 𝑊|𝐴 𝑃 𝐴 𝑃 𝑊|𝐴 𝑃 𝐴 1 1 1 1 3 1 19
3 3 2 3 4 3
ELEE 2110U Discrete Mathematics 54
Bayesian Spam Filtering
• Spam e-mails, also known as junk e-mails, are unwanted, irrelevant e-mails sent on the Internet to a large number of recipients, and
may contain disguised links, malware, and fraudulent messages. Bayesian spam filtering a popular spam-filtering technique that relies
on word probabilities and can tailor itself to the e-mail needs of individual users.
• Let 𝑆 be the event that the e-mail is spam and 𝑆 be the event that the e-mail is not spam. If we use 𝑘 words, say 𝑋 , 𝑋 , … , 𝑋 , we can
then increase significantly the probability of detecting spam correctly. Assuming that 𝑊 , 𝑊 , … , 𝑊 are the events that the e-mail
contains the words 𝑋 , 𝑋 , … , 𝑋 , the number of incoming spam e-mails is about the same as the number of incoming e-mails that are
not spam, and the events 𝑊 |𝑆, 𝑊 |𝑆, … , 𝑊 |𝑆 are independent, by using Bayes’ theorem, 𝑝 the probability that an e-mail containing
all the words 𝑋 , 𝑋 , … , 𝑋 is spam is thus as follows:
𝑃 𝑊 |𝑆 ⋯ 𝑃 𝑊 |𝑆
𝑝 𝑃 𝑆 𝑊 ∩ 𝑊 ∩ ⋯∩ 𝑊
𝑃 𝑊 |𝑆 ⋯ 𝑃 𝑊 |𝑆 𝑃 𝑊 |𝑆 ⋯ 𝑃 𝑊 |𝑆
𝑎 𝑋 ⋯ 𝑎 𝑋
𝑎 𝑋 ⋯ 𝑎 𝑋 𝑏 𝑋 ⋯ 𝑏 𝑋
Solution
Assuming 𝑋 , 𝑋 , and 𝑋 refer to the words “information”, “account, and “time”, respectively, we have the following
probabilities:
1500 20
𝑎 𝑋 0.15 & 𝑏 𝑋 0.004
10000 5000
800 200
𝑎 𝑋 0.08 & 𝑏 𝑋 0.04
10000 5000
200 500
𝑎 𝑋 0.02 & 𝑏 𝑋 0.1
10000 5000
We can thus obtain:
0.15 0.08 0.02
𝑝 0.9375
0.15 0.08 0.02 0.004 0.04 0.1
As 𝑝 0.9, an incoming e-mail containing all these three words will be rejected.
Solution
Probability of finding not even a defective one is 1 𝑝 , which does not depend on 𝑛. We need to find 𝑘, which is the
number of cell-phones tested, where every one of the 𝑘 cell-phones tested is good, we thus need to have
This probability is independent of 1,000,000, the total number of cell-phones in the factory. The MC algorithm saves a lot of
testing 1,000,000 1,375 998,625 . We can thus conclude that when more than 1375 tested cell-phones are all good,
where the probability of such an occurrence is less than one in a million, we could say the entire batch of 1,000,000 cell-
phones, even those not tested, is good, of course with some probability of error.
Solution
Graph 𝑎 is connected with no simple circuits, 𝑏 𝑐 𝑏 𝑐
it is thus is a tree.
𝑑 𝑒 𝑓 𝑔 𝑑 𝑒 𝑓 𝑔
Graph 𝑏 is circuit free, but is not connected,
ℎ ℎ
𝑎 𝑏
it is thus not a tree.
𝑎 𝑎
Graph 𝑐 is connected, but has a simple circuit,
it is thus not a tree.
𝑏 𝑐 𝑏 𝑐
Graph 𝑑 is not connected, and has a simple circuit,
it is thus not a tree. 𝑑 𝑒 𝑓 𝑔 𝑑 𝑒 𝑓 𝑔
ℎ ℎ
𝑐 𝑑
A child of a vertex 𝑣 in a rooted tree is a vertex that is the immediate successor of 𝑣 on a path away from the root. The
parent of a vertex 𝑣 in a rooted tree is a vertex that is the immediate predecessor of 𝑣 on the path to 𝑣 away from the root.
Two distinct vertices that are both children of the same parent are called siblings. Given two distinct vertices 𝑣 and 𝑤, if 𝑣
lies on the unique path between 𝑤 and the root, then 𝑣 is an ancestor of 𝑤 and 𝑤 is a descendant of 𝑣. A vertex of a rooted
tree is called a leaf if it has no children. Vertices that have children are called internal vertices.
Solution
𝑏 𝑐
The vertex 𝑎 is the root of the tree and the height of the tree is 4. The vertices 𝑏, 𝑐 each
has a level or depth of 1, the vertices ℎ, 𝑖, 𝑗 each has a level or depth of 3. The vertex 𝑑 𝑑 𝑒 𝑓 𝑔
is a child to the vertex 𝑏, is a sibling to the vertex 𝑒, and is a parent to the left child ℎ and ℎ 𝑖 𝑗
the right child 𝑖. The vertex 𝑏 is an ancestor of the vertex ℎ and the vertex ℎ is a
𝑘 𝑙 𝑚 𝑛
descendant of the vertex 𝑏. The vertices 𝑏, 𝑑, ℎ, 𝑔, 𝑗 are called internal vertices.
The vertices 𝑒, 𝑖, 𝑘, 𝑙, 𝑓, 𝑚, 𝑛 are called leaves. The tree is a binary tree, but not a full one. The
vertices 𝑎, 𝑏, 𝑑, ℎ, 𝑐, 𝑗 each has two children, but the vertex 𝑔 has only one child. The left
subtree rooted at the vertex 𝑎 consists of the vertices 𝑏, 𝑑, 𝑒, ℎ, 𝑖, 𝑘, 𝑙 and the right subtree
rooted at the vertex 𝑐 consists of the vertices 𝑐, 𝑔, 𝑗, 𝑚, 𝑛 . The subtree at the vertex 𝑑 is a
balanced subtree, but the subtree at the vertex 𝑐 is not a balanced subtree.
Solution
In summary, after the BFS traversal visits a vertex, all of the previously unvisited neighbors of that vertex go to the queue,
and then the transversal removes from the queue whatever vertex is at the front of the queue, and visits that vertex.
𝑒
𝑑 𝑓
𝑔 𝑖
ℎ
(a)
1 2 3
𝑎 𝑐 𝑎 𝑐 𝑎 𝑐
𝑏 𝑏 𝑏
𝑒
𝑓 𝑒 𝑓 𝑑 𝑓
4 5 6
𝑎 𝑐 𝑎 𝑐 𝑎 𝑐
𝑏 𝑏 𝑏
𝑒 𝑒 𝑒
𝑑 𝑓 𝑑 𝑓 𝑑 𝑓
𝑔 𝑔 ℎ 𝑔 ℎ 𝑖
7 8 9
(b)
ELEE 2110U Discrete Mathematics 14
Example (4)
𝑎 𝑎 𝑎
𝑏 𝑏
1 2 3
𝑎 𝑐 𝑎 𝑐 𝑎 𝑐
𝑏 𝑏 𝑏
𝑑 𝑑 𝑓 𝑑 𝑒 𝑓
4 5 6
𝑎 𝑐 𝑎 𝑐 𝑎 𝑐
𝑏 𝑏 𝑏
𝑑 𝑒 𝑓 𝑑 𝑒 𝑓 𝑑 𝑒 𝑓
𝑔 𝑔 ℎ 𝑔 ℎ 𝑖
7 8 9
We now discuss two algorithms, Prim’s algorithm and Kruskal’s algorithm, to construct a minimum spanning tree in a
connected graph, where each adds an edge with the smallest weight to the current configuration based on only local
information, nonetheless they both guarantee to produce a minimum spanning tree. These two algorithms employ a greedy
algorithm to make an optimal choice at each step, nevertheless, they produce optimal solutions. Note that a connected
weighted graph may have more than one minimal spanning tree. Nonetheless they all weigh the same.
Solution 4 4
There are two minimum spanning trees as shown in Fig. b and Fig. c. 𝑎 10 𝑓
(a) Starting at vertex 𝑎, edges are added in one of the following two orders: 6
i. 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 , 𝑑, 𝑓 , 𝑑, 𝑒 . 𝑏 (b) 𝑒
𝑐 8 𝑑
ii. 𝑎, 𝑐 , 𝑏, 𝑐 , 𝑐, 𝑑 , 𝑑, 𝑓 , 𝑑, 𝑒 .
4 4
(b) Edges are added in one of the following two orders:
𝑎 6 10 𝑓
i. 𝑑, 𝑓 , 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 , 𝑑, 𝑒 .
ii. 𝑑, 𝑓 , 𝑎, 𝑐 , 𝑏, 𝑐 , 𝑐, 𝑑 , 𝑑, 𝑒 .
𝑏 (c) 𝑒
W E
W
E
Championship W
E
W E W E
W E W E
E W E W
W E
W E
W E W E
W E W E
E E W W
W W E E
W E W E
E E W W
E W E W
W E W E
E W E W
There are 35 different There are 35 different
W E
W ways in the ways in the E
W left branch to win the right branch to win the E
E W
W E championship championship W E
E W when the Western team when the Eastern team E W
W W wins the first game wins the first game E E
W E W E
E E W W
W W E E
E W
E W
E E W W
W W E E
W E W E
E W E W
W W E E
E E W W
E E W W
W W E E
E W E W
E E W W
E W
Magic Square Example
𝟗 𝟗
8 𝟗
𝟗 𝟗 8
8 7 𝟗
𝟗 𝟗 8
𝟕 8 7
𝟔 𝟖 1 3 𝟖 4 𝟑 𝟕 𝟓 𝟔 𝟕 𝟐
2 4 𝟗 5 1 𝟗 𝟒 𝟐 𝟗 𝟏 𝟓 𝟗
𝟕 3 5 𝟕 6 2 𝟖 𝟔 𝟏 𝟖 𝟑 𝟒
Huffman Coding: Background
In order to reduce the storage requirements in digital systems as well as the transmission time requirements in digital
networks, data must be coded so fewer bits are used to represent a data symbol. For efficient coding, i.e., effective data
compression, data symbols that occur more frequently should be encoded using shorter bit sequences and longer bit
sequences should be used to encode rarely occurring data symbols. Therefore, data symbols are encoded using varying
number of bits. When the statistics regarding data symbols are available, the Huffman code is the optimum algorithm. The
Huffman code is a prefix-free (instantaneous) code, where no codeword is a prefix of another codeword, as such a Huffman
code can be represented using a rooted binary tree. It is important to note that Huffman code is widely used in compression
of image files.
Example
𝟎. 𝟎𝟐 𝟎. 𝟎𝟑 𝟎. 𝟎𝟓 𝟎. 𝟏𝟎 𝟎. 𝟏𝟓 𝟎. 𝟐𝟓 𝟎. 𝟒𝟎
𝟏
𝑨 𝑩 𝑪 𝑫 𝑬 𝑭 𝑮 𝟎 𝟏
𝟎. 𝟎𝟓 𝟎. 𝟎𝟓 𝟎. 𝟏𝟎 𝟎. 𝟏𝟓 𝟎. 𝟐𝟓 𝟎. 𝟒𝟎 𝑮
𝟎. 𝟒𝟎 𝟎. 𝟔𝟎 𝟎 𝟏
𝑪 𝑫 𝑬 𝑭 𝑮
𝟐 𝟎 𝟏 𝑮
𝟎 𝟏 𝑭
𝟎 𝟏
𝑨 𝑩
𝑭 𝟕
𝟎 𝟏 𝑬
𝟎 𝟏
𝟎. 𝟏𝟎 𝟎. 𝟏𝟎 𝟎. 𝟏𝟓 𝟎. 𝟐𝟓 𝟎. 𝟒𝟎
𝑪
𝑫 𝑬 𝑭 𝑮 𝑬
𝟎 𝟏 𝟔 𝟎 𝟏
𝟎 𝟏
𝑫
𝟑 𝟎. 𝟐𝟓 𝟎. 𝟑𝟓 𝟎. 𝟒𝟎
𝑪 𝑫
𝟎 𝟏 𝟎 𝟏 𝑪
𝑭 𝑮 𝟎 𝟏
𝟎 𝟏
𝑨 𝑩 𝑪
𝟎 𝟏 𝑨 𝑩
𝑬
𝟎. 𝟏𝟓 𝟎. 𝟐𝟎 𝟎. 𝟐𝟓 𝟎. 𝟒𝟎 𝟎 𝟏
𝑨 𝑩
𝑬 𝑭 𝑮 𝟓
𝟎 𝟏 𝑫
𝟎 𝟏
𝟎. 𝟎𝟐 𝟎. 𝟎𝟑 𝟎. 𝟎𝟓 𝟎. 𝟏𝟎 𝟎. 𝟏𝟓 𝟎. 𝟐𝟓 𝟎. 𝟒𝟎
𝑫 𝟖
𝟎 𝟏
𝟒 𝟎 𝟏
𝑪 𝑨 𝑩 𝑪 𝑫 𝑬 𝑭 𝑮
𝟎𝟎𝟎𝟎𝟎𝟎 𝟎𝟎𝟎𝟎𝟎𝟏 𝟎𝟎𝟎𝟎𝟏 𝟎𝟎𝟎𝟏 𝟎𝟎𝟏 𝟎𝟏 𝟏
𝟎 𝟏 𝑪
𝑨 𝑩
0.02 6 0.03 6 0.05 5 0.1 4 0.15 3 0.25
𝑨 𝑩 2 0.40 1 2.3 bits/symbol
ELEE 2110U Discrete Mathematics 1
Induction
𝑃 1 ∧ ∀𝑘 𝑃 𝑘 → 𝑃 𝑘 1 → ∀𝑛𝑃 𝑛 .
𝑛 𝑛 1
1 2 3 ⋯ 𝑛
2
Solution
Let 𝑃 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 1.
Basis step: When 𝑛 1, we have 1 , therefore 𝑃 1 is true.
Inductive step: Assuming the inductive hypothesis
𝑘 𝑘 1
𝑃 𝑘 1 2 ⋯ 𝑘
2
is true, for an arbitrary integer 𝑘 1, we must show
𝑘 1 𝑘 2
𝑃 𝑘 1 1 2 ⋯ 𝑘 𝑘 1
2
is true. If we add 𝑘 1 to both sides of the equation representing 𝑃 𝑘 , then we have
𝑘 𝑘 1 𝑘 1 𝑘 2
1 2 ⋯ 𝑘 𝑘 1 𝑘 1 .
2 2
This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
𝑟 1
1 𝑟 𝑟 ⋯ 𝑟 , 𝑟 1
𝑟 1
Solution
Let 𝑃 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 1.
Basis step: When 𝑛 1, we have 1 , therefore 𝑃 1 is true.
Inductive step: Assuming the inductive hypothesis
𝑟 1
𝑃 𝑘 1 𝑟 𝑟 ... 𝑟
𝑟 1
is true, for an arbitrary integer 𝑘 1, we must show
𝑟 1
𝑃 𝑘 1 1 𝑟 𝑟 ... 𝑟 𝑟
𝑟 1
is true. If we add 𝑟 to both sides of the equation representing 𝑃 𝑘 , then we have
𝑟 1 𝑟 1
1 𝑟 𝑟 … 𝑟 𝑟 𝑟 .
𝑟 1 𝑟 1
This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
ELEE 2110U Discrete Mathematics 13
Example
Using mathematical induction, prove the following inequality for every integer 𝑛 1:
Solution
Let 𝑃 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 1.
Basis step: When 𝑛 1, we have 1 𝑥 1 𝑥, therefore 𝑃 1 is true.
Inductive step: Assuming the inductive hypothesis
1 𝑥 1 𝑘𝑥
1 𝑥 1 𝑘 1 𝑥
is true, that is, 𝑃 𝑘 1 is true. Using the assumption that 𝑃 𝑘 is true, we multiply both sides of the inequality in 𝑃 𝑘 by
1 𝑥 , we thus obtain
1 𝑥 1 𝑥 1 𝑘𝑥 1 𝑘 1 𝑥 𝑘𝑥 1 𝑘 1 𝑥
as 𝑘𝑥 0. This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
ELEE 2110U Discrete Mathematics 14
Example
Using mathematical induction, prove the following inequality for every integer 𝑛 1:
2 𝑛.
Solution
Let 𝑃 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 1.
Basis step: When 𝑛 1, we have 2 1, therefore 𝑃 1 is true.
Inductive step: Assuming the inductive hypothesis
2 𝑘
2 𝑘 1
is true, that is, 𝑃 𝑘 1 is true. Using the assumption that 𝑃 𝑘 is true, we multiply both sides of the inequality in 𝑃 𝑘 by
2, we thus obtain
2 2 2 𝑘 → 2 2𝑘 𝑘 1
as 𝑘 1. This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
ELEE 2110U Discrete Mathematics 15
Example
Using mathematical induction, prove the following divisibility case for every integer 𝑛 0:
𝑛 2𝑛 𝑛 2𝑛 is divisible by 12
Solution
Let 𝑃 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 0.
Basis step: When 𝑛 0, the value of the function is 0 which is divisible by 12, therefore 𝑃 0 is true.
Inductive step: Assuming the inductive hypothesis
𝑘 2𝑘 𝑘 2𝑘 12𝑚
is true for a nonnegative integer 𝑚, that is, 𝑃 𝑘 is true for an arbitrary integer 𝑘 0, we must then show
𝑘 1 2 𝑘 1 𝑘 1 2 𝑘 1 12𝑡
is true for a nonnegative integer 𝑡, that is, 𝑃 𝑘 1 is true. Using the assumption that 𝑃 𝑘 is true, we have
𝑘 1 2 𝑘 1 𝑘 1 2 𝑘 1 𝑘 6𝑘 11𝑘 6𝑘 𝑘 2𝑘 𝑘 2𝑘 12𝑘 4𝑘 4𝑘
12𝑚 12𝑘 4 𝑘 1 𝑘 𝑘 1 12𝑡,
as 𝑘 1, 𝑘, and 𝑘 1 are three consecutive integers, their product is thus a multiple of 3, and as a result, 4 𝑘 1 𝑘 𝑘 1 is also a
multiple of 12. This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
7 2 is divisible by 5.
Solution
Basis step: When 𝑛 0, the value of the function is 0, which is divisible by 5, therefore 𝑃 0 is true.
Inductive step: Assuming the inductive hypothesis
7 2 5𝑚
is true for a nonnegative integer 𝑚, that is, 𝑃 𝑘 is true for an arbitrary integer 𝑘 0, we must show
7 2 5𝑡
is true for a nonnegative integer 𝑡, that is, 𝑃 𝑘 1 is true. Using the assumption that 𝑃 𝑘 is true, we have
7 2 7 7 2 7 5𝑚 2 2 2 35𝑚 5 2 5 7𝑚 2 5𝑡.
This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
This thus means that the statement 𝑃 𝑘 1 also holds true, as was to be shown.
𝑛
𝑥 𝑦 𝑥𝑦 .
𝑖
Solution
Let 𝑃 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 0.
Basis step: When 𝑛 0, both sides of the formula are equal to 1, therefore 𝑃 0 is true.
Inductive step: If we assume the inductive hypothesis
𝑘
𝑥 𝑦 𝑥𝑦
𝑖
is true, we must then show
𝑘 1
𝑥 𝑦 𝑥𝑦
𝑖
is true.
ELEE 2110U Discrete Mathematics 19
Example (2)
We have
𝑘 𝑘 𝑘
𝑥 𝑦 𝑥 𝑦 𝑥 𝑦 𝑥 𝑦 𝑥𝑦 𝑥 𝑦 𝑥𝑦
𝑖 𝑖 𝑖
As we take out the last term, i.e., 𝑥 , from the first sum and the first term, i.e., 𝑦 , from the second sum, we obtain
𝑘 𝑘
𝑥 𝑦 𝑥 𝑥 𝑦 𝑥𝑦 𝑦
𝑖 𝑖
We now make a change of variable in the first sum, as we set 𝑖 𝑖 1, we therefore have
𝑘 𝑘 𝑘 𝑘
𝑥 𝑦 𝑥 𝑥𝑦 𝑥𝑦 𝑦 𝑥 𝑥𝑦 𝑦
𝑖 1 𝑖 𝑖 1 𝑖
𝑘 1 𝑘 1
𝑥 𝑥𝑦 𝑦 𝑥𝑦
𝑖 𝑖
This thus means that the statement 𝑃 𝑘 1 also holds true, as it was to be shown.
ELEE 2110U Discrete Mathematics 20
Strong Induction
When the truth of 𝑃 𝑘 might not be enough to establish the truth of 𝑃 𝑘 1 , we need to use strong induction. Let 𝑃 𝑛 be
a propositional function, where 𝑛 is a positive integer. A proof by strong induction consists of two steps.
First, the basis step, where we show 𝑃 1 , called basis premise, is true.
Second, the inductive step, where we show that for all positive integers 𝑘 1, if 𝑃 1 , 𝑃 2 , …, 𝑃 𝑘 1 , 𝑃 𝑘 , called the
inductive hypothesis, are all true, then 𝑃 𝑘 1 is also true. The principle of strong induction states that by proving these
two key steps we can conclude that 𝑃 𝑛 is true for every positive integer 𝑛 1.
Expressing as a rule of inference, while assuming the domain is the set of positive integers 𝑵, the second principle of
mathematical induction can be stated as follows:
𝑃 1 ∧ ∀𝑘 𝑃 1 ∧𝑃 2 ∧... ∧𝑃 𝑘 1 ∧𝑃 𝑘 →𝑃 𝑘 1 → ∀𝑛𝑃 𝑛
Solution
Let 𝑃 𝑛 be the proposition that 𝑛 can be written as the product of primes or 𝑛 is divisible by a prime number, for every
integer 𝑛 2.
Basis step: 𝑃 2 is true, as 2 is a prime number.
Inductive step: Assuming 𝑃 𝑗 is true for all integers 𝑗 with 2 𝑗 𝑘, we need to prove 𝑃 𝑘 1 is true. There are
two mutually exclusive cases, namely when 𝑘 1 is prime and when 𝑘 1 is composite (not prime):
i) If 𝑘 1 is prime, then 𝑃 𝑘 1 is true.
ii) If 𝑘 1) is composite, then 𝑘 1 𝑎 𝑏, where 𝑎 and 𝑏 are integers with 2 𝑎 𝑏 𝑘 1. Using the
inductive hypothesis, both 𝑎 and 𝑏 can be written as product of primes. Thus, 𝑘 1 can be written as the product of those
primes in factorization of 𝑎 and those in the factorization of 𝑏.
Solution
Let 𝑆 𝑛 be the propositional function of interest that must be proven to be true for every integer 𝑛 0.
Basis step: 𝑆 0 and 𝑆 1 are both true, as we have 5 1 0 and 5 1 4.
Inductive step: Assuming 𝑆 𝑗 is true for all integers 𝑗 with 0 𝑗 𝑘, thus implying 𝑆 𝑘 and 𝑆 𝑘 1 are true, we then
need to prove
𝑆 𝑘 1 5 1
is true. We have
𝑆 𝑘 1 6𝑆 𝑘 5𝑆 𝑘 1 6 5 1 5 5 1 5 1.
This thus means that the statement 𝑆 𝑘 1 also holds true, as was to be shown.
Solution
(a) The compound amount 𝑓 is defined by 𝑓 𝑛 compound amount at the end of the 𝑛 1 year interest earned
during the 𝑛 year with an annual interest rate of 𝑖 , where 𝑓 0 𝑝, known as the principal. Therefore, 𝑓 can be defined
respectively as follows:
𝑓 0 𝑝 (initial condition)
𝑓 𝑛 𝑓 𝑛 1 𝑖 𝑓 𝑛 1 1 𝑖 𝑓 𝑛 1 , 𝑛 1 (recurrence relation)
𝑓 4 1 𝑖 𝑓 3 1 𝑖 1 𝑖 𝑓 2 1 𝑖 𝑓 2 1 𝑖 1 𝑖 𝑓 1
1 𝑖 𝑓 1 1 𝑖 1 𝑖 𝑓 0 𝑝 1 𝑖 .
(b) With one person in the group, the number of fist bumps is obviously zero. With 𝑛 persons in the group, one of them fist
bumps with each of the remaining 𝑛 1 persons resulting in 𝑛 1 fist bumps and the number of fist bumps made by the
other 𝑛 1 persons among themselves is 𝑓 𝑛 1 . Therefore, 𝑓 can be defined respectively as follows:
𝑓 1 0 (initial condition)
𝑓 𝑛 𝑓 𝑛 1 𝑛 1 , 𝑛 2 (recurrence relation)
𝑓 4 𝑓 3 3 𝑓 2 2 3 𝑓 1 1 2 3 6.
ELEE 2110U Discrete Mathematics 28
Recursive Algorithm vs Iterative Algorithm
• A recursive algorithm is an algorithm that invokes itself during execution with a reduced version of itself, as it proceeds
by reducing a problem to the same problem with smaller input.
• An iterative algorithm is developed to evaluate the value of a function at the base cases, and successively apply the
recursive definition to find values of the function at larger integers.
• Oftentimes, an iterative approach requires less computation than a recursive approach, but writing a software program for
the nonrecursive version of a recursive algorithm is often a difficult and time-consuming task.
Solution
(a) A recursive algorithm is based on a top-down approach. We evaluate the value of 𝑓 6 in terms of the values of the
function at smaller integers, namely 𝑓 5 and 𝑓 4 , and successively apply the recursive definition to find values of the
function at smaller integers. Therefore, we have the following:
𝑓 6 𝑓 5 𝑓 4 𝑓 4 𝑓 3 𝑓 3 𝑓 2 𝑓 3 𝑓 2 𝑓 2 𝑓 1 𝑓 2 𝑓 1 𝑓 1 𝑓 0
𝑓 2 𝑓 1 𝑓 1 𝑓 0 𝑓 1 𝑓 0 𝑓 1 𝑓 1 𝑓 0 𝑓 1 𝑓 1 𝑓 0
𝑓 1 𝑓 0 𝑓 1 𝑓 1 𝑓 0 𝑓 1 𝑓 0 𝑓 1 𝑓 1 𝑓 0 𝑓 1 𝑓 1 𝑓 0 .
Solution
(b) An iterative algorithm is based on a bottom-up approach. We use the given value of the function at the base cases,
namely 𝑓 0 and 𝑓 1 , and successively apply the recursive definition to find values of the function at larger integers until
𝑓 6 is obtained. Therefore, we have the following relations:
𝑓 2 𝑓 1 𝑓 0 .
𝑓 3 𝑓 2 𝑓 1 .
𝑓 4 𝑓 3 𝑓 2 .
𝑓 5 𝑓 4 𝑓 3 .
𝑓 6 𝑓 5 𝑓 4 .
We thus need to carry out 5 additions for an iterative algorithm.
ELEE 2110U Discrete Mathematics 31
Solving Recurrence Relations by Iteration
A sequence is called a solution of a recursive relation if its terms satisfy the recurrence relation. We often want to know an
explicit formula for a recurrence relation 𝑓 𝑛 or equivalently a sequence 𝑎 , especially when we need to compute terms
with very large 𝑛 or assess general properties of a relation.
The most basic method for finding a closed-form formula for a recursively defined function is iteration. In the iterative
method, we take the approach based on back substitution in order to see a pattern developing, and then guess or discover an
explicit formula. We can then use induction to verify the closed-form formula. Although it is a straightforward method, it can
become algebraically unwieldy if the recurrence relation is too complex.
It is important to highlight that when the iteration is used and substitution followed by simplification are performed
repeatedly, full simplification after a substitution should be in general avoided, so the terms left in expanded form can help
recognize the pattern that develops.
𝑛 𝑛 1
𝑎 𝑎 , 𝑛 1, 𝑎 0.
2
Solution
Using iteration, we have
𝑛 𝑛 1 𝑛 1 𝑛 𝑛 𝑛 1
𝑎 𝑎 𝑎 ⋯
2 2 2
1 2 𝑛 1 𝑛 𝑛 𝑛 1
𝑎 ⋯
2 2 2
𝑖 𝑖 1 𝑖 𝑖 1 1
𝑎 𝑖 𝑖
2 2 2
1 𝑛 𝑛 1 2𝑛 1 𝑛 𝑛 1 𝑛 𝑛 1 𝑛 2
,𝑛 0.
2 6 2 6
𝑛 𝑛 1
𝑎 .
2
ELEE 2110U Discrete Mathematics 34
Solving Recurrence Relations Using Generating Functions
Generating functions are a powerful and efficient tool to solve many types of problems, such as advanced counting,
calculating the probability of discrete random variables, and solving recurrence relations. The solution to a recurrence
relation with its initial conditions can be found when an explicit formula for the associated generating function is determined.
Generating functions can translate the terms of a sequence as coefficients of powers of a variable 𝑧 in a formal power series.
The generating function for the sequence 𝑎 , 𝑎 , 𝑎 . . . of real numbers is the following infinite series:
𝐺 𝑧 ≜𝑎 𝑎 𝑧 𝑎 𝑧 ... 𝑎 𝑧 .
Note that two generating functions can be added and multiplied as follows:
𝐺 𝑧 𝑎 𝑎 𝑧 𝑎 𝑧 ... 𝑎 𝑧 𝐺 𝑧 𝐹 𝑧 𝑎 𝑏 𝑧
𝐹 𝑧 𝑏 𝑏 𝑧 𝑏 𝑧 ... 𝑏 𝑧 𝐹 𝑧 𝐺 𝑧 𝑏𝑎 𝑧
𝑮 𝒛 𝒂𝒏
𝟏 𝟏 if m divides n
𝒛𝒎𝒏
𝟏 𝒛𝒎
𝒏 𝟎 𝟎 otherwise
𝟏 𝒎 𝒏 𝟏 𝒎 𝒏 𝟏
𝒄𝒏 𝒛𝒏 𝒄𝒏
𝟏 𝒄𝒛 𝒎 𝒏 𝒏
𝒏 𝟎
𝒛
𝟐
𝒏𝒛𝒏 n
𝟏 𝒛
𝒏 𝟎
𝒛𝟐 𝒛
𝒏𝟐 𝒛𝒏 𝒏𝟐
𝟏 𝒛 𝟑
𝒏 𝟎
𝑧 𝐺 𝑧 𝑎 𝑧 𝑎 𝑧
𝐺 𝑧 𝑛𝑎 𝑧 .
It is imperative to highlight that the goal is to use the generating function and its properties to a recurrence relation in order
to find 𝐺 𝑧 in the form of a single summation, of course after some mathematical manipulation, and then to determine the
sequence 𝑎 by using the definition of the generating function.
It is of utmost importance that after a recurrence relation of any type is solved by using any method, the solution is checked
not only to make sure that it satisfies the recurrence relation, but also it fully meets the given initial conditions.
ELEE 2110U Discrete Mathematics 37
Example (1)
Solve the following recurrence relation using generating functions:
𝑎 𝑎 𝑛, 𝑛 1, 𝑎 1
Solution
We first multiply both sides of the recurrence relation by 𝑧 to obtain
𝑎 𝑧 𝑎 𝑧 𝑛𝑧 .
We then sum both sides of the equation starting with 𝑛 1 to have the following equation:
𝑎 𝑧 𝑎 𝑧 𝑛𝑧 .
We now change the indices and simplify the equation, we thus have
𝑎 𝑧 𝑎 𝑧 𝑎 𝑧 𝑛𝑧
𝑧
𝐺 𝑧 𝑎 𝑧𝐺 𝑧 .
1 𝑧
1 𝑧
𝐺 𝑧 .
1 𝑧 1 𝑧
Using the properties highlighted in the table, we write each term in the equation in terms of a summation
𝑛 2
𝐺 𝑧 𝑧 𝑧 𝑧 .
𝑛
We now perform the following mathematical manipulation to obtain 𝐺 𝑧 in terms of a single summation:
𝑛 2 𝑛 1 𝑛 2 𝑛 1
𝐺 𝑧 𝑧 𝑧 𝑧 𝑧 𝑧
2 2
𝑛 1 𝑛 𝑛 1 𝑛 𝑛 1 𝑛
1 𝑧 𝑧 1 1 𝑧 1 𝑧
2 2 2
𝑛 2 𝑛 1
𝑧 .
2
𝑛 2 𝑛 1 𝑛 2 𝑛 1
𝐺 𝑧 𝑎 𝑧 𝑧 → 𝑎 , 𝑛 0.
2 2
𝑏
Solution
There are 5 vertices and 11 edges. The degrees are as
follows: deg 𝑎 4, deg 𝑏 6, deg 𝑐 1, deg 𝑑 5,
𝑒 𝑑
and deg 𝑒 6. Note that according to the handshaking
theorem, the sum of the degrees of all vertices is twice the
number of edges, i.e., 4 6 1 5 6 2 11 22.
List all the subgraphs of the graph 𝐺 with two edges and three vertices.
Determine the complement of the graph 𝐺.
Find the graph union of the graphs 𝐺 and 𝐻.
Find the graph intersection of the graphs 𝐺 and 𝐻. 𝑐 𝑑 𝑐 𝑑
G H
Solution
𝑎 𝑎 𝑏 𝑎 𝑏 𝑎 𝑏 𝑎 𝑏 𝑎 𝑏
𝑐 𝑑 𝑐 𝑑 𝑐 𝑑 𝑐
𝑐 𝑑
graph with 𝑛 vertices, denoted by 𝐾 , has edges and each vertex has degree 𝑛 1.
• A simple graph with at least one pair of distinct vertices not connected by an edge is called a noncomplete graph.
• The cycle graph (or ring topology), denoted by 𝐶 , with 𝑛 3, consists of 𝑛 vertices 𝑣 , 𝑣 , . . . , 𝑣 as well as 𝑛 edges
𝑣 ,𝑣 , 𝑣 ,𝑣 ,..., 𝑣 , 𝑣 , 𝑣 , 𝑣 , while noting that each vertex has degree 2.
• The star graph, denoted by 𝑆 , with 𝑛 3, has 𝑛 1 vertices 𝑣 , 𝑣 , . . . , 𝑣 as well as 𝑛 edges
𝑣 ,𝑣 , 𝑣 ,𝑣 ,..., 𝑣 ,𝑣 , that is, the vertices 𝑣 , 𝑣 , . . . , 𝑣 are all connected to a central vertex 𝑣 with
degree 𝑛, but each of the other 𝑛 vertices has degree 1.
• The wheel graph (or hybrid topology), denoted by 𝑊 , with 𝑛 3, is the union of 𝐶 and 𝑆 graphs, it thus has 𝑛
1 vertices as well as 2𝑛 edges, where each vertex around the perimeter has degree 3, but the central vertex has degree 𝑛.
• The linear graph (or bus topology), denoted by 𝐿 , has 𝑛 vertices 𝑣 , 𝑣 , . . . , 𝑣 and with 𝑛 1 edges
𝑣 ,𝑣 , 𝑣 ,𝑣 ,..., 𝑣 , 𝑣 , while noting that the last two vertices at the two ends of the bus each has degree 1, but
each of the other vertices has degree 2.
ELEE 2110U Discrete Mathematics 50
Types of Graphs (2)
Complete Graphs Cycle Graphs Star Graphs Wheel Graphs Linear Graphs
(Mesh Topology) (Ring Topology) (Star Topology) (Hybrid Topology) (Bus Topology)
Solution
Fig. a is a bipartite graph, as the vertex set 𝑉 𝑎, 𝑏, 𝑐, 𝑑, 𝑒, 𝑓 consists of the two disjoint sets
𝑉 𝑎, 𝑏, 𝑐 and 𝑉 𝑑, 𝑒, 𝑓 , and every edge has one vertex in 𝑉 and the other in 𝑉 . Note
that since there is no edge connecting vertices 𝑎 and 𝑓, Fig. a is not a complete bipartite.
Fig. b is not a bipartite graph, and Fig. c is a complete bipartite graph.
𝑎 𝑏
𝑎 𝑏 𝑐 𝑎 𝑏
𝑑 𝑒 𝑓 𝑐 𝑑 𝑐 𝑑 𝑒
𝑏 10 𝑑 10 𝑓
8 14
𝑎 4 6 2 4 𝑧
6 8
𝑐 12 𝑒 10 𝑔
Solution
We find the shortest path from 𝑎 to 𝑧 is 𝑎, 𝑐, 𝑑, 𝑒, 𝑔, ℎ, with length 32.
8 14
0 0
𝑎 4 6 2 4 𝑧 𝑎 𝑎
6 8 6
𝑐 12 𝑒 10 𝑔 𝑐 𝟔 𝑐 𝑒
Step 0 Step 1 Step 2
𝟖 𝑏 𝑑 𝟖 𝑏 𝟏𝟐 𝑑 𝑓 𝟖 𝑏 𝟏𝟐 𝑑 𝑓
8 8 8
0 0 0
𝑎 𝑎 6 𝑎 6 2
6 6 6
𝟔 𝑐 𝑒 𝟔 𝑐 𝑒 𝟔 𝑐 𝟏𝟒 𝑒 𝑔
Step 3 Step 4 Step 5
𝟖 𝑏 𝟏𝟐 𝑑 𝑓 𝟐𝟐 𝟖 𝑏 𝟏𝟐 𝑑 𝑓 𝟐𝟐 𝟖 𝑏 𝟏𝟐 𝑑 𝑓 𝟐𝟐
10 10 10
8 8 8
0 0 0
𝑎 6 2 𝑧 𝑎 6 2 𝑧 𝑎 6 2 𝑧
𝟑𝟐
6 6 6 8
𝟔 𝑐 𝟏𝟒 𝑒 𝑔 𝟔 𝑐 𝟏𝟒 𝑒 10 𝑔 𝟐𝟒 𝟔 𝑐 𝟏𝟒 𝑒 10 𝑔 𝟐𝟒
Step 6 Step 7 Step 8
0 𝟎 ∞ ∞ ∞ ∞ ∞ ∞ ∞
1 𝑎 ∅ 𝑏, 𝑐 8 6
2 𝑎, 𝑐 𝑎, 𝑐 𝑏, 𝑑, 𝑒 8 12 18
3 𝑎, 𝑐, 𝑏 𝑎, 𝑐 , 𝑎, 𝑏 𝑑, 𝑒 12 18
4 𝑎, 𝑐, 𝑏, 𝑑 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 𝑒, 𝑓 14 22
5 𝑎, 𝑐, 𝑏, 𝑑, 𝑒 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 , 𝑑, 𝑒 𝑓, 𝑔 22 24
6 𝑎, 𝑐, 𝑏, 𝑑, 𝑒, 𝑓 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 , 𝑑, 𝑒 , 𝑑, 𝑓 𝑔, 𝑧 24 36
7 𝑎, 𝑐, 𝑏, 𝑑, 𝑒, 𝑓, 𝑔 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 , 𝑑, 𝑒 , 𝑑, 𝑓 , 𝑒, 𝑔 𝑧 32
8 𝑎, 𝑐, 𝑏, 𝑑, 𝑒, 𝑓, 𝑔, 𝑧 𝑎, 𝑐 , 𝑎, 𝑏 , 𝑐, 𝑑 , 𝑑, 𝑒 , 𝑑, 𝑓 , 𝑒, 𝑔 , 𝑔, 𝑧
• The notation 𝑎|𝑏 denotes 𝑎 divides 𝑏, that is, is an integer. For instance, 16|48 implies 16 divides 48, as 3 is an
integer. In contrast, the notation 𝑎 ∤ 𝑏 denotes 𝑎 does not divide 𝑏, which in turn means is not an integer. For instance,
20 ∤ 48 implies 20 does not divide 48, as 2.4 is not an integer. Note that if 𝑎 is a nonzero integer, then 𝑎|0, as 0
0 𝑎.
• With 𝑏 𝑎𝑐, every integer 𝑏 is divisible by 𝑎 1 (i.e., 𝑐 𝑏) and by 𝑎 𝑏 (i.e., 𝑐 1), where they are called
the trivial divisors of 𝑏.
𝑞 𝑎 div 𝑑.
𝑎 𝑑𝑞 𝑟 ↔
𝑟 𝑎 mod 𝑑.
Solution
(a) 54 4 13 2 → 𝑞 13 and 𝑟 2. We thus have 2 54 mod 4 and 13 54 div 4.
(b) 51 5 11 4 → 𝑞 11 and 𝑟 4 (as the remainder must be positive).
We thus have 4 51 mod 5 and 11 51 div 5.
(c) 𝑎 mod 11 6 →𝑎 11𝑞 6 → 4𝑎 4 11𝑞 6 44𝑞 24 → 4𝑎 11 4𝑞 2 2 → 4𝑎 mod 11 2.
• An integer 𝑛 2 is composite if and only if there exists an integer 𝑎 such that 𝑎|𝑛 with 1 𝑎 𝑛, that is, is an
, while noting that has no prime factors less than 𝑝. Again, if is not divisible by any prime, from 𝑝 up to the largest
prime that is not exceeding , then is prime. If has a prime factor 𝑞, then continue by factoring . This process
Solution
(a) To find the prime factorization of 1547, first perform divisions of 1547 by successive primes, beginning with 2 and no
greater than 1547. None of the primes 2, 3, and 5 divides 1547. However, 7 divides 1547, with 221. We then
divide 221 by successive primes, beginning with 7 itself. None of the primes 7 and 11 divide 221. However, 13 divides 221,
with 17. As 17 is prime, the procedure is completed. We thus have 1547 7 13 17.
(b) We first list all primes less than or equal to 1601, namely 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, and 37. None of them is
a factor of 1601, so 1601 is prime.
𝜑 𝑛 𝜑 𝑝𝑞 𝜑 𝑝 𝜑 𝑞 𝑝 1 𝑞 1 .
1, then 𝑎 and 𝑏 are relatively prime. Note that if 𝑑 gcd 𝑎, 𝑏 , then gcd , 1.
• In addition, integers are called pairwise relatively prime if the greatest common divisor of any two integers is 1. For
instance, none of the integers 25, 26, and 27 are prime, yet they are pairwise relatively prime.
Prime factorization: The prime factorizations of integers 𝑎, 𝑏, and gcd 𝑎, 𝑏 are as follows:
𝑎 𝑝 𝑝 ...𝑝
, , ,
→ gcd 𝑎, 𝑏 𝑝 𝑝 ...𝑝 .
𝑏 𝑝 𝑝 ...𝑝
where 𝑝 𝑝 ⋯ 𝑝 are distinct primes, each exponent is a nonnegative integer with min 𝑥, 𝑦 representing the
minimum of the two nonnegative integers 𝑥 and 𝑦, all primes occurring in the prime factorization of either 𝑎 or 𝑏, that is, 𝑝 ,
𝑝 , …, 𝑝 are included in both factorizations, and an exponent may be zero if necessary.
where 𝑛 1 is an integer. Since the remainders are nonnegative and getting smaller, the sequence of remainders 𝑟 𝑟
... 0 must eventually terminate with a remainder of zero. Using mathematical induction, we can show
In summary, by applying the division algorithm successively, the greatest common divisor is the last (i.e., the smallest)
nonzero remainder in the sequence of divisions.
Solution
The divisors of 72 include 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, and 72, whereas the divisors of 108 include 2, 3, 4, 6, 9, 12, 18, 27,
36, 54, and 108. The common divisors are then 2, 3, 4, 6, 9, 12, 18, 36. The greatest common divisor is thus 36.
The prime factorizations of 72 and 108 are 2 3 and 2 3 , respectively. The greatest common divisor is thus
, ,
2 3 2 3 36.
Using the Euclidean algorithm, we have 108 72 1 36. As we have 72 36 2 0, 36, which is the last nonzero
remainder in the sequence of divisions, is the greatest common divisor.
Solution
Successive application of the division algorithm yields the following sequence of equations:
The greatest common divisor is 6, as it is the last (i.e., the smallest) nonzero remainder in the sequence of divisions.
Solution
Using the Euclidean algorithm, we first find gcd 210, 54 . Successive application of the division algorithm yields the
following sequence of equations:
210 54 3 48
54 48 1 𝟔
48 6 9 0
Note that gcd 210, 54 6, as 6 is the last nonzero remainder in the sequence of divisions. We now employ the Euclidean
algorithm in the reverse order as follows:
gcd 210, 54 6 54 1 48 54 1 210 54 3 1 210 4 54 210𝑠 54𝑡 → 𝑠 1 & 𝑡 4
𝑎 𝑝 𝑝 ...𝑝
, , ,
→ lcm 𝑎, 𝑏 𝑝 𝑝 ...𝑝
𝑏 𝑝 𝑝 ...𝑝
where 𝑝 𝑝 ⋯ 𝑝 are distinct primes, each exponent is a nonnegative integer with max 𝑥, 𝑦 representing the
maximum of the two numbers 𝑥 and 𝑦, and all primes occurring in the prime factorization of either 𝑎 or 𝑏, that is, 𝑝 ,
𝑝 , …, 𝑝 are included in both factorizations.
• It is important to note that with positive integers 𝑎 and 𝑏, we have the following identity:
𝑎 𝑏 ≡ gcd 𝑎, 𝑏 lcm 𝑎, 𝑏 .
Solution
The prime factorizations of 72 and 108 are 2 3 and 2 3 , respectively.
, ,
Their least common multiple is thus 2 3 2 3 216.
As we have 𝑎 𝑏 gcd 𝑎, 𝑏 lcm 𝑎, 𝑏 , we have 72 108 gcd 72,108 216. We therefore have gcd 72,108
36.
𝑎 𝑎 10 𝑎 10 ... 𝑎 10 𝑎 10 .
Note that 𝑎 is the least significant digit and 𝑎 is the most significant digit. As an example, we have the following:
𝑎 𝑐≡𝑏 𝑑 mod 𝑚
𝑎 ≡ 𝑏 mod 𝑚
Note that 𝑎𝑐 ≡ 𝑏𝑐 mod 𝑚 does not imply 𝑎 ≡ 𝑏 mod 𝑚 , unless gcd 𝑐, 𝑚 1. For instance, 85 ≡ 55 mod 10 does
not yield 17 ≡ 11 mod 10 as gcd 5, 10 1, but 85 ≡ 55 mod 6 does yield 17 ≡ 11 mod 6 as gcd 5, 6 1.
Solution
Note that 11 is prime and 3 is not divisible by 11, we can thus employ Fermat’s little theorem as follows:
𝑎 ≡ 1 mod 𝑛
where 𝜑 𝑛 is Euler’s totient function. As an example, 𝑎 3 and 𝑛 10 are relatively prime and 𝜑 10 4. We thus
have 3 3 81 ≡ 1 mod 10 . As another example, for 𝑎 2, if we have 𝑛 11 and consequently 𝜑 11
10, we then have 2 2 1024 ≡ 1 mod 11 .
For all integers 𝑎 and 𝑚 1, if gcd 𝑎, 𝑚 1, that is, 𝑎 and 𝑚 are relatively prime, then there exists a unique integer 𝑎,
such that 𝑎𝑎 ≡ 1 mod 𝑚 , where the integer 𝑎 is called an inverse of 𝒂 modulo 𝒎 and 0 𝑎 𝑚.
Solution
We use the Euclidean algorithm not to find gcd 43, 660 as we already know gcd 43, 660 1, but to employ the
extended Euclidean algorithm in order to find an inverse of 43 modulo 660. The steps are as follows:
660 43 15 15
43 15 2 13
15 13 1 2
13 2 6 1.
We now use the above results in the reverse order to find 1 in terms of 43 and 660:
1 13 2 6 13 15 13 6 7 13 6 15 7 43 15 2 6 15 7 43 20 15 7
43 20 660 43 15 307 43 20 660. Therefore, 307 is an inverse modulo 660, as 43 307 ≡
1 mod 660 .
𝑥≡ 𝑎 𝛽 𝑦 mod 𝑚
Solution
𝑥 ≡ 2 mod 3
We must find a unique solution 𝑥 for the following system of linear congruences: 𝑥 ≡ 4 mod 5
𝑥 ≡ 6 mod 7 .
As 3, 5, and 7 are pairwise relatively prime, we can use the Chinese remainder theorem. Noting 𝑦 , 𝑦 , and 𝑦 can be found
by using the extended Euclidean algorithm or the method of inspection, we can then have
𝑚
𝛽 35
𝑚
𝑚 3 𝑚 𝑦 2
𝑚 5 → 𝑚 𝑚 𝑚 𝑚 105 → 𝛽 21 → 𝑦 1
𝑚
𝑚 7 𝑚 𝑦 1
𝛽 15
𝑚
with 𝑎 2, 𝑎 4, 𝑎 6, the solution to the simultaneous congruences is as follows: 𝑥 ≡ 𝑎 𝛽 𝑦 𝑎 𝛽𝑦
𝑎 𝛽𝑦 mod 𝑚 ≡ 2 35 2 4 21 1 6 15 1 mod 105 ≡ 314 mod 105 ≡ 104
Solution
The exponent in the binary form is as follows: 644 2 2 2 512 128 4 → 3 mod 645 3 3 3 mod 645.
We now successively determine 3 mod 𝑚, 3 mod 𝑚, 3 mod 𝑚 as well as similar terms up to 3 mod 𝑚.
3 mod 645 3 mod 645 3.
3 mod 645 3 mod 645 3 mod 645 mod 645 3 3 mod 645 9.
3 mod 645 3 mod 645 3 mod 645 mod 645 9 9 mod 645 𝟖𝟏.
3 mod 645 3 mod 645 3 mod 645 mod 645 81 81 mod 645 111.
3 mod 645 3 mod 645 3 mod 645 mod 645 111 111 mod 645 66.
3 mod 645 3 mod 645 3 mod 645 mod 645 66 66 mod 645 486.
3 mod 645 3 mod 645 3 mod 645 mod 645 486 486 mod 645 126.
3 mod 645 3 mod 645 3 mod 645 mod 645 126 126 mod 645 𝟑𝟗𝟔.
3 mod 645 3 mod 645 3 mod 645 mod 645 396 396 mod 645 81.
3 mod 645 3 mod 645 3 mod 645 mod 645 81 81 mod 645 𝟏𝟏𝟏.
Based on the product of two integers in the modular arithmetic and the modular exponentiation, we have
3 mod 645 3 3 3 mod 645 3 mod 645 3 mod 645 3 mod 645 mod 645 𝟏𝟏𝟏 𝟑𝟗𝟔
𝟖𝟏 mod 645 36.
• In order to map data of arbitrarily large size to small fixed size, a hashing function ℎ is used to assign memory location
ℎ 𝑘 to the record that has 𝑘 as its key, i.e., a hashing function converts keys into lists positions. The location numbers
are formally called indices. The index produced by ℎ determines the spot in the list, i.e., the memory location, to store the
value of the record.
• Since a hashing function is not one-to-one, simply because there are much more possible keys than memory locations,
more than one record may be assigned to a memory location. In such a case, we say a collision has occurred. In other
words, ℎ 𝑘 ℎ 𝑘 , but 𝑘 𝑘 . To handle collisions, a collision resolution policy is required. One simple way to
resolve a collision is to find the next unoccupied memory location following the occupied memory location assigned by
the hashing function. If we come to the end of the list without finding a memory location, then we would continue the
search back at the beginning of the list, as if the array were circular. This method of collision resolution is called linear
probing.
𝑎 𝑎 𝑏 𝑎 𝑏 ... 𝑎 𝑏 𝑎 .
where 𝑏, known as the base, is an integer greater than 1, 𝑘 is a nonnegative integer, 𝑎 , 𝑎 , …, 𝑎 are nonnegative integers
less than 𝑏, and 𝑎 0. This representation of 𝑎 is called the base 𝒃 expansion of 𝑎, which can be denoted by
𝑎 𝑎 ... 𝑎 𝑎 . Note that 𝑏 represents the number of different symbols that can be used in a numeral system. There are
various representations of integers, including the following expansions:
Decimal expansions: 𝑏 10 → 10 symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 .
Binary expansions: 𝑏 2 → 2 symbols 0, 1 .
Octal expansions: 𝑏 8 → 8 symbols 0, 1, 2, 3, 4, 5, 6, 7 .
Hexadecimal expansions: 𝑏 16 → 16 symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F .
Base conversion of an integer 𝑎 in the decimal expansion into any nondecimal base 𝑏 is as follows: divide 𝑎 and its
successive quotients by 𝑏 until a zero quotient is reached, then pick the remainders in the reverse order.
ELEE 2110U Discrete Mathematics 38
Example
Express the following expansions in base 10:
(a) 11001101 .
(b) CD .
Solution
(a) 11001101 1 2 1 2 0 2 0 2 1 2 1 2 0 2 1 2 205
(b) CD 12 16 13 16 205.
• In binary addition, carry-overs of binary addition are performed in the same manner as in decimal addition. We thus have
0 0 0, 0 1 1, 1 0 1, and 1 1 10, all in base 2.
• The binary multiplication is carried out by multiplying the multiplicand by one bit of the multiplier at a time and the
result of the partial product for each bit is placed in such a manner that the least significant bit is under the corresponding
multiplier bit. Finally, the partial products are added to get the complete product.
• The binary division is similar to that employed in the decimal system. However, in the case of binary numbers, the
operation is simpler because the quotient can have either 1 or 0 depending upon the divisor.
• The one’s complement of a binary number can be obtained by inverting each bit from 1 to 0 or from 0 to 1. For example,
one’s complement of the binary number 110010 is 001101. To get two’s complement of a binary number is to first obtain
the one’s complement of the number and then add 1 to the least significant bit. For example, two’s complement of the
binary number 10010 is 01101 00001 01110.
• The binary subtraction can be carried out using the following steps:
Find the two’s complement of the subtrahend, and then add it to the minuend.
If the final carry over of the sum is 1, it is dropped and the result is positive, and if there is no carry over, the two’s
complement of the sum will be the result and it is negative.
Solution
Encryption → 𝑓 𝑝 𝑝 𝑏 mod 26
Decryption → 𝑓 𝑝 𝑝 𝑏 mod 26
Solution
The following steps, shown below, must be taken to encrypt the message:
i) Break the message “DESTROY ALL THE EVIDENCE” into a set of individual letters.
ii) Translate each letter to the corresponding number.
iii) Apply 𝑓 𝑝 𝑝 7 mod 26 to each number in part (ii).
iv) Translate the new set of numbers to get a set of encrypted letters.
The encrypted text is thus KLZAYVFHSSAOLLCPKLUJL
Solution
The following steps, shown below, must be taken to decrypt the message:
(i) Break the message “LEELNVHTESHSLEJZFSLGP” into a set of individual letters.
(ii) Translate each letter to the corresponding number.
(iii) Apply 𝑓 𝑝 𝑝 11 mod 26 to each number in part (ii).
(iv) Translate the new set of numbers to get a set of decrypted letters.
The decrypted text is thus ATTACK WITH WHAT YOU HAVE.
Solution
a. We first translate the letter M to the corresponding number, we therefore have p=13. We then apply 𝑓 𝑝 11𝑝
4 mod 26 for 𝑝 13 to obtain 𝑓 13 11 13 4 mod 26 17. We then translate 17 to get the letter P, the
encrypted letter of M.
b. We first translate the letter R to the corresponding number, and therefore obtain 𝑓 𝑝 18. With 𝑚 11, we find 𝑚
19 as 𝑚𝑚 ≡ 1 mod 26 . We thus have
𝑝 ≡ 19 18 4 mod 26 ≡ 19 14 mod 26 ≡ 266 mod 26 ≡ 6.
Having 𝑝 6, we translate 6 to get back the letter F, the decrypted letter of R.
• In private-key cryptography, decryption algorithm is the inverse of encryption algorithm, and the number of private keys for 𝑁 users to
• The number of keys for 𝑁 users to communicate is 2𝑁. The algorithm is complex and more efficient for short messages.
Solution
Suppose the sender arbitrarily chooses the two prime numbers 𝑝 83 and 𝑞 53, and thus has 𝑛 𝑝𝑞 83 53
4,399 and 𝜑 𝑛 𝑝 1 𝑞 1 82 52 4,264. The sender then chooses an arbitrary 𝑒 23, which is relatively
prime to 4,624, because we have gcd 4624, 23 1. Therefore, 4399, 23 is a valid public key. The encrypted message
using fast modular multiplication is then as follows: 𝑐 𝑚 mod 𝑛 19 mod 4399 2556.
The valid private key is thus 4399, 927 , which the receiver possesses. Note that 𝑑 927, as it is an inverse of
𝑒 modulo 𝜑 𝑛 23 modulo 4264, while noting that 𝑑𝑒 𝑐𝜑 𝑛 23𝑑 4264𝑐 1. The decrypted message using fast
modular multiplication is then as follows: 𝑚 𝑐 mod 𝑛 2556 mod 4399 19.
Solution
𝑝 23
Given → 𝑛 𝑝𝑞 713 → 𝜑 𝑛 𝑝 1 𝑞 1 660.
𝑞 31
𝑒 𝜑 𝑛 Choosing 𝑒 29
Having → as an arbitrary choice,
gcd 𝑒, 𝜑 𝑛 1 while meeting both requirements.
𝑑 𝜑 𝑛
Having → Using the Euclidean algorithm → 𝑑 569.
𝑑𝑒 ≡ 1 mod 𝜑 𝑛
Note that by replacing each exponent by its binary expansion and then using the modular exponentiation algorithm, 𝐶 and 𝑀 were calculated.
Solution
𝑝 53
Given → 𝑛 𝑝𝑞 3233 → 𝜑 𝑛 𝑝 1 𝑞 1 3120.
𝑞 61
𝑒 𝜑 𝑛 Choosing 𝑒 17
Having → as an arbitrary choice,
gcd 𝑒, 𝜑 𝑛 1 while meeting both requirements.
𝑑 𝜑 𝑛
Having → Using the Euclidean algorithm → 𝑑 2753.
𝑑𝑒 ≡ 1 mod 𝜑 𝑛
Note that by replacing each exponent by its binary expansion and then using the modular exponentiation algorithm, 𝐶 and 𝑀 were calculated.
𝑆 𝑖
Describe the steps of an algorithm that finds the sum 𝑆 for an integer 𝑛 1.
Solution
Noting that this algorithm meets all requirements, the following sequence of steps are required:
1) Input 𝑛.
2) Set 𝑆 0.
3) Set 𝑖 1.
4) Compute 𝑖 𝑖 𝑖.
5) Add 𝑖 to 𝑆.
6) Add 1 to 𝑖.
7) Compare 𝑖 to 𝑛, if 𝑖 𝑛, then output 𝑆 and stop.
8) Go back to step (4).
Brute-force algorithms: The brute-force algorithm is a simple algorithm in concept that blindly iterates all possible solutions to search for
one or more than one solution that may solve a problem without any regard to the heavy computational requirements. It takes an inefficient
approach for solving problems as it does not take advantage of the special structure of the problem. Examples include using all possible
permutations of numbers to open a safe, finding the largest number in a list of numbers, sorting problems, such as the bubble, insertion, and
selection sorts, and polling a multitude of communication devices to determine those having messages to transmit.
Divide-and-conquer algorithms: The divide-and-conquer algorithm is an effective algorithm that works by recursively breaking down a
problem into two or more subproblems of the same or related type, until these become simple enough to be solved directly and rather easily.
The solutions to the subproblems are then combined to give a solution to the original problem. Examples include sorting problems, such as
quicksort and merge sort, binary search, solving the closest pair problem, routing mail by sorting letters into separate bags for different
geographical areas, and applying the law of total probability.
Dynamic programming: It is an algorithm that can be effectively used for solving a complex problem by recursively breaking down the
problem. It requires that overlapping subproblems exist and the optimal solution of the problem can be obtained using optimal solutions of
its subproblems stored in memory with the help of a recurrence relation. Examples include scheduling problem, Fibonacci numbers, matrix
chain multiplication, and travelling salesman problem.
Probabilistic algorithms: The probabilistic algorithm can solve problems that cannot be easily solved by deterministic algorithms. In
contrast to a deterministic algorithm, which always follows the same steps for a given input and has to go through a very large number of
possible cases, the probabilistic algorithm makes some random choices at some steps, which may lead to different output in much fewer
steps, but with a tiny probability that the final answer may not be correct. Examples may include Monte Carlo algorithm in quality control,
collisions in hashing functions, and Bayesian spam filters.
Solution
In this case, the greedy algorithm produces an optimal solution. To make change for 92 cents for the least number of coins,
the focus at any step is on the largest possible coin, that is, on quarters, dimes, nickels, and pennies, respectively.
First, three quarters are selected, leaving 17 cents, next, one dime is selected, leaving 7 cents, followed by a nickel, leaving 2
cents, and finally by 2 pennies.
The total number of coins is thus 7 3 1 1 2 , as 92 3 25 1 10 1 5 2 1 .
Solution
In this case, the greedy algorithm does not produce an optimal solution. The greedy algorithm fails to find the largest sum,
simply because it makes decisions based only on the information it has at any one step, without regard to the overall
problem. In order to reach the largest sum, at each step, the greedy algorithm chooses what appears to be the optimal
immediate choice.
It therefore chooses 30 instead of 20 at the second step, and thus does not reach the best solution, which is 100 10
20 70 , and it mistakenly finds 90 10 30 50 as the largest sum.
ELEE 2110U Discrete Mathematics 68
Complexity of Algorithms
The two main measures for the computational complexity of an algorithm are as follows:
Space complexity: It is measured by the maximum amount of computer memory needed in the execution of the algorithm and the
requirement is frequently a multiple of the data size.
Time complexity: It is measured by counting the number of key operations using the size of the input as its argument.
The term complexity generally refers to the running time of the algorithm. The function 𝑓 𝑛 representing the time complexity of an
algorithm is measured by the following two factors:
The size 𝑛 of the input data and the characteristics of the particular input data.
The number of basic key operations that must be performed when the algorithm is executed, while noting they generally include
addition, subtraction, multiplication, division, and comparison.
There are typically two types of time complexity to analyze:
The average-case time complexity, i.e., the expected value of 𝑓 𝑛 , is usually difficult to analyze, and it is generally assumed that the
distribution of the possible inputs is uniform, when the actual distribution is unknown and the uniform distribution may not actually
apply to real situations.
The worst-case time complexity, i.e., the maximum value of 𝑓 𝑛 , is easier than the average-case complexity to analyze, as this
complexity is based on the largest number of operations required, as a solution for any possible input is guaranteed.
𝑂 1 𝑂 log 𝑥 𝑂 𝑥 𝑂 𝑥 log 𝑥 𝑂 𝑥 𝑂 2 𝑂 𝑥! 𝑂 𝑥 .
Solution
If we choose 𝑘 1, i.e., 𝑥 1, we then have 3𝑥 3𝑥 3𝑥 and 𝑥 1, where these inequalities are obtained by
multiplying both sides of 𝑥 1 by appropriate terms. An upper bound on 𝑓 𝑥 is thus as follows:
0 𝑥 3𝑥 3𝑥 1 𝑥 3𝑥 3𝑥 𝑥 8𝑥 → 𝐶 8.
If we choose 𝑘 2, i.e., 𝑥 2, we have 𝑥 3𝑥 , 𝑥 𝑥 3𝑥, and 1, where these inequalities are obtained by
multiplying both sides of 𝑥 2 by appropriate terms. An upper bound on 𝑓 𝑥 is thus as follows:
3 3 1 27 27
0 𝑥 3𝑥 3𝑥 1 𝑥 𝑥 𝑥 𝑥 𝑥 → 𝐶 .
2 4 8 8 8
If we choose 𝑘 3, i.e., 𝑥 3, we have 𝑥 3𝑥 , 𝑥 3𝑥, and 1, where these inequalities are obtained by
multiplying both sides of 𝑥 3 by appropriate terms. An upper bound on 𝑓 𝑥 is thus as follows:
1 1 64 64
0 𝑥 3𝑥 3𝑥 1 𝑥 𝑥 𝑥 𝑥 𝑥 → 𝐶 .
3 27 27 27
ELEE 2110U Discrete Mathematics 72
Example (2)
Show that 𝑓 𝑥 𝑥 3𝑥 3𝑥 1 is 𝑂 𝑥 for three pairs of witnesses.
Solution
𝑓 𝑥 𝑂 𝑥 for all these three pairs of witnesses.
Solution
We have
𝑎𝑛 log 𝑛! 𝑎𝑛 log 1 2 ... 𝑛 𝑎𝑛 log 𝑛 𝑛 ... 𝑛 𝑎𝑛 log 𝑛 𝑎𝑛 log 𝑛 .
We therefore have
𝑓 𝑛 𝑎𝑛 log 𝑛! 𝑛 𝑎 log 𝑛 𝑎 𝑎𝑛 log 𝑛 6𝑛 log 𝑛 𝑎𝑛 6𝑛 log 𝑛 𝑎 6 𝑛 log 𝑛
𝑂 𝑛 log 𝑛 → 𝐶 𝑎 6.
and only if 𝑔 𝑥 is 𝑂 𝑓 𝑥 .
In short, if, for sufficiently large value of 𝑥, the values of 𝑓 𝑥 are greater than those of a multiple of 𝑔 𝑥 , then 𝑓 𝑥 is
Ω 𝑔 𝑥 .
Solution
For 𝑥 1, we have
15 𝑥 2𝑥 9 15 𝑥 2𝑥 2 30 𝑥 𝑥 1
30 𝑥.
𝑥 1 𝑥 1 𝑥 1
Solution
Assuming 𝑥 1, we have the following:
Solution
(a) In each step of a pass, elements in boldface are being compared.
𝟕, 𝟔, 1, 9, 5 𝟔, 𝟏, 7, 5, 9 𝟏, 𝟔, 5, 7, 9 𝟏, 𝟓, 6, 7, 9
6, 𝟕, 𝟏, 9, 5 1, 𝟔, 𝟕, 5, 9 1, 𝟔, 𝟓, 7, 9 1, 𝟓, 𝟔, 7, 9
1 pass 6, 1, 𝟕, 𝟗, 5, 2 pass 1, 6, 𝟕, 𝟓, 9, 3rd pass
st nd 1, 5, 𝟔, 𝟕, 9, 4th pass 1, 5, 𝟔, 𝟕, 9
6, 1, 7, 𝟗, 𝟓 1, 6, 5, 𝟕, 𝟗 1, 5, 6, 𝟕, 𝟗 1, 5, 6, 𝟕, 𝟗
6, 1, 7, 5, 9 1, 6, 5, 7, 9 1, 5, 6, 7, 9 1, 5, 6, 7, 9
Note that the bubble sort needs one whole pass, i.e., the fourth pass, without any swap to know it is sorted.
(b) The insertion sort begins with 6 and compares it with 7. It inserts it before 7 as it does not exceed 7. Then, 1 is compared with 6 as it is
smaller than 6, it is inserted before 6. Next, 9 is compared with 1, as it is larger than 1, it is compared with 6, as it is larger than 6, it is
compared with 7, as it is larger than 7, it is inserted after 7. Lastly, 5 is compared with 1, as it is larger than 1, it is compared with 6, as it is
smaller than 6, it is inserted after 1 and before 6. Note that the following shows the required steps, where the element under consideration in
each step is in boldface:
7, 𝟔, 1, 9, 5 6, 7, 𝟏, 9, 5 1, 6, 7, 𝟗, 5 1, 6, 7, 9, 𝟓 1, 5, 6, 7, 9.
ELEE 2110U Discrete Mathematics 81
Example (2)
(c) As shown, the merge sort, where the top part is the split and the bottom part is the merge
(d) Employing the quicksort, the first element, i.e., 7, is selected, and we partition the other
elements into two sublists. The first sublist consists of all elements in the list less than 7, that
is, 6, 1, 5, and the other consists of all elements greater than 7, that is, 9. Then 7 is put at the
end of the first sublist as its final resting place. The two sublists are then recursively sorted
the same way, that is, 6 is selected in the first sublist and the other elements in that sublist are
compared with 6, i.e., 1, 5, and 9 is selected in the second sublist. Note that the following
shows the required steps, where the element under consideration in each step is in boldface:
𝟕, 6, 1, 9, 5 𝟔, 1, 5, 7, 9 𝟏, 5, 6, 7, 9 1, 5, 6, 7, 9.
(e) The selection sort finds 1 as it is the smallest element in the unsorted list, and moves it
to the top of the sorted list. Then, the least element among the remaining elements of
the unsorted list, that is, 5, is found and moves to the second position of the ordered list. This
procedure is repeated until the entire list has been sorted. Note that the following shows the
required steps, where the element under consideration in each step is in boldface:
7, 6, 1, 9, 5 𝟏 1, 𝟓 1, 5, 𝟔 1, 5, 6, 𝟕 1, 5, 6, 7, 𝟗 1, 5, 6, 7, 9.
Solution
(a) The first element of the array, that is, 2 is compared with 17, as they are not the same, 3 is compared with 17, as they are not the same, 5
is compared with 17, this process continues until 17 which is in the list is found. Then, the solution is 7, as 7 is the location of 17 in the list.
(b) In order to apply the binary search, we first need to sort the list. The sorted list, in an ascending order, is then as follows: 2, 3, 5, 7, 11,
13, 17, 19, 23, 29, 31, 37. As the number of integers in the list is twelve, there is no middle integer. Therefore, the sorted list is split into two
sublists each consisting of 6 integers, namely, 2, 3, 5, 7, 11, 13 and 17, 19, 23, 29, 31, 37. Then, compare 17 and the largest integer in the
first list. Because 17 13, the search for 17 must be restricted to the second sublist, namely 17, 19, 23, 29, 31, 37. Next, we split this
sublist into two smaller sublists, each with three integers, namely, 17, 19, 23 and 29, 31, 37. Then, compare 17 and the largest integer in the
first sublist. Because 23 17, the search for 17 can be restricted to the first sublist. Next, we compare 17 to the middle integer in this
sublist, namely 19, as 19 17, we split this sublist into two integers, one smaller than 19, i.e., 17, and the other larger than 19, i.e., 23. The
search has been narrowed down to one term, we thus compare 17 and 17, and 17 is thus located in the sorted list.
alphabet, i.e., 𝐴 𝐵.
• If the sets 𝐴 and 𝐵 are not equal, we then write 𝐴 𝐵.
• Example: the sets 𝐴 𝑥 ∈ 𝑷 | 𝑥 is an odd integer and
𝐵 𝑥 ∈ 𝑷 | 𝑥 is a prime number are not equal, where the
set 𝑷 represents all positive integers, i.e., 𝐴 𝐵.
contains 𝐵.
• In order to show that 𝐵 is not a subset of 𝐴, that is 𝐵 ⊈ 𝐴, it is only needed to find 𝑨
𝑩
one element 𝑥 ∈ 𝐵 with 𝑥 ∉ 𝐴.
• Every set is a subset of itself as well as a subset of the universal set.
• If 𝐵 ⊆ 𝐴 and 𝐴 ⊆ 𝐶, then 𝐵 ⊆ 𝐶.
• The set 𝐵 is a proper subset of the set 𝐴 if every member of 𝐵 is also a member of 𝐴,
but there is at least one element of 𝐴 that is not an element of 𝐵. We use the symbol ⊂
to denote proper subset, 𝐵 ⊂ 𝐴 thus implies 𝐵 is a proper subset of 𝐴, as shown here.
• Oftentimes, the terms “subset” and “proper subset” are interchangeable, as it is not
important to differentiate them.
• A set with one element is called a singleton set. An example of a singleton set is the set of positive integers that are both
prime and even, i.e., 2 .
years of age, senior citizens who are at least 65 years old, and those adults
who are at leats18 years old but younger than 65 years of age.
𝐴 ∪ 𝐵 ≜ 𝑥 ∈ 𝑈 | 𝑥 ∈ 𝐴 or 𝑥 ∈ 𝐵
𝐴 ∩ 𝐵 ≜ 𝑥 ∈ 𝑈 | 𝑥 ∈ 𝐴 and 𝑥 ∈ 𝐵
The intersection of two disjoint sets 𝐴 and 𝐵 is thus the empty set, i.e., 𝐴 ∩ 𝐵 ∅.
𝐴 𝐵 ≜ 𝑥 ∈ 𝑈 | 𝑥 ∈ 𝐴 and 𝑥 ∉ 𝐵
The complement of the universal set is the empty set, and vice versa.
𝑨𝒄
𝐴⨁𝐵 𝐴∆𝐵 ≜ 𝑥 ∈ 𝑈 | 𝑥 ∈ 𝐴, 𝑥 ∉ 𝐵 or 𝑥 ∉ 𝐴, 𝑥 ∈ 𝐵
Solution
We first identify the elements of the sets 𝐴 and 𝐵 from the universal set 𝑈, and then perform the required set operations:
𝐴∪𝐵 1, 2, 3, 5
𝐴∩𝐵 3, 5
𝐴 1, 3, 5
𝑈 1, 2, 3, 4, 5, 6 → → 𝐴 𝐵 1
𝐵 2, 3,5
𝐴 2, 4, 6
𝐴⨁𝐵 1, 2
Solution
We first identify the elements of the sets 𝐴, 𝐵, and 𝐶, and then perform the required set operations:
When the set operations are all unions or all intersections, associative law holds. However, when they are a mix of unions
and intersections, associative law does not hold, we therefore have 𝐴 ∪ 𝐵 ∩ 𝐶 𝐴 ∪ 𝐵 ∩ 𝐶 .
• De Morgan’s laws are prominent set identities that provide a pair of transformation rules. The laws can be expressed as
the complement of the union of two sets is the same as the intersection of their complements and the complement of the
intersection of two sets is the same as the union of their complements. De Morgan’s laws are used when the complements
of sets are easier to define than the sets themselves.
2) Transform one side into the other side step by step by employing the other known set identities. This method of proof is
known as the algebraic proof. This is usually the shortest method, provided that there are relevant set identities that can
be applied to simplify the set expressions.
3) Build a membership table step by step for each side of the set identity, and show the columns corresponding to the both
sides of the identity match. This method does not provide any insight into the proof; however, it is a straightforward
method if the number of the original sets in the identity is half a dozen or less, otherwise a computer should be used to
build the membership table of interest.
Solution
The first method is to show that each side of the identity is a subset of the other side.
The first step is to show 𝐴 𝐶 ∩ 𝐵 𝐶 ⊆ 𝐴 ∩ 𝐵 ∩ 𝐶̅ . When 𝑥 ∈ 𝐴 𝐶 ∩ 𝐵 𝐶 , then by definition of
intersection, 𝑥 ∈ 𝐴 𝐶 and 𝑥 ∈ 𝐵 𝐶 . When 𝑥 ∈ 𝐴 𝐶 , then by definition of difference, 𝑥 ∈ 𝐴 and 𝑥 ∉ 𝐶, and when
𝑥∈ 𝐵 𝐶 , then by definition of difference, 𝑥 ∈ 𝐵 and 𝑥 ∉ 𝐶. When 𝑥 ∈ 𝐴 and 𝑥 ∈ 𝐵 and 𝑥 ∉ 𝐶, then by definition of
complement, 𝑥 ∈ 𝐴 and 𝑥 ∈ 𝐵 and 𝑥 ∈ 𝐶̅ . Hence 𝑥 ∈ 𝐴 ∩ 𝐵 ∩ 𝐶̅ by definition of intersection.
The second step is to show 𝐴 ∩ 𝐵 ∩ 𝐶̅ ⊆ 𝐴 𝐶 ∩ 𝐵 𝐶 . When 𝑥 ∈ 𝐴 ∩ 𝐵 ∩ 𝐶̅ , then 𝑥 ∈ 𝐴 ∩ 𝐵 and 𝑥 ∈ 𝐶̅ by
definition of intersection. When 𝑥 ∈ 𝐴 ∩ 𝐵 , then 𝑥 ∈ 𝐴 and 𝑥 ∈ 𝐵 by definition of intersection, and when 𝑥 ∈ 𝐶̅ then 𝑥 ∉
𝐶 by definition of complement. When 𝑥 ∈ 𝐴 and 𝑥 ∈ 𝐵 and 𝑥 ∉ 𝐶, then 𝑥 ∈ 𝐴 𝐶 and 𝑥 ∈ 𝐵 𝐶 by definition of
difference. Hence 𝐴 𝐶 ∩ 𝐵 𝐶 by definition of intersection.
Solution
The second method is to apply the relevant set identities step by step to make one side equal to the other side, as follows:
Solution
The third method is to build a membership table. There are three basic sets 𝐴, 𝐵, and 𝐶 that have been combined to create the
set identity of interest. The presence of an element to any one of these three sets is denoted by 1 and its absence by 0. We
thus have a membership table consisting of 8 2 rows, as shown below. After forming the three columns associated with
the three sets 𝐴, 𝐵, and 𝐶, which are the building sets of the identity, we first form the columns corresponding to the sets
𝐴 𝐶 and 𝐵 𝐶 to construct the column associated
with the set 𝐴 𝐶 ∩ 𝐵 𝐶 , which is the left-hand side
of the identity. We then form the columns corresponding to
the sets 𝐴 𝐵 and 𝐶̅ to construct the column associated
with the set 𝐴 ∩ 𝐵 ∩ 𝐶̅ , which is the right-hand side of the
identity. We notice that because the columns for the sets
𝐴 𝐶 ∩ 𝐵 𝐶 and 𝐴 ∩ 𝐵 ∩ 𝐶̅ are the same, the identity is valid.
𝑃 𝐴 2 → 𝐴 |𝑃 𝐴 |.
𝐴 𝐴 ⋯ 𝐴 𝑎 ,𝑎 ,…,𝑎 | 𝑎 ∈ 𝐴 ,𝑎 ∈ 𝐴 ,…,𝑎 ∈ 𝐴
• The notation for an ordered 𝑛-tuple is a generalization of the notation for an ordered pair, and it takes both order and
multiplicity into account.
• A subset 𝑅 of the Cartesian product 𝐴 𝐵 is called a relation from the set 𝐴 to the set 𝐵. The elements of 𝑅 are ordered
pairs, where the first element belongs to 𝐴 and the second to 𝐵. As relations are important, a later chapter will be
exclusively devoted to the topic of relations. In general, we have 𝐴 𝐵 𝐵 𝐴, unless 𝐴 ∅ or 𝐵 ∅ or 𝐴 𝐵.
Solution
(a) Since we have 𝑋 3, we have 𝑃 𝑋 2 8. 𝑃 𝑋 is thus a set with the following eight subsets:
𝑃 𝑋 ∅, 3 , 6 , 9 , 3, 6 , 3, 9 , 6, 9 , 3, 6, 9
(b) We thus have
𝐴 𝐵 𝐶 1, 𝑎, 1 , 1, 𝑎, # , 1, 𝑏, 1 , 1, 𝑏, # ,
2, 𝑎, 1 , 2, 𝑎, # , 2, 𝑏, 1 , 2, 𝑏, # ,
3, 𝑎, 1 , 3, 𝑎, # , 3, 𝑏, 1 , 3, 𝑏, #
and
𝐴 𝐶 𝐵 1,1, 𝑎 , 1,1, 𝑏 , 1, #, 𝑎 , 1, #, 𝑏 ,
2,1, 𝑎 , 2,1, 𝑏 , 2, #, 𝑎 , 2, #, 𝑏 ,
1,1, 𝑎 , 1,1, 𝑏 , 1, #, 𝑎 , 1, #, 𝑏
Each of these two Cartesian products is a set consisting of 12 3 2 2 ordered triples. However, the resulting two sets
are different, i.e., 𝐴 𝐵 𝐶 𝐴 𝐶 𝐵, as both order and multiplicity matter.
ELEE 2110U Discrete Mathematics 30
Principle of Inclusion-Exclusion
• The cardinality of the union of two finite sets 𝐴 and 𝐵 can be found using the principle of inclusion-exclusion, as
reflected below:
𝐴∪𝐵 𝐴 𝐵 |𝐴 ∩ 𝐵|
• 𝐴 |𝐵| counts each element that is in set 𝐴 but not in set 𝐵 once and in set 𝐵 but not in set 𝐴 once, and each element
that is in both sets 𝐴 and 𝐵 exactly twice. The number of elements that are in both 𝐴 and 𝐵, i.e., |𝐴 ∩ 𝐵|, is subtracted
from 𝐴 |𝐵| so as to count the elements in the intersection only once. If the sets 𝐴 and 𝐵 are disjoint, then we have
𝐴∪𝐵 ≜ 𝐴 𝐵.
• The principle of inclusion-exclusion can be extended to 𝑛 sets 𝐴 , 𝐴 , … , 𝐴 , as reflected below:
𝐴 ∪ 𝐴 ∪ ⋯∪ 𝐴 𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 ∩𝐴 ⋯ 1 𝐴 ∩ 𝐴 ∩ ⋯∩ 𝐴
• In general, for 𝑛 sets, where 𝑛 is a positive integer, the principle of inclusion-exclusion has a maximum of 2 1 terms.
However, some of these terms may be zero, as it is possible that some of the 𝑛 sets are mutually exclusive.
Solution
As highlighted below, the formula for three sets contains 7 2 1 different terms and that for four sets contains
15 2 1 different terms:
𝐴 ∪𝐴 ∪𝐴 𝐴 𝐴 𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 ∩𝐴
and
𝐴 ∪𝐴 ∪𝐴 ∪𝐴
𝐴 𝐴 𝐴 𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴 𝐴 ∩𝐴
𝐴 ∩𝐴 ∩𝐴 𝐴 ∩𝐴 ∩𝐴 𝐴 ∩𝐴 ∩𝐴 𝐴 ∩𝐴 ∩𝐴 𝐴 ∩𝐴 ∩𝐴 ∩𝐴
Solution
We first determine the sets 𝑈, 𝐴, and 𝐵, and then obtain their computer representations, as follows:
𝑈 1, 2, 3, 4, 5, 6, 7, 8 → 𝑈 1, 1, 1, 1, 1, 1, 1, 1
𝐴 2, 4, 6, 8 → 𝐴 0, 1, 0, 1, 0, 1, 0, 1
𝐵 3, 6 → 𝐵 0, 0, 1, 0, 0, 1, 0, 0
The bit sequences representing the union, intersection, difference, and symmetric difference of sets 𝐴 and 𝐵 are thus as
follows:
𝐴∪𝐵 2, 3, 4, 6, 8 → 𝐴 ∪ 𝐵 0, 1, 1, 1, 0, 1, 0, 1
𝐴∩𝐵 6 →𝐴∩𝐵 0, 0, 0, 0, 0, 1, 0, 0
𝐴 𝐵 2, 4, 8 → 𝐴 𝐵 0, 1, 0, 1, 0, 0, 0, 1
𝐴⨁𝐵 2, 3, 4, 8 → 𝐴⨁𝐵 0, 1, 1, 1, 0, 0, 0, 1
Solution
We thus have the following multisets sets:
𝐻∪𝐾 max 4, 2 . 𝑎, max 3, 3 . 𝑏, max 2, 4 . 𝑐, max 1, 0 . 𝑑, max 0, 1 . 𝑒
4. 𝑎, 3. 𝑏, 4. 𝑐, 1. 𝑑, 1. 𝑒 .
𝐻∩𝐾 min 4, 2 . 𝑎, min 3, 3 . 𝑏, min 2, 4 . 𝑐, min 1, 0 . 𝑑, min 0, 1 . 𝑒
2. 𝑎, 3. 𝑏, 2. 𝑐 .
𝐻 𝐾 max 4 2, 0 . 𝑎, max 3 3, 0 . 𝑏, max 2 4, 0 . 𝑐, max 1 0, 0 . 𝑑, max 0 1, 0 . 𝑎
2. 𝑎, 1. 𝑑 .
𝐻 𝐾 4 2 . 𝑎, 3 3 . 𝑏, 2 4 . 𝑐, 1 0 . 𝑑, 0 1 .𝑒
6. 𝑎, 6. 𝑏, 6. 𝑐, 1. 𝑑, 1. 𝑒 .
people (i.e., the person’s height ranges between 170 cm and 190
cm).
• Set operations in classical sets can be extended to fuzzy sets in terms of membership function, namely we have
• The complement of fuzzy set 𝐴 is 𝐴 , where 𝜇 𝑥 1 𝜇 𝑥 .
• The union of fuzzy sets 𝐴 and 𝐵 is 𝐴 ∪ 𝐵, where 𝜇 ∪ 𝑥 max 𝜇 𝑥 , 𝜇 𝑥 .
• The intersection of fuzzy sets 𝐴 and 𝐵 is 𝐴 ∩ 𝐵, where 𝜇 ∩ 𝑥 min 𝜇 𝑥 , 𝜇 𝑥 .
Solution
We thus have the following fuzzy sets:
Solution
(a) The correspondence in Figure-a is not a function, because it maps an element in 𝑋 to
two distinct elements in 𝑌.
(b) The correspondence in Figure-b is a function, as each member in 𝑋 is associated with
exactly one member in 𝑌. Its domain is the set 𝑎, 𝑏, 𝑐, 𝑑 , codomain is the set
1, 2, 3, 4 , and range is the set 1, 3, 4 .
(c) The correspondence in Figure-c is not a function, because there is an element of 𝑋,
namely 𝑏 that is not mapped to any element of 𝑌.
𝑓𝑔 𝑥 𝑓 𝑥 𝑔 𝑥
• The functions 𝑓 𝑔 and 𝑓𝑔 are defined only wherever both 𝑓 and 𝑔 are defined.
• The domain of the function 𝑓 𝑔 or the domain of the function 𝑓𝑔 is the intersection of the domain of 𝑓 and the domain
of 𝑔.
Solution
We first find the domains of 𝑓 𝑥 and 𝑔 𝑥 .
The domain of 𝑓 𝑥 is 2 𝑥 2 and the domain of 𝑔 𝑥 is 𝑥 1.
Therefore, both 𝑓 𝑔 𝑥 and 𝑓𝑔 𝑥 are defined only when 1 𝑥 2.
We can now have the sum and product of the two functions as follows:
𝑓 𝑔 𝑥 4 𝑥 𝑥 1
𝑓𝑔 𝑥 4 𝑥 𝑥 1
Increasing function 𝑓 → ∀𝑥 ∀𝑥 𝑥 𝑥 →𝑓 𝑥 𝑓 𝑥
Non-increasing function 𝑓 → ∀𝑥 ∀𝑥 𝑥 𝑥 →𝑓 𝑥 𝑓 𝑥
Decreasing function 𝑓 → ∀𝑥 ∀𝑥 𝑥 𝑥 →𝑓 𝑥 𝑓 𝑥
Solution 𝑐 3 𝑐 3
Only the arrow diagrams in (a) and (c) are one-to-one functions, because in
4 𝑑
each of them, different elements of domain have distinct images, i.e., no two
𝑋 𝑌 𝑋 (b) 𝑌
values in the domain are assigned to the same function value. (a)
Only the arrow diagrams in (b) and (c) are onto functions, because in each of
𝑎 1 𝑎 1
them, all elements in the codomain are images of elements in the domain.
𝑏 2 𝑏 2
In summary, the function in (a) is one-to-one, but not onto, the function in (b)
is onto, but not one-to-one, the function in (c) is both one-to-one and onto, 𝑐 3 𝑐 3
nor onto.
𝑋 𝑌 𝑋 𝑌
(c) (d)
Solution
The functions 𝑔 𝑥 and 𝑘 𝑥 are both one-to-one, as in the graph of 𝑔 𝑥 or the graph of 𝑘 𝑥 , no horizontal line intersects
the graph in more than one point.
The functions ℎ 𝑥 and 𝑘 𝑥 are both onto, as in the graph of ℎ 𝑥 or the graph of 𝑘 𝑥 , each horizontal line intersects the
graph at one or more points.
In summary, the function 𝑔 𝑥 is one-to-one, but not onto, the function ℎ 𝑥 is onto, but not one-to-one, the function
𝑘 𝑥 is both one-to-one and onto, i.e., one-to-one correspondence, and the function 𝑓 𝑥 is neither one-to-one nor onto.
Solution
𝑔∘𝑓 𝑥 𝑔 𝑓 𝑥 𝑔 𝑥 1 𝑥 1 𝑥 1 𝑥 3𝑥 4𝑥 2
and
𝑓∘𝑔 𝑥 𝑓 𝑔 𝑥 𝑓 𝑥 𝑥 𝑥 𝑥 1 𝑥 𝑥 1
a one-to-one correspondence.
• The inverse function of the function 𝑓, denoted by 𝑓 , is the function that assigns to an 𝑥 𝑓 𝑥
element 𝑦 belonging to 𝑌 the unique element 𝑥 in 𝑋 such that 𝑓 𝑥 𝑦. Hence, we have
𝑓 𝑥
𝑓
𝑓 𝑦 𝑥 ↔ 𝑦 𝑓 𝑥 .
• The domain of 𝑓 becomes the codomain of 𝑓 and the codomain of 𝑓 becomes the domain 𝑓
𝑋 𝑌
of 𝑓 . The independent variable 𝑥 for 𝑓 acts as the dependent variable for 𝑓 , and
correspondingly the dependent variable 𝑦 for 𝑓 becomes the independent variable for 𝑓 .
• Example: if we have 𝑓 𝑥 𝑒 , we then have ln 𝑓 𝑥 𝑥. By changing the roles of the
independent and dependent variables, the inverse function of 𝑓 𝑥 𝑒 is then 𝑓 𝑥
ln 𝑥.
Solution
(a) The function ℎ 𝑥 is not one-to-one correspondence, as it is not even one-to-one. Therefore, it is not invertible. In other
words, its inverse, ℎ 𝑥 𝑥 2 1, is not a function simply because for a given 𝑥 2, we have two distinct
values for ℎ 𝑥 .
(b) The function 𝑘 𝑥 is one-to-one correspondence, as it is both one-to-one and onto. Therefore, it is invertible. In other
words, its inverse, 𝑘 𝑥 𝑥 7, is also a function, for a given 𝑥 0.
Solution
(a) 𝐴 𝐵 1, 7 , 1, 8 , 1, 9 , 2, 7 , 2, 8 , 2, 9 , 3, 7 , 3, 8 , 3, 9 .
𝐵 𝐴 7, 1 , 8, 1 , 9, 1 , 7, 2 , 8, 2 , 9, 2 , 7, 3 , 8, 3 , 9, 3 .
(b) Since we have 𝑅 12, 6 , 18, 6 , 20, 10 , the domain of 𝑅 is 12, 18, 20 and the range of 𝑅 is 6, 10 .
(c) Since we have the relation 𝑅 2, 8 , 2, 10 , 3, 9 , 4, 8 , we have the inverse relation
𝑅 8, 2 , 10, 2 , 9, 3 , 8, 4 . Therefore, for all 𝑏, 𝑎 ∈ 𝑅 , 𝑏 is a multiple of 𝑎.
Solution
𝑅 is not symmetric since 1, 2 ∈ 𝑅 , but 2, 1 ∉ 𝑅 . However, 𝑅 is antisymmetric.
𝑅 is not antisymmetric, as 1, 2 and 2, 1 belong to 𝑅 , but 2 1. However, 𝑅 is symmetric.
𝑅 is neither symmetric nor antisymmetric.
𝑅 is both symmetric and antisymmetric.
Property Requirement
Solution
a) The relation is neither reflexive nor symmetric, but it is transitive.
b) The relation is reflexive, symmetric, and transitive.
c) The relation is both reflexive and symmetric, but it is not transitive.
𝑅 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 .
Solution
1 0 1 1 0 1 2 0 2
𝑀 0 1 0 → 𝑀 0 1 0 & 𝑀 0 1 0 .
1 0 1 1 0 1 2 0 2
The relation 𝑅 is reflexive, as all the diagonal elements of the matrix 𝑀 are equal to 1.
Since we have 𝑀 𝑀 , the relation 𝑅 is symmetric.
The relation 𝑅 is not antisymmetric, for there are two 1s symmetrically placed about the main diagonal, i.e., at positions
row 1, column 3 and row 3, column 1.
Whenever entry row 𝑖, column 𝑗 in 𝑀 is nonzero, entry row 𝑖, column 𝑗 in 𝑀 is also nonzero, the relation 𝑅 is thus transitive.
𝑅 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎
and
𝑆 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎
Identify the zero-one matrices for the relations reflecting the union and intersection of these two relations, and determine the
corresponding relations.
Solution
The zero-one matrices of 𝑅, 𝑆, 𝑅 ∪ 𝑆, and 𝑅 ∩ 𝑆 are as follows:
1 1 0 1 0 1 1 1 1 1 0 0
𝑀 0 0 1 , 𝑀 0 1 1 , 𝑀 ∪ 0 1 1 & 𝑀 ∩ 0 0 1 .
0 0 0 0 0 1 0 0 1 0 0 0
We thus have
𝑅∪𝑆 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎 , 𝑎 ,𝑎
and
𝑅∩𝑆 𝑎 ,𝑎 , 𝑎 ,𝑎 .
𝑀 ∘ 𝑀 ⨀𝑀 .
Solution
The corresponding zero-one matrices are as follows:
0 1 1 0
1 0 1 0 0 1 1 0
𝑀 & 𝑀 1 0 0 1 → 𝑀 𝑀 ⨀𝑀
0 1 0 0 0 0 0 0 ∘ 1 0 0 1 .
0 0 0 0 0 0 0 0
0 0 1 0
Although logic is an essential tool in our interactions with other people as well as in our
decisions made every day, it does have limitations, simply because logic cannot help
convince someone out of something they were not reasoned into in the first place.
Solution
As 𝑝𝑝 and 𝑞𝑞 each can have two different truth values, there are four possibilities (rows) in the following table:
• If the implication is true, we do not automatically know that either the hypothesis or the conclusion is true. For instance,
consider the conditional statement “if you obey the law, you never go to prison.” In this implication, if you obey the law,
then you do not expect to go to prison. If you do not obey the law, you may or may not go to prison depending on other
factors. However, if you do obey the law, but you go to prison, you feel outraged. This last scenario corresponds to the
case when 𝑝𝑝 is true but 𝑞𝑞 is false and thus the truth value of the conditional statement 𝑝𝑝 → 𝑞𝑞 is false.
Solution
Noting 𝑝𝑝 represents the statement “you start using drugs” and 𝑞𝑞 represents the statement “you are a moron”, that is for 𝑝𝑝 →
𝑞𝑞, we have the following statements:
• 𝑞𝑞 → 𝑝𝑝)̅ is “if you are not a moron, then you do not start using drugs.”
The contrapositive statement (�
• The converse statement (𝑞𝑞 → 𝑝𝑝 ) is “if you are a moron, then you start using drugs.”
• The inverse statement (𝑝𝑝̅ → 𝑞𝑞)
� is “if you do not start using drugs, then you are not a moron.”
Write the following propositions using 𝑝𝑝 and 𝑞𝑞 and logical connectivities including negations:
• You do not drive impaired 𝑝𝑝̅
• You drive impaired, but you do not die in a car accident. 𝑝𝑝 ∧ 𝑞𝑞�
• You will die in a car accident if you drive impaired. 𝑝𝑝 → 𝑞𝑞
• If you do not drive impaired, then you will not die in a car accident. 𝑝𝑝̅ → 𝑞𝑞�
• Driving impaired is sufficient for dying in a car accident. 𝑝𝑝 → 𝑞𝑞
• You die in a car accident, but you do not drive impaired. 𝑞𝑞 ∧ 𝑝𝑝̅
• Whenever you die in a car accident, you are driving impaired. 𝑞𝑞 → 𝑝𝑝
Solution
(a) We have 𝑝𝑝 → 𝑞𝑞 ≡ 𝑝𝑝̅ ∨ 𝑞𝑞, therefore its negation using De Morgan’s laws and the double negative law is as follows:
𝑝𝑝 → 𝑞𝑞 ≡ 𝑝𝑝̅ ∨ 𝑞𝑞 ≡ 𝑝𝑝̿ ∧ 𝑞𝑞� ≡ 𝑝𝑝 ∧ 𝑞𝑞,
� which means 𝑝𝑝 and not 𝑞𝑞.
(b) Let 𝑝𝑝 be the proposition “I sleep late at night” and 𝑞𝑞 be the proposition “I can get up early in the morning.” Based on
𝑝𝑝 → 𝑞𝑞� ≡ 𝑝𝑝 ∧ 𝑞𝑞, the negation is “I sleep late at night and I can get up early in the morning.” Note that the negation of an
implication (if-then statement) does not start with the word if.
Solution
Note that in order to avoid any potential confusion in the English language, De Morgan’s laws can be applied if there exist
complete statements on either side of each “and” as well as on either side of each “or.”
(a) My friend is not 2 meters tall or he weighs less than 100 kilograms.
(b) The flight was not delayed and the airport’s clock was not slow.
Solution
We need to show that 𝑝𝑝 ↔ 𝑞𝑞 ↔ 𝑝𝑝 ⊕ 𝑞𝑞 is a tautology, i.e., the last column of the truth table consists of trues only.
Solution
We need to show that the last column of the truth table consists of both truth and false values.
Solution
The statement 𝑥𝑥 > 2 has two parts. The first part is the variable 𝑥𝑥, which is the subject of the statement, and the second part
is the predicate 𝑃𝑃, which denotes “is greater than 2”. The propositional function 𝑃𝑃(𝑥𝑥) denotes the statement 𝑥𝑥 > 2.
Therefore, 𝑃𝑃(0) and 𝑃𝑃(7.2) are both propositional statements, where 𝑃𝑃(0), indicating 0 ≯ 2, is false and 𝑃𝑃(7.2), indicating
7.2 > 2, is true.
Solution
The statement 𝑥𝑥 2 + 𝑦𝑦 2 = 𝑧𝑧 2 has two parts. The first part consists of the variables 𝑥𝑥, 𝑦𝑦, and 𝑧𝑧, and the second part is the
predicate 𝑄𝑄. The propositional function 𝑄𝑄(𝑥𝑥, 𝑦𝑦, 𝑧𝑧) denotes the statement 𝑥𝑥 2 + 𝑦𝑦 2 = 𝑧𝑧 2 . Therefore, 𝑄𝑄(3, 4, 5) and 𝑄𝑄(5, 6, 7)
are both propositional statements, where 𝑄𝑄(3, 4, 5), indicating 9 + 16 = 25, is true and 𝑄𝑄(5, 6, 7), indicating 25 + 36 =
49, is false.
Solution
(a) The statement is true for each element in the domain, that is for 𝑥𝑥 ∈ 1, 2, 3 , as we have 1 = 1, 2 > 2 and 3 > 3.
Hence, ∀𝑥𝑥(𝑥𝑥 ≥ 𝑥𝑥) is true.
(b) The statement is false for at least one element in the domain 𝑥𝑥 ∈ (0, 3]. As a counterexample, if 𝑥𝑥 = 0.49, we then have
0.49 ≥ 0.49 = 0.7, which in turn mean ∀𝑥𝑥(𝑥𝑥 ≥ 𝑥𝑥) is false. In fact, the statement is false for 𝑥𝑥 ∈ (0, 1). Note that to
prove a universal statement is false, a single example is sufficient.
Solution
(a) The statement is false for each element in the domain, that is, for 𝑥𝑥 ∈ 1, 2, 3 , as we have 1 = 1, 2 > 2 and 3 > 3.
Hence, ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is false.
(b) The statement is true for an element in the domain 𝑥𝑥 ∈ (0, 3], as for 𝑥𝑥 = 0.49, we have 0.49 < 0.49 = 0.7. Hence,
∃𝑥𝑥𝑥𝑥(𝑥𝑥) is true. In fact, the statement is true for 𝑥𝑥 ∈ (0, 1). Note that to prove an existential statement is true, a single
example is sufficient.
Solution
In order to prove these two quantified statements are logically equivalent, we need to prove first if ∃𝑥𝑥 𝑃𝑃(𝑥𝑥) ∨ 𝑄𝑄(𝑥𝑥) is true,
then ∃𝑥𝑥𝑥𝑥(𝑥𝑥) ∨ ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is true, and second if ∃𝑥𝑥𝑥𝑥(𝑥𝑥) ∨ ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is true, then ∃𝑥𝑥 𝑃𝑃(𝑥𝑥) ∨ 𝑄𝑄(𝑥𝑥) is true.
First, suppose that ∃𝑥𝑥 𝑃𝑃(𝑥𝑥) ∨ 𝑄𝑄(𝑥𝑥) is true. This means that there exists a 𝑐𝑐 for which 𝑃𝑃(𝑐𝑐) ∨ 𝑄𝑄(𝑐𝑐) is true. Hence, either
𝑃𝑃(𝑐𝑐) or 𝑄𝑄(𝑐𝑐) or both are true. Therefore, either ∃𝑥𝑥𝑥𝑥(𝑥𝑥) or ∃𝑥𝑥𝑥𝑥(𝑥𝑥) or both are true. This means that ∃𝑥𝑥𝑥𝑥(𝑥𝑥) ∨ ∃𝑥𝑥𝑥𝑥(𝑥𝑥) is
true.
Second, suppose that ∃𝑥𝑥𝑥𝑥 𝑥𝑥 ∨ ∃𝑥𝑥𝑥𝑥 𝑥𝑥 is true. This means that either ∃𝑥𝑥𝑥𝑥 𝑥𝑥 or ∃𝑥𝑥𝑥𝑥 𝑥𝑥 or both are true. Hence, there
exists a 𝑐𝑐 for which either 𝑃𝑃 𝑐𝑐 or 𝑄𝑄 𝑐𝑐 or both are true. Therefore, 𝑃𝑃 𝑐𝑐 ∨ 𝑄𝑄 𝑐𝑐 is true. This means that ∃𝑥𝑥 𝑃𝑃(𝑥𝑥) ∨ 𝑄𝑄(𝑥𝑥)
is true.
∀𝑥𝑥𝑥𝑥(𝑥𝑥 ) ≡ ∃𝑥𝑥𝑃𝑃(𝑥𝑥 )
�
∃𝑥𝑥𝑥𝑥 𝑥𝑥 ≡ ∀𝑥𝑥𝑃𝑃(𝑥𝑥 )
Solution
(a) Let 𝑃𝑃(𝑥𝑥) denote “𝑥𝑥 is an odd number” and the domain consists of all prime numbers. Then the statement “all prime
numbers are odd” is represented by ∀𝑥𝑥𝑥𝑥 𝑥𝑥 and its negation is ∃𝑥𝑥𝑃𝑃(𝑥𝑥). This negation can be expressed as “there exists
at least one prime number that is not odd.”
(b) Let 𝑃𝑃(𝑥𝑥) denote “𝑥𝑥 is an honest politician” and the domain consists of all politicians. Then the statement “there is an
honest politician” is represented by ∃𝑥𝑥𝑥𝑥(𝑥𝑥) and its negation is ∀𝑥𝑥𝑃𝑃(𝑥𝑥). This negation can be expressed as “all
politicians are dishonest.”
(c) Let 𝑃𝑃(𝑥𝑥) denote “𝑥𝑥 has empathy” and the domain consists of all rich people. Then the statement “rich people do not have
empathy” is represented by ∀𝑥𝑥𝑃𝑃(𝑥𝑥) and its negation is ∃𝑥𝑥𝑥𝑥(𝑥𝑥). This negation can be expressed as “some rich people
have empathy.”
(d) Let 𝑃𝑃(𝑥𝑥) denote “𝑥𝑥 lives to be 100 years old” and the domain consists of all people. Then the statement “some people do
not live to be 100 years old” is represented by ∃𝑥𝑥𝑃𝑃(𝑥𝑥) and its negation is ∀𝑥𝑥𝑥𝑥(𝑥𝑥). This negation can be expressed as “all
people live to be 100 years old.”
ELEE 2110U Discrete Mathematics 44
Negations of Universal Conditional Statements
Noting that in propositional logic, the negation of an implication is logically equivalent to an “and” statement, namely
𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥) ≡ 𝑃𝑃(𝑥𝑥) ∧ 𝑄𝑄(𝑥𝑥), the negation of a universal conditional statement is thus as follows:
Solution
(a) Let 𝑃𝑃(𝑥𝑥) denote “𝑥𝑥 is a vegetarian” and 𝑄𝑄(𝑥𝑥) denote “𝑥𝑥 is healthy,” where the domain consists of all people. The
statement “every person who is a vegetarian is healthy” is represented by ∀𝑥𝑥 𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥) , and its negation is thus
∃𝑥𝑥(𝑃𝑃(𝑥𝑥) ∧ 𝑄𝑄 𝑥𝑥 ), i.e., there are some people who are vegetarian and not healthy.
(b) Let 𝑃𝑃(𝑥𝑥) denote “𝑥𝑥 weighs more than 100 kg” and 𝑄𝑄(𝑥𝑥) denote “𝑥𝑥 is healthy,” where the domain consists of all people.
The statement “some people weigh more than 100 kg and are not healthy” is represented by ∃𝑥𝑥(𝑃𝑃(𝑥𝑥) ∧ 𝑄𝑄 𝑥𝑥 ), and its
negation is thus ∀𝑥𝑥 𝑃𝑃(𝑥𝑥) → 𝑄𝑄(𝑥𝑥) , i.e., every person who weighs more than 100 kg is healthy.
Solution
(a) This quantification denotes that the proposition “for all real numbers 𝑥𝑥 and all real numbers 𝑦𝑦 , 𝑦𝑦 < 𝑥𝑥 2 .”
It is false, as any point above the graph does not satisfy the inequality.
(b) This quantification denotes that the proposition “for all real numbers 𝑦𝑦 and all real numbers 𝑥𝑥 , 𝑦𝑦 < 𝑥𝑥 2 .”
It is false, as any point above the graph does not satisfy the inequality.
(c) This quantification denotes that the proposition “for every real number 𝑥𝑥, there is a real number 𝑦𝑦, 𝑦𝑦 < 𝑥𝑥 2 .”
It is true, as every vertical line intersecting the region of interest satisfies the inequality.
(d) This quantification denotes that the proposition “for every real number 𝑦𝑦, there is a real number 𝑥𝑥, 𝑦𝑦 < 𝑥𝑥 2 .”
It is true, as every horizontal line intersecting the region of interest satisfies the inequality.
Solution
(a) This quantification denotes that the proposition “there is a real number 𝑥𝑥 , for all real numbers 𝑦𝑦 , 𝑦𝑦 < 𝑥𝑥 2 .”
It is false, as there is no vertical line wholly within the region of interest satisfying the inequality.
(b) This quantification denotes that the proposition “there is a real number 𝑦𝑦 , for all real numbers 𝑥𝑥, 𝑦𝑦 < 𝑥𝑥 2 .”
It is true, as there is a horizontal line wholly within the region of interest satisfying the inequality.
(c) This quantification denotes that the proposition “there is a real number 𝑥𝑥, there is a real number 𝑦𝑦, 𝑦𝑦 < 𝑥𝑥 2 .”
It is true, as any point in the region of interest satisfies the inequality.
(d) This quantification denotes that the proposition “there is a real number 𝑦𝑦, there is a real number 𝑥𝑥, 𝑦𝑦 < 𝑥𝑥 2 .”
It is true, as any point in the region of interest satisfies the inequality.
Solution
(a) Let 𝑥𝑥 and 𝑦𝑦 represents the two real numbers that are added. The logical expression is thus ∀𝑥𝑥∀𝑦𝑦 �� 𝑥𝑥 < 0 ∧
(b) Let 𝑃𝑃(𝑥𝑥, 𝑦𝑦) mean that student 𝑥𝑥 has solved exercise 𝑦𝑦, and 𝑄𝑄(𝑦𝑦, 𝑧𝑧) mean that exercise 𝑦𝑦 is in topic 𝑧𝑧 in this course. The
logical expression is thus ∃𝑥𝑥∀𝑧𝑧∃𝑦𝑦 𝑃𝑃(𝑥𝑥, 𝑦𝑦) ∧ 𝑄𝑄(𝑦𝑦, 𝑧𝑧) .
(c) For every positive number 𝑥𝑥, there exists a real number 𝑦𝑦 such that 𝑦𝑦 = ln 𝑥𝑥.
Solution
(a) The English translation of the statement is as follows: “For every 𝑥𝑥, there exist a 𝑦𝑦 and a 𝑧𝑧, such that 𝑥𝑥𝑥𝑥 > 𝑧𝑧.” It is thus
true.
(b) As the statement ∀𝑥𝑥∃𝑦𝑦∃𝑧𝑧(𝑥𝑥𝑥𝑥 > 𝑧𝑧) involves nested quantifiers, it can be negated by sequentially applying the rules for
negating statements with a single quantifier. The resulting quantification denotes the following proposition:
∀𝑥𝑥∃𝑦𝑦∃𝑧𝑧(𝑥𝑥𝑥𝑥 > 𝑧𝑧) ≡ ∃𝑥𝑥∃𝑦𝑦∃𝑧𝑧 𝑥𝑥𝑥𝑥 > 𝑧𝑧 ≡ ∃𝑥𝑥∀𝑦𝑦∃𝑧𝑧 𝑥𝑥𝑥𝑥 > 𝑧𝑧 ≡ ∃𝑥𝑥∀𝑦𝑦∀𝑧𝑧 𝑥𝑥𝑥𝑥 > 𝑧𝑧 ≡ ∃𝑥𝑥∀𝑦𝑦∀𝑧𝑧(𝑥𝑥𝑥𝑥 ≤ 𝑧𝑧).
The negation of the statement is as follows: “There is an 𝑥𝑥, for all real numbers 𝑦𝑦 and 𝑧𝑧, such that 𝑥𝑥𝑥𝑥 ≤ 𝑧𝑧.” It is thus false.
Solution
Suppose there are 𝑛𝑛 residents in that small town, where 𝑛𝑛 is obviously a positive integer.
The argument contains two hypotheses, which we assume they are both true. The first hypothesis suggests that the number of
days every resident has ever lived is less than 𝑛𝑛 and the second hypothesis suggests that the number of days every resident
has ever lived is at least one.
If no two residents are of the same age, there must be 𝑛𝑛 positive integers less than 𝑛𝑛, which is impossible. Therefore, at least
two residents have been born on the same day. The logical conclusion agrees with the given conclusion, the argument is thus
valid.
Solution
As the truth table reflects, there are critical rows, namely rows 1 and 3, where each row has a false conclusion
𝑟𝑟 → 𝑠𝑠 ⊕ 𝑡𝑡 , but its premises 𝑠𝑠 = 𝑞𝑞 ∨ 𝑟𝑟 and 𝑡𝑡 = 𝑝𝑝 ∧ 𝑟𝑟 are true. Hence this form of argument is invalid.
Solution
(a) All human beings need water to survive. My teacher is a human being. Therefore, my teacher needs water to survive.
Because of the logical necessity of the conclusion, this argument is valid. The argument is valid and its premises are true, the
argument is thus sound.
(b) All birds can fly. Ostriches are birds. Therefore, ostriches can fly. This argument is valid because, assuming the premises
are true, the conclusion must be true. However, the first premise is false. Not all birds can fly. Hence, the argument is valid
but not sound.
Modus ponens (law of attachment): Suppose that the conditional statement “If the weather is nice tonight, then I will go
for a walk” and its hypothesis “The weather is nice tonight” are both true. Then, it follows that the conclusion of the
conditional statement “I will go for a walk” is also true.
Modus tollens (law of contrapositive): Suppose that the conditional statement “If the weather is nice tonight, then I will go
for a walk” is true, but its conclusion, “I will go for a walk,” is false. Then, it follows that the hypothesis “The weather is
nice tonight” is false too.
Hypothetical syllogism (rule of transitivity): As the statements “If a number is divisible by 6, then it is divisible by 3” and
“If a number is divisible by 3, then the sum of its digits is divisible by 3” are both true, the statement “If a number is
divisible by 6, then the sum of its digits is divisible by 3” is also true.
Disjunctive syllogism (rule of elimination): As an example, “Positive integers are either even or odd” and “If a positive
integer is not even, then it must be odd.”
ELEE 2110U Discrete Mathematics 60
Example
Generalization (rule of addition): As an example, “It is sunny today.” Therefore, “it is sunny today or it is cold today.”
Simplification rule: As an example, “It is sunny and cold today.” Therefore, “It is sunny today,” and “It is cold today.”
Conjunction rule: As an example, “All students in a math course have passed the course” and “All students in a physics
course have passed the course” are both true, then “Any student who took both courses has passed them both” is true.
Resolution rule: As an example, if the propositions “Lily is happy or Neda is sad” and “Lily is not happy or Mat is happy”
are both true, then the proposition “Neda is sad or Mat is happy” is true.
Solution
Let’s define these propositions: 𝑝𝑝 as “I am sad tonight,” 𝑞𝑞 as “today is more fun than yesterday,” 𝑟𝑟 as “I will go out,” 𝑠𝑠 as “I
will watch a basketball game on TV,” and 𝑡𝑡 as “I will sleep late.” We can thus construct:
i. 𝑝𝑝̅ ∧ 𝑞𝑞 Premise
ii. 𝑝𝑝̅ Simplification using (i)
iii. 𝑟𝑟 → 𝑝𝑝 Premise
iv. 𝑟𝑟̅ Modus tollens using (ii) and (iii)
v. 𝑟𝑟̅ → 𝑠𝑠 Premise
vi. 𝑠𝑠 Modus ponens using (iv) and (v)
vii. 𝑠𝑠 → 𝑡𝑡 Premise
viii. 𝑡𝑡 Modus ponens using (vi) and (vii)
Solution
Let 𝑈𝑈(𝑥𝑥), 𝑉𝑉(𝑥𝑥), and 𝑊𝑊(𝑥𝑥) be propositions “𝑥𝑥 wrote the exam,” “𝑥𝑥 cheated on the exam,” and “𝑥𝑥 was penalized”,
respectively. Using rules of inference for both propositions and qualified statements, we start off with the two premises:
i. ∃𝑥𝑥 𝑈𝑈 𝑥𝑥 ∧ 𝑉𝑉 𝑥𝑥 Hypothesis
ii. 𝑈𝑈 𝑎𝑎 ∧ 𝑉𝑉 𝑎𝑎 Existential instantiation from (i)
iii. 𝑈𝑈 𝑎𝑎 Simplification from (ii)
iv. ∀𝑥𝑥 𝑈𝑈 𝑥𝑥 → 𝑊𝑊 𝑥𝑥 Hypothesis
v. 𝑈𝑈 𝑎𝑎 → 𝑊𝑊 𝑎𝑎 Universal instantiation from (iv)
vi. 𝑊𝑊(𝑎𝑎) Modus ponens from (iii) and (v)
vii. 𝑉𝑉(𝑎𝑎) Simplification from (ii)
viii. 𝑉𝑉 𝑎𝑎 ∧ 𝑊𝑊 𝑎𝑎 Conjunction from (vi) and (vii)
ix. ∃𝑥𝑥(𝑉𝑉(𝑥𝑥) ∧ 𝑊𝑊(𝑥𝑥)) Existential generalization from (viii)
Solution
(a) Let 𝑃𝑃(𝑥𝑥) and 𝑄𝑄(𝑥𝑥) be the propositions “𝑥𝑥 is human being,” and “𝑥𝑥 is mortal,” respectively, and let 𝑎𝑎 represent Rumi.
Then the argument (∀𝑥𝑥 𝑃𝑃 𝑥𝑥 → 𝑄𝑄(𝑥𝑥)) ∧ 𝑃𝑃(𝑎𝑎) → 𝑄𝑄(𝑎𝑎) is in the form of universal modus ponens and it is therefore
valid.
(b) Let 𝑃𝑃(𝑥𝑥) and 𝑄𝑄(𝑥𝑥) be the propositions “𝑥𝑥 is human being,” and “𝑥𝑥 is mortal,” respectively, and let 𝑎𝑎 represent Rumi.
Then the argument (∀𝑥𝑥 𝑃𝑃 𝑥𝑥 → 𝑄𝑄(𝑥𝑥)) ∧ 𝑄𝑄 𝑎𝑎 → 𝑃𝑃(𝑎𝑎) is in the form of universal modes tollens and it is therefore
valid.
Solution
Definition: A circle is a closed plane curve every point of which is equidistant from a fixed point within the curve.
Axiom: In Euclidean geometry, within a two-dimensional plane, for any given straight line and a point that is not
on the line, there exists exactly one straight line passing through the point that is parallel to the line.
Theorem: If two sides of a triangle are equal, then the angles opposite them are equal.
Corollary: If three sides of a triangle are equal, then all three angles opposite them are equal.
Lemma: If we subtract 1 from a positive integer, then the result is either a positive integer or 0.
𝑥𝑥
Conjecture: If a transformation sends an even integer 𝑥𝑥 to and an odd integer 𝑥𝑥 to 3𝑥𝑥 + 1, then for all positive
2
integers 𝑥𝑥, the repeated application of the transformation will eventually reach integer 1.
Instead of bidirectional statements (if and only if statements), implications (if, then statements) are employed.
Solution
There are two statements 𝑝𝑝1 : 𝑛𝑛 is even, and 𝑝𝑝2 : 𝑛𝑛 − 1 is odd. In order to show they are equivalent, i.e., 𝑝𝑝1 ↔ 𝑝𝑝2 , we need to
prove that 𝑝𝑝1 → 𝑝𝑝2 and 𝑝𝑝2 → 𝑝𝑝1 .
We first prove that if 𝑛𝑛 is even, then 𝑛𝑛 − 1 is odd. If 𝑛𝑛 is even, then 𝑛𝑛 = 2𝑘𝑘 for some integer 𝑘𝑘, and thus 𝑛𝑛 − 1 = 2𝑘𝑘 − 1,
which is odd.
We then prove that if 𝑛𝑛 − 1 is odd, then 𝑛𝑛 is even. If 𝑛𝑛 − 1 is odd, then 𝑛𝑛 − 1 = 2𝑘𝑘 + 1 for some integer 𝑘𝑘, and thus 𝑛𝑛 =
2𝑘𝑘 + 2 = 2(𝑘𝑘 + 1), which is even.
Solution
In order to disprove it, we need a counterexample. When 𝑛𝑛 = 4, we have 24 + 4 = 20, which is not prime.
Solution
Assuming 𝑛𝑛 is odd, i.e., 𝑛𝑛 = 2𝑘𝑘 + 1 for some integer 𝑘𝑘, we have 𝑛𝑛2 = (2𝑘𝑘 + 1)2 = 4𝑘𝑘 2 + 4𝑘𝑘 + 1. Noting that 𝑚𝑚 =
4𝑘𝑘 2 + 4𝑘𝑘 is an even integer as it is a multiple of 4, we can thus conclude that 𝑛𝑛2 = 𝑚𝑚 + 1 is an odd integer.
Solution
By letting 𝑥𝑥 be an arbitrary real number, we need to prove if 𝑥𝑥 is irrational, then 𝑥𝑥 is irrational. Using a proof of
contraposition, we want to prove that if 𝑥𝑥 is not irrational, then 𝑥𝑥 is not irrational or equivalently if 𝑥𝑥 is rational, then 𝑥𝑥 is
𝑚𝑚 𝑚𝑚2
rational. If 𝑥𝑥 is rational, then 𝑥𝑥 = for some integers 𝑚𝑚 and 𝑛𝑛. As a result, we have 𝑥𝑥 = , which is the quotient of
𝑛𝑛 𝑛𝑛2
integers. Hence, 𝑥𝑥 is rational. We just showed the negation of the hypothesis of the original conditional statement is true.
Solution
𝑝𝑝
If 2 is not irrational, then it is rational and can be thus written as the fraction of two integers 𝑝𝑝 and 𝑞𝑞, where we assume is
𝑞𝑞
in lowest terms so 𝑝𝑝 and 𝑞𝑞 are not both even.
𝑚𝑚 𝑚𝑚2
We therefore have 2= → 2= → 𝑚𝑚2 = 2𝑛𝑛2 → 𝑚𝑚2 is even → 𝑚𝑚 is even → 𝑚𝑚 = 2𝑘𝑘 → 𝑚𝑚2 = 2𝑛𝑛2 = 4𝑘𝑘 2 →
𝑛𝑛 𝑛𝑛2
𝑛𝑛2 = 2𝑘𝑘 2 → 𝑛𝑛2 is even → 𝑛𝑛 is even.
We showed that if 2 is not irrational, then both 𝑚𝑚 and 𝑛𝑛 are even, which contradicts our assumption that 𝑚𝑚 and 𝑛𝑛 are not
both even. Therefore, 2 is irrational.
𝑝𝑝𝑛𝑛 ) → 𝑞𝑞 � ↔ 𝑝𝑝1 → 𝑞𝑞 ∧ 𝑝𝑝2 → 𝑞𝑞 ∧ ⋯ ∧ 𝑝𝑝𝑛𝑛 → 𝑞𝑞 can be used as a rule of inference. It is then called proof by cases.
Solution
Using a proof by cases, we consider two mutually exclusive cases for 𝑘𝑘, i.e., 𝑘𝑘 is even and 𝑘𝑘 is odd, as every positive integer
falls into one of these two cases. Assuming 𝑘𝑘 is even, we then have 𝑘𝑘 = 2𝑛𝑛 → 𝑚𝑚 = 𝑘𝑘 3 − 𝑘𝑘 = 𝑘𝑘(𝑘𝑘 + 1)(𝑘𝑘 − 1) =
2𝑛𝑛 2𝑛𝑛 + 1 2𝑛𝑛 − 1 , that is, 𝑚𝑚 is even, as it is a multiple of 2. Assuming 𝑘𝑘 is odd, we then have 𝑘𝑘 = 2𝑛𝑛 + 1 → 𝑚𝑚 = 𝑘𝑘 3 −
𝑘𝑘 = (𝑘𝑘 − 1)𝑘𝑘(𝑘𝑘 + 1) = 2𝑛𝑛 2𝑛𝑛 + 1 2𝑛𝑛 + 2 , that is, 𝑚𝑚 is even, as it is a multiple of 2.
Solution
Since 4𝑚𝑚2 and 9𝑛𝑛2 are both positive, we can conclude 4𝑚𝑚2 < 36 → 2𝑚𝑚 < 6 → 𝑚𝑚 < 3 and 9𝑛𝑛2 < 36 → 3𝑛𝑛 < 6 → 𝑛𝑛 < 2.
Using a proof by exhaustion, this leaves the cases that 𝑚𝑚 =1 or 𝑚𝑚 = 2 as well as 𝑛𝑛 = 1. Neither when we have 𝑚𝑚 = 1 and
𝑛𝑛 = 1 nor when we have 𝑚𝑚 = 2 and 𝑛𝑛 = 1 can make the left-hand side of the equation equal to 36. It is therefore impossible
for 4𝑚𝑚2 + 9𝑛𝑛2 = 36 to hold when 𝑚𝑚 and 𝑛𝑛 are positive integers.