0% found this document useful (0 votes)
9 views43 pages

Discrete Paper 2

The document provides a comprehensive overview of key concepts in Discrete Mathematics, focusing on principles of counting such as the Sum Rule, Product Rule, permutations, and combinations. It includes essential rules, examples, visual aids, and step-by-step practice problems to illustrate the application of these concepts. Additionally, it offers tips for identifying when to use specific counting techniques and a topic coverage guide for further study.

Uploaded by

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

Discrete Paper 2

The document provides a comprehensive overview of key concepts in Discrete Mathematics, focusing on principles of counting such as the Sum Rule, Product Rule, permutations, and combinations. It includes essential rules, examples, visual aids, and step-by-step practice problems to illustrate the application of these concepts. Additionally, it offers tips for identifying when to use specific counting techniques and a topic coverage guide for further study.

Uploaded by

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

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.

Here's the revised content:

Paper 2: Discrete Mathematics


Chapter 1: Principles of Counting
Key Concepts 💯
Counting principles (also known as combinatorics) are fundamental techniques used to
determine the number of possible outcomes or ways an event or a sequence of events
can occur without actually listing all of them.
These principles are crucial in many areas of computer science, including algorithm
analysis, probability, and network design.
The two most basic principles are the Sum Rule and the Product Rule. More advanced
techniques include permutations and combinations.

Essential Rules & Principles

1. The Sum Rule (Rule of Addition):


If a task can be done in one of n ways and a second task can be done in n ways,
1 2

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

do one of these tasks is n + n + ⋯ + n .


1 2 k

Keywords: "OR", "either...or" often suggest the Sum Rule.


Example: If a student can choose a project from one of three lists, containing 10, 15,
and 8 projects respectively, and no project is on more than one list, then the student
can choose a project in 10 + 15 + 8 = 33 ways.
2. The Product Rule (Rule of Multiplication):
If a procedure can be broken down into a sequence of two tasks, and if there are n 1

ways to do the first task and for each of these ways, there are n ways to do the
2

second task, then there are n × n ways to do the procedure.


