Top Banner Ad

BCS402 — Unit 1: Basic Concepts and Automata Theory

Table of Contents (18 sections)

BCS402 · Theory of Automata and Formal Languages · Unit 1

Basic Concepts and Automata Theory

Unit Scope & Exam Weightage: This unit covers automata and computation basics, alphabet/symbol/string/formal language, DFA definition, representation and acceptability, NFA, DFA–NFA equivalence and subset construction, ε-NFA and its equivalence, Moore and Mealy machines with output, equivalence of Moore/Mealy, and minimization of finite automata. AKTU asks 2-mark definitions plus 7-mark construction questions — every answer needs a state table and a trace.


Importance-Wise Roadmap (BCS402 Unit 1)

Priority Exact Syllabus Topic PYQ Evidence Marks Pattern Tag
1 DFA design & acceptability (ends-with, substring, avoidance) 2023-24, 2025-26 2m + 7m × 2 Guaranteed construction
2 NFA design + DFA–NFA equivalence (subset method) 2024-25, 2025-26 7m × 3 Table method
3 Moore machine / 1's complement 2025-26 7m Output automaton
4 Minimization of finite automata 2023-24, 2024-25 (predicted cluster) 7m Partitioning
5 DFA vs NFA, formal definition of DFA, alphabet 2023-24, 2024-25, 2025-26 2m × 4 Quick marks
6 ε-NFA and equivalence, Mealy machine, computability/complexity Not directly asked Predicted Backup theory

Automata-specific examiner guidance: A construction answer is incomplete without (i) the set of states with meaning, (ii) a transition table, (iii) the start/final marking, and (iv) one accepted and one rejected trace. Write these four parts in order for every 7-mark design question.


1. Fundamental Definitions

Term Definition Example
Symbol A single atomic character 0, a, #
Alphabet (Σ) Finite non-empty set of symbols Σ={0,1}\Sigma=\{0,1\}
String Finite sequence of symbols from Σ; length $ w
Empty string (ε) String of length zero ε\varepsilon
Language A set of strings over an alphabet L={0n1n∣n≥0}L=\{0^n1^n\mid n\ge0\}
Automaton A finite-state machine that reads a string and accepts/rejects it DFA, NFA, PDA, TM

PYQ (2024-25, 2 marks): "Define the term 'Alphabet' in the context of automata theory." An alphabet is a finite, non-empty set of symbols used to form strings; conventionally denoted Σ\Sigma. Example: Σ={a,b}\Sigma=\{a,b\}; every input string is a member of Σ∗\Sigma^*.

Σ∗\Sigma^* = set of all finite strings over Σ, including ε (Kleene star).
Σ+\Sigma^+ = Σ∗∖{ε}\Sigma^* \setminus \{\varepsilon\} (at least one symbol).
Computability asks whether a problem can be solved by an algorithm; complexity asks how many resources (time/space) the solution needs.

1.1 DFA — Formal Definition

Deterministic Finite Automaton (DFA): a 5-tuple M=(Q,Σ,δ,q0,F)M=(Q,\Sigma,\delta,q_0,F) where QQ is a finite set of states, Σ\Sigma a finite alphabet, δ:Q×Σ→Q\delta: Q\times\Sigma\rightarrow Q a total transition function (exactly one next state per state-symbol pair), q0∈Qq_0\in Q the start state and F⊆QF\subseteq Q the set of final/accepting states.

PYQ (2023-24, 2 marks): "Give the mathematical definition of DFA. Differentiate between NFA and DFA." Write the 5-tuple, then the table:

Feature DFA NFA
Transition δ(q,a)\delta(q,a) = one state δ(q,a)\delta(q,a) = set of states
Backtracking Never needed May explore many paths
ε-moves Not allowed Allowed in ε-NFA
Dead state Usually shown explicitly May simply omit undefined transitions
Implementation Deterministic, fast simulation Needs set-of-states tracking
Power Same — both accept exactly regular languages Same

PYQ (2025-26, 2 marks): "Define Deterministic Finite Automata (DFA)." Use the definition-box: five components, one transition per symbol, accepts when the last state after reading the whole string lies in FF.

Acceptability: A string w=a1a2…anw=a_1a_2\dots a_n is accepted iff the unique run q0→a1q1→a2⋯→anqnq_0 \xrightarrow{a_1} q_1 \xrightarrow{a_2}\dots\xrightarrow{a_n} q_n ends with qn∈Fq_n\in F. A language is DFA-accepted if every member is accepted and every non-member rejected.


2. DFA Construction Questions (Solved PYQs)

2.1 DFA Ending with 101 (PYQ 2023-24, 2 marks)

