2022 question paper

FORMAL LANGUAGE & AUTOMATA THEORY

29 questions

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

    The minimum number of states required to recognize an octal number divisible by 3 is:

    (i) 1
    (ii) 3
    (iii) 5
    (iv) 7

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (ii) 3

    Explanation

    To check divisibility by 33, 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 33, there are exactly 33 possible remainders:

    • r=0r = 0 → number divisible by 3 (accepting state)
    • r=1r = 1 → remainder 1
    • r=2r = 2 → remainder 2

    DFA Construction for Octal Alphabet

    • Alphabet: Σ={0,1,2,3,4,5,6,7}\Sigma = \{0,1,2,3,4,5,6,7\}
    • States: q0,q1,q2q_0, q_1, q_2 representing remainder 0,1,20,1,2
    • Start state: q0q_0 (value 0)
    • Accepting state: q0q_0
    • Transition: On reading octal digit dd from state qrq_r,
      δ(qr,d)=q(r×8+d) mod 3 \delta(q_r, d) = q_{(r \times 8 + d) \bmod 3}
      Since 8≡2(mod3)8 \equiv 2 \pmod 3, this simplifies to q(2r+d) mod 3q_{(2r + d) \bmod 3}.

    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; ⌈log⁡23⌉\lceil \log_2 3 \rceil is not relevant.

    Final Answer

    Minimum number of states = 3 (one per residue class mod 3).

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

    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 predicted

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) ∣Input∣+1|Input|+1

    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 nn, the machine visits n+1n+1 states: q0q_0 (initial, no input) →a1q1→a2⋯→anqn\xrightarrow{a_1} q_1 \xrightarrow{a_2} \dots \xrightarrow{a_n} q_n.
    • Each state produces one output symbol λ(qi)\lambda(q_i).
    • Hence output string length = n+1n+1.

    Mealy Machine contrast: Output depends on transition (state + input), so output length = ∣Input∣|Input| = nn (one per input symbol).

    Given input 101010, ∣Input∣=6|Input|=6 → Moore output length = 77.

    Final Answer

    Moore machine output length is ∣Input∣+1|Input|+1 → Option (i).

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

    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 5

    View this question on its own page →
    Worked Solution

    Answer

    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 0,1,20,1,2.

    • Alphabet: e.g., binary or unary? For general input, Moore machine that outputs residue after each symbol needs 3 states.
    • Transitions: For binary alphabet {0,1}\{0,1\}, from each of 3 states there are 2 outgoing transitions (00 and 11): 3×2=63 \times 2 =6 transitions. Formula: new remainder r′=(r×base+digit) mod 3r' = (r \times base + digit) \bmod 3.

    If alphabet were {0}\{0\} 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 ∣Σ∣=k|\Sigma|=k, transitions =3k=3k.

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

    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 above

    View this question on its own page →
    Worked Solution

    Answer

    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 λ:Q→Γ\lambda: Q \rightarrow \Gamma (state output). Mealy: λ:Q×Σ→Γ\lambda: Q \times \Sigma \rightarrow \Gamma (transition output).
    • In classical transducer definition (Hopcroft-Ullman), they are not acceptors — they have no FF 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 ∣Q∣⋅∣Γ∣|Q|\cdot|\Gamma|), 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 FF, 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 FF, and they are mutually convertible.

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

    The minimum number of transitions to reach the final state as per the regular expression:

    {a,b}∗baaa \{a, b\}^* baaa

    is:

    (i) 4
    (ii) 5
    (iii) 6
    (iv) 3

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) 4

    Explanation

    Regular expression: {a,b}∗baaa\{a,b\}^* baaa — language is all strings over {a,b}\{a,b\} 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:

    • q0q_0: no part matched (or last bb irrelevant)
    • q1q_1: suffix b
    • q2q_2: suffix ba
    • q3q_3: suffix baa
    • q4q_4: suffix baaa (accepting)

    Transitions: each new character extends/collapses the match. From q0q_0, on b → q1q_1, on a → q0q_0; etc.

    Number of transitions on the shortest path from start q0q_0 to final q4q_4 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.

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

    Let w=xyzw = xyz, yy is the middle portion and ∣y∣>0|y| > 0. Repeating yy zero or more times before checking membership in LL is known as:

    (i) Generating
    (ii) Pumping
    (iii) Producing
    (iv) None of the above

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (ii) Pumping

    Explanation

    Pumping Lemma concept: For regular/CFL languages, any long string w=xyzw = xyz (with ∣y∣>0|y|>0, ∣xy∣≤p|xy|\le p) can be pumped: xyiz∈Lxy^i z \in L for all i≥0i \ge 0 (repeating yy zero, one, or more times).

    • Pumping = repeating the middle portion yy 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 yy is Pumping → Option (ii).

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

    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 above

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (ii) universal Turing machine

    Explanation

    Universal Turing Machine UU: A TM that takes as input encoding of any TM MM and input ww: U(⟨M,w⟩)=M(w)U(\langle M, w\rangle) = M(w).

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

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

    A recursively enumerable language LL is recursive if:

    (i) L′L' is recursively enumerable
    (ii) every sequence of moves of TT halts
    (iii) Both (i) and (ii)
    (iv) None of the above

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (i) L′L' is recursively enumerable (equivalently (iii) Both if TT is decider)

    Explanation

    Theorem (Sipser): RE language LL is recursive (decidable) iff both LL and L‾\overline{L} are RE.

    • If LL is RE and L‾\overline{L} is RE, then dovetail enumerators for LL and L‾\overline{L}; whichever enumerates ww first decides.
    • Formal: LL recursive ⇔ LL RE and L′L' RE.

    Option (ii) “every sequence of moves halts” is characterization of decider (always halts), also true for recursive LL 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

    LL recursive iff L′L' is RE → Option (i) (and (iii) Both if inclusive).

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

    RASP stands for:

    (i) Random Access Storage Program
    (ii) Random Access Stored Program
    (iii) Randomly Accessed Stored Program
    (iv) Random Access Storage Programming

    View this question on its own page →
    Worked Solution

    Answer

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

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

    A language LL is Turing decidable if:

    (i) recursive
    (ii) TM recognizes LL
    (iii) TM accepts LL
    (iv) None of the above

    View this question on its own page →
    Worked Solution

    Answer

    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 LL (accepts if w∈Lw\in L, may loop if $w
      otin L$). Options (ii) “TM recognizes” and (iii) “TM accepts” describe RE, not decidable.
    • Recursive: TM decides LL : for every ww, TM halts and says accept/reject.

    So LL is Turing decidable iff LL is recursive.

    Decider vs Recognizer distinction is key: recognizer may not halt on rejection.

    Final Answer

    Decidable = recursive → Option (i).

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

    Install Pocketly
  12. 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

    Design a DFA for strings over {a,b}\{a, b\} containing at least three occurrences of bbb (overlapping allowed). Example: bbbbbb is accepted.

    View this question on its own page →
    Worked Solution

    Answer

    Design a DFA for at least three occurrences of substring bbb (overlapping allowed). Example bbbbbb accepted.

    1. Language

    L={w∈{a,b}∗∣w contains bbb at least 3 times, overlapping counts}L = \{ w \in \{a,b\}^* \mid w \text{ contains } bbb \text{ at least 3 times, overlapping counts} \}.

    Occurrences are counted with overlap: bbbb contains 2 occurrences (bbb at positions 1-3 and 2-4), bbbbbb contains 4 occurrences.

    We need to count up to 3 and stay in accepting state after.

    2. Construction Idea

    Track:

    • suffix of consecutive bb's (0,1,2) and number of bbbbbb seen so far (0,1,2,≥3).

    States: qc,kq_{c,k} where cc = trailing bb run capped at 2, kk = count of bbbbbb seen (0-2, ≥3). But we can compress to 7 states:

    State Meaning kk, trailing bb’s
    q0q_0 no bbbbbb yet, ends with aa or start k=0k=0, c=0c=0
    q1q_{1} ends with bb (c=1c=1) k=0k=0, c=1c=1
    q2q_{2} ends with bbbb (c=2c=2) k=0k=0, c=2c=2
    q3q_{3} seen 1 bbbbbb, ends with bbbbbb (c=3→2) k=1k=1, c=2c=2
    q4q_{4} 11 bbbbbb + ends with bb (after aa) k=1k=1, c=1c=1? etc. Simpler: count after detection
    q5q_{5} seen 2 bbbbbb k=2k=2
    q6q_{6} seen ≥3 bbbbbb (accepting, trap) k≥3k\ge3

    Simplified minimal DFA with 7 states (q0q_0–q6q_6, q6q_6 accepting):

    Transitions (partial, showing bb-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 aa bb
    q0(0)q_0 (0) q0q_0 q1q_1
    q1q_1 q0q_0 q2q_2
    q2q_2 q0q_0 q3q_3
    q3(1)q_3 (1) q4aq_{4a} q5q_5
    q4q_4 (1 with reset) q0q_0 q1′q_1'?
    q5(2)q_5 (2) q4bq_{4b} q6q_6
    q6(≥3)q_6 (≥3) q6q_6 q6q_6

    For exam, you can draw diagram:

    MermaidDiagram
    Rendering diagram…

    Set initial q0q_0, final F={q6}F=\{q_6\}.

    Test: bbbbbb:
    q0→bq1→bq2→bq3→bq5→bq6→bq6q_0 \xrightarrow{b} q_1 \xrightarrow{b} q_2 \xrightarrow{b} q_3 \xrightarrow{b} q_5 \xrightarrow{b} q_6 \xrightarrow{b} q_6 → accepted (4 occurrences ≥3).

    3. Minimality

    77 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 q6q_6 that counts overlapping bbbbbb occurrences ≥3, as above. Regular expression: (a+ba+bba)∗bbb(a+ba+bba)∗bbb(a+ba+bba)∗bbb(a+b)∗(a+ba+bba)^* bbb (a+ba+bba)^* bbb (a+ba+bba)^* bbb (a+b)^* (overlap makes regex messy, DFA preferred).

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

    Let L⊆{0,1,2}∗L \subseteq \{0,1,2\}^* be strings without consecutive identical symbols (no 0000, no 1111, no 2222). Design a DFA for LL.

    View this question on its own page →
    Worked Solution

    Answer

    Language: L={w∈{0,1,2}∗∣no 00,11,22 as substring}L = \{ w \in \{0,1,2\}^* \mid \text{no } 00, 11, 22 \text{ as substring} \}

    DFA Construction

    Idea: Track the last symbol seen (0, 1, or 2) or "none yet" (start). Forbid transition on same symbol as last.

    States:

    • qϵq_\epsilon : start, no symbol yet (also accepting)
    • q0q_0 : last symbol was 0 (accepting)
    • q1q_1 : last symbol was 1 (accepting)
    • q2q_2 : last symbol was 2 (accepting)
    • q×q_\times : dead/reject state (non-accepting)

    Alphabet: Σ={0,1,2}\Sigma = \{0,1,2\}

    Transition Function δ\delta:

    State \\backslash Input 0 1 2
    qϵq_\epsilon q0q_0 q1q_1 q2q_2
    q0q_0 q×q_\times q1q_1 q2q_2
    q1q_1 q0q_0 q×q_\times q2q_2
    q2q_2 q0q_0 q1q_1 q×q_\times
    q×q_\times q×q_\times q×q_\times q×q_\times

    Formal DFA: M=(Q,Σ,δ,qϵ,F)M = (Q, \Sigma, \delta, q_\epsilon, F) where

    • Q={qϵ,q0,q1,q2,q×}Q = \{q_\epsilon, q_0, q_1, q_2, q_\times\}
    • Σ={0,1,2}\Sigma = \{0,1,2\}
    • qϵq_\epsilon initial
    • F={qϵ,q0,q1,q2}F = \{q_\epsilon, q_0, q_1, q_2\} (all except dead)
    • δ\delta as table above

    State Diagram (Mermaid)

    MermaidDiagram
    Rendering diagram…

    Regular Expression (for verification)

    L=ϵ+(0+1+2)((0+1+2)−(00+11+22))∗L = \epsilon + (0+1+2)( (0+1+2) - (00+11+22) )^*
    More compactly using complement:
    L=Σ∗∖Σ∗(00+11+22)Σ∗L = \Sigma^* \setminus \Sigma^*(00+11+22)\Sigma^*

    Test Cases

    Input Path Accept?
    ϵ\epsilon qϵq_\epsilon Yes
    012012 qϵ→0q0→1q1→2q2q_\epsilon \xrightarrow{0} q_0 \xrightarrow{1} q_1 \xrightarrow{2} q_2 Yes
    010010 q0→q1→q0q_0 \to q_1 \to q_0 Yes
    0000 q0→0q×q_0 \xrightarrow{0} q_\times No
    101101 q1→q0→q1q_1 \to q_0 \to q_1 Yes
    21212121 q2→q1→q2→q1q_2 \to q_1 \to q_2 \to q_1 Yes

    Minimality

    5 states are minimal (Myhill-Nerode: ϵ,0,1,2\epsilon, 0, 1, 2 are pairwise distinguishable; dead state needed).

    Final Answer

    DFA with 5 states (qϵ,q0,q1,q2,q×q_\epsilon, q_0, q_1, q_2, q_\times), accepting all except q×q_\times, transitions as table above. Rejects any string with 00,11,00, 11, or 2222.

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

    Prove that if LL is accepted by a PDA, then LL can be generated by a CFG.

    View this question on its own page →
    Worked Solution

    Answer

    Theorem: LL is accepted by a PDA   ⟺  \iff LL is generated by a CFG (i.e., CFL = NPDA languages).

    We prove PDA →\rightarrow CFG using the Triplet Construction (Sipser / standard textbook method).


    Given

    PDA P=(Q,Σ,Γ,δ,q0,Z0,F)P = (Q, \Sigma, \Gamma, \delta, q_0, Z_0, F) accepting L(P)L(P) by final state (empty stack can be converted).

    Assume δ\delta has no ϵ\epsilon-transitions on input (can be eliminated). If ϵ\epsilon-moves exist, handle via closure.


    Construction of CFG G=(V,Σ,R,S)G = (V, \Sigma, R, S)

    Variables VV:

    • Start symbol SS
    • Triplet variables [pAq][p A q] for every p,q∈Qp,q \in Q and A∈ΓA \in \Gamma
      • Meaning: "Starting in state pp with stack top AA, PP can reach state qq with AA popped off (and any symbols pushed above it matched)."

    Productions RR:

    1. Start: S→[q0Z0p]S \rightarrow [q_0 Z_0 p] for each p∈Fp \in F

      • Begin at q0q_0 with initial stack Z0Z_0, end in any final state pp.
    2. From PDA transitions:
      For every transition $\delta(p, a, A)
      i (q, \alpha)where where a \in \Sigma \cup {\epsilon}$:

      • Case α=ϵ\alpha = \epsilon (pop AA, no push):
        [pAq]→a [p A q] \rightarrow a
        (if a=ϵa=\epsilon, RHS is ϵ\epsilon)

      • Case α=B1B2…Bk\alpha = B_1 B_2 \dots B_k (k≥1k \ge 1):
        For all r1,r2,…,rk+1∈Qr_1, r_2, \dots, r_{k+1} \in Q:
        [pArk+1]→a  [qB1r1]  [r1B2r2]…[rkBkrk+1] [p A r_{k+1}] \rightarrow a\; [q B_1 r_1]\; [r_1 B_2 r_2] \dots [r_k B_k r_{k+1}]

        • Push B1…BkB_1\dots B_k; must pop them in order via intermediate states.
        • aa consumed on transition; each [riBi+1ri+1][r_i B_{i+1} r_{i+1}] matches push/pop of Bi+1B_{i+1}.
    3. Empty stack (optional, for empty-stack acceptance):
      Add [pϵp]→ϵ[p \epsilon p] \rightarrow \epsilon for all p∈Qp \in Q (not needed for final-state).


    Intuition of Triplet [pAq][p A q]

    • Represents a matching push-pop pair on symbol AA.
    • pp: state where AA is pushed
    • qq: state where AA is popped
    • The derivation inside [pAq][p A q] generates the string read between push and pop of AA.

    Proof of Correctness (Sketch)

    Soundness (CFG ⊆\subseteq PDA):
    Every derivation in GG corresponds to a valid PDA computation:

    • S⇒∗[q0Z0p]S \Rightarrow^* [q_0 Z_0 p] maps to initial config.
    • Production [pAr]→a[qBr1]…[p A r] \rightarrow a [q B r_1] \dots mimics transition (p,a,A)→(q,B… )(p,a,A) \to (q,B\dots).
    • Base case [pAq]→a[p A q] \rightarrow a mimics (p,a,A)→(q,ϵ)(p,a,A) \to (q,\epsilon).
    • Induction on derivation length shows derived string is accepted by PP.

    Completeness (PDA ⊆\subseteq CFG):
    For any accepting run of PP on ww, build a parse tree in GG:

    • Root S→[q0Z0p]S \to [q_0 Z_0 p].
    • Each push of AA at state pp and corresponding pop at qq gives variable [pAq][p A q].
    • The substring read between push and pop is generated by that variable.
    • By induction on height of push-pop pairs, ww is generated.

    Example

    PDA for {anbn}\{a^n b^n\}:

    • δ(q0,a,Z0)=(q0,XZ0)\delta(q_0, a, Z_0) = (q_0, XZ_0)
    • δ(q0,a,X)=(q0,XX)\delta(q_0, a, X) = (q_0, XX)
    • δ(q0,b,X)=(q1,ϵ)\delta(q_0, b, X) = (q_1, \epsilon)
    • F={q1}F = \{q_1\}

    CFG variables: S,[q0Z0q1],[q0Xq0],[q0Xq1],…S, [q_0 Z_0 q_1], [q_0 X q_0], [q_0 X q_1], \dots
    Productions:
    S→[q0Z0q1]S \rightarrow [q_0 Z_0 q_1]
    [q0Xq1]→a[q0Xq1]b∣ab[q_0 X q_1] \rightarrow a [q_0 X q_1] b \mid ab (after resolving all intermediate states)
    [q0Z0q1]→a[q0Xq1]b[q_0 Z_0 q_1] \rightarrow a [q_0 X q_1] b

    Yields anbna^n b^n.


    Formal Statement

    Theorem: LL is accepted by a (nondeterministic) PDA iff LL is generated by a CFG.
    Corollary: CFL = languages accepted by NPDA. DPDA ⊂\subset CFL (strict).


    Final Answer

    Proof via Triplet Construction: Create CFG with variables [pAq][p A q] representing push-pop of AA from state pp to qq. Productions mirror PDA transitions. S→[q0Z0p]S \to [q_0 Z_0 p] for final pp. Induction on derivations/computations proves L(G)=L(P)L(G) = L(P). Hence every PDA language is a CFL.

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

    Design an NPDA (empty stack and final state acceptance) for:

    L={palindromes over {a,b}} L = \{\text{palindromes over } \{a,b\}\}

    View this question on its own page →
  16. 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

    Design Mealy and Moore machines to detect the sequence 1010 (overlapping allowed). Then convert the Moore machine into a Mealy machine and prove equivalence.

    View this question on its own page →
  17. 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

    Show whether the given grammar is ambiguous:

    S→a∣abSb∣aAbA→bS∣aAAb S \to a \mid abSb \mid aAb \\ A \to bS \mid aAAb

    View this question on its own page →
  18. 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

    Give examples of L1L_1 and L2L_2 such that:

    (i) L1L_1 is regular, L2L_2 is not regular, and L1−L2L_1 - L_2 is regular.
    (ii) L1L_1 and L2L_2 are not regular but L1∪L2L_1 \cup L_2 is regular.

    View this question on its own page →
  19. Q5b. Show that the language of palindromes over \{a, b\} is not regular.20227m

    Module 1: Introduction & Regular Languages

    Show that the language of palindromes over {a,b}\{a, b\} is not regular.

    View this question on its own page →
  20. 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

    Construct a CFG for:

    {0i1j2k∣i+j≥2k} \{ 0^i 1^j 2^k \mid i + j \ge 2k \}

    View this question on its own page →
  21. 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

    Convert the CFG to GNF:

    S→AB∣BCA→aB∣bA∣aB→bB∣cC∣bC→c S \to AB \mid BC \\ A \to aB \mid bA \mid a \\ B \to bB \mid cC \mid b \\ C \to c

    View this question on its own page →
  22. Budget 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.

    Install Pocketly
  23. Q7a. Design a Turing machine that accepts all palindromes over: \Sigma = \{ a, b \}20227m

    Module 4: Turing Machines (TM)

    Design a Turing machine that accepts all palindromes over:

    Σ={a,b} \Sigma = \{ a, b \}

    View this question on its own page →
  24. Q7b. Explain the Myhill–Nerode theorem for minimization of automata with an example.20227m

    Module 1: Introduction & Regular Languages

    Explain the Myhill–Nerode theorem for minimization of automata with an example.

    View this question on its own page →
  25. 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

    Construct FOLLOW sets for the grammar:

    E→TE′E′→+ T E′∣εT→FT′T′→− F T′∣εF→(E)∣id E \to T E' \\ E' \to +\,T\,E' \mid \varepsilon \\ T \to F T' \\ T' \to -\,F\,T' \mid \varepsilon \\ F \to (E) \mid id

    View this question on its own page →
  26. Q8b. Show that the language: L = \{ a^{n^2} b^n \mid n \ge 0 \} is not regular.20227m

    Module 1: Introduction & Regular Languages

    Show that the language:

    L={an2bn∣n≥0} L = \{ a^{n^2} b^n \mid n \ge 0 \}

    is not regular.

    View this question on its own page →
  27. Q9a. Prove that the halting problem for Turing machines is recursively undecidable.20227m

    Module 5: Undecidability

    Prove that the halting problem for Turing machines is recursively undecidable.

    View this question on its own page →
  28. Q9b(i). Write a short note on Deterministic PDA vs. Non-deterministic PDA.20227m

    Module 2: Context-Free Languages (CFL) and PDA

    Write a short note on Deterministic PDA vs. Non-deterministic PDA.

    View this question on its own page →
  29. Q9b(ii). Write a short note on Chomsky Normal Form (CNF).20227m

    Module 2: Context-Free Languages (CFL) and PDA

    Write a short note on Chomsky Normal Form (CNF).

    View this question on its own page →
  30. Q9b(iii). Write a short note on Multi-stack Turing Machine.20227m

    Module 4: Turing Machines (TM)

    Write a short note on Multi-stack Turing Machine.

    View this question on its own page →
  31. Q9b(iv). Write a short note on Finite-state Machine (FSM).20227m

    Module 1: Introduction & Regular Languages

    Write a short note on Finite-state Machine (FSM).

    View this question on its own page →
Student FinanceWeb Platform

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.