1 2
This extends to a sequence of k tasks. If task i can be done in n ways (after the i

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.

3. The Principle of Inclusion-Exclusion (for two sets):


If a task can be done in n ways or n ways, but there is some overlap (i.e., some
1 2

ways are counted in both n and n ), then the total number of ways is
1 2

n + n − |A ∩ B|, where |A ∩ B| is the number of ways common to both tasks (the


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.

5. Combinations (Order Does NOT Matter):


A combination is a selection of objects without regard to the order.
The number of combinations of n distinct objects taken r at a time is denoted by
C(n, r), nCr, or ( ).
n

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

of type 1, n identical objects of type 2, ..., n identical objects of type k is:


2 k

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

7. Combinations with Repetitions (Multisets):


The number of ways to choose r objects from n types of objects with replacement
(repetition allowed) is:

(n + r − 1)!
C(n + r − 1, r) =
r! × (n − 1)!

This is equivalent to finding the number of non-negative integer solutions to


x + x + ⋯ + x
1 2 = r. n

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

Are there multiple ways to


do a single task OR a
sequence of multiple tasks?

Single Task, Mutually


Sequence of Multiple Tasks
Exclusive Choices

Product Rule: Multiply


Sum Rule: Add ways for
ways for each step in
each choice
sequence

2. Permutation vs. Combination Flowchart


This flowchart differentiates between permutations and combinations based on whether
order matters.
Have a set of 'n' objects,
need to select 'r'

Does the order of selection


matter?

Yes No

Permutation P(n, r) Combination C(n, r)

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.

Topic Coverage Guide 📚


Breadth: Understand and be able to apply the Sum Rule, Product Rule, basic
permutations (P (n, r) and n!), and basic combinations (C(n, r)). Familiarity with
permutations with repetitions is also important.
Depth: Ability to differentiate between scenarios requiring permutations vs.
combinations. Solving problems that involve a mix of product and sum rules, or multiple
cases, requires deeper understanding. Inclusion-Exclusion for two sets is good to know.
Combinations with repetitions is a more advanced topic but can appear.

Chapter 2: Recurrence Relations


Key Concepts 💯
A recurrence relation for a sequence {a n
} is an equation that expresses a in terms of n

one or more of the previous terms of the sequence (a 0


, a 1 , … , a n−1 ) for all integers n with
n ≥ n , where n is a nonnegative integer.
0 0

Recurrence relations are also known as difference equations.


A sequence is called a solution of a recurrence relation if its terms satisfy the recurrence
relation.
Initial conditions for a sequence specify the values of the first few terms of the
sequence (e.g., a , a , …). These are needed to find a unique solution for a recurrence
0 1

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.

Essential Rules & Principles

1. Order of a Recurrence Relation: The order of a linear recurrence relation is the


difference between the largest and smallest subscripts of the terms of the sequence
appearing in the relation. For example, a = a + a is a second-order relation.
n n−1 n−2

2. Linear Homogeneous Recurrence Relations with Constant Coefficients:


A recurrence relation is linear if a is a linear combination of previous terms.
n

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

Characteristic Equation: To solve such relations, we form the characteristic


equation:
k k−1 k−2
r − c1 r − c2 r − ⋯ − ck = 0

Solutions based on Roots of the Characteristic Equation:


Distinct Roots: If the characteristic equation has k distinct roots r , r , … , r , 1 2 k

then the general solution is a = α r + α r + ⋯ + α r , where α are


n 1
n
1
2
n
2
k
n
k
i

constants determined by initial conditions.


Repeated Roots: If a root r has multiplicity m (i.e., it's a root m times), then
1

the part of the general solution corresponding to this root is


(α 1,0 + α 1,1 n + ⋯ + α 1,m−1 n
m−1
)r
n
1
.
Example (Fibonacci Sequence): F n = F n−1 + F n−2 with F 0 = 0, F 1 = 1 .
Characteristic equation: r 2
− r − 1 = 0 .
Roots: r 1
=
1+√ 5

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

3. Linear Nonhomogeneous Recurrence Relations with Constant Coefficients:


These have the form: a n
= c 1 a n−1 + ⋯ + c k a n−k + F (n) , where F (n) is a non-zero
function of n.
General Solution: The general solution is the sum of two parts:
The solution to the associated homogeneous recurrence relation (a ).
(h)
n

A particular solution to the nonhomogeneous recurrence relation (a ).


(p)
n

an = an
(h)
+ an
(p)
.
Finding the Particular Solution a : This often involves a method of "undetermined
(p)
n

coefficients," where the form of a is guessed based on the form of F (n).


(p)
n

If F (n) is a polynomial of degree d, try a polynomial of degree d.


If F (n) is an exponential b , try C ⋅ b . n n

If F (n) is b and b is a root of the characteristic equation with multiplicity m, try


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

Comparing coefficients of n: C = 3C + 2 ⇒ −2C = 2 ⇒ C = −1 .


Comparing constant terms:
D = −3C + 3D ⇒ −2D = −3C ⇒ −2D = −3(−1) = 3 ⇒ D = −3/2 .
So, a .
(p)
n
= −n − 3/2

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

Case 2: If f (n) = Θ(n log


b
a
(log n) )
k
for some constant k ≥ 0, then
T (n) = Θ(n
log
b
a
(log n)
k+1
) . (If k = 0, T (n) = Θ(n log
b
a
).
log n)

Case 3: If f (n) = Ω(n log


b
a+ϵ
) for some ϵ > 0, and if a ⋅ f (n/b) ≤ c ⋅ f (n) for some
constant c < 1 and sufficiently large n (regularity condition), then
T (n) = Θ(f (n)) .
Example (Merge Sort): T (n) = 2T (n/2) + Θ(n).
a = 2, b = 2, f (n) = Θ(n) .
log b a = log 2 2 = 1 .
n
log b a
= n
1
.
= n

Since f (n) = Θ(n) = Θ(n log


b
a
, this is Case 2 with k = 0.
)

So, T (n) = Θ(n log


b
a
log n) = Θ(n log n) .

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

Find Roots r_1, r_2, ..., r_k

Roots Distinct?

Yes No (Repeated Roots)

General Solution: (α_0 +


G l S l ti 1
General Solution: α_1
α_1 n + ...) r^n for repeated
r_1^n + ... + α_k r_k^n
root r

Use Initial Conditions to


find α_i

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

For particular solution, F (n) = 1 (constant). Try H .


(p)
n = C

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

Step-by-Step Practice Problems ✍️


1. Problem: Solve the recurrence relation a n = 7a n−1 − 10a n−2 for n ≥ 2, with initial
conditions a = 2 and a = 1.
0 1

Step 1: Form the characteristic equation.


r
2
− 7r + 10 = 0 .
Step 2: Find the roots of the characteristic equation.
(r − 2)(r − 5) = 0 . So, r 1 = 2 ,r 2 = 5 .
Step 3: Write the general solution (distinct roots).
an = α1 ⋅ 2
n
+ α2 ⋅ 5
n
.
Step 4: Use the initial conditions to find α and α . 1 2

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

Try a . But r = 1 is a root of the characteristic equation. So, try a .


(p) (p)
n = C n = Cn

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

Step 5: Use initial condition a 0


= 1 .
1 = α + 6(0) ⇒ α = 1 .
Step 6: Particular solution.
a n = 1 + 6n .
Answer: a n = 1 + 6n .
3. Problem: What is the asymptotic complexity of T (n) = 4T (n/2) + n ? 2

Step 1: Identify a, b, f (n) for Master Theorem.


a = 4 , b = 2, f (n) = n . 2

Step 2: Calculate n log


b
a
.
log b a = log 2 4 = 2 .
n
log
b
a
= n
2
.
Step 3: Compare f (n) with n log
b
a
.
f (n) = n
2
and n log b a
= n
2
.
So, f (n) = Θ(n log
. This is Master Theorem Case 2 with k = 0 (since
b
a
)

(log n) )).
log a 0
f (n) = Θ(n b

Step 4: Apply Master Theorem Case 2.


T (n) = Θ(n
log b a
(log n)
k+1
) = Θ(n (log n)
2 0+1
) = Θ(n
2
log n) .
Answer: Θ(n 2
log n) .

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.

Topic Coverage Guide 📚


Breadth: Understand the definition of recurrence relations and initial conditions. Be able
to solve first and second-order linear homogeneous recurrence relations with constant
coefficients (distinct and repeated roots). Basic understanding of how to approach linear
nonhomogeneous ones (finding homogeneous solution + particular solution for simple
F (n) like constants or polynomials).

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.

Chapter 3: Sets, Functions, Relations


Part 1: Sets

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

If A ⊆ B and A ≠ B, then A is a proper subset of B (A ⊂ B).


The empty set ∅ is a subset of every set. Every set is a subset of itself.
Power Set (P (A) or P(A)): The set of all subsets of a set A. If |A| = n, then |P (A)| = 2 . n

Example: If A = {1, 2}, then P (A) = {∅, {1}, {2}, {1, 2}}.

Set Operations

1. Union (A ∪ B): The set of elements that are in A, or in B, or in both.


A ∪ B = {x ∣ x ∈ A ∨ x ∈ B} .
Example: If A = {1, 2, 3} and B = {3, 4, 5}, then A ∪ B = {1, 2, 3, 4, 5}.
2. Intersection (A ∩ B): The set of elements that are in both A and B.
A ∩ B = {x ∣ x ∈ A ∧ x ∈ B} .
Example: If A = {1, 2, 3} and B = {3, 4, 5}, then A ∩ B = {3}.
If A ∩ B = ∅, then A and B are disjoint sets.
3. Difference (A − B or A ∖ B): The set of elements that are in A but not in B.
A − B = {x ∣ x ∈ A ∧ x ∉ B} .
Example: If A = {1, 2, 3} and B = {3, 4, 5}, then A − B = {1, 2}.
4. Complement (A or A or A¯): The set of elements in the universal set U that are not in
′ c

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

Set Identities (Algebra of Sets)


Commutative Laws: A ∪ B = B ∪ A; A ∩ B = B ∩ A
Associative Laws: (A ∪ B) ∪ C = A ∪ (B ∪ C) ; (A ∩ B) ∩ C = A ∩ (B ∩ C)

Distributive Laws: A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C); A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)


Identity Laws: A ∪ ∅ = A; A ∩ U = A

Domination Laws: A ∪ U = U ;A∩∅=∅


Idempotent Laws: A ∪ A = A; A ∩ A = A
Complement Laws: A ∪ A ′
= U ;A∩A ′
= ∅

Double Complement Law: (A ) ′ ′


= A

De Morgan's Laws: (A ∪ B) ′
= A ∩ B
′ ′
; (A ∩ B) ′ ′
= A ∪ B

Principle of Inclusion-Exclusion

For two sets: |A ∪ B| = |A| + |B| − |A ∩ B|


For three sets: |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|

Visual Aids 📊
Venn Diagrams: Used to represent sets and their relationships visually.

Union: The total area covered by circles representing A and B.


Intersection: The overlapping area of circles A and B.
Difference A-B: The area of circle A that does not overlap with B.
Complement A': The area outside circle A but within the universal set rectangle.

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

3. Using De Morgan's Law: If we want elements not in (A or B), that's (A ∪ B) , which ′

equals A ∩ B (elements not in A AND not in B).


′ ′

Step-by-Step Practice Problems ✍️


1. Problem: Given U = {1, 2, 3, 4, 5, 6, 7, 8} , A = {1, 2, 3, 4}, and B = {3, 4, 5, 6}. Find
(A ∪ B) .

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|

Number liking neither = 50 − 45 = 5.


Answer: 5.
3. Problem: If set A has 4 elements, how many subsets does A have? How many proper
subsets does A have?
Step 1: The number of subsets of a set with n elements is 2 . n

Here, n = 4. So, number of subsets = 2 4


= 16 .
Step 2: Proper subsets are all subsets except the set itself.
Number of proper subsets = 2 n
− 1 .
2
4
− 1 = 16 − 1 = 15 .
Answer: 16 subsets, 15 proper subsets.

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

1. One-to-One (Injective) Function:


A function f : A → B is one-to-one (or injective) if and only if f (a) = f (b) implies that
a = b for all a and b in the domain A.

Equivalently, if a ≠ b, then f (a) ≠ f (b).


Every element in the codomain B has at most one preimage in A.
Example: f (x) = x + 1 from Z to Z is injective. If a + 1 = b + 1, then a = b.
2. Onto (Surjective) Function:
A function f : A → B is onto (or surjective) if and only if for every element b ∈ B,
there is an element a ∈ A such that f (a) = b.
Every element in the codomain B has at least one preimage in A. The range of f is
equal to its codomain B.
Example: f (x) = x − 1 from Z to Z is surjective. For any integer y in the codomain,
we can find x = y + 1 in the domain such that f (x) = y.
3. One-to-One Correspondence (Bijective) Function:
A function f : A → B is a bijection (or bijective) if it is both one-to-one (injective) and
onto (surjective).
Example: f (x) = x + 2 from R to R is bijective.
4. Inverse Function (f −1
):
If f : A → B is a bijective function, then its inverse function f −1
: B → A exists.
f
−1
(b) = a if and only if f (a) = b.
A function has an inverse if and only if it is bijective.
Example: If f (x) = 2x + 1, then f −1
(y) =
y−1

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

(g ∘ f )(x) = g(f (x)) = g(x + 1) = (x + 1)


2
.
(f ∘ g)(x) = f (g(x)) = f (x ) = x
2 2
+ 1 .

Special Types of Functions

Identity Function (I ): I A A : A → A where I A (x) = x for all x ∈ A.


Constant Function: f : A → B where f (x) = c for all x ∈ A, where c is a fixed element
in B.
Floor Function (⌊x⌋): The greatest integer less than or equal to x.
Example: ⌊3.7⌋ = 3, ⌊−2.1⌋ = −3.
Ceiling Function (⌈x⌉): The smallest integer greater than or equal to x.
Example: ⌈3.7⌉ = 4, ⌈−2.1⌉ = −2.

Properties of Functions

If f and g are both injective, then g ∘ f is injective.


If f and g are both surjective, then g ∘ f is surjective.
If f and g are both bijective, then g ∘ f is bijective.
If f : A → B is bijective, then f −1
∘ f = IA and f ∘ f −1
= IB .

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-by-Step Practice Problems ✍️


1. Problem: Let f : Z → Z be defined by f (x) = x . Is f injective? Is it surjective?
2

Step 1: Test for injectivity.


A function is injective if f (a) = f (b) implies a = b.
Let f (a) = f (b). Then a 2
= b
2
.
This implies a = b OR a = −b.
For example, f (2) = 2 2
= 4 and f (−2) = (−2) 2
= 4 . Here f (2) = f (−2) but
2 ≠ −2.

Therefore, f is not injective.


Step 2: Test for surjectivity.
A function is surjective if for every y in the codomain (Z), there exists an x in the
domain (Z) such that f (x) = y.
Consider y = −1 (which is in Z). Is there an integer x such that x 2
= −1 ? No,
the square of an integer cannot be negative.
Consider y = 2. Is there an integer x such that x 2
= 2? No.
Therefore, f is not surjective (its range is only non-negative perfect squares).
Answer: Not injective, not surjective.
2. Problem: Let A = {1, 2, 3} and B = {a, b}. Define f : A → B as
f (1) = a, f (2) = b, f (3) = a . Is this function onto?
Step 1: Identify the domain and codomain. Domain A = {1, 2, 3}, Codomain
B = {a, b}.

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.

If A = B, then R is a binary relation on set A.


Relations can be represented using:
Set of ordered pairs: R = {(a 1, b 1 ), (a 2 , b 2 ), …}

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.

Properties of Relations (on a set A)

1. Reflexive: A relation R on a set A is reflexive if (a, a) ∈ R for every element a ∈ A.


Example: The relation "≤" on the set of integers is reflexive because a ≤ a for every
integer a.
Digraph: Every vertex has a loop.
Matrix: All diagonal elements are 1.
2. Symmetric: A relation R on a set A is symmetric if (b, a) ∈ R whenever (a, b) ∈ R, for all
a, b ∈ A.
Example: The relation "=" on integers is symmetric. If a = b, then b = a. The relation
"is a sibling of" is symmetric.
Digraph: If there is an edge from a to b, there must be an edge from b to a.
Matrix: The matrix is equal to its transpose (M = M
T
).
3. Antisymmetric: A relation R on a set A is antisymmetric if for all a, b ∈ A, if (a, b) ∈ R
and (b, a) ∈ R, then a = b.
This means if a ≠ b, then (a, b) and (b, a) cannot both be in R.
Example: The relation "≤" on integers is antisymmetric. If a ≤ b and b ≤ a, then a = b.
The "divides" relation on positive integers is antisymmetric.
Digraph: There cannot be edges in both directions between two distinct vertices.
Matrix: If M ij = 1 and i ≠ j, then M ji = 0.
4. Transitive: A relation R on a set A is transitive if whenever (a, b) ∈ R and (b, c) ∈ R, then
(a, c) ∈ R , for all a, b, c ∈ A.
Example: The relations "<", "≤", "=", "divides" are transitive. The relation "is an
ancestor of" is transitive.
Digraph: If there is a path of length 2 from a to c (i.e., a → b → c), then there must be
a direct edge from a to c (a → c).
Matrix: If M is the matrix of R, let M = M ⋅ M (Boolean matrix product). If
R
2
R
R R

= 1, then (M ) must be 1 for R to be transitive. (More accurately, R is


2
(M ) ij R ij
R

transitive if R 2
).
⊆ R

Types of Relations

1. Equivalence Relation: A relation R on a set A is an equivalence relation if it is reflexive,


symmetric, and transitive.
Equivalence relations partition the set A into disjoint equivalence classes.
The equivalence class of an element a ∈ A, denoted [a], is the set of all elements
x ∈ A such that xRa.
Example: The relation "=" on integers. The relation "congruence modulo m" (
a ≡ b (mod m)) on integers. "Having the same birthday" on a set of people.

2. Partial Order Relation (Poset): A relation R on a set A is a partial order if it is reflexive,


antisymmetric, and transitive. A set A together with a partial order R is called a
partially ordered set or poset, denoted (A, R).
Example: The relation "≤" on integers. The "divides" relation on positive integers (
a ∣ b). The subset relation "⊆" on the power set of a set.

Hasse Diagrams: Used to represent finite posets.


3. Total Order Relation (Linearly Ordered Set): A partial order R on a set A is a total
order (or linear order) if for every a, b ∈ A, either aRb or bRa (i.e., every pair of elements
is comparable).
Example: The relation "≤" on the set of integers is a total order. The "divides" relation
on positive integers is not a total order (e.g., neither 2 divides 3 nor 3 divides 2).

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.

S ∘ R = {(a, c) ∣ ∃b ∈ B such that (a, b) ∈ R ∧ (b, c) ∈ S} .


(Read as: a is related to c if there exists an intermediate b such that a is R-related to
b and b is S-related to c).
If using matrices, M S∘R = MR ⋅ MS (Boolean matrix multiplication, order of matrices
might depend on convention, here M is |A| × |B| and M is |B| × |C|).
R S

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

The reflexive closure of R is R ∪ Δ, where Δ = {(a, a) ∣ a ∈ A} (the diagonal relation).


The symmetric closure of R is R ∪ R . −1

The transitive closure of R, denoted R or R (depending on definition: R = ⋃ ,


∗ + ∗ n i
i=0
R

R ), is the smallest transitive relation containing R. It can be found by


+ n i
R = ⋃ i=1

R

= R
0
∪ R
1
(where R = Δ, n = |A| for a finite set A) using Boolean
∪ R
2
∪ ⋯ ∪ R
n 0

matrix powers, or by algorithms like Warshall's algorithm.

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

Transitive? ∀ (a, b), (b, c) ∈


R, (a, c) ∈ R
Antisymmetric? (a, b), (b,
Equivalence Relation
a) ∈ R implies a = b

Partial Order

Matrix for Properties:


Reflexive: All main diagonal elements (M ) are 1. ii

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

Transitive: If M ⋅ M (Boolean product, call it M ) has (M ) = 1, then (M


R R
2
R
2
R ij R
) ij

must also be 1. (More precisely, R is transitive if for all i, j, if (M ) = 1 then 2


R ij

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

Step-by-Step Practice Problems ✍️


1. Problem: Let A = {1, 2, 3, 4} and relation R on A be defined as aRb if a ∣ b (a divides b).
Write R as a set of ordered pairs and check if it's an equivalence relation.
Step 1: Write R as ordered pairs.
R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}

Step 2: Check Reflexivity. Is (a, a) ∈ R for all a ∈ A?


(1, 1) ∈ R , (2, 2) ∈ R, (3, 3) ∈ R, (4, 4) ∈ R. Yes, it's reflexive.
Step 3: Check Symmetry. If (a, b) ∈ R, is (b, a) ∈ R?
(1, 2) ∈ R . Is (2, 1) ∈ R? No (2 does not divide 1).
Therefore, it's not symmetric.
Step 4: Conclusion about equivalence relation. Since it's not symmetric, it cannot
be an equivalence relation.
Answer: R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}. It is not an
equivalence relation because it is not symmetric. (It is, however, reflexive,
antisymmetric, and transitive, making it a partial order).
2. Problem: Let R = {(a,b), (b,c), (c,a)} on set {a,b,c}. Find R 2
.
= R ∘ R

