Discrete Paper 2
Discrete Paper 2
Okay, I've reformatted and refined your markdown notes for Discrete Mathematics. I've paid
special attention to mathematical equations using LaTeX, ensured Mermaid diagrams are
correctly formatted, and aimed for overall clarity and consistency in the markdown structure.
and if these two tasks cannot be done at the same time (mutually exclusive),
then there are n + n ways to do either task.
1 2
This extends to more than two tasks. If there are k tasks, and task i can be done in
n ways, and no two tasks can be done simultaneously, then the number of ways to
i
ways to do the first task and for each of these ways, there are n ways to do the
2
preceding tasks have been done), then the total number of ways to perform the
entire sequence of tasks is n 1
× n2 × ⋯ × nk .
Keywords: "AND", "sequence of tasks" often suggest the Product Rule.
Example: If a restaurant offers 5 appetizers and 10 main courses, then a two-course
meal consisting of one appetizer AND one main course can be ordered in
5 × 10 = 50 ways.
ways are counted in both n and n ), then the total number of ways is
1 2
intersection).
This is used when tasks are not mutually exclusive.
Example: How many positive integers not exceeding 100 are divisible by 5 or by 7?
Divisible by 5 (|A|): 100/5 = 20
Divisible by 7 (|B|): ⌊100/7⌋ = 14
Divisible by both 5 and 7 (i.e., by 35) (|A ∩ B|): ⌊100/35⌋ = 2
Total = |A| + |B| − |A ∩ B| = 20 + 14 − 2 = 32.
4. Permutations (Order Matters):
A permutation is an ordered arrangement of objects.
The number of permutations of n distinct objects taken r at a time is denoted by
P (n, r) or nP r.
n!
P (n, r) =
(n − r)!
where n! = n × (n − 1) × (n − 2) × ⋯ × 1.
If all n objects are arranged (r = n), then P (n, n) = n!.
Example: How many ways can 3 distinct books be arranged on a shelf from a set of
5 distinct books?
P (5, 3) =
5!
(5−3)!
=
5!
2!
=
5×4×3×2×1
2×1
=
120
2
= 60 ways.
n!
C(n, r) =
r! × (n − r)!
P (n,r)
C(n, r) =
r!
Example: How many ways can a committee of 3 people be chosen from a group of 5
people?
C(5, 3) =
5!
3!×(5−3)!
=
5!
3!×2!
=
5×4×3×2×1
(3×2×1)×(2×1)
=
120
6×2
=
120
12
= 10 ways.
6. Permutations with Repetitions (Distinguishable Permutations):
The number of distinct permutations of n objects where there are n identical objects 1
n!
n1 ! × n2 ! × ⋯ × nk !
where n = n 1 + n2 + ⋯ + nk .
Example: How many distinct permutations of the letters in the word "MISSISSIPPI"?
Total letters (n) = 11
M = 1 (n 1 = 1 )
I = 4 (n 2
= 4 )
S = 4 (n 3 = 4 )
P = 2 (n 4 = 2 )
Number of permutations = 11!
1!×4!×4!×2!
=
39916800
1×24×24×2
=
39916800
1152
.
= 34650
(n + r − 1)!
C(n + r − 1, r) =
r! × (n − 1)!
Example: How many ways to choose 5 cookies from 3 types of cookies (chocolate,
oatmeal, peanut butter), if there are at least 5 of each type?
n = 3 (types of cookies), r = 5 (cookies to choose)
C(3 + 5 − 1, 5) = C(7, 5) =
7!
5!×2!
=
7×6
2×1
=
42
2
= 21 ways.
Visual Aids 📊
1. Decision Tree for Sum vs. Product Rule
This diagram helps decide when to use the Sum or Product Rule based on the task
structure.
Start: Considering a
Task/Procedure
Yes No
Note: To view these Mermaid diagrams, use a Markdown viewer that supports Mermaid,
such as GitHub, GitLab, or Obsidian with the Mermaid plugin enabled. You can also copy the
code into https://mermaid.live/ to preview.
Examples 💡
1. Sum Rule: A student can choose to take a course in either Math (4 options) OR Physics
(3 options). Total choices = 4 + 3 = 7.
2. Product Rule: To travel from city A to city C via city B, there are 3 routes from A to B and
2 routes from B to C. Total routes from A to C = 3 × 2 = 6.
3. Permutation: How many 3-letter words (meaningful or not) can be formed from the
letters P, Q, R without repetition?
P (3, 3) = 3! = 3 × 2 × 1 = 6 (PQR, PRQ, QPR, QRP, RPQ, RQP)
4. Combination: How many ways to choose 2 fruits from apples, bananas, and oranges?
= 3 (Apple-Banana, Apple-Orange, Banana-Orange). Order doesn't
3!
C(3, 2) =
2!×1!
matter.
5. Inclusion-Exclusion: In a group of 25 people, 15 like tea, 12 like coffee, and 5 like both.
How many like either tea or coffee?
.
|Tea ∪ Cof f ee| = |Tea| + |Cof f ee| − |Tea ∩ Cof f ee| = 15 + 12 − 5 = 22
Step-by-Step Practice Problems ✍️
1. Problem: A car license plate consists of 3 letters followed by 4 digits. How many different
license plates are possible if letters and digits can be repeated?
Step 1: Identify the number of tasks. There are 7 positions to fill (3 letters, 4 digits).
This is a sequence of tasks.
Step 2: Determine the number of ways for each task.
For each of the 3 letter positions, there are 26 choices (A-Z).
For each of the 4 digit positions, there are 10 choices (0-9).
Step 3: Apply the Product Rule.
Total possibilities = 26 × 26 × 26 × 10 × 10 × 10 × 10 = 26 3
× 10
4
.
Answer: 26 3
× 10
4
= 17576 × 10000 = 175, 760, 000 .
2. Problem: How many ways can a committee of 5 members be formed from a group of 8
men and 6 women if the committee must consist of exactly 3 men and 2 women?
Step 1: Break the problem into parts: choosing men AND choosing women.
Step 2: Choosing 3 men from 8 (order doesn't matter): C(8, 3).
C(8, 3) =
8!
3!×5!
=
8×7×6
3×2×1
= 56 .
Step 3: Choosing 2 women from 6 (order doesn't matter): C(6, 2).
C(6, 2) =
6!
2!×4!
=
6×5
2×1
= 15 .
Step 4: Apply the Product Rule (since we need 3 men AND 2 women).
Total ways = C(8, 3) × C(6, 2) = 56 × 15.
Answer: 56 × 15 = 840.
3. Problem: In how many different ways can the letters of the word 'ARRANGE' be
arranged?
Step 1: Count the total number of letters (n) and the frequency of each distinct letter.
n = 7
A appears 2 times (n 1 = 2 )
R appears 2 times (n 2 = 2 )
N appears 1 time (n 3
= 1 )
G appears 1 time (n 4 = 1 )
E appears 1 time (n 5
= 1 )
Step 2: Apply the formula for permutations with repetitions: n!
n 1 !×n 2 !×⋯×n k !
.
7!
2!×2!×1!×1!×1!
=
5040
2×2×1×1×1
=
5040
4
.
Answer: 1260.
4. Problem: A student has to answer 10 questions, choosing at least 4 from each of Part A
and Part B. If there are 6 questions in Part A and 7 questions in Part B, in how many
ways can the student choose 10 questions?
Step 1: Identify the possible combinations of questions from Part A and Part B that
sum to 10, respecting the "at least 4" condition.
Case 1: 4 from Part A and 6 from Part B.
Case 2: 5 from Part A and 5 from Part B.
Case 3: 6 from Part A and 4 from Part B.
Step 2: Calculate the number of ways for each case (using combinations as order
doesn't matter).
Case 1: C(6, 4) × C(7, 6) = ( 6!
4!2!
) × (
7!
6!1!
) = 15 × 7 = 105 .
Case 2: C(6, 5) × C(7, 5) = ( 6!
5!1!
) × (
7!
5!2!
) = 6 × 21 = 126 .
Case 3: C(6, 6) × C(7, 4) = ( 6!
6!0!
) × (
7!
4!3!
.
) = 1 × 35 = 35
Step 3: Since these cases are mutually exclusive (the student chooses one such
combination), apply the Sum Rule.
Total ways = 105 + 126 + 35.
Answer: 266.
Pro Tips 🎯
Identify if Order Matters: This is the crucial difference between Permutations (order
matters) and Combinations (order doesn't matter). "Arrangement," "sequence,"
"schedule" usually imply permutations. "Selection," "committee," "group," "sample"
usually imply combinations.
"AND" vs. "OR": "AND" typically means multiply (Product Rule). "OR" (for mutually
exclusive choices) typically means add (Sum Rule).
Distinct vs. Identical Items: Be mindful if items are distinct or if there are repetitions, as
this affects permutation formulas.
"At least" / "At most": These often require considering multiple cases and using the
Sum Rule, or sometimes using the complementary counting principle (Total ways -
Unwanted ways).
Break Down Complex Problems: Decompose larger problems into smaller,
manageable sub-problems or sequential tasks.
relation.
Recurrence relations are used to model problems in various fields, including computer
science (e.g., analysis of algorithms like divide-and-conquer algorithms, dynamic
programming), finance, and biology.
It is homogeneous if all terms are multiples of some a (i.e., no terms are constants i
or functions of n alone).
It has constant coefficients if the coefficients of the a terms are constants. i
The general form of a k-th order linear homogeneous recurrence relation with
constant coefficients is:
an= c a1 + c a
n−1 + ⋯ + c a
2 n−2 where c ≠ 0. k n−k k
2
(the golden ratio, ϕ) and r 2
=
1−√ 5
2
.
n n
General solution: F n = α1 (
1+√ 5
2
) + α2 (
1−√ 5
2
) .
α1 and α are found using F
2 0
= 0 and F 1
= 1 . (Resulting in
α1 = 1/√ 5, α = −1/√ 5). 2
an = an
(h)
+ an
(p)
.
Finding the Particular Solution a : This often involves a method of "undetermined
(p)
n
C ⋅ n
m
⋅ b
n
.
Example: a n
= 3a n−1 + 2n . Initial condition: a 1
.
= 3
Associated homogeneous: a n
= 3a n−1 . Characteristic eq: r − 3 = 0 ⇒ r = 3. So,
(h)
an = α ⋅ 3
n
.
For particular solution (F (n) = 2n, a linear polynomial), try a .
(p)
n = Cn + D
Cn + D = 3(C(n − 1) + D) + 2n
Cn + D = 3Cn − 3C + 3D + 2n
General solution: a n = α ⋅ 3
n
− n − 3/2 .
Use a 1
= 3 to find α:
3 = α ⋅ 3
1
− 1 − 3/2 ⇒ 3 = 3α − 5/2 ⇒ 6 = 6α − 5 ⇒ 11 = 6α ⇒ α = 11/6 .
Final solution: a n =
11
6
⋅ 3
n
− n −
3
2
.
4. Divide-and-Conquer Recurrence Relations:
Many algorithms that divide a problem into subproblems lead to recurrence relations
of the form T (n) = aT (n/b) + f (n).
Master Theorem: Provides a way to find the asymptotic behavior (Big-O, Big-Θ) of
such recurrences.
Let T (n) be a monotonically increasing function satisfying:
T (n) = aT (n/b) + f (n) where a ≥ 1, b > 1.
Case 1: If f (n) = O(n log b a−ϵ
) for some constant ϵ > 0, then T (n) = Θ(n log b a
.
)
Visual Aids 📊
Solving Linear Homogeneous Recurrence:
Recurrence: a_n = c_1
a_(n-1) + ... + c_k a_(n-k)
Form Characteristic
Equation: r^k - c_1 r^(k-1) -
... - c_k = 0
Roots Distinct?
Examples 💡
1. First-Order Linear Homogeneous: a n
= 5a n−1 , with a 0
= 2 .
Characteristic equation: r − 5 = 0 ⇒ r = 5.
General solution: a n = α ⋅ 5
n
.
Using a 0 = 2 :2=α⋅5 0
= α ⋅ 1 ⇒ α = 2 .
Solution: a n
= 2 ⋅ 5
n
.
2. Tower of Hanoi: H n = 2H n−1 + 1 , with H 1 = 1 (moves for n disks).
This is a nonhomogeneous relation.
Associated homogeneous: H .
(h)
n
n = 2H n−1 ⇒ H n = α ⋅ 2
. So, H .
(p)
C = 2C + 1 ⇒ −C = 1 ⇒ C = −1 n = −1
General solution: H n = α ⋅ 2
n
− 1 .
Using H 1
= 1 :1=α⋅2 1
− 1 ⇒ 1 = 2α − 1 ⇒ 2 = 2α ⇒ α = 1 .
Solution: H n = 2
n
− 1 .
For n = 0, a 0
= 2 :2=α 1
⋅ 2
0
+ α2 ⋅ 5
0
⇒ 2 = α1 + α2 (Equation 1)
For n = 1, a 1 = 1 :1=α 1 ⋅ 2
1
+ α2 ⋅ 5
1
⇒ 1 = 2α 1 + 5α 2 (Equation 2)
Step 5: Solve the system of linear equations.
From Eq 1: α 1 = 2 − α2 . Substitute into Eq 2:
1 = 2(2 − α 2 ) + 5α 2
1 = 4 − 2α 2 + 5α 2
1 = 4 + 3α 2
−3 = 3α 2 ⇒ α 2 = −1 .
Substitute α 2
= −1 into α 1
= 2 − α2 :α 1
= 2 − (−1) = 3 .
Step 6: Write the particular solution.
an = 3 ⋅ 2
n
− 1 ⋅ 5
n
.
Answer: a n = 3 ⋅ 2
n
− 5
n
.
2. Problem: Find the solution to a n
= a n−1 + 6 for n ≥ 1, with a 0
= 1 .
Step 1: Identify as linear nonhomogeneous. F (n) = 6.
Step 2: Solve associated homogeneous: a n = a n−1 .
Characteristic equation: r − 1 = 0 ⇒ r = 1.
(h)
an = α ⋅ 1
n
= α .
Step 3: Find a particular solution a . F (n) = 6 (constant).
(p)
n
Cn = C(n − 1) + 6
Cn = Cn − C + 6
0 = −C + 6 ⇒ C = 6 .
So, a (p)
n = 6n .
Step 4: General solution: a .
(h) (p)
n = an + an = α + 6n
(log n) )).
log a 0
f (n) = Θ(n b
Pro Tips 🎯
Characteristic Equation is Key: For linear homogeneous relations with constant
coefficients, correctly forming and solving the characteristic equation is the primary step.
Watch for Repeated Roots: The form of the solution changes if the characteristic
equation has repeated roots.
Nonhomogeneous - Homogeneous First: Always solve the associated homogeneous
part first. The form of F (n) guides the guess for the particular solution. If your guess for
is part of a , multiply your guess by n (or n if n times the guess is also part of a ).
(p) (h) (h)
2
an n n
Master Theorem Conditions: Ensure all conditions of the Master Theorem are met
before applying it. Pay attention to the regularity condition for Case 3.
Unrolling/Iteration Method: For simpler recurrences or when the Master Theorem
doesn't directly apply, try "unrolling" the recurrence a few times to see a pattern emerge.
Then, sum the terms. This is a more fundamental method but can be more work.
Depth: For algorithm analysis, understanding and applying the Master Theorem for
divide-and-conquer recurrences is important. Being able to set up recurrence relations
from problem descriptions (like Tower of Hanoi or simple counting problems) is a
valuable skill.
Key Concepts 💯
A set is a well-defined collection of distinct objects, considered as an object in its own
right. The objects in a set are called its elements or members.
Sets are usually denoted by capital letters (e.g., A, B, S). Elements are usually denoted
by lowercase letters.
If x is an element of set A, we write x ∈ A. If x is not an element of set A, we write x ∉ A.
Defining Sets:
Roster Method (Tabular Form): Listing all the elements, separated by commas,
within braces {} .
Example: A = {1, 2, 3, 4, 5}. V .
= {a, e, i, o, u}
Set-Builder Notation (Rule Method): Describing the elements by a property they
must satisfy.
Example: B = {x ∣ x is an even integer and x > 0} (The set of all x such that x
is a positive even integer).
Example: C = {x ∈ Z ∣ 0 < x < 10} (The set of integers x such that x is
between 0 and 10).
Cardinality of a Set (|A|): The number of distinct elements in a set A.
Example: If A = {a, b, c}, then |A| = 3.
Empty Set (Null Set, ∅ or {} ): A set with no elements. Its cardinality is 0.
Universal Set (U ): A set containing all possible elements relevant to a particular
discussion or problem.
Subset (⊆): Set A is a subset of set B if every element of A is also an element of B (
A ⊆ B).
Example: If A = {1, 2}, then P (A) = {∅, {1}, {2}, {1, 2}}.
Set Operations
A.
A
′
= U − A = {x ∈ U ∣ x ∉ A} .
Example: If U = {1, 2, 3, 4, 5} and A = {1, 2}, then A ′
.
= {3, 4, 5}
5. Cartesian Product (Cross Product, A × B): The set of all ordered pairs (a, b) where
a ∈ A and b ∈ B.
|A × B| = |A| × |B| .
Example: If A = {1, 2} and B = {x, y}, then A × B = {(1, x), (1, y), (2, x), (2, y)}.
De Morgan's Laws: (A ∪ B) ′
= A ∩ B
′ ′
; (A ∩ B) ′ ′
= A ∪ B
′
Principle of Inclusion-Exclusion
Visual Aids 📊
Venn Diagrams: Used to represent sets and their relationships visually.
Set A
A ∩ B (overlap)
Set B
(Note: Mermaid's direct visual overlap for intersection can be tricky. The diagram above
is a basic representation; actual Venn diagrams are typically drawn with overlapping
circles).
Examples 💡
1. If A = {a, b, c, d} and B = {c, d, e, f }:
A ∪ B = {a, b, c, d, e, f }
A ∩ B = {c, d}
A − B = {a, b}
B − A = {e, f }
2. If A = {1, 2}, Power set P (A) = {∅, {1}, {2}, {1, 2}}. |P (A)| = 2 2
.
= 4
Step 1: Find A ∪ B.
A ∪ B = {x ∣ x ∈ A ∨ x ∈ B} = {1, 2, 3, 4} ∪ {3, 4, 5, 6} = {1, 2, 3, 4, 5, 6} .
Step 2: Find the complement of A ∪ B with respect to U.
(A ∪ B)
′
= U − (A ∪ B) = {1, 2, 3, 4, 5, 6, 7, 8} − {1, 2, 3, 4, 5, 6} = {7, 8} .
Alternative using De Morgan's Law: (A ∪ B) ′ ′
= A ∩ B
′
.
A
′
= U − A = {5, 6, 7, 8} .
B
′
= U − B = {1, 2, 7, 8} .
′
A ∩ B
′
= {5, 6, 7, 8} ∩ {1, 2, 7, 8} = {7, 8} .
Answer: {7, 8}.
2. Problem: In a class of 50 students, 30 like Math, 25 like Science, and 10 like both Math
and Science. How many students like neither Math nor Science?
Step 1: Use the Principle of Inclusion-Exclusion to find the number of students who
like Math or Science or both: |M ∪ S| = |M | + |S| − |M ∩ S|.
|M ∪ S| = 30 + 25 − 10 = 45 .
So, 45 students like at least one of the subjects.
Step 2: The total number of students is |U | = 50.
Step 3: The number of students who like neither Math nor Science is |U | − |M .
∪ S|
Pro Tips 🎯
Venn Diagrams: Sketch Venn diagrams for problems involving union, intersection, and
complements of 2 or 3 sets. It greatly helps in visualizing the problem.
De Morgan's Laws: These are very useful for simplifying expressions involving
complements of unions or intersections.
Cardinality of Power Set: Remember |P (A)| = 2 |A|
.
Empty Set Properties: ∅ is a subset of every set. A ∪ ∅ = A, A ∩ ∅ = ∅.
Distinguish Subsets from Elements: {a} is a subset containing element a. a is an
element. ∅ is the empty set (a subset). {∅} is a set containing one element, which is the
empty set.
Part 2: Functions
Key Concepts 💯
A function f from a set A (the domain) to a set B (the codomain) is an assignment of
exactly one element of B to each element of A.
We write f : A → B .
If f (a) = b, then b is the image of a, and a is a preimage of b.
The range (or image) of f is the set of all images of elements of A. The range is a subset
of the codomain.
For a valid function:
1. Every element in the domain A must be mapped to some element in the codomain B.
2. No element in the domain A can be mapped to more than one element in the
codomain B.
Types of Functions
2
.
To find the inverse: Let y = 2x + 1. Solve for x: y − 1 = 2x ⇒ x = y−1
2
. So,
f
−1
(y) = .
y−1
5. Composition of Functions (g ∘ f ):
Let f : A → B and g : B → C be functions. The composition of g and f , denoted g ∘ f ,
is defined as (g ∘ f )(a) = g(f (a)) for all a ∈ A.
The domain of g ∘ f is A, and the codomain is C.
Composition is not generally commutative (f ∘ g ≠ g ∘ f ).
Composition is associative: (h ∘ g) ∘ f = h ∘ (g ∘ f ) .
Example: If f (x) = x + 1 and g(x) = x . 2
Properties of Functions
Visual Aids 📊
1. Function Types
Shows injective, surjective, bijective mappings.
Injective
Domain A
a1 a2 a3
Codomain B
b1 b2 b3 b4
Surjective
Domain A
a1 a4 a2 a3
Codomain B
b1 b2 b3
Bijective
Domain A
a1 a2 a3
Codomain B
b1 b2 b3
Examples 💡
1. Let A = {1, 2, 3}, B = {a, b, c, d}.
f = {(1, a), (2, b), (3, c)} is one-to-one (injective) but not onto (surjective because 'd'
has no preimage).
g = {(1, a), (2, b), (3, a)} is a function, but not one-to-one (1 and 3 map to 'a') and not
onto.
2. Let f : R → R , f (x) = 2x.
Injective: If f (a) = f (b), then 2a = 2b, so a = b. Yes.
Surjective: For any y ∈ R, can we find x such that f (x) = y? 2x = y ⇒ x = y/2.
Since y/2 is real for any real y, yes.
Since it's injective and surjective, it's bijective.
Inverse: f −1
(y) = y/2 .
3. Composition: f (x) = x , g(x) = x + 3. Both from R to R.
2
(f ∘ g)(x) = f (g(x)) = f (x + 3) = (x + 3)
2
.
(g ∘ f )(x) = g(f (x)) = g(x ) = x
2 2
+ 3 .
Step 2: Determine the range of f. The range is the set of all images:
{f (1), f (2), f (3)} = {a, b, a} = {a, b}.
Step 3: Compare the range with the codomain. Range = {a, b}, Codomain =
{a, b} .
Since the range equals the codomain, every element in B has at least one preimage.
Answer: Yes, the function is onto (surjective).
3. Problem: If f (x) = 3x − 2 and g(x) = x 2
+ 1 . Find (f ∘ g)(2).
Step 1: Calculate g(2).
g(2) = 2
2
+ 1 = 4 + 1 = 5 .
Step 2: Calculate f (g(2)), which is f (5).
f (5) = 3(5) − 2 = 15 − 2 = 13 .
Answer: (f ∘ g)(2) = 13.
Alternative (find formula first):
(f ∘ g)(x) = f (g(x)) = f (x
2
+ 1) = 3(x
2
+ 1) − 2 = 3x
2
+ 3 − 2 = 3x
2
.
+ 1
2
(f ∘ g)(2) = 3(2 ) + 1 = 3(4) + 1 = 12 + 1 = 13 .
Pro Tips 🎯
Injective Test: To prove injective, show f (x 1
) = f (x 2 ) ⇒ x 1 = x 2 . To disprove, find one
counterexample where f (x 1
) = f (x 2 ) but x 1
≠ x2 .
Surjective Test: To prove surjective, for an arbitrary y in the codomain, show there
exists an x in the domain such that f (x) = y. To disprove, find one y in the codomain that
has no preimage.
Bijective means Invertible: A function has an inverse if and only if it's bijective.
Domain and Codomain Matter: The properties of a function (injective, surjective,
bijective) heavily depend on its specified domain and codomain. f (x) = x is not injective 2
on R but is injective on [0, ∞).
Composition Order: Remember (g ∘ f )(x) = g(f (x)). Work from the inside out.
Part 3: Relations
Key Concepts 💯
A binary relation R from a set A to a set B is a subset of the Cartesian product A × B. If
(a, b) ∈ R, we say a is related to b by R, often written as aRb.
Matrix (Relation Matrix): For finite sets A and B, an m × n matrix where m = |A|
and n = |B|. M ij
= 1 if a i
Rb j , and 0 otherwise.
Directed Graph (Digraph): For a relation on a set A, elements are vertices, and a
directed edge exists from a to b if aRb.
transitive if R 2
).
⊆ R
Types of Relations
Operations on Relations
Since relations are sets of ordered pairs, set operations like union, intersection,
difference, and complement can be applied.
Composition of Relations (S ∘ R):
If R is a relation from A to B, and S is a relation from B to C, then the composition
S ∘ R is a relation from A to C.
Inverse Relation (R ): −1
If R is a relation from A to B, then R −1
is a relation from B to A.
R
−1
= {(b, a) ∣ (a, b) ∈ R} .
Closures of Relations
R
∗
= R
0
∪ R
1
(where R = Δ, n = |A| for a finite set A) using Boolean
∪ R
2
∪ ⋯ ∪ R
n 0
Visual Aids 📊
1. Relation Properties
Checks properties for equivalence or partial order.
Relation R on A × A
Reflexive? ∀ a, (a, a) ∈ R
Symmetric? ∀ (a, b) ∈ R,
(b, a) ∈ R
Partial Order
Symmetric: M ij
= M ji for all i, j (Matrix is symmetric: M = M
T
).
Antisymmetric: If M ij = 1 and i ≠ j, then M ji .
= 0
(M R ) ij = 1, which means R 2
⊆ R).
Examples 💡
1. Let A = {1, 2, 3}.
R 1 = {(1, 1), (2, 2), (3, 3), (1, 2)} is reflexive, antisymmetric, transitive (Partial Order).
R 2 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)} is reflexive, symmetric, transitive (Equivalence
Relation). [1] = {1, 2}, [3] = {3}.
R 3 = {(1, 2), (2, 3)} is not reflexive, not symmetric, not antisymmetric, not transitive
(to be transitive, it would need (1, 3)).
2. Composition: R = {(1, a), (2, b)} from {1, 2} to {a,b,c}. S = {(a,x), (b,y), (a,z)} from
{a,b,c} to {x,y,z}.
S ∘ R :
(1, a) ∈ R and (a,x) ∈ S ⇒ (1, x) ∈ S ∘ R .
(1, a) ∈ R and (a,z) ∈ S ⇒ (1, z) ∈ S ∘ R .
(2, b) ∈ R and (b,y) ∈ S ⇒ (2, y) ∈ S ∘ R .
S ∘ R = {(1, x), (1, z), (2, y)} .
3. Problem: Consider the relation R on the set of integers Z where aRb if a − b is an even
integer. Is R an equivalence relation?
Step 1: Check Reflexivity. Is aRa for all a ∈ Z?
a − a = 0 . Is 0 even? Yes (0 = 2 × 0). So, R is reflexive.
Step 2: Check Symmetry. If aRb, is bRa?
If aRb, then a − b is even. So a − b = 2k for some integer k.
Then b − a = −(a − b) = −(2k) = 2(−k). Since −k is an integer, b − a is also
even.
So, bRa. Thus, R is symmetric.
Step 3: Check Transitivity. If aRb and bRc, is aRc?
If aRb, then a − b = 2k for some integer k.
If bRc, then b − c = 2m for some integer m.
We want to check a − c. a − c = (a − b) + (b − c) = 2k + 2m = 2(k + m).
Since k + m is an integer, a − c is even. So, aRc. Thus, R is transitive.
Step 4: Conclusion. Since R is reflexive, symmetric, and transitive, it is an
equivalence relation.
Answer: Yes, R is an equivalence relation. (The equivalence classes are the set of
even integers and the set of odd integers).
Pro Tips 🎯
Definitions are Key: For properties (reflexive, symmetric, etc.), always go back to the
precise definition.
Counterexamples: To prove a relation does not have a property, find a single
counterexample.
Small Sets: For relations on small finite sets, drawing a digraph or a matrix can be very
helpful.
Equivalence Classes: Remember that an equivalence relation partitions a set into
disjoint equivalence classes. All elements within a class are related to each other.
Partial Orders & Hasse Diagrams: For posets, Hasse diagrams simplify the
visualization by omitting self-loops and transitive edges, and assuming upward direction
for the relation.
Composition Logic: Think of composition S ∘ R as "first apply R, then apply S."
Key Concepts 💯
A proposition is a declarative sentence (a statement) that is either true (T) or false (F),
but not both. This truth value is called its truth value.
Propositions are the basic building blocks of propositional logic.
Examples:
"Visakhapatnam is in Andhra Pradesh." (True)
"2 + 2 = 5." (False)
"What time is it?" (Not a proposition, as it's a question)
"x + 1 = 3." (Not a proposition until x is defined; it's a predicate)
Propositional Variables: Letters like p, q, r, s are used to represent propositions.
Logical Connectives (Operators): These are used to combine or modify propositions to
form more complex propositions (compound propositions).
Negation (NOT): ¬p (or ∼ p or p ) - "not p"
′
Truth Tables
A truth table displays the truth values of a compound proposition for all possible
combinations of truth values of its constituent propositional variables.
p q ¬p p ∧ q p ∨ q p ⊕ q p → q p ↔ q
T T F T T F T T
T F F F T T F F
F T T F T T T F
F F T F F F T T
Logical Equivalences
Two compound propositions P and Q are logically equivalent if they have the same
truth table, denoted P ⇔ Q or P ≡ Q.
Important Logical Equivalences (Laws):
Identity Laws: p ∧ T ≡ p; p ∨ F ≡ p
Domination Laws: p ∨ T ≡ T; p ∧ F ≡ F
Idempotent Laws: p ∨ p ≡ p; p ∧ p ≡ p
Double Negation Law: ¬(¬p) ≡ p
Commutative Laws: p ∨ q ≡ q ∨ p; p ∧ q ≡ q ∧ p
Associative Laws: (p ∨ q) ∨ r ≡ p ∨ (q ∨ r); (p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
Distributive Laws: p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r); p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
De Morgan's Laws: ¬(p ∧ q) ≡ ¬p ∨ ¬q; ¬(p ∨ q) ≡ ¬p ∧ ¬q
Absorption Laws: p ∨ (p ∧ q) ≡ p; p ∧ (p ∨ q) ≡ p
Negation Laws (Complement Laws): p ∨ ¬p ≡ T; p ∧ ¬p ≡ F
Implication Equivalence: p → q ≡ ¬p ∨ q
Biconditional Equivalence: p ↔ q ≡ (p → q) ∧ (q → p)
Contrapositive Equivalence: p → q ≡ ¬q → ¬p
Tautology: A compound proposition that is always true, regardless of the truth values of
its propositional variables (e.g., p ∨ ¬p).
Contradiction: A compound proposition that is always false (e.g., p ∧ ¬p).
Contingency: A compound proposition that is neither a tautology nor a contradiction.
Visual Aids 📊
Truth Table Structure:
Examples 💡
1. Implication: If p: "It is raining," q: "The ground is wet." Then p → q: "If it is raining, then
the ground is wet."
Converse (q → p): "If the ground is wet, then it is raining." (Not necessarily true)
Inverse (¬p → ¬q): "If it is not raining, then the ground is not wet." (Not necessarily
true)
Contrapositive (¬q → ¬p): "If the ground is not wet, then it is not raining." (Logically
equivalent to original)
2. De Morgan's Law: "It is not the case that both x > 0 and y < 0" (¬(p ∧ q)) is equivalent
to "x ≤ 0 or y ≥ 0" (¬p ∨ ¬q).
3. Modus Ponens:
Premise 1: If you study hard, you will pass (S → P ).
Premise 2: You study hard (S ).
Conclusion: Therefore, you will pass (P ).
| p | q | ¬p | p ∧ q | p ∨ q | p ⊕ q | p → q | p ↔ q |
|---|---|----|-------|-------|-------|-------|-------|
| T | T | F | T | T | F | T | T |
| T | F | F | F | T | T | F | F |
| F | T | T | F | T | T | T | F |
| F | F | T | F | F | F | T | T |
Answer: The last column is identical to the truth table for p ↔ q. So,
(p → q) ∧ (q → p) ≡ p ↔ q.
2. Problem: Show that ¬(p ∨ (¬p ∧ q)) is logically equivalent to ¬p ∧ ¬q using logical
equivalence laws.
Step 1: ¬(p ∨ (¬p ∧ q))
Step 2 (De Morgan's Law): ≡ ¬p ∧ ¬(¬p ∧ q)
Step 3 (De Morgan's Law again): ≡ ¬p ∧ (¬(¬p) ∨ ¬q)
Step 4 (Double Negation): ≡ ¬p ∧ (p ∨ ¬q)
Step 5 (Distributive Law): ≡ (¬p ∧ p) ∨ (¬p ∧ ¬q)
Step 6 (Negation Law): ≡ F ∨ (¬p ∧ ¬q) (since ¬p ∧ p ≡ F)
Step 7 (Identity Law): ≡ ¬p ∧ ¬q
Answer: The equivalence is shown.
3. Problem: Determine if the following argument is valid:
If it snows, I will study discrete math.
I will not study discrete math.
Therefore, it did not snow.
Step 1: Assign propositional variables.
s: It snows.
d : I will study discrete math.
Step 2: Write the argument in symbolic form.
Premise 1: s → d
Premise 2: ¬d
Conclusion: ¬s
Step 3: Check if this matches a known rule of inference or test for tautology
[(s → d) ∧ ¬d] → ¬s .
This is the form of Modus Tollens.
Answer: The argument is valid (by Modus Tollens).
Pro Tips 🎯
Master Truth Tables: They are fundamental for understanding connectives and proving
equivalences or validity.
Memorize Key Equivalences: Especially De Morgan's Laws, Implication Equivalence (
p → q ≡ ¬p ∨ q ), and Distributive Laws. They simplify complex expressions quickly.
Contrapositive: Remember p → q is equivalent to ¬q → ¬p. This is often useful.
Argument Validity: An argument is valid if, whenever all premises are true, the
conclusion must also be true. It's about the logical structure, not the actual truth of the
statements in the real world.
Key Concepts 💯
Predicate Logic extends propositional logic by allowing variables, predicates, and
quantifiers. It can express the meaning of a wider range of statements than propositional
logic.
Predicate (Propositional Function): A statement involving variables, which becomes a
proposition (true or false) when the variables are replaced by specific values from a
particular domain (also called the universe of discourse).
Example: P (x) :′′x > 3′′. P (4) is true, P (2) is false. x is the variable.
Example: Q(x, y) :′′x = y + 3′′. Q(4, 1) is true, Q(5, 3) is false.
Domain of Discourse (Universe of Discourse, UoD): The set of all possible values
that a variable in a predicate can take.
Quantifiers: Symbols used to express the extent to which a predicate is true over a
range of elements.
Universal Quantifier (∀): "For all" or "For every." ∀xP (x) means P (x) is true for
every x in the domain.
To prove ∀xP (x) is true, show P (x) is true for all x.
To prove ∀xP (x) is false, find one counterexample x for which P (x) is false.
Existential Quantifier (∃): "There exists" or "For some" or "There is at least one."
∃xP (x) means there is at least one x in the domain for which P (x) is true.
To prove ∃xP (x) is true, find one example x for which P (x) is true.
To prove ∃xP (x) is false, show P (x) is false for all x.
Binding Variables
"It is not the case that for all x, P (x) is true" is equivalent to "There exists an x for
which P (x) is false."
¬(∃xP (x)) ≡ ∀x¬P (x)
"It is not the case that there exists an x for which P (x) is true" is equivalent to "For
all x, P (x) is false."
Nested Quantifiers
Quantifiers can be nested, meaning one quantifier is within the scope of another. The
order of quantifiers matters if they are different.
∀x∀yP (x, y) : P (x, y) is true for every pair x, y. (Order doesn't matter: ≡ ∀y∀xP (x, y))
∃x∃yP (x, y) : There is at least one pair x, y for which P (x, y) is true. (Order doesn't
matter: ≡ ∃y∃xP (x, y))
∀x∃yP (x, y) : For every x, there is a y (which may depend on x) such that P (x, y) is
true.
∃y∀xP (x, y) : There is a y such that for every x, P (x, y) is true. (This is a stronger
statement than ∀x∃yP (x, y)).
Example: Domain = set of real numbers. P (x, y) : x + y = 0.
∀x∃yP (x, y): For every real number x, there exists a real number y (namely
y = −x ) such that x + y = 0. (True)
∃y∀xP (x, y): There exists a real number y such that for all real numbers x,
x + y = 0 . (False, because y would have to be −x for all x, which is impossible
for a single y).
Visual Aids 📊
Nested Quantifier Interpretation Aid (Conceptual):
∀x∃yP (x, y): "For every choice of x, you can find a y..." (Your opponent picks x, you
pick y to make P (x, y) true).
∃y∀xP (x, y) : "You can find one y that works for all x..." (You pick a single y first, and
it must work for any x your opponent picks).
Examples 💡
1. Domain: All integers. P (x) : x > 0.
∀xP (x) : "All integers are greater than 0." (False, e.g., -1)
∃xP (x) : "There exists an integer greater than 0." (True, e.g., 1)
¬(∀xP (x)) ≡ ∃x¬P (x) : "It's not true that all integers are positive" ≡ "There's an
integer that is not positive (≤ 0)."
2. L(x, y): "x loves y." Domain: All people.
∀x∃yL(x, y) : Everyone loves someone.
∃y∀xL(x, y) : There is someone who is loved by everyone.
¬∃x∀yL(x, y) : "There isn't anyone who loves everyone."
≡ ∀x¬∀yL(x, y)
Pro Tips 🎯
Domain is Crucial: The truth value of a quantified statement depends heavily on the
domain of discourse. ∀x(x ≥ 0) is true if the domain is real numbers, but false if the
2
Translating "Some": "Some A are B" is usually ∃x(A(x) ∧ B(x)). It's not
∃x(A(x) → B(x)), because if no A's exist, A(x) → B(x) could be true for all x
Language (L): A language over an alphabet Σ is any subset of Σ . That is, a language is ∗
a set of strings.
Languages can be finite or infinite.
Examples:
L 1 = {0, 00, 000} (a finite language over Σ = {0, 1}).
L 2 = {w ∈ {0, 1}
∗
∣ w has an even number of 0s} (an infinite language).
∅ (the empty set) is a language.
{λ} (the language consisting only of the empty string) is a language.
Operations on Languages
Since languages are sets of strings, set operations apply:
L 1 ∪ L 2 = {w ∣ w ∈ L 1 ∨ w ∈ L 2 } .
2. Intersection (L 1
∩ L2 ): The set of strings that are in both L and L . 1 2
L 1 ∩ L 2 = {w ∣ w ∈ L 1 ∧ w ∈ L 2 } .
3. Difference (L 1 − L2 ): The set of strings that are in L but not in L . 1 2
L 1 − L 2 = {w ∣ w ∈ L 1 ∧ w ∉ L 2 } .
4. Complement (L or L̄): The set of strings in Σ that are not in L.
′ ∗
L
′
= Σ
∗
− L .
L 1 L 2 = {xy ∣ x ∈ L 1 ∧ y ∈ L 2 } .
Example: If L 1 = {a, ab} and L 2 = {b, bb} , then L 1 L2 = {ab, abb, abbb} . (Note:
ab + b = abb , and a + bb = abb. Since sets don't contain duplicates, abb is listed
once).
6. Kleene Star (L ): The set of all strings formed by concatenating zero or more strings
∗
0
L = {λ}
1
L = L
L
2
= LL (concatenation of L with itself), and so on.
Example: If L = {a}, then L ∗
= {λ, a, aa, aaa, …} .
Example: If L = {0, 1}, then L is the set of all binary strings, i.e., L
∗ ∗
= Σ
∗
.
7. Positive Closure (L ): The set of all strings formed by concatenating one or more
+
strings from L.
+ 1 2 3
L = L ∪ L ∪ L ∪ …
L
+
= LL
∗
(if L does not contain λ, or more generally L +
= L ⋅ L
∗
).
Alternatively, L ∗
= {λ} ∪ L
+
.
Example: If L = {a}, then L +
= {a, aa, aaa, …} .
Regular Expressions (REs) are a powerful way to describe patterns in strings and
define regular languages.
Basic REs:
∅ denotes the empty language L = ∅.
λ (or ϵ) denotes the language L = {λ}.
a (where a ∈ Σ) denotes the language L = {a}.
Operations on REs (to form more complex REs):
Union (r 1
+ r2 or r 1
|r 2 ): If r and r are REs, then r
1 2 1
+ r2 denotes L(r 1
) ∪ L(r 2 ) .
Concatenation (r 1 r2 ): If r and r are REs, then r
1 2 1 r2 denotes L(r 1 )L(r 2 ) .
Kleene Star (r ): If r is an RE, then r denotes (L(r)) .
∗ ∗ ∗
a*b : Zero or more 'a's followed by a single 'b'. Language: {b, ab, aab, …} .
Visual Aids 📊
Language Operations Example (Conceptual):
Let L = {0, 01} and L = {1, 10} over Σ = {0, 1}.
1 2
L1 ∩ L2 = ∅
L 1 L 2 = {w 1 w 2 ∣ w 1 ∈ L 1 , w 2 ∈ L 2 }
0 ⋅ 1 = 01
0 ⋅ 10 = 010
01 ⋅ 1 = 011
01 ⋅ 10 = 0110
L1
∗
:
0
L = {λ}
1
1
L = {0, 01}
1
2
L 1 = L 1 L 1 = {00, 001, 010, 0101}
∗
L 1 = {λ, 0, 01, 00, 001, 010, 0101, 000, …} (all finite concatenations of strings
from L ) 1
Examples 💡
1. Alphabet Σ = {x, y, z}.
Strings: x , xyz , yy , λ.
|xyz| = 3 .
Σ
∗
includes λ, x, y, z, xx, xy, xz, yx, …
2. Language L = {w ∈ {a,b} ∗
∣ w starts with ’a’ and ends with ’b’} .
Strings in L: ab, aab, abb, aaab, abab, abbb, ...
Is aba ∈ L ? No (doesn't end with 'b').
Is b ∈ L ? No (doesn't start with 'a').
3. Regular Expression (a+b)c* : Defines the language of strings that start with either 'a' or
'b', followed by zero or more 'c's.
Examples: a, b, ac, bc, acc, bcc, ...
a (from L ) ⋅ b (from L ) = ab
1 2
L 1 L 2 = {ab, aab} .
Step 2: Find L 2
L1 . Concatenate each string in L with each string in L .
2 1
b (from L ) ⋅ a (from L ) = ba
2 1
L 2 L 1 = {ba, baa} .
Answer: L 1 L2 = {ab, aab} ,L 2 L1 = {ba, baa} . (Note that language concatenation is
generally not commutative).
3. Problem: Let L = {01, 1}. Find the strings in L . 2
Step 1: L 2
= LL . This means concatenating every string in L with every string in L.
Step 2: List all combinations.
01 (from L) ⋅ 01 (from L) = 0101
01 (from L) ⋅ 1 (from L) = 011
1 (from L) ⋅ 01 (from L) = 101
1 (from L) ⋅ 1 (from L) = 11
Answer: L 2
= {0101, 011, 101, 11} .
4. Problem: Give a regular expression for the language of all binary strings that start with a
'1' and have an even number of '0's in total.
Step 1: Must start with '1'.
Step 2: "Even number of '0's" can be achieved by having zero '0's, or pairs of '0's.
Any number of '1's can appear before, between, or after these '0's.
Step 3: A common RE for strings with an even number of '0's over Σ = {0, 1} is
1 (01 01 ) . This means any number of '1's, followed by zero or more blocks, where
∗ ∗ ∗ ∗
each block consists of a '0', then any '1's, then another '0', then any '1's.
Step 4: Combine with the "starts with '1'" condition. The initial '1' takes care of the
start. The rest of the string must then contain an even number of '0's and can start
with '1's or '0's (as part of the even count).
The string starts with 1 .
The remainder of the string must contribute to an even total of '0's, when
combined with the '0's already counted (which is zero from the initial '1'). So the
remainder must itself have an even number of '0's.
A string with an even number of '0's (and any '1's) can be represented as
1 (01 01 ) .
∗ ∗ ∗ ∗
Answer: 1(1 ∗ ∗
(01 01 ) )
∗ ∗
.
Alternative/Simplified thought: Starts with 1 . Then, any sequence of 1 s and
pairs of 0 s. A pair of 0 s can be 01*0 . The 1 s can be handled by 1* around
these pairs.
So: 1 followed by (1*01*0)*1* . This means:
Starts with 1 .
Then, (1*01*0)* : zero or more occurrences of (any 1 s, a 0 , any 1 s, a
0 ). This ensures 0 s come in pairs.
Then, 1* : any trailing 1 s.
This expression is 1(1 ∗ ∗
01 0) 1
∗ ∗
. This is a valid RE.
Pro Tips 🎯
λ is a String: Remember the empty string λ is a string of length 0. It's in Σ and L for ∗ ∗
any language L.
L vs. L : L always includes λ. L includes concatenations of one or more strings from
∗ + ∗ +
L ⋅ {λ} = {λ} ⋅ L = L
∗
∅ = {λ}
∗
{λ} = {λ}
This completes the Discrete Mathematics section. Let me know what's next!