CSCI 2670
Introduction to Theory of
Computing
September 5, 2007
Agenda
• Last class
– Introduced deterministic finite
automata
• Formally defined DFA’s
• Informally described DFA’s
• This class
– Formal definition of computation
• Definition of a regular language
– Designing finite automata
Formalizing computation
• Let M = (Q,,,q0,F) be a finite
automaton and let w = w1w2…wn be any
string over . M accepts w if there is
a sequence of states r0, r1, …, rn, of Q
such that
– r0 = q0
• start in the start state
– ri = (ri-1, wi)
• the transition function determines each step
– rn F
• the last state is one of the final states
Regular languages
• A deterministic finite automaton M
recognizes the language A if
A = { w | M accepts w }
• Alternatively, we say the language of
M is A
L(M) = { w | M accepts w }
• Any language recognized by a
deterministic finite automaton is
called a regular language
Designing finite automata
• Select states specifically to reflect
some important concept
– even number of 0’s
– odd number of occurrences of the string
010
• Ensure this meaning is relevant to the
language you are trying to define
• Try to get “in the head” of the
automaton
Example
• Design a DFA accepting all strings
over {0,1,2,3} such that the sum of
the symbols in the string is equivalent
to 2 modulo 4 or 3 modulo 4
Step 1
• What states do we need?
– One state for each value modulo 4
•
•
•
•
q1 represents 1 modulo 4
q2 represents 2 modulo 4
q3 represents 3 modulo 4
q4 represents 0 modulo 4
Step 2
• Create the state transition table
0
1
2
3
q1 (1 mod 4)
q1
q2
q3
q4
q2 (2 mod 4)
q2
q3
q4
q1
q3 (3 mod 4)
q3
q4
q1
q2
q4 (0 mod 4)
q4
q1
q2
q3
Step 3
• What elements of the 5-tuple do we know?
– Q, , and
• So we still need q0 and F
– q0 = q4
– F = {q2, q3}
Draw DFA
3
0
q1
1
q2
2
0
2
3
1
1
3
2
0
q4
2
1
3
q3
0
Combining regular languages
• We can create a regular language
from other regular languages A and B
using specific allowable operations
called regular operations
– Union: A B
– Concatenation: A B
– Kleene star: A*
Union is a regular operation
Theorem: The class of regular
languages is closed under the union
operation
Proof approach: Assume A1 and A2 are
both regular languages with A1=L(M1)
and A2=L(M2) and create a DFA M
such that L(M) = A1A2
Method: Proof by construction
Idea of construction
• Each state of the new DFA
represents both where the same word
would be if it was being processed in
M1 and where it would be if it were
processed in M2
– Keeping track of the progress of the
string in both DFA’s simultaneously
0,1
1
q1 0
q2 0
0
Example
0
q 1’ 1
q3
1
M1
q 2’ 0
q3 ’
1
1
M2
0
0
q2,q1’
q1,q1’
1
q3,q2’
q3,q1’
1
q1,q2’
1
etc.
Maximum
number of
states?
9
product of
number of
states in M1 and
in M2
0,1
1
q1 0
q2 0
0
Example
q 1’ 1
q3
1
M1
1
1
0
q2,q1’
1
1
q 2’ 0
q3 ’
1
1
M2
0
q1,q1’
0
0
q3,q1’
1
1
Formally defining M
• M = (Q,,,q0,F)
– Q = Q1 × Q2
• Q1 and Q2 are the states in machines M1 and
M2, respectively
– = 1 2
• 1 and 2 are the alphabets for machines M1
and M2, respectively
– ((r1,r2),a) = (1(r1,a), 2(r2,a))
• 1 and 2 are the state transition functions
for machines M1 and M2, respectively
Formally defining M
• M = (Q,,,q0,F)
– q0 = (r1, r2)
• r1 and r2 are the starting states in machines
M1 and M2, respectively
– F = {(r1,r2) | r1F1 or r2F2}
• F1 and F2 are the accepting states for
machines M1 and M2, respectively
1
1
q1 0
q2 0
1
Another Example
q3
0
M1
• Q=
0
q 1’ 1
M2
q2 ’
0,1
– {(q1,q1’), (q1,q2’), (q2,q1’), (q2,q2’), (q3,q1’), (q3,q2’)}
• Σ = {0,1}
• q0 =
– (q1,q1’)
• F=
– {(q1,q1’), (q1,q2’), (q2,q2’), (q3,q2’)}
1
1
q1 0
q2 0
1
Another Example
q 1’ 1
q3
0
M1
(q1,q1’)
(q1,q2’)
(q2,q1’)
(q2,q2’)
(q3,q1’)
(q3,q2’)
0
M2
0
(,)
(q2,q
,) 1’)
(,)
(q2,q
,) 2’)
(,)
(q3,q
,) 1’)
(,)
(q3,q
,) 2’)
(,)
(q1,q
,) 1’)
(,)
(q1,q
,) 2’)
1
(,)
(q1,q
,) 2’)
(,)
(q1,q
,) 2’)
(,)
(q2,q
,) 2’)
(,)
(q2,q
,) 2’)
(,)
(q3,q
,) 2’)
(,)
(q3,q
,) 2’)
q2 ’
0,1
Another example
0
0
q1’q1’
0
q2’q1’
1
1
1
q3’q1’
1
1
q1’q2’
0
q2’q2’ 0
1
0
q3’q2’
Concatenation is a regular operation
Theorem: The class of regular
languages is closed under the
concatenation operation
Proof approach: Assume A1 and A2 are
both regular languages with A1=L(M1)
and A2=L(M2) and create a DFA M
such that L(M) = A1A2
Method: Proof by construction
Idea of construction
• Any accepting state in M1 has a copy
of M2 “tacked on”
– Problem: if we tack a copy of M2 on at
each accepting states, we lose the
deterministic property
0,1
1
q1 0
q2 0
0
Example
0
q 1’ 1
q3
1
M1
q 2’ 0
q3 ’
1
1
M2
0,1
1
q1 0
q2 0
q3
0
ε
q 1’ 1
1
Can jump to q1’ nondeterministically
0
q2 ’ 0
q3 ’
1
1
© Copyright 2026 Paperzz