Step 1: Understand R ∘ R. (x, z) ∈ R ∘ R if there exists y such that (x, y) ∈ R and


(y, z) ∈ R .
Step 2: Systematically find pairs.
(a,b) ∈ R and (b,c) ∈ R ⇒ (a,c) ∈ R . 2

(b,c) ∈ R and (c,a) ∈ R ⇒ (b,a) ∈ R . 2

(c,a) ∈ R and (a,b) ∈ R ⇒ (c,b) ∈ R . 2

Step 3: Check for other possibilities. No other intermediate links exist.


Answer: R 2
.
= {(a,c), (b,a), (c,b)}

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

Topic Coverage Guide 📚


Breadth: Understand the definition of a binary relation, how to represent it (set of pairs,
matrix, digraph). Know the definitions of reflexive, symmetric, antisymmetric, and
transitive properties. Be familiar with the definitions of equivalence relations and partial
orders.
Depth: Ability to determine if a given relation possesses these properties. Understanding
how to find equivalence classes. Basic understanding of relation composition and
inverse. Solving problems involving these concepts on small sets.

Chapter 4: Propositional Logic and Predicate Logic


Part 1: Propositional Logic (Propositional Calculus)

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"

Conjunction (AND): p ∧ q - "p and q"


Disjunction (OR): p ∨ q - "p or q" (inclusive OR, meaning p or q or both)
Exclusive OR (XOR): p ⊕ q - "p xor q" (p or q, but not both)
Implication (Conditional): p → q - "if p, then q" (p implies q)
p is the hypothesis (antecedent, premise).
q is the conclusion (consequent).
Biconditional (If and Only If, IFF): p ↔ q - "p if and only if q"

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

