2022 question paper
FORMAL LANGUAGE & AUTOMATA THEORY
29 questions
Q1a. The minimum number of states required to recognize an octal number divisible by 3 is: (i) 1 (ii) 3 (iii) 5 (iv) 720222m
Module 1: Introduction & Regular Languages
View this question on its own page →The minimum number of states required to recognize an octal number divisible by 3 is:
(i) 1
(ii) 3
(iii) 5
(iv) 7Worked SolutionAnswer
Correct Option: (ii) 3
Explanation
To check divisibility by , we only need the remainder modulo 3 of the number. Whether the input is binary, decimal, or octal does not change the number of remainders.
For modulus , there are exactly possible remainders:
- → number divisible by 3 (accepting state)
- → remainder 1
- → remainder 2
DFA Construction for Octal Alphabet
- Alphabet:
- States: representing remainder
- Start state: (value 0)
- Accepting state:
- Transition: On reading octal digit from state ,
Since , this simplifies to .
This DFA is complete and minimal – each remainder is distinguishable (Myhill-Nerode equivalence).
Why other options are wrong
- (i) 1 state: would accept all or no strings, cannot distinguish remainders.
- (iii) 5 and (iv) 7: unnecessary extra states; is not relevant.
Final Answer
Minimum number of states = 3 (one per residue class mod 3).
Q1b. For a given Moore machine, given input = 101010, the output would be of length: (i) |Input| + 1 (ii) |Input| (iii) |Input| − 1 (iv) Cannot be predicted20222m
Module 1: Introduction & Regular Languages
View this question on its own page →For a given Moore machine, given input =
101010, the output would be of length:(i) |Input| + 1
(ii) |Input|
(iii) |Input| − 1
(iv) Cannot be predictedWorked SolutionAnswer
Correct Option: (i)
Explanation
Moore Machine: Output depends only on present state, and output is associated with state entry, including the initial state before any input is consumed.
- For input length , the machine visits states: (initial, no input) .
- Each state produces one output symbol .
- Hence output string length = .
Mealy Machine contrast: Output depends on transition (state + input), so output length = = (one per input symbol).
Given input
101010, → Moore output length = .Final Answer
Moore machine output length is → Option (i).
Q1c. The total number of states and transitions required to form a Moore machine that produces residue mod 3 are: (i) 3 and 6 (ii) 3 and 5 (iii) 2 and 4 (iv) 2 and 520222m
Module 1: Introduction & Regular Languages
View this question on its own page →The total number of states and transitions required to form a Moore machine that produces residue mod 3 are:
(i) 3 and 6
(ii) 3 and 5
(iii) 2 and 4
(iv) 2 and 5Worked SolutionAnswer
Correct Option: (i) 3 states and 6 transitions (for residue mod 3 Moore machine)
Explanation
To produce residue mod 3, need 3 states corresponding to remainders .
- Alphabet: e.g., binary or unary? For general input, Moore machine that outputs residue after each symbol needs 3 states.
- Transitions: For binary alphabet , from each of 3 states there are 2 outgoing transitions ( and ): transitions. Formula: new remainder .
If alphabet were unary, transitions =3; but typical exam assumes binary/decimal digit input, hence 6.
Other options (3,5), (2,4) insufficient to represent 3 residues.
Final Answer
3 states, 6 transitions → Option (i). If input alphabet size , transitions .
Q1d. Which of the following is a correct statement? (i) Moore machine has no accepting states. (ii) Mealy machine has accepting states. (iii) We can convert Mealy to Moore but not vice versa. (iv) All of the above20222m
Module 1: Introduction & Regular Languages
View this question on its own page →Which of the following is a correct statement?
(i) Moore machine has no accepting states.
(ii) Mealy machine has accepting states.
(iii) We can convert Mealy to Moore but not vice versa.
(iv) All of the aboveWorked SolutionAnswer
Correct Option: (i) Moore machine has no accepting states (in transducer sense; strictly all (i)-(iii) as stated are inaccurate, so if “None of the above” were an option it would be correct — see note)
Explanation
Moore vs Mealy as Transducers
- Moore: Output (state output). Mealy: (transition output).
- In classical transducer definition (Hopcroft-Ullman), they are not acceptors — they have no set. They translate every input to an output, not accept/reject. In that sense (i) “Moore has no accepting states” is true for the pure transducer, and similarly Mealy also has none, making (ii) false.
Convertibility
- Mealy ↔ Moore are interconvertible:
- Mealy → Moore: expand states (at most ), output delayed by one symbol.
- Moore → Mealy: keep same states, shift output to transitions.
- So (iii) “Mealy to Moore but not vice versa” is false. Both directions possible.
Evaluation
Statement Truth (i) Moore has no accepting states (pure transducer) True (ii) Mealy has accepting states False (pure Mealy also has none) (iii) Mealy→Moore only one way False (iv) All of above False If the question is asked in the acceptor + transducer mixed sense where Moore/Mealy can be defined with , then (i) and (ii) are both false and no option is strictly correct; the intended exam key is usually (i).
Final Answer
Per standard syllabus, (i) is the expected correct choice. Rigorously, pure Moore/Mealy are transducers without , and they are mutually convertible.
Q1e. The minimum number of transitions to reach the final state as per the regular expression: \{a, b\}^* baaa is: (i) 4 (ii) 5 (iii) 6 (iv) 320222m
Module 1: Introduction & Regular Languages
View this question on its own page →The minimum number of transitions to reach the final state as per the regular expression:
is:
(i) 4
(ii) 5
(iii) 6
(iv) 3Worked SolutionAnswer
Correct Option: (i) 4
Explanation
Regular expression: — language is all strings over ending with suffix baaa.
To accept, a DFA must detect suffix b a a a (length 4).
Minimal DFA (suffix automaton)
States represent longest suffix of processed prefix that is prefix of baaa:
- : no part matched (or last irrelevant)
- : suffix b
- : suffix ba
- : suffix baa
- : suffix baaa (accepting)
Transitions: each new character extends/collapses the match. From , on b → , on a → ; etc.
Number of transitions on the shortest path from start to final is 4 (b→a→a→a).
Number of states =5, transitions to reach final =4. Some keys count states=5 as “transitions”, but minimum edge traversals is 4.
Final Answer
4 transitions (5 states) to reach final — Option (i) 4. If counting states, answer is 5.
Q1f. Let w = xyz, y is the middle portion and |y| > 0. Repeating y zero or more times before checking membership in L is known as: (i) Generating (ii) Pumping (iii) Producing (iv) None of the above20222m
Module 1: Introduction & Regular Languages
View this question on its own page →Let , is the middle portion and . Repeating zero or more times before checking membership in is known as:
(i) Generating
(ii) Pumping
(iii) Producing
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (ii) Pumping
Explanation
Pumping Lemma concept: For regular/CFL languages, any long string (with , ) can be pumped: for all (repeating zero, one, or more times).
- Pumping = repeating the middle portion zero or more times and checking membership.
- Generating is general derivation.
- Producing is vague.
The lemma is used to prove non-regularity/non-CFL by contradiction.
Final Answer
Repeating is Pumping → Option (ii).
Q1g. A Turing machine that is able to simulate other Turing machines is called: (i) nested Turing machine (ii) universal Turing machine (iii) counter machine (iv) None of the above20222m
Module 4: Turing Machines (TM)
View this question on its own page →A Turing machine that is able to simulate other Turing machines is called:
(i) nested Turing machine
(ii) universal Turing machine
(iii) counter machine
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (ii) universal Turing machine
Explanation
Universal Turing Machine : A TM that takes as input encoding of any TM and input : .
- Can simulate any other TM (stored-program concept).
- Basis for von Neumann architecture, stored-program computers.
- Exists by Church-Turing thesis; constructed by Turing (1936).
- Leads to undecidability of halting problem.
Other options:
- Nested TM — not standard.
- Counter machine — weaker (but Turing-equivalent with 2 counters).
Final Answer
Universal TM → Option (ii).
Q1h. A recursively enumerable language L is recursive if: (i) L' is recursively enumerable (ii) every sequence of moves of T halts (iii) Both (i) and (ii) (iv) None of the above20222m
Module 5: Undecidability
View this question on its own page →A recursively enumerable language is recursive if:
(i) is recursively enumerable
(ii) every sequence of moves of halts
(iii) Both (i) and (ii)
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (i) is recursively enumerable (equivalently (iii) Both if is decider)
Explanation
Theorem (Sipser): RE language is recursive (decidable) iff both and are RE.
- If is RE and is RE, then dovetail enumerators for and ; whichever enumerates first decides.
- Formal: recursive ⇔ RE and RE.
Option (ii) “every sequence of moves halts” is characterization of decider (always halts), also true for recursive but not the standard RE condition. Option (i) is the textbook criterion.
If exam lists (iii) Both (i) and (ii), that is also correct for decider TM. Most keys mark (i) or (iii).
Final Answer
recursive iff is RE → Option (i) (and (iii) Both if inclusive).
Q1i. RASP stands for: (i) Random Access Storage Program (ii) Random Access Stored Program (iii) Randomly Accessed Stored Program (iv) Random Access Storage Programming20222m
Module 4: Turing Machines (TM)
View this question on its own page →RASP stands for:
(i) Random Access Storage Program
(ii) Random Access Stored Program
(iii) Randomly Accessed Stored Program
(iv) Random Access Storage ProgrammingWorked SolutionAnswer
Correct Option: (ii) Random Access Stored Program
Explanation
RASP = Random Access Stored Program machine.
- Model by Elgot–Robinson, Hartmanis.
- Like RAM but program stored in memory like data (von Neumann).
- Has registers and memory with random access, program counter.
- Turing-equivalent, but more realistic cost model.
Other expansions are incorrect variations.
Final Answer
Random Access Stored Program → Option (ii).
Q1j. A language L is Turing decidable if: (i) recursive (ii) TM recognizes L (iii) TM accepts L (iv) None of the above20222m
Module 4: Turing Machines (TM)
View this question on its own page →A language is Turing decidable if:
(i) recursive
(ii) TM recognizes
(iii) TM accepts
(iv) None of the aboveWorked SolutionAnswer
Correct Option: (i) recursive (Turing decidable = recursive)
Explanation
Turing decidable ≡ Recursive language ≡ Decided by a TM that always halts (decider).
Definitions:
- Recursively Enumerable (RE): TM recognizes (accepts if , may loop if $w
otin L$). Options (ii) “TM recognizes” and (iii) “TM accepts” describe RE, not decidable. - Recursive: TM decides : for every , TM halts and says accept/reject.
So is Turing decidable iff is recursive.
Decider vs Recognizer distinction is key: recognizer may not halt on rejection.
Final Answer
Decidable = recursive → Option (i).
- Recursively Enumerable (RE): TM recognizes (accepts if , may loop if $w
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q2a. Design a DFA for strings over \{a, b\} containing at least three occurrences of bbb (overlapping allowed). Example: bbbbbb is accepted.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Design a DFA for strings over containing at least three occurrences of
bbb(overlapping allowed). Example:bbbbbbis accepted.Worked SolutionAnswer
Design a DFA for at least three occurrences of substring
bbb(overlapping allowed). Examplebbbbbbaccepted.1. Language
.
Occurrences are counted with overlap:
bbbbcontains 2 occurrences (bbbat positions 1-3 and 2-4),bbbbbbcontains 4 occurrences.We need to count up to 3 and stay in accepting state after.
2. Construction Idea
Track:
- suffix of consecutive 's (0,1,2) and number of seen so far (0,1,2,≥3).
States: where = trailing run capped at 2, = count of seen (0-2, ≥3). But we can compress to 7 states:
State Meaning , trailing ’s no yet, ends with or start , ends with () , ends with () , seen 1 , ends with (c=3→2) , + ends with (after ) , ? etc. Simpler: count after detection seen 2 seen ≥3 (accepting, trap) Simplified minimal DFA with 7 states (–, accepting):
Transitions (partial, showing -chain):
q0 --a--> q0 , q0 --b--> q1 q1 --a--> q0 , q1 --b--> q2 q2 --a--> q0 , q2 --b--> q3 // first bbb detected, k=1 q3 --a--> q4 , q3 --b--> q5 // bbbb: overlapping second bbb (q3 --b--> q5) q4 --a--> q0 , q4 --b--> q1? Actually after a, reset; need systematic.Full systematic table (compressed):
State (1 with reset) ? For exam, you can draw diagram:
MermaidDiagramRendering diagram…Set initial , final .
Test:
bbbbbb:
→ accepted (4 occurrences ≥3).3. Minimality
states are minimal (need to distinguish counts 0,1,2 and trailing run). Could be reduced to 6 with optimization but 7 is clear for exam.
Final Answer
DFA with 7 states, one accepting trap that counts overlapping occurrences ≥3, as above. Regular expression: (overlap makes regex messy, DFA preferred).
Q2b. Let L \subseteq \{0,1,2\}^* be strings without consecutive identical symbols (no 00, no 11, no 22). Design a DFA for L.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Let be strings without consecutive identical symbols (no , no , no ). Design a DFA for .
Worked SolutionAnswer
Language:
DFA Construction
Idea: Track the last symbol seen (0, 1, or 2) or "none yet" (start). Forbid transition on same symbol as last.
States:
- : start, no symbol yet (also accepting)
- : last symbol was 0 (accepting)
- : last symbol was 1 (accepting)
- : last symbol was 2 (accepting)
- : dead/reject state (non-accepting)
Alphabet:
Transition Function :
State Input 0 1 2 Formal DFA: where
- initial
- (all except dead)
- as table above
State Diagram (Mermaid)
MermaidDiagramRendering diagram…Regular Expression (for verification)
More compactly using complement:Test Cases
Input Path Accept? Yes Yes Yes No Yes Yes Minimality
5 states are minimal (Myhill-Nerode: are pairwise distinguishable; dead state needed).
Final Answer
DFA with 5 states (), accepting all except , transitions as table above. Rejects any string with or .
Q3a. Prove that if L is accepted by a PDA, then L can be generated by a CFG.20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Prove that if is accepted by a PDA, then can be generated by a CFG.
Worked SolutionAnswer
Theorem: is accepted by a PDA is generated by a CFG (i.e., CFL = NPDA languages).
We prove PDA CFG using the Triplet Construction (Sipser / standard textbook method).
Given
PDA accepting by final state (empty stack can be converted).
Assume has no -transitions on input (can be eliminated). If -moves exist, handle via closure.
Construction of CFG
Variables :
- Start symbol
- Triplet variables for every and
- Meaning: "Starting in state with stack top , can reach state with popped off (and any symbols pushed above it matched)."
Productions :
Start: for each
- Begin at with initial stack , end in any final state .
From PDA transitions:
For every transition $\delta(p, a, A)
i (q, \alpha)a \in \Sigma \cup {\epsilon}$:Case (pop , no push):
(if , RHS is )Case ():
For all :- Push ; must pop them in order via intermediate states.
- consumed on transition; each matches push/pop of .
Empty stack (optional, for empty-stack acceptance):
Add for all (not needed for final-state).
Intuition of Triplet
- Represents a matching push-pop pair on symbol .
- : state where is pushed
- : state where is popped
- The derivation inside generates the string read between push and pop of .
Proof of Correctness (Sketch)
Soundness (CFG PDA):
Every derivation in corresponds to a valid PDA computation:- maps to initial config.
- Production mimics transition .
- Base case mimics .
- Induction on derivation length shows derived string is accepted by .
Completeness (PDA CFG):
For any accepting run of on , build a parse tree in :- Root .
- Each push of at state and corresponding pop at gives variable .
- The substring read between push and pop is generated by that variable.
- By induction on height of push-pop pairs, is generated.
Example
PDA for :
CFG variables:
Productions:
(after resolving all intermediate states)Yields .
Formal Statement
Theorem: is accepted by a (nondeterministic) PDA iff is generated by a CFG.
Corollary: CFL = languages accepted by NPDA. DPDA CFL (strict).
Final Answer
Proof via Triplet Construction: Create CFG with variables representing push-pop of from state to . Productions mirror PDA transitions. for final . Induction on derivations/computations proves . Hence every PDA language is a CFL.
Q3b. Design an NPDA (empty stack and final state acceptance) for: L = \{\text{palindromes over } \{a,b\}\}20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Design an NPDA (empty stack and final state acceptance) for:
Q4a. Design Mealy and Moore machines to detect the sequence 1010 (overlapping allowed). Then convert the Moore machine into a Mealy machine and prove equivalence.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Design Mealy and Moore machines to detect the sequence
1010(overlapping allowed). Then convert the Moore machine into a Mealy machine and prove equivalence.Q4b. Show whether the given grammar is ambiguous: S \to a \mid abSb \mid aAb \\ A \to bS \mid aAAb20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Show whether the given grammar is ambiguous:
Q5a. Give examples of L_1 and L_2 such that: (i) L_1 is regular, L_2 is not regular, and L_1 - L_2 is regular. (ii) L_1 and L_2 are not regular but L_1 \cup L_2 is regular.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Give examples of and such that:
(i) is regular, is not regular, and is regular.
(ii) and are not regular but is regular.Q5b. Show that the language of palindromes over \{a, b\} is not regular.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Show that the language of palindromes over is not regular.
Q6a. Construct a CFG for: \{ 0^i 1^j 2^k \mid i + j \ge 2k \}20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Construct a CFG for:
Q6b. Convert the CFG to GNF: S \to AB \mid BC \\ A \to aB \mid bA \mid a \\ B \to bB \mid cC \mid b \\ C \to c20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Convert the CFG to GNF:
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q7a. Design a Turing machine that accepts all palindromes over: \Sigma = \{ a, b \}20227m
Module 4: Turing Machines (TM)
View this question on its own page →Design a Turing machine that accepts all palindromes over:
Q7b. Explain the Myhill–Nerode theorem for minimization of automata with an example.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Explain the Myhill–Nerode theorem for minimization of automata with an example.
Q8a. Construct FOLLOW sets for the grammar: E \to T E' \\ E' \to +\,T\,E' \mid \varepsilon \\ T \to F T' \\ T' \to -\,F\,T' \mid \varepsilon \\ F \to (E) \mid id20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Construct FOLLOW sets for the grammar:
Q8b. Show that the language: L = \{ a^{n^2} b^n \mid n \ge 0 \} is not regular.20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Show that the language:
is not regular.
Q9a. Prove that the halting problem for Turing machines is recursively undecidable.20227m
Module 5: Undecidability
View this question on its own page →Prove that the halting problem for Turing machines is recursively undecidable.
Q9b(i). Write a short note on Deterministic PDA vs. Non-deterministic PDA.20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Write a short note on Deterministic PDA vs. Non-deterministic PDA.
Q9b(ii). Write a short note on Chomsky Normal Form (CNF).20227m
Module 2: Context-Free Languages (CFL) and PDA
View this question on its own page →Write a short note on Chomsky Normal Form (CNF).
Q9b(iii). Write a short note on Multi-stack Turing Machine.20227m
Module 4: Turing Machines (TM)
View this question on its own page →Write a short note on Multi-stack Turing Machine.
Q9b(iv). Write a short note on Finite-state Machine (FSM).20227m
Module 1: Introduction & Regular Languages
View this question on its own page →Write a short note on Finite-state Machine (FSM).
Pocketly — Personal Finance for Students
Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.