Track the longest suffix that is a prefix of 101:

State Meaning 0 1
→ q0q_0 no useful suffix q0q_0 q1q_1
q1q_1 seen 1 q2q_2 q1q_1
q2q_2 seen 10 q0q_0 q3q_3
*q3q_3 seen 101 (final) q2q_2 q1q_1

Trace 1101: q0→1q1→1q1→0q2→1q3q_0 \xrightarrow{1}q_1\xrightarrow{1}q_1\xrightarrow{0}q_2\xrightarrow{1}q_3 ✔ accepted. Trace 1010: ends in q2q_2 ✘ rejected. Why q3→1q1q_3 \xrightarrow{1} q_1? The suffix after ...1011 is 1, a fresh prefix.

2.2 DFA: Contains "00" but Not "000" (PYQ 2025-26, 7 marks)

We need to remember (a) whether 00 has occurred, and (b) whether the current run of zeros has length 2 (dangerous: next 0 gives 000).

State Meaning 0 1
→ AA no 00 yet, last bit 1/start BB AA
BB no 00 yet, last bit 0 CC AA
*CC 00 seen, last run of zeros = 2 DD EE
DD 000 has occurred (dead/trap) DD DD
*EE 00 seen, last run of zeros = 1 FF EE
*FF 00 seen, last bit 1 EE FF

Final states: {C,E,F}\{C,E,F\}. State DD is non-final and loops on everything.

Verification traces:

String Path Result
00 A→B→CA\to B\to C accepted
000 A→B→C→DA\to B\to C\to D rejected
1001 A→A→B→C→FA\to A\to B\to C\to F accepted
0010 A→B→C→F→EA\to B\to C\to F\to E accepted (ends 10, no 000)
010 A→B→A→BA\to B\to A\to B rejected (no 00)
00100 A→B→C→F→E→CA\to B\to C\to F\to E\to C accepted

Examiner note: after seeing 00 in 001, the third 0 of a future run is still forbidden only when two consecutive zeros follow a one. State FF remembers that 00 already happened, so 00100 must remain accepted.

2.3 DFA with "abb" as Substring (PYQ 2025-26, 2 marks)

State Meaning a b
→ q0q_0 no prefix matched q1q_1 q0q_0
q1q_1 seen a q1q_1 q2q_2
q2q_2 seen ab q1q_1 q3q_3
*q3q_3 seen abb q3q_3 q3q_3

Trace aabb: q0→aq1→aq1→bq2→bq3q_0\xrightarrow{a}q_1\xrightarrow{a}q_1\xrightarrow{b}q_2\xrightarrow{b}q_3 ✔. Once in q3q_3, remain there (substring found forever).

2.4 DFA for Binary Numbers Divisible by 4 (Predicted cluster)

Remainder transition rule: δ(qr,b)=q(2r+b) mod 4\delta(q_r, b) = q_{(2r+b)\bmod 4}.

State (remainder) 0 1 Final?
→ *q0q_0 (0) q0q_0 q1q_1 yes
q1q_1 (1) q2q_2 q3q_3 no
q2q_2 (2) q0q_0 q1q_1 no
q3q_3 (3) q2q_2 q3q_3 no

Check 1100 (12): q0→1q1→1q3→0q2→0q0q_0\xrightarrow{1}q_1\xrightarrow{1}q_3\xrightarrow{0}q_2\xrightarrow{0}q_0 ✔. Equivalently, a non-zero binary number is divisible by 4 iff its last two bits are 00.


3. NFA, Equivalence and ε-Moves

3.1 NFA Definition and Substring Design

Nondeterministic Finite Automaton (NFA): M=(Q,Σ,δ,q0,F)M=(Q,\Sigma,\delta,q_0,F) with δ:Q×Σ→2Q\delta:Q\times\Sigma\rightarrow 2^Q — a symbol may lead to several states or none. A string is accepted if at least one computation path ends in a final state.

PYQ (2025-26, 7 marks): "Define Non-Deterministic Finite Automata. Design an NFA to accept strings over {0,1} containing the substring 1101."

State Meaning 0 1
→ q0q_0 nothing matched yet {q0}\{q_0\} {q0,q1}\{q_0,q_1\}
q1q_1 seen 1 {q0}\{q_0\} {q2}\{q_2\}
q2q_2 seen 11 {q3}\{q_3\} {q2}\{q_2\}
q3q_3 seen 110 {q0}\{q_0\} {q4}\{q_4\}
*q4q_4 seen 1101 {q4}\{q_4\} {q4}\{q_4\}