Notes on Implication (p → q):

p → q is only false when p is true and q is false.


If p is false, p → q is always true, regardless of the truth value of q (this is called vacuous
truth).
Related implications:
Converse: q → p
Inverse: ¬p → ¬q
Contrapositive: ¬q → ¬p (Logically equivalent to the original implication p → q)

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, Contradiction, Contingency

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.

Arguments and Rules of Inference

An argument in propositional logic is a sequence of propositions. All but the final


proposition are called premises (or hypotheses), and the final proposition is called the
conclusion.
An argument is valid if the truth of all its premises implies that the conclusion is true.
(i.e., (premise ∧ premise ∧ ⋯ ∧ premise ) → conclusion is a tautology).
1 2 N

Rules of Inference (Valid Argument Forms):


Modus Ponens: [(p → q) ∧ p] → q (If p implies q, and p is true, then q is true)
Modus Tollens: [(p → q) ∧ ¬q] → ¬p (If p implies q, and q is false, then p is false)
Hypothetical Syllogism: [(p → q) ∧ (q → r)] → (p → r) (Transitivity of implication)
Disjunctive Syllogism: [(p ∨ q) ∧ ¬p] → q
Addition: p → (p ∨ q)
Simplification: (p ∧ q) → p
Conjunction: [(p) ∧ (q)] → (p ∧ q)
Resolution: [(p ∨ q) ∧ (¬p ∨ r)] → (q ∨ r)

Visual Aids 📊
Truth Table Structure:

| p | q | ... | Compound Proposition |


|---|---|-----|----------------------|
| T | T | ... | Resulting Truth Value|
| T | F | ... | Resulting Truth Value|
| F | T | ... | Resulting Truth Value|
| F | F | ... | Resulting Truth Value|

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

Step-by-Step Practice Problems ✍️


1. Problem: Construct a truth table for the proposition (p → q) ∧ (q → p). What is this
equivalent to?
Step 1: Set up columns for p, q, p → q, q → p, and (p → q) ∧ (q → p).
Step 2: Fill in truth values for p and q.
Step 3: Calculate p → q. (False only if T → F)
Step 4: Calculate q → p. (False only if T → F)
Step 5: Calculate (p → q) ∧ (q → p). (True only if both parts are T)

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

Part 2: Predicate Logic (First-Order Logic)

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

When a quantifier is used on a variable x, or when a value is assigned to x, the variable


x is said to be bound.

A variable that is not bound is called free.


A statement with no free variables is a proposition.

Negation of Quantified Statements (De Morgan's Laws for Quantifiers)

¬(∀xP (x)) ≡ ∃x¬P (x)

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

Translating English Sentences into Logical Expressions

"All students in this class have studied calculus."


Let S(x) be "x is a student in this class."
Let C(x) be "x has studied calculus."
Domain: All people.
Translation: ∀x(S(x) → C(x)) (For all people x, if x is a student in this class, then x
has studied calculus).
"Some students in this class are intelligent."
Let S(x) be "x is a student in this class."
Let I (x) be "x is intelligent."
Domain: All people.
Translation: ∃x(S(x) ∧ I (x)) (There exists a person x such that x is a student in this
class AND x is intelligent).
"No student in this class is a morning person."
Let S(x) be "x is a student in this class."
Let M (x) be "x is a morning person."
Translation: ∀x(S(x) → ¬M (x)) OR ¬∃x(S(x) ∧ M (x)).

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

Arguments in Predicate Logic

Rules of inference for propositional logic can be extended.


Universal Instantiation (UI): From ∀xP (x), we can infer P (c) for any specific element c
in the domain.
Universal Generalization (UG): If P (c) is true for an arbitrary element c from the
domain, then we can infer ∀xP (x). (Requires c to be truly arbitrary).
Existential Instantiation (EI): From ∃xP (x), we can infer P (c) for some element c in the
domain (but we don't know which c without more info; c must be a new constant not
appearing elsewhere).
Existential Generalization (EG): If P (c) is true for some specific element c in the
domain, then we can infer ∃xP (x).

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)

