Discrete Mathematics
Discrete Mathematics
Examples
Sets can themselves be elements of other sets e.g., {1, {1}} has two elements i.e., the number 1 and
set {1}.
Symbols of special sets
ℤ+ − Positive integers
ℚ − Rational numbers
ℝ − Real numbers
ℂ − Complex numbers
Recall that 𝑎 < 𝑥 < 𝑏 means that 𝑎 < 𝑥 and 𝑥 < 𝑏 and therefore D consists of all numbers greater
than 5 and less than 2. since there are no such numbers, D has no elements ∴ 𝐷 = ∅.
Subsets
Suppose that every element in a set A is also an element of set B, then A is called a subset of B
written 𝐴 ⊆ 𝐵. The set A is called a subset of B if and only if every element of A is an element of
B. If there is at least one element of A not in B, then A is not a subset of B and we write 𝐴 ⊈ 𝐵 or
𝐵 ⊉ 𝐴.
Example
1. Every set A is a subset of the universal set 𝑈 since by definition all elements of A belong
to U.
2. Every set A is a subset of itself since trivially the elements of A belong to A.
3. If every element of A belongs to B and every element of B belongs to C then clearly every
element of A belongs to C.
4. If 𝐴 ⊆ 𝐵 and 𝐵 ⊆ 𝐴 then 𝐴 = 𝐵 since they have the same elements. Conversely, if 𝐴 = 𝐵
then 𝐴 ≤ 𝐵 and 𝐵 ≤ 𝐴.
Let A and B be sets. When 𝐴 ≤ 𝐵 but 𝐴 ≠ 𝐵, then we say that A is a proper subset of B i.e., 𝐴 ⊂
𝐵. For example, consider 𝐴 = {1, 3}, 𝐵 = {1, 2, 3} and 𝐶 = {1, 3, 2} then 𝐴 ⊂ 𝐵, 𝐴 ⊂ 𝐶 , 𝐵 ⊆ 𝐶
Two sets are said to be disjoint if they have no elements in common. e.g., if 𝐴 = {1, 2, 3} 𝐵 =
{4, 5} then A and B are disjoint.
Note:
Let S be a set. If there are exactly n distinct elements in S where n is non-negative integer, we say
S is a finite set and n is the cardinality of S or length of S denoted |𝑆| e.g., Let 𝑆 =
{𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑎𝑙𝑝ℎ𝑎𝑏𝑒𝑡𝑠} then |𝑆| = 26.
Singleton Set
Set Operations
1. Set Union
The union of two sets A and B denoted by 𝐴 ∪ 𝐵 is the set that contains the elements either in A
or in B or in both i.e., 𝐴 = {𝑥: 𝑥 ∈ 𝐴 𝑜𝑟 𝑥 ∈ 𝐵}. It is shown in the shaded region below;
Given that 𝐴 = {1,2,3} 𝐵 = {1,3,5} then 𝐴 ∪ 𝐵 = {1,2,3,5}
2. Intersection
The intersection of two sets A and B denoted by 𝐴 ∩ 𝐵 is the set containing those elements in both
A and B i.e., 𝐴 ∩ 𝐵 = {𝑥: 𝑥 ∈ 𝐴 𝑎𝑛𝑑 𝑥 ∈ 𝐵}
𝐴−𝐵 ≠𝐵−𝐴
5. Symmetric difference
The symmetric difference of A and B denoted by 𝐴 ⊕ 𝐵 consists of those elements which belong
to A or B but not in both A and B. i.e., 𝐴 ⊕ 𝐵 = {𝐴 ∪ 𝐵\𝐴 ∩ 𝐵} = {𝐴 ∪ 𝐵} − {𝐴 ∩ 𝐵} or 𝐴 ⊕
𝐵 = {𝐴\𝐵 ∪ 𝐵\𝐴} = {𝐴 − 𝐵} ∪ {𝐵 − 𝐴}
Example
If 𝐴 = {1,2,3,4}, 𝐵 = {3,4,5,6,7} and 𝐶 = {6,7,8,9} then;
𝐴 − 𝐵 = {1,2}
𝐵 − 𝐴 = {5,6,7}
𝐵 − 𝐶 = {3,4,5}
𝐶 − 𝐵 = {8,9}
𝐴 − 𝐶 = {1,2,3,4}
𝐶 − 𝐴 = {6,7,8,9}
𝐴 ⊕ 𝐵 = {1,2,5,6,7}
𝐵 ⊕ 𝐶 = {3,4,5,8,9}
𝐴 ⊕ 𝐶 = 𝐴 ∪ 𝐶 = {1,2,3,4,6,7,8,9}
De’Morgans Laws
For all set A and B
i. (𝐴 ∩ 𝐵)𝐶 = 𝐴𝐶 ∪ 𝐵 𝐶
ii. (𝐴 ∪ 𝐵)𝐶 = 𝐴𝐶 ∩ 𝐵 𝐶
Proof
i. Let 𝑥 ∈ (𝐴 ∩ 𝐵)𝐶 then 𝑥 ∉ (𝐴 ∩ B) ⇒ 𝑥 ∉ 𝐴 𝑎𝑛𝑑 𝑥 ∉ 𝐵 ⇒ 𝑥 ∈ 𝐴𝐶 𝑜𝑟 𝑥 ∈ 𝐵 𝐶 ⇒
𝑥 ∈ 𝐴𝐶 ∪ 𝐵 𝐶 .
∴ (𝐴 ∩ 𝐵)𝐶 ⊆ 𝐴𝐶 ∪ 𝐵 𝐶 ………………… (*)
Conversely, let 𝑥 ∈ 𝐴𝐶 ∪ 𝐵 𝐶 ⇒ 𝑥 ∈ 𝐴𝐶 𝑜𝑟 𝑥 ∈ 𝐵 𝐶 ⇒ 𝑥 ∉ 𝐴 𝑎𝑛𝑑 𝑥 ∉ 𝐵 ⇒ 𝑥 ∉
(𝐴 ∩ B) ⇒ 𝑥 ∈ (𝐴 ∩ 𝐵)𝐶 and
∴ 𝐴𝐶 ∪ 𝐵 𝐶 ⊆ (𝐴 ∩ 𝐵)𝐶 ………………… (**)
ii. Let 𝑥 ∈ (𝐴 ∪ 𝐵)𝐶 ⇒ 𝑥 ∉ (𝐴 ∪ B) ⇒ 𝑥 ∉ 𝐴 𝑎𝑛𝑑 𝑥 ∉ 𝐵 ⇒ 𝑥 ∈ 𝐴𝐶 𝑎𝑛𝑑 𝑥 ∈ 𝐵 𝐶 ⇒ 𝑥 ∈
𝐴𝐶 ∩ 𝐵 𝐶 .
∴ (𝐴 ∪ 𝐵)𝐶 ⊆ 𝐴𝐶 ∩ 𝐵 𝐶 ………………… (*)
Next, let 𝑥 ∈ 𝐴𝐶 ∩ 𝐵 𝐶 ⇒ 𝑥 ∈ 𝐴𝐶 𝑎𝑛𝑑 𝑥 ∈ 𝐵 𝐶 ⇒ 𝑥 ∉ 𝐴 𝑜𝑟 𝑥 ∉ 𝐵 ⇒ 𝑥 ∉ (𝐴 ∪ B) ⇒
𝑥 ∈ (𝐴 ∪ 𝐵)𝐶 .
∴ 𝐴𝐶 ∩ 𝐵 𝐶 ⊆ (𝐴 ∪ 𝐵)𝐶 ………………… (**)
Set identities
𝐴∪∅=𝐴 𝐴∩𝑈 = 𝐴 Identity laws
𝐴∪𝐴 =𝐴 𝐴∩∅= ∅ Domination laws
𝐴∪𝐴 =𝐴 𝐴∩𝐴 =𝐴 Idempotent laws
̅̅̅̅̅̅) = 𝐴
(𝐴 Complementation
𝐴∪𝐵 =𝐵∪𝐴 𝐴∩𝐵 =𝐵∩𝐴 Commutative laws
𝐴 ∪ (𝐵 ∪ 𝐶) = (𝐴 ∪ 𝐵) ∪ 𝐶, 𝐴 ∩ (𝐵 ∩ 𝐶) = (𝐴 ∩ 𝐵) ∩ 𝐶 Associative Law
𝐴 ∩ (𝐵 ∪ 𝐶) = (𝐴 ∩ 𝐵) ∪ (𝐴 ∩ 𝐶), 𝐴 ∪ (𝐵 ∩ 𝐶) = (𝐴 ∪ 𝐵) ∩ (𝐴 ∪ 𝐶) Distributive law
̅̅̅̅̅̅̅
𝐴 ∪ 𝐵 = 𝐴̅ ∩ 𝐵̅ , ̅̅̅̅̅̅̅
𝐴 ∩ 𝐵 = 𝐴̅ ∪ 𝐵̅ Demorgans Law
𝐴 ∪ (𝐴 ∩ 𝐵) = 𝐴, 𝐴 ∩ (𝐴 ∪ 𝐵) = 𝐴 Absorption Law
𝐴 ∪ 𝐴̅ = 𝑈, 𝐴 ∩ 𝐴̅ = ∅ Complement Law
Exercise
Prove the distributive law
Cartesian Product
Given two sets A and B, the cartesian product denoted by 𝐴 × 𝐵 (𝐴 𝑐𝑟𝑜𝑠𝑠 𝐵) is the set of all
ordered pairs (𝑎, 𝑏) where 𝑎 ∈ 𝐴 𝑎𝑛𝑑 𝑏 ∈ 𝐵. i.e., 𝐴 × 𝐵 = {𝑎, 𝑏}: 𝑎 ∈ 𝐴 𝑎𝑛𝑑 𝑏 ∈ 𝐵
Example
𝐴 = {1,2}, 𝐵 = {3,4,5}. Find 𝐴 × 𝐵, 𝐵 × 𝐴
Note: 𝐴 × 𝐵 ≠ 𝐵 × 𝐴
The cartesian product of 𝐴 × 𝐵 × 𝐶 consists of all ordered triples (𝑎, 𝑏, 𝑐) such that 𝑎 ∈ 𝐴, 𝑏 ∈
𝐵, 𝑐 ∈ 𝐶.
Given 𝐴 = {0,1}, 𝐵 = {1,2}, 𝐶 = {0,1,2}. Find 𝐴 × 𝐵, (𝐴 × 𝐵) × 𝐶, 𝑎𝑛𝑑 𝐴 × 𝐵 × 𝐶
Exercise
1. List the numbers of the following sets if 𝑃 = {1,2,3 ⋯ }.
a. 𝐴 = {𝑥: 𝑥 ∈ 𝑃, 3 < 𝑥 < 12}
b. 𝐵 = {𝑥: 𝑥 ∈ 𝑃, 4 + 𝑥 = 3}
2. Show that 𝐴 = {2,3,4,5} is not a subset of 𝐵 = {𝑥: 𝑥 ∈ 𝑃; 𝑥 𝑖𝑠 𝑒𝑣𝑒𝑛} where 𝑃 =
{1,2,3 ⋯ }.
3. Show by shading the wanted region on the Venn diagram the following:
(𝐴 ∩ 𝐵)𝐶
𝐴 − (𝐵 ∩ 𝐶)
𝐶
(𝐴 ∪ (𝐵 − 𝐶))
(𝐴 − 𝐵)𝐶
4. Give 𝐴 = {1,2, {3,2}, 7, 8}, 𝐵 = {1,2}, 𝐶 = {3, 2}. Find 𝐴 ∪ (𝐵 ∩ 𝐶)𝐶 , 𝐴 − (𝐵 ∩ 𝐶)
5. Let 𝐴 = {𝑎, 𝑏}, 𝐵 = {1,2}, 𝐶 = {2,3}, 𝐷 = {3,4} 𝑎𝑛𝑑 𝑈 = {1,4,6,8}. Find
∅𝐶 , 𝐴 × (𝐵 ∪ 𝐶), 𝐴 × (𝐵\𝐶) (𝐴 × 𝐶) ∩ (𝐵 × 𝐷)
LOGICS
Proposition and Compound Statements
A proposition or statement is a declaration sentence that is either true or false but not both.
Example
1. Nairobi is the capital of Kenya – True, T
2. 1 + 1 = 2 – True, T
3. 8 < 5 – False, F
4. 2 + 3 = 6 – False, F
Some sentences are not propositions e.g.,
1. What is your name?
2. What time is it?
3. 𝑥+4=2
4. 𝑥+𝑦 =𝑧
5. Read this correctly.
1,2,5 are not propositions – are not declarative. 3,4 are not propositions since they are neither true
nor false – no values assigned. Letters are used to denoted propositions just as they are used to
denote variables. The convenient letters used are 𝑝, 𝑞, 𝑟, 𝑠 ⋯
If a proposition is true, its truth value id denoted by T and if it is false, its truth value if false
denoted by F. the area of logics that deals with propositions is called propositional calculus or
proportional logic.
A compound proposition is one that is composed of sub propositions and various connectives or
logical operators.
Example
1. Roses are red and violets are blue
2. John is intelligent or studies every night.
The truth value of a compound proposition is determined by the truth values of its sub propositions
together with the way they are connected.
Basic logical operators and their connectives
Operation Logical Operator/ Connective Symbol
Negation Not ¬ 𝑜𝑟~
Conjunction And ∧
Disjunction Or ∨
¬𝑃 𝑜𝑟 ~𝑃 is read as “not P”
1. Negation
Given any proposition P, the negation of P denoted by ¬𝑃 𝑜𝑟 ~𝑃 can eb formed by writing; “it is
not the case that P”, “it is false that P” or if possible, it can be written by inserting in P the word
“not”.
Example
a. Find the negation of “Nairobi is in Kenya”
Solution
It is not the case that Nairobi is in Kenya or it is false that Nairobi is in Kenya or Nairobi is not in
Kenya.
b. Today is Friday
Solution
It is not the case that today is Friday or it is false that today id Friday or Today is not Friday.
The truth value of the negation of P is always opposite that of P and the table is as below.
p ~𝑝
T F
F T
A truth table displays the relationship between the truth values of propositions. They are especially
valuable in the determination of the truth values of propositions constructed from simple
propositions.
2. Conjunction
If p and q are propositions, the conjunction of p and q denoted by 𝑝 ∧ 𝑞 is the proposition “p and
q”. the conjunction 𝑝 ∧ 𝑞 is true when and only when both p and q are true and is false otherwise.
Table;
p q 𝑝∧𝑞
T T T
T F F
F T F
F F F
Note that “p but q” means “p and q” e.g., He is tall but plump means he is tall and plump. Neither
p nor q means not p and not q i.e., ~𝑝 and ~𝑞.
3. Disjunction
If p and q are propositions, the disjunction of p and q denoted by 𝑝 ∨ 𝑞 is the proposition “p or q”.
the disjunction 𝑝 ∨ 𝑞 are false otherwise it is false. The truth table is as below;
p q 𝑝∨𝑞
T T T
T F T
F T T
F F F
4. Exclusive
Let p and q be propositions, the exclusive of p and q denoted by 𝑝 ⊕ 𝑞 is the proposition that is
true when exactly one of p and q is true and is false otherwise.
Truth table
p q 𝑝⊕𝑞
T T F
T F T
F T T
F F F
Exercise
Construct truth tables for;
(𝑝 ∨ 𝑞) ∨ 𝑟 (𝑝 ∨ 𝑞) ∧ 𝑟 (𝑝 ∧ 𝑞) ∨ 𝑟 (𝑝 ∧ 𝑞) ∧ 𝑟 (𝑝 ∧ 𝑞) ∨∼ 𝑟 (𝑝 ∧ 𝑞) ∨∼ 𝑟
Tautologies and Contradictions
A tautology is a compound proposition that is true for any truth value of its variables. A
contradiction is a compound proposition that is always false. A contingency is a compound
proposition that is neither a tautology nor a contradiction.
Example
1. ‘p or not p’ is a tautology e.g., he is short or not short.
p ~𝑝 𝑝 ∨∼ 𝑝
T F T
F T T
LOGICAL EQUIVALENCE
Two propositions p and q are said to be logically equivalent denoted 𝑝 ≡ 𝑞 or 𝑝 ⟺ 𝑞 if and only
if the columns giving their truth values agree or have identical values.
Example
~(𝑝 ∧ 𝑞) ≡∼ 𝑝 ∨∼ 𝑞
~(𝑝 ∨ 𝑞) ≡∼ 𝑝 ∧∼ 𝑞
p q 𝑝∧𝑞 ∼ (𝑝 ∧ 𝑞) ∼𝑝 ∼𝑞 ∼ 𝑝 ∨∼ 𝑞
T T T F F F F
T F F T F T T
F T F T T F T
F F F T T T T
Exercise
1. Show that ~(𝑝 ∨ 𝑞) ≡∼ 𝑝 ∧∼ 𝑞.
2. Use the truth table to verify the associative laws
i. (𝑝 ∨ 𝑞) ∨ 𝑟 ≡ 𝑝 ∨ (𝑞 ∨ 𝑟)
ii. (𝑝 ∧ 𝑞) ∧ 𝑟 ≡ 𝑝 ∧ (𝑞 ∧ 𝑟)
3. Use the truth tables to verify the distributive laws (𝑝 ∧ 𝑞) ∨ 𝑟 ≡ (𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑟).
Example
Show that (𝑝 ∨ 𝑞) ∧ 𝑟 and (𝑝 ∨ 𝑞) ∧ (𝑝 ∨ 𝑟) are logically equivalent.
Solution
p q r 𝑞∧𝑟 𝑝∨𝑞 𝑝∨𝑟 𝑝 ∨ (𝑞 ∧ 𝑟) (𝑝 ∨ 𝑞) ∧ (𝑝 ∨ 𝑟)
T T T T T T T T
T T F F T T T T
T F T F T T T T
T F F F T T T T
F T T T T T T T
F T F F T F F F
F F T F F T F F
F F F F F F F F
Exercise
Use the truth tables to show that the following propositions are tautologies.
a. [∼ 𝑝 ∧ (𝑝 ∨ 𝑞)] → 𝑞
b. [(𝑝 → 𝑞) ∧ (𝑞 → 𝑟)] → (𝑝 → 𝑟)
c. [𝑝 ∧ (𝑝 → 𝑞)] → 𝑞
d. [(𝑝 ∨ 𝑞) ∧ (𝑝 → 𝑟) ∧ (𝑞 → 𝑟)] → 𝑟
e. [∼ (𝑝 → 𝑞)] ⟺ [𝑝 ∧ (∼ 𝑞)]
f. [𝑝 ∨ (𝑞 ∨ 𝑟)] ⟺ [(𝑝 ∨ 𝑞) ∨ 𝑟]
g. [𝑝 ∧ (𝑞 ∨ 𝑟)] ⟺ [(𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑟)]
h. [(𝑝 → 𝑞) ∧ (𝑞 → 𝑟)] → (𝑝 → 𝑟)
Logical Equivalence
Equivalence Name
𝑝∧𝑇 ≡𝑝 Identity Laws
𝑝∨𝐹 ≡𝑝
𝑝∨𝑇 ≡𝑇 Domination laws
𝑝∧𝐹 ≡𝐹
𝑝∨𝑝 ≡𝑝 Idempotent laws
𝑝∧𝑝 ≡𝑝
∼ (∼ 𝑝) ≡ 𝑝 Double negation law
𝑝∨𝑞 ≡𝑞∨𝑝 Commutative law
𝑝∧𝑞 ≡𝑞∧𝑝
(𝑝 ∨ 𝑞) ∨ 𝑟 ≡ 𝑝 ∨ (𝑞 ∨ 𝑟) Associative law
(𝑝 ∧ 𝑞) ∧ 𝑟 ≡ 𝑝 ∧ (𝑞 ∧ 𝑟)
(𝑝 ∧ 𝑞) ∧ 𝑟 ≡ 𝑝 ∧ (𝑞 ∧ 𝑟)
𝑝 ∨ (𝑞 ∧ 𝑟) ≡ (𝑝 ∨ 𝑞) ∧ (𝑝 ∨ 𝑟) Distributive law
𝑝 ∧ (𝑞 ∨ 𝑟) ≡ (𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑟)
∼ (𝑝 ∧ 𝑞) ≡∼ 𝑝 ∨∼ 𝑞 Demorgans laws
∼ (𝑝 ∨ 𝑞) ≡∼ 𝑝 ∧∼ 𝑞
𝑝 ∨ (𝑝 ∧ 𝑞) ≡ 𝑝 Absorption laws
𝑝 ∧ (𝑞 ∨ 𝑟) ≡ 𝑝
𝑝 ∨∼ 𝑝 ≡ 𝑇 Negation laws
𝑝 ∧∼ 𝑝 ≡ 𝐹
NUMBERS
Set of numbers
The set of numbers can be represented in a Venn diagram as below;
Notations
ℕ = {1,2,3, ⋯ } - Natural or counting numbers
ℤ = {⋯ , −2, −1,0,1,2, ⋯ } - Integers
𝑝 𝑝
ℚ = {𝑞 : 𝑝, 𝑞 ∈ ℤ, 𝑞 ≠ 0} – Irrational numbers i.e., numbers that can be written as 𝑞 where p and q
are integers, 𝑞 ≠ 0 and the gcd of p and q, (𝑝, 𝑞) = 1.
𝑝
ℚ𝐶 are numbers that cannot be written as e.g., 𝑒, 𝜋, √2, ⋯
𝑞
Intervals
Let a and b be distinct numbers with say 𝑎 < 𝑏. The intervals with points a and b are defined as
follows;
(𝑎, 𝑏) = {𝑥: 𝑎 < 𝑥 < 𝑏} – open interval
[𝑎, 𝑏] = {𝑥: 𝑎 ≤ 𝑥 ≤ 𝑏} – closed interval
(𝑎, 𝑏] = {𝑥: 𝑎 < 𝑥 ≤ 𝑏} – open – closed interval
[𝑎, 𝑏) = {𝑥: 𝑎 ≤ 𝑥 < 𝑏} – closed open interval
Example
Find all integers n such that 2𝑛 < 8 − 3𝑛 < 18
Solution
2𝑛 < 8 − 3𝑛 < 18 ⇒ 2𝑛 < 8 − 3𝑛 𝑎nd 8 − 3𝑛 < 18
5𝑛 < 8 −3𝑛 < 10
𝑛 < 1.6 and 𝑛 > −3.3
⇒ −3.3 < 𝑛 < 1.6
⇒ 𝑛 = −3, −2, −1,0,1
Exercise
1. Find the distance between each pair of integers below;
a. 3 and 7 b. -8 and -5 c. 1 and 9 d. -14 and 6 e. 16 and 7.
2. Find the integers x such that 6 < 2𝑥 − 6 < 14
3. Rewrite each interval below using the set builder notation.
a. [-3,8) b. (3,8) c. (4,9] d. [-4,-2]
Examples
1. Prove that if 𝑎 ≤ 𝑏 and 𝑏 ≤ 𝑐 then 𝑎 ≤ 𝑐
Proof:
The proposition is true when 𝑎 = 𝑏 or 𝑏 = 𝑐 thus we need only to consider the case when 𝑎 < 𝑏
and 𝑏 < 𝑐. By proposition 1, if 𝑎 < 𝑏 and 𝑏 < 𝑐 then 𝑏 − 𝑎 and 𝑐 − 𝑏 are positive. The sum is
also positive. i.e.,
(𝑏 − 𝑎) + (𝑐 − 𝑏) > 0
𝑏−𝑎+𝑐−𝑏 > 0
𝑐−𝑎 >0
⇒ 𝑐 > 𝑎 and hence 𝑎 ≤ 𝑐.
2. Write the interval 2 < 𝑥 < 10 in the form |𝑥 − 𝑎| < 𝑟
Solution
Here, a will be the “center” and r the “radius” of the interval i.e., a is the midpoint and r is half the
length of the interval. Thus;
10+2
𝑎= =6 sum of ends and divide by 2
2
10−2
𝑟= =4 find d and divide by 2
2
∴ 2 < 𝑥 < 10 = |𝑥 − 6| < 4
3. Write the interval −7 < 𝑥 < 3 in the form |𝑥 − 𝑎| < 𝑟
Solution
−7 + 3
𝑎= =2
2
3 − (−7)
𝑟= =5
2
∴ −7 < 𝑥 < 3 = |𝑥 − 2| < 5
FUNCTIONS
A function f from a set A to a set B is a relation between elements of A and B with the property
that each input (element of A) is related to one and only one output (element of B).
Solution
a. 𝐷𝑜𝑚 𝑓 = {𝑎, 𝑏, 𝑐}, 𝑐𝑜 − 𝑑𝑜𝑟𝑚𝑎𝑖𝑛 𝑜𝑓 𝑓 = {1,2,3,4}
b. 𝑓(𝑎) = 2, 𝑓(𝑏) = 4, 𝑓(𝑐) = 2
c. Range of f={2,4}
d. Pre image of 1= ∅, 4 = {𝑏}
2. Let 𝑓: ℤ → ℤ+ be defined by 𝑓(𝑥) = 𝑥 2 . Find the domain, codomain and range of f
Solution
Domain = ℤ, set of all integers
Codomain = ℤ+ , set of all positive integers
Range = {0,1,4,9,16, ⋯ }, the set of all integers that are perfect squares.
A function f is said to be 1 – 1 (injective) if it never assigns the same value to two different domain
elements. Let f be a function from a set X to a set Y, f is 1 – 1 or injective iff for all elements 𝑥1
and 𝑥2 in X; if 𝑓(𝑥1 ) = 𝑓(𝑥2 ) 𝑡ℎ𝑒𝑛 𝑥1 = 𝑥2 𝑜𝑟 𝑖𝑓 𝑥1 ≠ 𝑥2 , 𝑡ℎ𝑒𝑛 𝑓(𝑥1 ) ≠ 𝑓(𝑥2 )
Example
Solution
𝑓(𝑥) = 𝑥 2 is not 1 – 1 because for instance 𝑓(1) = 1 and 𝑓(−1) = 1 yet 1 ≠ −1.
2. Determine whether the function f from {a, b, c, d} to {1, 2, 3, 4, 5} with 𝑓(𝑎) = 4, 𝑓(𝑏) =
5, 𝑓(𝑐) = 1 𝑎𝑛𝑑 𝑓(𝑑) = 3 is 1 – 1.
Solution
The function is 1 – 1 since f takes on different values at the four elements of its domain.
3. Determine whether 𝑓(𝑥) = 𝑥 + 1 is 1 – 1
Solution
Onto function
A function is said to be onto (surjective) if every member of the codomain is an image of some
element of the domain. Let f be a function from a set X to a set Y, f is onto iff given any element
𝑦 ∈ 𝑌, it is possible to find an element 𝑥 ∈ 𝑋 with the property 𝑦 = 𝑓(𝑥).
Examples
Solution
2. Let f be the function from {a, b, c, d} to {1, 2, 3} defined by 𝑓(𝑎) = 3, 𝑓(𝑏) = 2, 𝑓(𝑐) =
1, 𝑓(𝑑) = 3. Is f onto?
Solution
Since all three elements of the codomain are images of elements in the domain, f is onto.
Solution
The function is onto since for every integer y, there is an integer x such that 𝑓(𝑥) = 𝑦. Note that
𝑓(𝑥) = 𝑦 iff 𝑥 + 1 = 𝑦 ⇒ 𝑖𝑓 𝑥 = 𝑦 − 1.
Bijective (one to one and onto) functions
Example
the function f is 1 – 1. It is also onto and therefore it is a 1 – 1 and onto i.e., a bijection.
Inverse Functions
If f is a bijection from a set X to a set Y, then the inverse of f, 𝑓 −1 is the function from Y to X that
sets each element of Y back to the element of X that it came from. i.e., if 𝑓(𝑥) = 𝑦 then 𝑓 −1 (𝑦) =
𝑥.
Examples
a. 𝑓(𝑥) = 4𝑥 − 1
Solution
𝑦 = 4𝑥 − 1
4𝑥 = 𝑦 + 1
𝑦+1
𝑥=
4
𝑥+1
Replace x with 𝑓 −1 (𝑥) and y with x to get 𝑓 −1 (𝑥) = 4
b. 𝑓(𝑥) = 2𝑥 + 3
3−𝑦
𝑦 = 2𝑥 + 3 ⇒ 2𝑥 = 3 − 𝑦 ⇒ 𝑥 =
2
3−𝑦
𝑓 −1 (𝑥) =
2
c. Given 𝑓(𝑥) = 3𝑥 2 + 4, find 𝑓(2), 𝑓 −1 (𝑥), 𝑓 −1 (7)
𝑓(2) = 3(22 ) + 4 = 16
𝑦−4 𝑦−4
𝑦 = 3𝑥 2 + 4 ⇒ 3𝑥 2 = 𝑦 − 4 ⇒ 𝑥 2 = ⇒𝑥=√
3 3
𝑥−4
𝑓 −1 (𝑥) = √
3
7−4
𝑓 −1 (7) = √ = ±1
3
d. Let f be the function from {a, b, c} to {1, 2, 3} such that 𝑓(𝑎) = 2, 𝑓(𝑏) = 3 𝑎𝑛𝑑 𝑓(𝑐) =
1. Is f invertible and if it is, what is its inverse?
Solution
The function is a bijection since it is both 1 – 1 and onto and therefore invertible. The inverse
function 𝑓 −1 reverses the correspondence given by f so that 𝑓 −1 (1) = 𝑐, 𝑓 −1 (2) = 𝑎, 𝑓 −1 (3) =
𝑏.
Addition and Multiplication and composition of functions
Let 𝑓1 and 𝑓2 be functions from A to B. then 𝑓1 + 𝑓2 and 𝑓1 𝑓2 are also functions from A to B defined
by;
(𝑓1 + 𝑓2 )𝑥 = 𝑓1 (𝑥) + 𝑓2 (𝑥)
(𝑓1 𝑓2 )𝑥 = 𝑓1 (𝑥)𝑓2 (𝑥)
Let g be a function from set A to B and let f be a function from set B to C. the composition of the
functions f and g denoted by (𝑓 ∘ 𝑔)𝑥 = 𝑓(𝑔(𝑥)).
Example
Let 𝑓(𝑥) = 𝑥 2 , 𝑔(𝑥) = 𝑥 − 𝑥 2 find;
a. 𝑓(𝑥) + 𝑔(𝑥) b. (𝑓𝑔)𝑥 c. (𝑓 ∘ 𝑔)𝑥 d. (𝑔 ∘ 𝑓)𝑥
Solution
a. 𝑓(𝑥) + 𝑔(𝑥) = 𝑥 2 + 𝑥 − 𝑥 2 = 𝑥
b. (𝑓𝑔)𝑥 = 𝑥 2 (𝑥 − 𝑥 2 ) = 𝑥 3 − 𝑥 4
c. (𝑓 ∘ 𝑔)𝑥 = 𝑓(𝑔(𝑥)) = 𝑓(𝑥 − 𝑥 2 ) = (𝑥 − 𝑥 2 ) 2 = 𝑥 2 − 2𝑥 3 + 𝑥 4
d. (𝑔 ∘ 𝑓)𝑥 = 𝑔(𝑓(𝑥)) = 𝑔(𝑥 2 ) = 𝑥 2 − (𝑥 2 )2 = 𝑥 2 − 𝑥 4
Examples
1
1. Given that 𝑓(𝑥) = 2 𝑥 + 4, 𝑔(𝑥) = 𝑥 − 5. Show that (𝑓 ∘ 𝑔)−1 (𝑥) = (𝑔−1 ∘ 𝑓 −1 )𝑥.
1
2. Given that 𝑓(𝑥) = 2𝑥 + 3, 𝑔(𝑥) = 3 𝑥 find
a. (𝑓 ∘ 𝑔)−1 (𝑥) b. (𝑔 ∘ 𝑓)−1 (𝑥)
1
3. If 𝑓(𝑥) = 3𝑥, 𝑔(𝑥) = 2𝑥 + 4, ℎ(𝑥) = 4 𝑥, find
a. (𝑓 ∘ 𝑔 ∘ ℎ)(𝑥) b. (𝑔 ∘ 𝑓 ∘ ℎ)𝑥 (ℎ ∘ 𝑔 ∘ 𝑓)𝑥
−1 (𝑥) −1
(𝑓
4. Show that ∘ 𝑔 ∘ ℎ) = (ℎ ∘ 𝑔 ∘ 𝑓 −1 )𝑥
−1
METHODS OF PROOF AND ELEMENTARY NUMBER THEORY
Proofs in mathematics are valid arguments that establish the truth of a mathematical statement of
formula. An argument is a sequence of statements that end with a conclusion. An argument is valid
iff it is impossible for all premises to be true and the conclusion false. Proofs in computer science
are used in;
Definitions
The set of natural numbers ℕ is said to be closed under + and × i.e., if a and b are natural numbers,
then 𝑎 + 𝑏 and 𝑎 × 𝑏 are also natural numbers. The set of integers ℤ is closed under +,× 𝑎𝑛𝑑 −
but not under ÷.
There are two types of integers; odd and even. An integer n is said to be even iff ∃ an integer k
such that 𝑛 = 2𝑘. An integer n is said to be odd iff ∃ an integer k such that 𝑛 = 2𝑘 + 1. r is a
𝑎
rational number if ∃ integers a and b such that 𝑟 = 𝑏 , 𝑏 ≠ 0 𝑎𝑛𝑑 (𝑎, 𝑏) = 1.
If n and d are integers, then n is divisible by d iff 𝑛 = 𝑘𝑑 for some integer k. We say ‘d divides n’
𝑑
and write 𝑛.
Methods of Proof
1. Direct Proof
This method makes use of axioms or postulate i.e., statements assumed to be true. to proof a
conditional statement, 𝑝 → 𝑞, we assume that p is true and then proceed to show that q must also
be true.
Example
a. Show that if m and n are even numbers, then their sum is even
Solution
We assume that m and n are even i.e., 𝑚 = 2𝑘, 𝑛 = 2𝑙 for integers k and l. then 𝑚 + 𝑛 = 2𝑘 +
2𝑙 = 2(𝑘 + 𝑙); let 𝑘 + 𝑙 = 𝑠 which is an integer, then 𝑚 + 𝑛 = 2𝑠 hence even.
b. Give a direct proof of the theorem, ‘if n is odd, then 𝑛2 is also odd”
Proof
𝑛2 = (2𝑘 + 1)2
= 4𝑘 2 + 4𝑘 + 1
= 2(2𝑘 2 + 2𝑘) + 1
Exercise
Proof that the sum of two odd numbers is even while the product is odd
2. Proof by Contradiction
We assume that the opposite of what we want to proof, show that the assumption leads to a
contradiction and then conclude that what was supposed to be proved must have been true.
Example
Solution
Suppose that there exists and integer n that is both even and odd, then
2𝑘 = 2𝑏 + 1
2(𝑘 − 𝑏) = 1 since 𝑘, 𝑏 ∈ ℤ then 𝑘 − 𝑏 = 𝑐 ∈ ℤ ⇒ 2(𝑘 − 𝑏) = 2𝑐 = 1 i.e., 1 is even. This is a
contradiction since 1 is odd. Therefore, the assumption that n is both even and odd is false and
hence the theorem must be true.
b. Prove that √2 is irrational.
Proof
𝑎
Suppose that √2 is irrational, then √2 = 𝑏 where 𝑎, 𝑏 ∈ ℤ, 𝑏 ≠ 0 𝑎𝑛𝑑 (𝑎, 𝑏) = 1 i.e., a and b do
not have another divisor other than 1.
𝑎2
⇒ 𝑏2 = 2 ⇒ 𝑎2 = 2𝑏 2 i.e., 𝑎2 is even ⇒ 𝑎 is even ⟹ 𝑎 = 2𝑘 𝑎𝑛𝑑 𝑎2 = 4𝑘 2 ⇒ 2𝑏 2 =
4𝑘 2 𝑜𝑟 𝑏 2 = 2𝑘 2 ⇒ 𝑏 2 is even and b is even. i.e., both a and b are even a contradiction since
gcd(𝑎, 𝑏) = 1 and therefore √2 is irrational.
Exercise
Solution
Assume 3𝑛 + 2 is odd and that n is not odd so that n is even, then 𝑛 = 2𝑘 ∀ 𝑘 ∈ ℤ. It follows that
3𝑛 + 2 = 3(2𝑘) + 2 = 6𝑘 + 2 = 2(3𝑘 + 1) is even since it is a multiple of 2 and therefore not
odd. This is contradicting the assumption that 3𝑛 + 2 is odd.
This method is used only for those statements that are universal and conditional. To prove by
contraposition;
Example
Solution
4. Proof by Induction
This method is used to prove the statements that assert that 𝑝(𝑛) is true for all positive integers n
where 𝑝(𝑛) is a propositional function (predicate) i.e., ∀ 𝑛, 𝑝(𝑛). A proof by this method has 2
main steps.
To complete the inductive step, we assume that p(k) is true for any arbitrary integer k and show
that under this assumption, 𝑝(𝑘 + 1) must be true i.e., 𝑝(𝑘) ⟶ 𝑝(𝑘 + 1) is true.
Examples
𝑛(𝑛+1)
a. Show that if n is a positive integer, then 1 + 2 + 3 + ⋯ + 𝑛 = .
2
Solution
𝑛(𝑛+1)
Let p(n) be the proposition, “sum of first n positive integers is .” i.e., 𝑝(𝑛) ⟹ 1 + 2 + 3 +
2
𝑛(𝑛+1)
⋯+ 𝑛 = 2
1(1+1)
Then 𝑝(1) ⟹ 1 = = 1 is true.
2
Now, assume 𝑝(𝑘) is true for any arbitrary integer k and show that 𝑝(𝑘 + 1) is true.
𝑘(𝑘+1)
𝑝(𝑘) ⟹ 1 + 2 + 3 + ⋯ + 𝑘 = ……………(i)
2
Replacing k with k+1, we get
(𝑘+1)((𝑘+1)+1) (𝑘+1)(𝑘+2)
1 + 2 + 3 + ⋯+ 𝑘 + 1 = = ………………(ii)
2 2
The RHS of (ii) and (iii) are similar and therefore 𝑝(𝑘 + 1) is true. therefore p(n) is true for all
integers.
Solution
𝑝(1) = 1 = 12 is true.
The RHS of the above two statements are similar and therefore 𝑝(𝑘 + 1) is true. since 𝑝(1) is true
and 𝑝(𝑘) → 𝑝(𝑘 + 1) is true, then by induction, p(n) is true ∀ 𝑛 ∈ ℤ.
Solution
Solution
3
Let 𝑝(𝑛): 3⁄𝑛3 − 𝑛. By division algorithm, 𝑝(0) = 0 which is true since 0 = 3 × 0
e. Use mathematical induction to prove that 2𝑛 < 𝑛! for every positive integer 𝑛 ≥ 4.
Solution
𝑝(4) = 24 < 4!
16 < 24 true
Let 𝑝(𝑘) = 2𝑘 < 4! Be true. we show that 𝑝(𝑘 + 1): 2𝑘+1 < (𝑘 + 1)!
Now
𝑝(𝑘) = 2𝑘 + 1 < 2𝑘 , 𝑘 ≥ 3
We must show that 2𝑛 + 1 < 2𝑛 is true for 𝑛 = 𝑘 + 1 i.e., 2(𝑘 + 1) + 1 < 2(𝑘+1) 𝑜𝑟 2𝑘 + 3 <
2(𝑘+1) .
Now,
2𝑘 + 3 = (2𝑘 + 1) + 2 by algebra
< 2(2𝑘 )
Exercise
a. 22𝑛−1 is dividible by 3 ∀ 𝑛 ≥ 1
𝑛(𝑛+1)(2𝑛+1)
b. 1 + 22 + 32 + ⋯ + 𝑛2 = 6
c. 2 + 4 + 6 + 8 + ⋯ + 2𝑛 = 𝑛(𝑛 + 1)
d. 𝑛3 − 𝑛 is divisible by 6 for each integer 𝑛 ≥ 2
e. 2𝑛 < (𝑛 + 2)! ∀ 𝑛 ≥ 0, 𝑛 ∈ ℤ