Week 2
Week 2
Week 2
other character
(delimeter)
L(M) = {???}
*q2 q2 q2
Regular Languages
Regular Operations
More formally, an FA M accepts a string w =
a0,a1,a2,...,an if there exists a sequence of states
r0,r1,r2, ...,rn in Q such that Union
1. r0 = q0,
2. !(ri, ai+1) = ri+1, for i = 0, ..., n-1, and
3. rn # F. Concatenation
Proof
• Let N = (Q,$,!,q0,F) be an NFA recognizing some language A
Visual version
• Construct a DFA recognizing A !({7,9},a)= )
– M = (Q’,$,!’,q0’,F’) !({7,9},b)= )
5 Start state q0= {1} !({5,6,8},a)= )
1. Q’ = the set of subsets of Q -- P(Q) b
6
!({5,6,8},b)= )
2. For R # Q’ and a # $ let !’(R,a) = {q # Q | q # !(r,a) for some r !(1,a)= {2,3} !({10},a)= )
# R} b !(1,b)= {4}
2 7 !({10},b)= )
– If R is a state of M, it is also a set of states of N (because of 1 above). When a a
M reads a symbol a in a state R, it shows where a takes each state in R. a b !({2,3},a)= !({2},a) ( !({3},a)
Because each state may go to a set of states, we take the union of all these 1 3 8
a = ) ( {7,9}
sets. This can be written as:
b = {7,9}
9
!' (R, a) = U! (r, a) 4 !({2,3},b)= !({2},b) ( !({3},b)
– q0={q0} r"R b = {5,6} ( {8}
• M starts in the state corresponding to the collection containing just the start state 10
of N.
= {5,6,8}
– F’ = {R # Q’|R contains an accept state of N}.
Final states F’=
!({4},a)= )
• The machine M accepts if one of the possible states that N could be in at this point {{5,6,8},{10}}
is an accept state. !({4},b)= {10}
" Labels
The DFA
In an NFA (NFA- "), arrows can be labeled with the
a
" symbol, meaning that a transition(s) can be made
!(1,a)={2,3} {7,9}
!(1,b)={4} to the following state(s) after consuming an input, or
{2,3} from the start state without consuming an input
!({2,3},a)={7,9} a
b {5,6,8} a,b symbol.
!({2,3},b)={5,6,8} {1}
!({4},a)=) a,b
b {4} a The convention used in our book is to follow the
!({4},b)={10} {)}
!({7,9},a)= ) arrow(s) with label " out of the state the NFA is in
!({7,9},b)= ) b after a symbol has been read and the arrow labeled
{10} a,b
!({5,6,8},a)= ) with that symbol has already been traversed.
!({5,6,8},b)= ) Start state q0={1}
!({10},a)= ) Final states F’={{5,6,8},{10}}
!({10},b)= )
"
Example
NFA With "-Transitions 0
For two languages R1 and R2, take two NFAs N1 and N2 and For a language R1, modify N1 to accept (R1)*.
combine them sequentially into one new NFA N.
N1
N1 N2
The new machine
guesses non-
deterministically
where to split the N
input in order to The new machine
N have a first part " has the option of
accepted by N1 and " jumping back to the
" a second part " start state to read
accepted by N2. another piece that
" N1 accepts.