Problem Solving in Automata, Languages, and Complexity

(Dana P.) #1
32 FINITE AUTOMATA

0 a

04

9


Figure 2.11: Solution to Example 2.10.

At state q2, if we read more input symbols, then we need to follow the same
idea to set S(Q,O) = 41 and 6(q2,1) = 40. The complete DFA is shown in
Figure 2.11(b). Cl


Example 2.11 The set of ~11 binary expansions of positive integers which are
congruent to zero modulo 5.

Solution. The idea of this DFA is similar to that of the last two examples.
We need to set up five states 40, ~1,... ,44, with each state pi meaning β€œthe
prefix y of the input string read so far has the property of y z i (mod 5).”
That is, we need to define S(~O, ~1x2 0 l l xk) = pi if ~1x2 l l l Q E i (mod 5).
How do we determine the edges between these five states from this idea?
Recall that the transition function S of a DFA has to satisfy

qqqo, x), a) = QlO~ xa)y


for any x E {O,l}* and any a E (0, 1). Suppose &JO, x) = pi and s(40, xa) =
qj. Then, we must have x G i (mod 5) and xa s j (mod 5). Thus,

j E xu (mod 5)
G 2*x+a (mod5)
E 2G+a (mod5).

Therefore, we need to define S(qi, a) = qj, where j G 2i + a (mod 5). For
instance, 6(q2,0) = q4 and S(q2,l) = qo. See Figure 2.12 for the other edges.
In addition, state qo is the unique final state, since S(q0, x) = qo means x E
0 (mod 5).
Finally, we note that a binary expansion of a positive integer always begins
with the symbol 1. So, we need to add a new initial state and a failure state,
as shown in Figure 2.12. cl

Note that the set AU{l}, w h ere A is the set defined in Example 2.10, may
be regarded as the set of binary expansions of integers congruent to 1 modulo

Free download pdf