The nondeterminism appears at q0q_0 on input 1: either stay (this 1 is not the start of the target) or move to q1q_1 (it is). Trace 01101: q0→0q0→1{q0,q1}→1{q0,q2}→0{q0,q3}→1{q0,q1,q4}q_0\xrightarrow{0}q_0\xrightarrow{1}\{q_0,q_1\}\xrightarrow{1}\{q_0,q_2\}\xrightarrow{0}\{q_0,q_3\}\xrightarrow{1}\{q_0,q_1,q_4\} — q4q_4 is reachable, so accepted.

3.2 Subset Construction: NFA ⇒ DFA

Predicted (bank PRED, 2023-24 & 2024-25, 7 marks): "Construct a DFA corresponding to the given NFA" / "Prove that for every NFA there exists an equivalent DFA using subset construction." Worked instance from the bank: states {q0,q1}\{q_0,q_1\}, Σ={0,1}\Sigma=\{0,1\}, start q0q_0, final {q1}\{q_1\}, δ(q0,0)={q0,q1}\delta(q_0,0)=\{q_0,q_1\}, δ(q0,1)={q0}\delta(q_0,1)=\{q_0\}, δ(q1,1)={q1}\delta(q_1,1)=\{q_1\}, δ(q1,0)=∅\delta(q_1,0)=\varnothing.

Theorem: For an NFA N=(Q,Σ,δ,q0,F)N=(Q,\Sigma,\delta,q_0,F) define DFA D=(2Q,Σ,δD,{q0},FD)D=(2^Q,\Sigma,\delta_D,\{q_0\},F_D) where δD(S,a)=⋃q∈Sδ(q,a)\delta_D(S,a)=\bigcup_{q\in S}\delta(q,a) and FD={S⊆Q∣S∩F≠∅}F_D=\{S\subseteq Q\mid S\cap F\ne\varnothing\}. Every NFA path corresponds to a DFA state containing its current NFA states; induction on string length gives L(D)=L(N)L(D)=L(N). Hence NFA and DFA accept the same class — regular languages.

DFA state (subset) 0 1 Final?
→ A={q0}A=\{q_0\} {q0,q1}=B\{q_0,q_1\}=B {q0}=A\{q_0\}=A no
*B={q0,q1}B=\{q_0,q_1\} {q0,q1}=B\{q_0,q_1\}=B {q0,q1}=B\{q_0,q_1\}=B yes
∅\varnothing (dead) ∅\varnothing ∅\varnothing no

Explanation: from BB, input 0 gives δ(q0,0)∪δ(q1,0)={q0,q1}∪∅=B\delta(q_0,0)\cup\delta(q_1,0)=\{q_0,q_1\}\cup\varnothing=B; input 1 gives {q0}∪{q1}=B\{q_0\}\cup\{q_1\}=B. Once a 0 is seen the DFA stays in BB, so the accepted language is "all strings containing at least one 0". Accept check: 101 → A→1A→0B→1BA\xrightarrow{1}A\xrightarrow{0}B\xrightarrow{1}B ✔; 111 → AA ✘.

3.3 ε-NFA and Its Equivalence

An ε-NFA allows transitions labelled ε, taken without consuming input. Define ε-closure(q) = set of states reachable from qq using only ε-moves. To convert an ε-NFA to an NFA (then a DFA):

  1. For every state and symbol, compute δ′(q,a)=ε-closure(⋃p∈ε-closure(q)δ(p,a))\delta'(q,a)=\varepsilon\text{-closure}\big(\bigcup_{p\in\varepsilon\text{-closure}(q)}\delta(p,a)\big).
  2. Keep the same start state; a state is final if its ε-closure contains an original final state.
  3. Apply subset construction to the resulting NFA.

Example: q0→εq1q_0\xrightarrow{\varepsilon}q_1, q1→aq2q_1\xrightarrow{a}q_2, q2q_2 final. ε-closure(q0)={q0,q1}\varepsilon\text{-closure}(q_0)=\{q_0,q_1\}, so on aa the start reaches {q2}\{q_2\}; the machine accepts exactly a, matching the intuitive behaviour. Equivalence follows because every ε-move can be bypassed by the closure computation without changing the set of accepted strings.

3.4 Finite Automata with Output

Feature Moore machine Mealy machine
Output depends on Current state only Current state and current input
Output function λ:Q→Δ\lambda:Q\rightarrow\Delta λ:Q×Σ→Δ\lambda:Q\times\Sigma\rightarrow\Delta
Output changes At state entry (one step later) Immediately with input
Number of states Often one more (start/output state) Often fewer
Clock behaviour Output is synchronous with states Output may glitch with input changes

PYQ (2025-26, 7 marks): "Define the Moore machine. Design a Moore machine to generate 1's complement of given binary numbers."

