- Asked 4/9
- 2070 Magh · 2+6 marks
Define FSM; design FSA with two consecutive a's
Short answer
DFA with states q0 (no a seen), q1 (last symbol a), q2 (has aa, final trap). On a: q0→q1, q1→q2, q2 loops. On b: q1→q0, q0 loops, q2 loops. Accepts strings with aa.
Define Finite State Machines. Design a Finite State Automata that accepts precisely those strings over {a, b} that contain two consecutive a's. Your design should include the proper definition of the finite-state automaton, transition table and the transition diagram.
Definition
A finite-state machine (FSM) is a 6-tuple M = (S, I, O, f, g, s₀): S a finite set of states, I the input alphabet, O the output alphabet, f : S × I → S the next-state function, g : S × I → O the output function and s₀ the initial state. When no output is needed and we only decide acceptance, it is a finite-state automaton (FSA) M = (S, I, f, s₀, F), where F ⊆ S is the set of final states. A string is accepted if it takes the machine from s₀ to a state in F.
Design
The machine remembers how much of "aa" it has seen:
- q₀: no useful a seen (start, last symbol was b or nothing).
- q₁: the last symbol was a (one a seen).
- q₂: two consecutive a's have been seen (final, a trap: once found, always accepted).
Formal definition: M = ({q₀, q₁, q₂}, {a, b}, f, q₀, {q₂})
Transition table
| State | a | b |
|---|---|---|
| → q₀ | q₁ | q₀ |
| q₁ | q₂ | q₀ |
| *q₂ (final) | q₂ | q₂ |
Transition diagram
b (loop) a,b (loop)
+--+ +--+
v | v |
->(q0)------a------>(q1)------a------>((q2))-+
^ |
+--------b---------+
(q₀ loops on b; q₁ returns to q₀ on b; q₂ loops on a and b.)
Check
- baab: q₀ → q₀ → q₁ → q₂ → q₂. Accepted.
- abab: q₀ → q₁ → q₀ → q₁ → q₀. Rejected (no aa).
- Brute-force test on all strings up to length 10 confirmed the machine accepts exactly the strings containing aa.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Design FSA accepting odd number of b's · Discrete Structure, chapter 2 · asked 4×
- Design FSA accepting even number of a's · Discrete Structure, chapter 2 · asked 4×
- Design FSA for strings beginning with baa · Discrete Structure, chapter 2
- Design NFA for strings ending with aba · Discrete Structure, chapter 2
- Regular expression and FSA: at least three b's · Discrete Structure, chapter 2
- Differentiate Finite State Machine and Automata · Discrete Structure, chapter 2 · asked 2×