- 2071 Chaitra
DFA for (a(ab)*b)*
Short answer
DFA: states s0 (start/final), s1, s2, dead d. Transitions: s0-a→s1, s1-b→s0, s1-a→s2, s2-b→s1; others go to d. Accepts ε and zero or more blocks of a(ab)*b. Example: aabb (accepted by s0→s1→s2→s1→s0), aab (rejected, ends in s1).
Design a DFA for the regular expression (a(ab)b). Verify your design by taking one accepted and one rejected string.
Language. (a(ab)b) is a repetition of blocks of the form a(ab)ᵏb, k ≥ 0: ab, aabb, aababb, ... Zero blocks (ε) is allowed.
Idea. s0 = at a block boundary (start and final). After the first a of a block we are in s1. In s1 we may close the block with b, or open an "ab" pair with a (going to s2), which must be finished by b (back to s1).
M = ({s0, s1, s2, d}, {a, b}, δ, s0, {s0})
| State | a | b |
|---|---|---|
| → *s0 | s1 | d |
| s1 | s2 | s0 |
| s2 | d | s1 |
| d (dead) | d | d |
a a
──►((s0)) ───► (s1) ───► (s2)
◄─── b ──┘ ◄─── b ──┘
(s0 -b-> d, s2 -a-> d, d loops on a,b)
Edges: s0 –a→ s1, s1 –b→ s0, s1 –a→ s2, s2 –b→ s1.
Verification
- Accepted: aabb. s0 →a s1 →a s2 →b s1 →b s0, which is final. (It is a(ab)b.)
- Accepted: abab. s0 → s1 → s0 → s1 → s0 (two blocks ab, ab).
- Rejected: aab. s0 → s1 → s2 → s1, and s1 is not final.
- Rejected: ba. s0 →b d, and d is not final.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Configuration of DFA; DFA with 01 and 10 · Theory of Computation, chapter 2
- Regular expression with substring 0101 · Theory of Computation, chapter 2
- DFA avoiding substring 10110 · Theory of Computation, chapter 2
- DFA for {00}*{11}* language · Theory of Computation, chapter 2
- Regular grammar to RE and FA · Theory of Computation, chapter 2
- Every RE has NFA; ε-NFA for bb(a∪b)*ab · Theory of Computation, chapter 2
- Regular expression and FSA: at least three b's · Discrete Structure, chapter 2
- Design pipes AB and BC, A RL 210 m, 44 and 18 lps · Water Supply Engineering, chapter 7
- Design pipes AB, BC, AD (min pressure 1.1 kg/cm2) · Water Supply Engineering, chapter 7 · asked 2×
- Design pipes AB and BC, 75 lpcd, tank 6 m high · Water Supply Engineering, chapter 7