Definition: A Moore machine is a 6-tuple (Q,Σ,Δ,δ,λ,q0)(Q,\Sigma,\Delta,\delta,\lambda,q_0) where λ\lambda maps each state to an output symbol; the output is determined solely by the current state.

1's complement design: state q0q_0 outputs 0 (last input bit was 1 or start), state q1q_1 outputs 1 (last input bit was 0).

Present state Input 0 → next (output) Input 1 → next (output)
→ q0q_0 / out 0 q1q_1 / 1 q0q_0 / 0
q1q_1 / out 1 q1q_1 / 1 q0q_0 / 0

Trace input 1011:

Step Input State entered Output emitted
start – q0q_0 0 (initial)
1 1 q0q_0 0
2 0 q1q_1 1
3 1 q0q_0 0
4 1 q0q_0 0

Output sequence including the start output: 01010; dropping the leading start output gives 1010, the 1's complement of 1011. Equivalence of Moore and Mealy: for every Moore machine there is an equivalent Mealy machine with the same number of states (attach state output to incoming transitions); for every Mealy machine there is an equivalent Moore machine that may need one extra state to hold the last output. They produce the same output string after aligning the initial symbol.


4. Minimization of Finite Automata

Goal: merge states that cannot be distinguished by any string — the Myhill–Nerode equivalence. Algorithm:

  1. Partition P0P_0 into final and non-final states.
  2. For each block, split states whose transitions on each symbol land in different blocks of PiP_i.
  3. Repeat until no block splits; merged states form the minimal DFA.

Predicted (bank PRED, 2023-24 & 2024-25, 7 marks): "Express the minimum state automata equivalent to the DFA described in the given figure." Worked illustration: DFA with q0q_0 start, q2q_2 final: q0q_0: 0→q1q_1, 1→q2q_2; q2q_2: 0→q1q_1, 1→q2q_2; q1q_1: 0→q1q_1, 1→q0q_0.

Stage Blocks Reason
P0P_0 {q2}\{q_2\}, {q0,q1}\{q_0,q_1\} final vs. non-final
P1P_1 {q2}\{q_2\}, {q0}\{q_0\}, {q1}\{q_1\} q0q_0 on 1 → final q2q_2, q1q_1 on 1 → non-final q0q_0

Minimal DFA (3 states):

State 0 1 Final?
→ q0q_0 q1q_1 q2q_2 no
q1q_1 q1q_1 q0q_0 no
*q2q_2 q1q_1 q2q_2 yes

No two states can be merged, so this is minimal. A classic merge example: q0q_0 and q2q_2 with identical transitions (both non-final, 0→q1q_1, 1→q2q_2) stay in one block through all refinements and are merged into a single state.


5. Exam-Ready Questions, Practice and Checklist

Solved 2-mark drills

  1. DFA definition: 5-tuple with total δ\delta (see §1.1).
  2. DFA vs NFA: one next state vs. a set; same language power.
  3. Alphabet: finite non-empty symbol set, e.g. {0,1}\{0,1\}.
  4. Ends with 101: four-state table in §2.1.

Practice questions (label: practice, not real PYQs)

  1. Practice: Design a DFA over {0,1}\{0,1\} accepting strings whose length is divisible by 3.
  2. Practice: Convert the NFA for substring 1101 (§3.1) into a DFA by subset construction; how many subset states appear?
  3. Practice: Build a Mealy machine for 1's complement and compare its state count with the Moore version.
  4. Practice: Minimise a DFA where states p,qp,q are both final and have identical outgoing transitions; show the partition steps.
  5. Practice: Write ε\varepsilon-closure for a graph with q0→εq1→εq2q_0\xrightarrow{\varepsilon}q_1\xrightarrow{\varepsilon}q_2 and q2→aq3q_2\xrightarrow{a}q_3.

6. Last-Night Survival Checklist (Unit 1 only)

  1. Five-tuple first: every DFA/NFA answer begins with Q,Σ,δ,q0,FQ,\Sigma,\delta,q_0,F written explicitly.
  2. State meanings: label each state with the substring/remainder it represents before drawing transitions.
  3. Four constructions to reproduce: ends-with-101; contains-00-not-000; contains-abb; divisible-by-4.
  4. Subset construction: DFA state = set of NFA states; final if the set intersects FF; include the empty dead set.
  5. Moore vs Mealy: output from state vs. output from (state, input); trace 1011 for 1's complement.

Final automata reminder: In a 7-mark construction, the transition table carries most of the marks. Verify each final state with one accepted string and each trap/dead state with one rejected string — examiners look for this validation line.