Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
4
Need of TOC
• TOC provides the mathematical basis for understanding how computation
works, defining what problems can or cannot be solved by machines.
• It helps in designing abstract machines (like Finite Automata, Pushdown
Automata, Turing Machines) to model and solve real-world problems
systematically.
• Essential for building compilers, interpreters, and parsers, as it classifies
languages into Regular, Context-Free, and others—each with specific
machine models.
• TOC helps in understanding time and space complexity.
5.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
5
Application of TOC
• Compiler Design: TOC concepts like finite automata and grammars are
used in lexical analysis and syntax parsing in compilers.
• Artificial Intelligence: State machines help model decision-making
processes in AI agents and robotics.
• Natural Language Processing (NLP): Regular and context-free grammars
are used for syntax checking, sentence parsing, and Chatbot design.
• Cryptography and Security: Computability and complexity theory guide the
design of secure encryption and authentication algorithms.
• Software Verification and Model Checking: TOC helps ensure that software
and hardware systems behave correctly and reliably through formal
verification methods.
6.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
6
Basic of Sets
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
9
Type Example
Finite Set A = {1, 2, 3, 4}
Infinite Set N = {1, 2, 3, …}
Empty Set ( )
∅ B = {}
Subset A B every element of A is in B
⊆ ⇒
Power Set P(A) = set of all subsets of A
Universal Set U = set containing all elements under consideration
Equal Sets A = {1, 2}, B = {2, 1} A = B
⇒
Types of Sets
10.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
10
Operation Symbol Description
Union A B
∪ All elements in A or B or both
Intersection A ∩ B Common elements in A and B
Difference A − B Elements in A but not in B
Complement A' Elements not in A (in Universal Set)
Cartesian Product A × B
Set of ordered pairs (a, b) with a ∈
A, b B
∈
Set Operations
11.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
11
Set Operations
Union ( ), Intersection ( ∩ ), Difference ( − )
∪
• A = {1, 2, 3}, B = {3, 4, 5}
A B = {1, 2, 3, 4, 5}
∪
A ∩ B = {3}
A − B = {1, 2}
Complement ( A' or U − A )
• If U = {1, 2, 3, 4, 5} and A = {2, 3}
Then A = {1, 4, 5}
′
12.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
12
Set Operations
Symmetric Difference ( or )
⊕ △
(A − B) (B − A)
∪
• A = {1, 2, 3}, B = {3, 4, 5}
A B = {1, 2, 4, 5}
△
Cartesian Product ( × )
• A = {1, 2}, B = {x, y}
A × B = {(1, x), (1, y), (2, x), (2, y)}
13.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
13
Questions
1. Let A = {a, b, c}, B = {b, c, d, e}. Find A B.
∪
2. A = {1, 3, 5, 7}, B = {2, 3, 5, 8}. Find A ∩ B.
3. A = {10, 20, 30, 40}, B = {20, 50, 60}. Find A − B.
4. A = {p, q, r}, B = {q, r, s, t}. Find A B.
△
5. Universal set U = {1, 2, 3, 4, 5, 6},
Set A = {2, 4, 6}. Find A .
′
6. A = {1, 2}, B = {x, y}. Find A × B.
14.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
14
Questions
Let A = {a, b, c}, B = {b, c, d, e}. Find A B.
∪
A B = {a, b, c, d, e}
∪
A = {1, 3, 5, 7}, B = {2, 3, 5, 8}. Find A ∩ B.
A ∩ B = {3, 5}
A = {10, 20, 30, 40}, B = {20, 50, 60}. Find A − B.
A − B = {10, 30, 40}
15.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
15
Questions
Universal set U = {1, 2, 3, 4, 5, 6},
Set A = {2, 4, 6}. Find A .
′
A = {1, 3, 5}
′
A = {p, q, r}, B = {q, r, s, t}. Find A B.
△
A B = {p, s, t}
△
A = {1, 2}, B = {x, y}. Find A × B.
A × B = {(1, x), (1, y), (2, x), (2, y)}
16.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
16
Questions
• Let
A = {1, 2, 3, 4},
B = {3, 4, 5, 6},
U = {1, 2, 3, 4, 5, 6, 7}
Find:
• A ∩ B = ?
• A B = ?
∪
• B − A = ?
• A = ?
′
17.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
17
Answers
• Let
A = {1, 2, 3, 4},
B = {3, 4, 5, 6},
U = {1, 2, 3, 4, 5, 6, 7}
Answers:
A ∩ B = {3, 4}
A B = {1, 2, 3, 4, 5, 6}
∪
B − A = {5, 6}
A = {5, 6, 7}
′
18.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
18
Relations
• A relation is a subset of the Cartesian product of two sets.
• If you have sets A and B, a relation R from A to B is any subset of A×B.
Example 1: Basic Relation
Let:
• A={1,2}
• B={x,y}
Then A×B={(1,x),(1,y),(2,x),(2,y)}
A relation R A×B could be:
⊆
R = { (1, x), (2, y) }
19.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
19
Relations
20.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
20
Relations
21.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
21
Relations
22.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
22
Types of Relation
1. Reflexive Relation
• Definition: A relation R on set A is reflexive if every element is related
to itself.
• Condition: a A, (a, a) R
∀ ∈ ∈
• Example: On A = {1, 2, 3}, R = {(1,1), (2,2), (3,3)}
2. Irreflexive Relation
• ∀a A,(a,a) R
∈ ∉
• No self-pairs like (1,1)
23.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
23
Types of Relation
3. Symmetric Relation
• Definition: A relation R is symmetric if (a, b) R implies (b, a) R.
∈ ∈
• Example: If (1, 2) R, then (2, 1) must also be in R.
∈
4. Anti-Symmetric Relation
• Definition: A relation R is anti-symmetric if (a, b) R and (b, a) R
∈ ∈
implies a = b.
• Example: On A = {1, 2}, R = {(1,1), (2,2), (1,2)} is anti-symmetric
because (2,1) is not in R
24.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
24
Types of Relation
5. Asymmetric Relation
In an asymmetric relation, if the pair (a, b) is in the relation, then the pair
(b, a) must not be in the relation for any elements a and b from the set.
∀ a, b A
∈ , if (a, b) R
∈ then (b, a) R
∉ and vice versa.
6. Transitive Relation
• Definition: A relation R is transitive if (a, b) R and (b, c) R implies
∈ ∈
(a, c) R.
∈
• Example: If (1,2) R and (2,3) R, then (1,3) must also be in R.
∈ ∈
25.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
25
Types of Relation
6. Equivalence Relation
• Definition: A relation that is reflexive, symmetric, and transitive.
• Example: "Is congruent modulo n" on integers. a≡b (mod n)
a−b=kn, for some integer k.
17 ≡ 5 (mod 12)
Because 17−5=12, and 12 is divisible by 12.
7. Partial Order Relation (Poset)
• Definition: A relation that is reflexive, anti-symmetric, and transitive.
• Example: “≤” on set of natural numbers.
26.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
26
Example
Let A={1,2,3}
Define relation R={(1,1),(2,2),(3,3),(1,2),(2,1)}
Let's test whether it's an equivalence relation:
• Reflexive?
Yes, because all elements of A appear as (a,a): (1,1), (2,2), (3,3)
• Symmetric?
(1,2) is in R, and (2,1) is also in R→ OK
• Transitive?
(1,2) and (2,1) are in R, but (1,1) is already in R, so OK.
No other pairs violate transitivity.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
30
Closure of Relations
• In mathematics, especially in the context of set theory and algebra, the closure
of relations is a crucial concept.
• It involves extending a given relation to include additional elements based on
specific properties, such as reflexivity, symmetry, and transitivity.
1. Reflexive Closure
• The reflexive closure of a relation R on a set A is the smallest relation R that
′
contains R and is reflexive. This means that every element in A is related to itself.
• Formula: R = R {(a,a) a A}
′ ∪ ∣ ∈
• Example: Let A = {1,2} and R={(1,2)}. The reflexive closure of R is: R = {(1,2),(1,1),
′
(2,2)}.
31.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
31
2. Symmetric Closure
• The symmetric closure of a relation R on a set A is the smallest
relation R that contains R and is symmetric.
′
• Formula: R = R {(b,a) (a,b) R}
′ ∪ ∣ ∈
• Example: Let A = {1,2} and R = {(1,2)}. The symmetric closure of R is: R
= {(1,2),(2,1)}.
′
32.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
32
3. Transitive Closure
• The transitive closure of a relation R on a set A is the smallest relation
R that contains R and is transitive.
′
Example:
• Let A = {1,2,3} and R = {(1,2),(2,3)}. The transitive closure of R is:
• R = {(1,2),(2,3),(1,3)}.
′
33.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
33
Mathematical Induction
• Mathematical induction is a proof technique used to prove that a
statement is true for all natural numbers (usually starting from 1 or 0).
Steps of Mathematical Induction
• To prove a statement P(n) true for all n≥n0
, follow these steps:
Step 1: Base Case
• Prove that the statement is true for the initial value (usually n=1 or n=0).
Step 2: Inductive Hypothesis
• Assume that the statement is true for n=k.
i.e., Assume P(k) is true.
34.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
34
Step 3: Inductive Step
• Prove that if the statement is true for n=k, then it must also be true
for n=k+1.
i.e., show that P(k) P(k+1)
⇒
35.
Department of ComputerScience And Engineering, Poornima
University, Jaipur, India
35
Prove that