Complete Engineering Notes, Practice Lab & Exam Preparation
Master computational theory with our comprehensive resource featuring complete lecture notes, interactive practice environment, 200+ solved questions, step-by-step explanations, visual automata simulator, and exam-focused content. Everything you need to excel in TOC - from basic concepts to advanced proofs and problem solving.
Comprehensive lecture notes with detailed explanations
Alphabet (Ξ£): A finite non-empty set of symbols or characters.
Example: Ξ£ = {0, 1} (binary alphabet), Ξ£ = {a, b, c, ..., z} (English alphabet)
String: A finite sequence of symbols from an alphabet.
Language (L): A set of strings over an alphabet Ξ£. L β Ξ£*
Deterministic Finite Automaton (DFA):
M = (Q, Ξ£, Ξ΄, qβ, F) where:
M = (Q, Ξ£, Ξ΄, qβ, F) where Ξ΄: Q Γ Ξ£_Ξ΅ β P(Q)
Algebraic notation to describe regular languages:
Theorem: The following are equivalent for any language L:
These languages are called Regular Languages.
Statement: If L is regular, then βp β₯ 1 such that βs β L with |s| β₯ p, s = xyz where:
Use: To prove a language is NOT regular (proof by contradiction)
Regular languages are closed under:
Problem: Construct DFA for L = {w β {0,1}* | w has even number of 0s and odd number of 1s}
State Representation:
States: {qββ, qββ, qββ, qββ}
Transition Table:
| State | Input 0 | Input 1 |
|---|---|---|
| qββ | qββ | qββ |
| qββ | qββ | qββ |
| qββ | qββ | qββ |
| qββ | qββ | qββ |
G = (V, Ξ£, R, S) where:
Production Rule: A β Ξ± where A β V and Ξ± β (V βͺ Ξ£)*
A CFG is ambiguous if some string has multiple parse trees.
A language is inherently ambiguous if every CFG for it is ambiguous.
Every production is of the form:
M = (Q, Ξ£, Ξ, Ξ΄, qβ, Zβ, F) where:
Theorem: A language L is context-free iff it is accepted by some PDA.
If L is context-free, then βp such that βs β L with |s| β₯ p, s = uvwxy where:
Closed under: Union, Concatenation, Kleene Star
NOT closed under: Intersection, Complement
Problem: Convert CFG for {0βΏ1βΏ | n β₯ 0} to PDA
CFG:
PDA Construction:
Transitions:
M = (Q, Ξ£, Ξ, Ξ΄, qβ, q_accept, q_reject) where:
Intuitive notion of "algorithm" = Turing Machine computation
Cannot be proven (it's a thesis), but universally accepted.
A language L is decidable if some TM decides it.
A TM decides L if it accepts all strings in L and rejects all strings not in L.
Examples of decidable languages:
Halting Problem: A_TM = {β¨M,wβ© | M is TM that accepts w}
Theorem: A_TM is undecidable.
Proof by diagonalization:
Language A is reducible to B (A β€_m B) if there exists computable function f such that:
w β A βΊ f(w) β B
If A β€_m B and B is decidable, then A is decidable.
If A β€_m B and A is undecidable, then B is undecidable.
Every non-trivial property of Turing-recognizable languages is undecidable.
A property P is trivial if P = β or P = all TM languages.
Algorithm:
Formal Description:
State qβ: Scan right for first 0
If 0 found: Mark as X, go to qβ
If Y or Z found: go to qβ
(check phase)
If blank: accept
State qβ: Scan right for first 1
If 1 found: Mark as Y, go to qβ
If 2 or blank: reject
State qβ: Scan right for first 2
If 2 found: Mark as Z, go to qβ
If blank: reject
State qβ: Return to start
Move left until start marker
Go to qβ
State qβ
: Final check
If only X,Y,Z remain: accept
Otherwise: reject
Time complexity f(n) = maximum number of steps TM uses on input of length n.
TIME(f(n)): Collection of languages decidable by TM running in time O(f(n))
A verifier for language A is algorithm V such that:
A = {w | V accepts β¨w,cβ© for some certificate c}
Polynomial verifier: V runs in polynomial time in |w|
NP = {L | L has polynomial verifier}
Language B is NP-complete if:
Cook-Levin Theorem: SAT is NP-complete
SPACE(f(n)): Languages decidable by TM using O(f(n)) space
Time Hierarchy: If f(n) log f(n) = o(g(n)), then TIME(f(n)) β TIME(g(n))
Space Hierarchy: If f(n) = o(g(n)), then SPACE(f(n)) β SPACE(g(n))
Savitch's Theorem: NSPACE(f(n)) β SPACE(f(n)Β²)
Problem: Prove CLIQUE is NP-complete
Step 1: Show CLIQUE β NP
Given graph G and k, certificate is a set of k vertices. Verify in O(kΒ²) time that all pairs are connected.
Step 2: Show 3SAT β€_p CLIQUE
Given 3SAT formula Ο with m clauses:
Example: Ο = (xβ β¨ xβ β¨ xβ) β§ (xΜβ β¨ xΜβ β¨ xβ)
Creates 6 vertices, connections between non-contradictory literals from different clauses.
Test your understanding with interactive exercises
Enter a string to test if it's accepted by the DFA for "strings ending with 01":
Results will appear here...
Test if strings match common regular expressions:
Results will appear here...
Practice using pumping lemma to prove languages are not regular:
Select a language to see pumping lemma proof...
200+ Solved Questions with Detailed Explanations
Click to reveal answer β
Answer:
Deterministic Finite Automaton (DFA):
Non-Deterministic Finite Automaton (NFA):
Example: Language L = {strings over {0,1} containing "01"}
NFA: 3 states with Ξ΅-transition. DFA: Requires subset construction.
Click to reveal answer β
Proof by Contradiction:
Click to reveal answer β
Step-by-step Construction:
Final NFA: States {qβ, qβ, qβ}, transitions preserve the pattern recognition for strings ending in 01.
Click to reveal answer β
Analysis: Union of two languages - Lβ (i=j) and Lβ (j=k)
Grammar G:
S β Sβ | Sβ
Sβ β AB // For i = j
A β aAb | Ξ΅ // Equal a's and b's
B β cB | Ξ΅ // Any number of c's
Sβ β CB // For j = k
C β aC | Ξ΅ // Any number of a's
B β bBc | Ξ΅ // Equal b's and c's
Example derivations:
Click to reveal answer β
Step 1: Original grammar generates {aβΏbβΏ | n β₯ 1}
Step 2: Eliminate productions with mixed terminals/variables
S β ASB | AB
A β a
B β b
Step 3: Break down productions with >2 variables
S β AC | AB // where C β SB
A β a
B β b
C β SB
Final CNF:
S β AC | AB
A β a
B β b
C β SB
Click to reveal answer β
Input: 1Λ£ (x ones)
Output: 1Β²Λ£ (2x ones)
Algorithm:
Detailed Steps:
1. Mark first 1 as X, move right to find blank
2. Write 11 after blank, return to next unmarked 1
3. Repeat until all 1s processed
4. Clean up: replace X's with blanks, position result
5. Accept
Transitions:
Ξ΄(qβ, 1) = (qβ, X, R) // Mark and move right
Ξ΄(qβ, 1) = (qβ, 1, R) // Skip over 1s
Ξ΄(qβ, B) = (qβ, 1, R) // Write first copy
Ξ΄(qβ, B) = (qβ, 1, L) // Write second copy
... (return transitions)
Click to reveal answer β
Theorem: A_TM = {β¨M,wβ© | M is TM that accepts w} is undecidable.
Proof by Contradiction:
D on input β¨Mβ©:
1. Run H on β¨M,β¨Mβ©β©
2. If H accepts: REJECT
3. If H rejects: ACCEPT
Click to reveal answer β
Step 1: Show VERTEX-COVER β NP
Step 2: Reduce 3SAT β€_p VERTEX-COVER
Given: 3SAT formula Ο with variables xβ,...,xβ and clauses Cβ,...,Cβ
Construct graph G:
Set k = n + 2m
Correctness:
Click to reveal answer β
Class Definitions:
Known Relationships:
Justification:
Open Questions:
Practical Implications:
Click to reveal answer β
Cook-Levin Theorem (1971): SAT (Boolean Satisfiability) is NP-complete.
Significance:
Proof Idea:
Construction Details:
Impact: Led to discovery of thousands of NP-complete problems across all areas of computer science.
Foundation of computational models
A finite state machine that accepts or rejects strings based on a sequence of characters, with exactly one transition per state-symbol pair.
Similar to DFA but can have multiple transitions for the same input symbol, including Ξ΅-transitions (empty string transitions).
A powerful notation for describing patterns in strings, equivalent in power to finite automata for recognizing regular languages.
A DFA is a 5-tuple M = (Q, Ξ£, Ξ΄, qβ, F) where:
This DFA accepts strings that end with the pattern '01'. State qβ is the initial state, qβ represents having seen a '0', and qβ (final) represents having seen '01'.
If L is a regular language, then there exists a positive integer p such that for any string s β L with |s| β₯ p, s can be divided into three parts s = xyz such that:
Handling nested structures and programming languages
Formal grammars that can generate context-free languages, essential for parsing programming languages and handling nested structures.
Finite automata enhanced with a stack memory, providing the computational power needed to recognize context-free languages.
Standardized forms of CFGs like Chomsky Normal Form (CNF) and Greibach Normal Form (GNF) for easier analysis and parsing.
A CFG is a 4-tuple G = (V, Ξ£, R, S) where:
This grammar generates all strings of balanced parentheses. The rules allow for empty string (Ξ΅), concatenation of balanced strings (SS), and nesting within parentheses ((S)).
A PDA is a 6-tuple M = (Q, Ξ£, Ξ, Ξ΄, qβ, F) where:
If L is a context-free language, then there exists p > 0 such that for any string s β L with |s| β₯ p, s can be written as s = uvwxy where:
The ultimate model of computation
The most powerful model of computation, equivalent to any algorithm that can be computed. Foundation for understanding computability limits.
The famous undecidable problem: determining whether a given program will halt on a specific input. Proof of computational limits.
Classification of problems into those that can be solved algorithmically (decidable) and those that cannot (undecidable).
A Turing Machine is a 7-tuple M = (Q, Ξ£, Ξ, Ξ΄, qβ, q_accept, q_reject) where:
The informal statement that the class of functions computable by a Turing Machine corresponds exactly to the class of functions that we would intuitively consider to be "computable" by an algorithm.
For any non-trivial property P of the language recognized by Turing machines, the problem of determining whether a given Turing machine recognizes a language with property P is undecidable.
Analyzing the resources required for computation
The most famous open problem in computer science: whether every problem whose solution can be verified in polynomial time can also be solved in polynomial time.
The hardest problems in NP class. If any NP-complete problem can be solved in polynomial time, then P = NP.
Hierarchy of complexity classes: P, NP, PSPACE, EXPTIME, and their relationships and separations.
The Boolean satisfiability problem (SAT) is NP-complete. This was the first problem proven to be NP-complete and forms the basis for proving other problems NP-complete through polynomial-time reductions.
Test your understanding with these problems
Construct a DFA that accepts strings over {0,1} where the number of 1s is odd and the number of 0s is even.
We need 4 states to track parity of both 0s and 1s:
Prove that the language L = {0βΏ1βΏ | n β₯ 0} is not regular using the pumping lemma.
Proof by contradiction:
Write a CFG for the language L = {aβ±bΚ²cα΅ | i = j or j = k, i,j,k β₯ 0}.
Design a Turing machine that computes the function f(n) = n + 1 where n is represented in unary (as 1βΏ).
Algorithm:
Prove that CLIQUE is NP-complete by showing: (1) CLIQUE β NP, (2) 3-SAT β€β CLIQUE.
(1) CLIQUE β NP: Given graph G and integer k, we can verify a clique of size k in polynomial time by checking all edges between claimed clique vertices.
(2) 3-SAT β€β CLIQUE: For each clause in 3-SAT formula, create vertices for each literal. Connect vertices if they're from different clauses and don't contradict each other. A k-clique exists iff the 3-SAT formula with k clauses is satisfiable.
Everything you need to excel in TOC exams
Essential formulas, definitions, and theorems for quick reference during exams and problem solving.
Solved previous exam questions with detailed explanations and marking schemes.
Timed practice tests with instant feedback and performance analysis.
Expert tips and shortcuts for common problem patterns and construction techniques.
Practice consistently rather than cramming. Work through problems systematically, understand the underlying concepts, and build your intuition through multiple examples. Focus on problem-solving techniques rather than just memorizing solutions. Remember: TOC is about logical reasoning and formal methods - these skills improve with practice!