A machine is represented by states Q, input alphabet Σ, transition function δ,…

2025

A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q₀ and final state F. The machine accepts all the strings over Σ = {a, b}, which start and ended with any combination of all alphabet and abb works/lies as substring in all the strings to be accepted.
For the above specified passage, which of the following represent the grammar for the language accepted the machine?

  1. A.

    S → AabbB, A → aA | ε, B → bB | ε

  2. B.

    S → abbA, A → aA | ε | bA

  3. C.

    S → AabbA, A → aA | bA | ε

  4. D.

    S → Aabb, A → aA | bA | ε

Attempted by 79 students.

Show answer & explanation

Correct answer: C

Given language description (interpreted clearly)

The machine accepts all strings over Σ={a,b}\Sigma = \{a, b\}Σ={a,b} such that:

  • The string may start and end with any combination of symbols from {a,b}\{a,b\}{a,b}, and

  • The substring abb must occur somewhere in the string.

In formal language terms, the language is:

L=Σ∗ abb Σ∗L = \Sigma^*\,abb\,\Sigma^*L=Σ∗abbΣ∗

Given grammar

S→A abb AA→aA∣bA∣ε\begin{aligned} S &\rightarrow A\,abb\,A \\ A &\rightarrow aA \mid bA \mid \varepsilon \end{aligned}SA​→AabbA→aA∣bA∣ε​

Verification of the grammar

  • Non-terminal AAA generates:

    A⇒Σ∗(any string over {a,b},including empty string)A \Rightarrow \Sigma^* \quad (\text{any string over } \{a,b\}, \text{including empty string})A⇒Σ∗(any string over {a,b},including empty string)

  • Start symbol SSS generates:

    S⇒Σ∗ abb Σ∗S \Rightarrow \Sigma^*\,abb\,\Sigma^*S⇒Σ∗abbΣ∗

This exactly matches the language description:

  • Any prefix of aaa's and bbb's

  • Followed by the fixed substring abb

  • Followed by any suffix of aaa's and bbb's

✅ Conclusion

The given grammar correctly represents the language accepted by the machine.

S→AabbA,A→aA∣bA∣ε\boxed{ S \rightarrow AabbA,\quad A \rightarrow aA \mid bA \mid \varepsilon }S→AabbA,A→aA∣bA∣ε​

This grammar generates all and only those strings over {a,b}\{a,b\}{a,b} that contain abb as a substring, regardless of what appears before or after it.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor