Example 1.11 I
Fig 1.12
Example 1.11 II
s
q1
q2
r1
r2
a b
a
b b
a
b a
a b
Example 1.11 III
L(M) =?
a . . . a, b . . . b
where “. . .” can be any string of a and b First we check that any string accepted by the machine must be
a . . . a, b . . . b Second we check that any
a . . . a, b . . . b can be recognized by the machine
Example 1.11 IV
This machine handles strings with the same character in the beginning and in the end
Example 1.13 I
Figure 1.14
Example 1.13 II
q0
q1
q2 2,⟨reset
⟩ 1
0, ⟨reset⟩
0
1 2
0 2
1, ⟨reset⟩
Example 1.13 III
Σ = {⟨reset⟩, 0, 1, 2}
L(M) = . . . ⟨reset⟩ . . . ⟨reset⟩ . . .
= {sum of the last segment mod 3 = 0}
Example:
10⟨reset⟩22⟨reset⟩012
Example 1.13 IV
An example of running a string
q0 −→ q1 1 −→ q0 1 −−−→ q⟨reset⟩ 0 −→ q2 2 −→ q2 1
⟨reset⟩
−−−→ q0 −→ q0 0 −→ q1 1 −→ q2 0 Accepted
Each node stores the sum of the current segment mod 3
Formal Definition of Computation I
M accepts w = w1· · · wn if ∃ states r0· · · rn such that
1 r0 = q0
2 δ(ri, wi +1) = ri +1, i = 0, . . . , n − 1
3 rn ∈ F
Definition: a language is regular if recognized by some automata
This is a very important definition
Examples described earlier are regular languages We say some automata, so it’s possible to have several automata for the same language
Formal Definition of Computation II
As long as there is one, then the language is regular
Designing Automata I
Given a language, how do we construct a machine to recognize it?
Basically we need to get a state diagram (where the number of states is finite)
Earlier we had the opposite: a machine is given and we check the corresponding language
Example: an automaton recognizing {0, 1} strings with an odd # of 1’s
Fig 1.20
Designing Automata II
qe qo
1
0 0
1 Sample strings
01
qe −→ q0 e −→ q1 o 010101
q −→ q0 −→ q1 −→ q0 −→ q1 −→ q0 −→ q1
Designing Automata III
Two ways to think about the design
After the first 1, we go to qo. Subsequently, every 1, . . . , 1 pair is cancelled out by
qo −→ q1 e → · · · → qe −→ q1 o qe, qo respectively remember whether the number of 1’s so far is even or odd
Example 1.21
Language: strings containing 001 Fig 1.22
Designing Automata IV
q q0 q00 q001
1
0
1
0
0
1
0, 1 q0, q00 indicate that before the current input
character, we have 0 and 00, respectively