≡ ∀x∃y¬L(x, y) (Everyone has someone they don't love).

Step-by-Step Practice Problems ✍️


1. Problem: Translate the statement "Every student in this class has a computer or has a
friend who has a computer" into predicate logic.
Step 1: Define predicates and domain.
Domain: All people.
S(x) : "x is a student in this class."
C(x) : "x has a computer."
F (x, y) : "x and y are friends."
Step 2: Translate the parts.
"x has a computer": C(x)
"x has a friend who has a computer": This means there exists a person y such
that y is a friend of x AND y has a computer. So, ∃y(F (x, y) ∧ C(y)).
Step 3: Combine with "or".
C(x) ∨ (∃y(F (x, y) ∧ C(y))) . Let this whole expression be Q(x).
Step 4: Apply "Every student in this class".
∀x(S(x) → Q(x)) .
Answer: ∀x(S(x) → (C(x) ∨ (∃y(F (x, y) ∧ C(y))))).
2. Problem: What is the negation of ∀x∃y(xy = 1)? (Domain: Real numbers)
Step 1: Apply De Morgan's Law for quantifiers ¬(∀xP (x)) ≡ ∃x¬P (x).
Let P (x) be ∃y(xy = 1).
¬(∀x∃y(xy = 1)) ≡ ∃x¬(∃y(xy = 1)) .
Step 2: Apply De Morgan's Law again ¬(∃yQ(y)) ≡ ∀y¬Q(y).
Let Q(y) be (xy = 1).
∃x¬(∃y(xy = 1)) ≡ ∃x∀y¬(xy = 1) .
Step 3: Simplify ¬(xy = 1).
¬(xy = 1) ≡ xy ≠ 1 .
Answer: ∃x∀y(xy ≠ 1).
(Meaning: There exists a real number x such that for all real numbers y, their
product is not 1. This is true, e.g., if x = 0.)
3. Problem: Let P (x, y) be "x + y = y + x". What are the truth values of ∀x∀yP (x, y) and
∃x∃yP (x, y) if the domain for all variables is the set of real numbers?
Step 1: Analyze P (x, y) : x + y = y + x. This is the commutative law of addition for
real numbers, which is always true.
Step 2: Evaluate ∀x∀yP (x, y).
"For all real numbers x and for all real numbers y, x + y = y + x."
Since the commutative law holds for all real numbers, this statement is True.
Step 3: Evaluate ∃x∃yP (x, y).
"There exists a real number x and there exists a real number y such that
x + y = y + x ."
Since P (x, y) is true for all pairs, it is certainly true for at least one pair (e.g.,
x = 1, y = 2 gives 1 + 2 = 2 + 1). This statement is True.

Answer: Both are True.

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

domain includes complex numbers (where i 2


= −1).
Order of Mixed Quantifiers Matters: ∀x∃yP (x, y) is generally not equivalent to
∃y∀xP (x, y). The latter is a stronger statement.

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

(vacuously), making ∃x(A(x) → B(x)) true even if no A's are B.


Translating "All": "All A are B" is ∀x(A(x) → B(x)). It's not ∀x(A(x) ∧ B(x)), because
that would mean everything in the domain is an A and also a B.
Practice Negations: Mastering the negation of quantified statements using De Morgan's
laws is important.
Topic Coverage Guide 📚
Breadth: Understand the definition of predicates, quantifiers (∀, ∃), and bound/free
variables. Be able to translate simple English sentences with quantifiers into logical
expressions. Know De Morgan's laws for quantifiers.
Depth: Ability to determine the truth value of quantified statements (especially with
nested quantifiers) over a given domain. Understanding the difference in meaning based
on the order of mixed quantifiers. Basic application of rules of inference for quantified
statements.

Chapter 5: Strings and Languages


Key Concepts 💯
Alphabet (Σ): A finite, non-empty set of symbols (characters).
Examples: Σ = {0, 1} (binary alphabet), Σ = {a, b, c},
Σ = {A, B, ..., Z, a, b, ..., z, 0, 1, ..., 9} .
String (Word): A finite sequence of symbols chosen from some alphabet.
Example: If Σ = {a, b}, then aba , aaabbb , b are strings over Σ.
Empty String (λ or ϵ): A string with no symbols. Its length is 0.
Length of a String (|w|): The number of symbols in the string w.
Example: If w = abca, then |w| = 4. |λ| = 0.
Concatenation: If w and w are strings, their concatenation w
1 2 1 w2 is the string formed
by appending w to w . 2 1

Example: If w 1 = abc and w 2 , then w


= de 1 w2 = abcde.
Concatenation with the empty string: wλ = λw = w.
Σ

(Sigma Star / Kleene Star): The set of all possible strings of finite length (including
the empty string λ) that can be formed from the symbols in the alphabet Σ. This is an
infinite set if Σ is not empty.
Σ (Sigma Plus / Kleene Plus): The set of all possible non-empty strings of finite length
+

from the alphabet Σ. Σ = Σ − {λ}. + ∗

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:

1. Union (L 1 ∪ L2 ): The set of strings that are in L or in L or in both. 1 2

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 .

Other Language Operations:

5. Concatenation of Languages (L 1 L2 or L 1 ⋅ L2 ): The set of all strings formed by


concatenating a string from L with a string from L . 1 2

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

from L. This always includes the empty string λ.


∗ 0 1 2
L = L ∪ L ∪ L ∪ …

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 (Brief Introduction)

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

Parentheses () can be used for grouping.


Examples:
01* : Strings starting with a 0 followed by zero or more 1 s. Language:
{0, 01, 011, 0111, …} .
(0+1)* : Any string of 0 s and 1 s (all binary strings, including λ). Language:
{λ, 0, 1, 00, 01, 10, 11, …} . This is Σ for Σ = {0, 1}.

a*b : Zero or more 'a's followed by a single 'b'. Language: {b, ab, aab, …} .

Grammars (Brief Introduction)

A formal grammar provides rules for generating strings in a language.


A common type is a phrase-structure grammar G = (V , T , S, P ) where:
V is a finite set of variables (or non-terminal symbols).
T is a finite set of terminal symbols (the alphabet Σ of the language). V ∩ T = ∅ .
S ∈ V is the start symbol.
P is a finite set of production rules of the form α → β, where α and β are strings of
symbols from V ∪ T , and α contains at least one variable.

Visual Aids 📊
Language Operations Example (Conceptual):
Let L = {0, 01} and L = {1, 10} over Σ = {0, 1}.
1 2

L 1 ∪ L 2 = {0, 01, 1, 10}

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

So, L 1 L2 = {01, 010, 011, 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, ...

Step-by-Step Practice Problems ✍️


1. Problem: Let Σ = {0, 1}. Describe the language L = {w ∈ Σ ∗
∣ |w| = 2} by listing its
elements.
Step 1: The alphabet is binary.
Step 2: We need strings of length 2.
Step 3: Possible strings:
00
01
10
11
Answer: L = {00, 01, 10, 11}.
2. Problem: Let L 1 = {a, aa} and L 2 = {b}. Find L 1 L2 and L 2 L1 .
Step 1: Find L 1 L2 . Concatenate each string in L with each string in L .
1 2

a (from L ) ⋅ b (from L ) = ab
1 2

aa (from L ) ⋅ b (from L ) = aab


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

b (from L ) ⋅ aa (from L ) = baa


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. So, L = {λ} ∪ L . If λ ∈ L, then L = L .


∗ + + ∗
Concatenation is Not Commutative: L 1
L2 ≠ L2 L1 in general.
Regular Expressions are Patterns: Think of them as rules for generating or matching
strings. Practice with common RE patterns.
Distinguish ∅ (empty language) from {λ} (language containing only the empty
string):
L ∪ ∅ = L

L ∪ {λ} is L with λ added (if not already there).


L ⋅ ∅ = ∅ ⋅ L = ∅

L ⋅ {λ} = {λ} ⋅ L = L


∅ = {λ}


{λ} = {λ}

Topic Coverage Guide 📚


Breadth: Understand the definitions of alphabet, string, empty string, length,
concatenation, Σ , and language. Be familiar with basic set operations on languages

(union, intersection, complement) and language-specific operations (concatenation,


Kleene star, positive closure). A basic understanding of what regular expressions
represent is beneficial.
Depth: Ability to perform operations like concatenation and Kleene star on small, given
languages. Ability to determine if simple strings belong to a language defined by simple
rules or a basic regular expression.

This completes the Discrete Mathematics section. Let me know what's next!

You might also like