SlideShare a Scribd company logo
1 of 43
Download to read offline
Equivalence of DFA and NFA
• NFA’s are usually easier to “program” in.
• Surprisingly, for any NFA N there is a DFA D,
such that L(D) = L(N), and vice versa.
• This involves the subset construction, an im-
portant example how an automaton B can be
generically constructed from another automa-
ton A.
• Given an NFA
N = (QN, Σ, δN, q0, FN)
we will construct a DFA
D = (QD, Σ, δD, {q0}, FD)
such that
L(D) = L(N)
.
33
The details of the subset construction:
• QD = {S : S ⊆ QN}.
Note: |QD| = 2|QN|, although most states in
QD are likely to be garbage.
• FD = {S ⊆ QN : S ∩ FN 6= ∅}
• For every S ⊆ QN and a ∈ Σ,
δD(S, a) =
[
p∈S
δN(p, a)
34
Let’s construct δD from the NFA on slide 27
0 1
∅ ∅ ∅
→ {q0} {q0, q1} {q0}
{q1} ∅ {q2}
?{q2} ∅ ∅
{q0, q1} {q0, q1} {q0, q2}
?{q0, q2} {q0, q1} {q0}
?{q1, q2} ∅ {q2}
?{q0, q1, q2} {q0, q1} {q0, q2}
35
Note: The states of D correspond to subsets
of states of N, but we could have denoted the
states of D by, say, A − F just as well.
0 1
A A A
→ B E B
C A D
?D A A
E E F
?F E B
?G A D
?H E F
36
We can often avoid the exponential blow-up
by constructing the transition table for D only
for accessible states S as follows:
Basis: S = {q0} is accessible in D
Induction: If state S is accessible, so are the
states in
S
a∈Σ δD(S, a).
Example: The “subset” DFA with accessible
states only.
Start
{ {
q q {q
0 0 0
, ,
q q
1 2
}
}
0 1
1 0
0
1
}
37
{ }
Theorem 2.11: Let D be the “subset” DFA
of an NFA N. Then L(D) = L(N).
Proof: First we show onby an induction on |w|
that
δ̂D({q0}, w) = δ̂N(q0, w)
Basis: w = . The claim follows from def.
38
Induction:
δ̂D({q0}, xa)
def
= δD(δ̂D({q0}, x), a)
i.h.
= δD(δ̂N(q0, x), a)
cst
=
[
p∈δ̂N(q0,x)
δN(p, a)
def
= δ̂N(q0, xa)
Now (why?) it follows that L(D) = L(N).
39
Theorem 2.12: A language L is accepted by
some DFA if and only if L is accepted by some
NFA.
Proof: The “if” part is Theorem 2.11.
For the “only if” part we note that any DFA
can be converted to an equivalent NFA by mod-
ifying the δD to δN by the rule
• If δD(q, a) = p, then δN(q, a) = {p}.
By induction on |w| it will be shown in the
tutorial that if δ̂D(q0, w) = p, then δ̂N(q0, w) =
{p}.
The claim of the theorem follows.
40
How do you convert an NFA to C/C++ code?
Exponential Blow-Up
There is an NFA N with n + 1 states that has
no equivalent DFA with fewer than 2n states
Start
0, 1
0, 1 0, 1 0, 1
q q q
q0 1 2 n
1 0, 1
L(N) = {x1c2c3 · · · cn : x ∈ {0, 1}∗, ci ∈ {0, 1}}
Suppose an equivalent DFA D with fewer than
2n states exists.
D must remember the last n symbols it has
read.
There are 2n bitsequences a1a2 · · · an
∃ q, a1a2 · · · an, b1b2 · · · bn : q = ∈ δ̂ND(q0, a1a2 · · · an),
q = ∈ δ̂ND(q0, b1b2 · · · bn),
a1a2 · · · an 6= b1b2 · · · bn
41
Case 1:
1a2 · · · an
0b2 · · · bn
Then q has to be both an accepting and a
nonaccepting state.
Case 2:
a1 · · · ai−11ai+1 · · · an
b1 · · · bi−10bi+1 · · · bn
Now δ̂N
(q0, a1 · · · ai−11ai+1 · · · an0i−1) =
δ̂N
(q0, b1 · · · bi−10bi+1 · · · bn0i−1)
and δ̂N
(q0, a1 · · · ai−11ai+1 · · · an0i−1) ∈ FD
δ̂N
(q0, b1 · · · bi−10bi+1 · · · bn0i−1) /
∈ FD
42
D
D
D
D
FA’s with Epsilon-Transitions
An -NFA accepting decimal numbers consist-
ing of:
1. An optional + or - sign
2. A string of digits
3. a decimal point
4. another string of digits
One of the strings (2) are (4) are optional
q q q q q
q
0 1 2 3 5
4
Start
0,1,...,9 0,1,...,9
ε ε
0,1,...,9
0,1,...,9
,+,-
.
.
43
E.g. -12.5
+10.00
5.
-.6
Example:
-NFA accepting the set of keywords {ebay, web}
1
2 3 4
5 6 7 8
Start
Σ
w
e
e
y
b a
b
44
We can have an ε-moves for each keyword.
An -NFA is a quintuple (Q, Σ, δ, q0, F ) where δ
is a function from Q × (Σ ∪ {}) to the powerset
of Q.
Example: The -NFA from the previous slide
E = ({q0, q1, . . . , q5}, {., +, −, 0, 1, . . . , 9} δ, q0, {q5})
where the transition table for δ is
 +,- . 0, . . . , 9
→ q0 {q1} {q1} ∅ ∅
q1 ∅ ∅ {q2} {q1, q4}
q2 ∅ ∅ ∅ {q3}
q3 {q5} ∅ ∅ {q3}
q4 ∅ ∅ {q3} ∅
?q5 ∅ ∅ ∅ ∅
45
ECLOSE
We close a state by adding all states reachable
by a sequence  · · · 
Inductive definition of ECLOSE(q)
Basis:
q ∈ ECLOSE(q)
Induction:
p ∈ ECLOSE(q) and r ∈ δ(p, ) ⇒
r ∈ ECLOSE(q)
46
or ε-closure
Example of -closure
1
2 3 6
4 5 7
ε
ε ε
ε
ε
a
b
For instance,
ECLOSE(1) = {1, 2, 3, 4, 6}
47
• Inductive definition of δ̂ for -NFA’s
Basis:
δ̂(q, ) = ECLOSE(q)
Induction:
δ̂(q, xa) =
[
p∈δ(δ̂(q,x),a)
ECLOSE(p)
Let’s compute on the blackboard in class
δ̂(q0, 5.6) for the NFA on slide 43
48
δ(q0,ε) = ECLOSE(q0) = {q0,q1}
δ(q0,5) = ECLOSE({q1,q4}) = {q1,q4}, because δ(q0,5) U δ(q1,5) = {q1,q4}
δ(q0,5.) = ECLOSE({q2,q3}) = {q2,q3,q5}
δ(q0,5.6) = ECLOSE({q3}) = {q3,q5}
^
^
^
^
where δ(δ(q,x),a) = U δ(r,a)
r ε δ(q,x)
^
^
Given an -NFA
E = (QE, Σ, δE, q0, FE)
we will construct a DFA
D = (QD, Σ, δD, qD, FD)
such that
L(D) = L(E)
Details of the construction:
• QD = {S : S ⊆ QE and S = ECLOSE(S)}
• qD = ECLOSE(q0)
• FD = {S : S ∈ QD and S ∩ FE 6= ∅}
• δD(S, a) =
[
{ECLOSE(p) : p ∈ δ(t, a) for some t ∈ S}
49
E
Example: -NFA E
q q q q q
q
0 1 2 3 5
4
Start
0,1,...,9 0,1,...,9
ε ε
0,1,...,9
0,1,...,9
,+,-
.
.
DFA D corresponding to E
Start
{ { { {
{ {
q q q q
q q
0 1 1
, }
q
1
} , q
4
} 2, q
3
, q5
}
2}
3
, q5
}
0,1,...,9 0,1,...,9
0,1,...,9
0,1,...,9
0,1,...,9
0,1,...,9
+,-
.
.
.
50
{φ}
.,+,−
+,−
.,+,−
+,−
.,+,−
+,−,.,0,1,...,9
Theorem 2.22: A language L is accepted by
some -NFA E if and only if L is accepted by
some DFA.
Proof: We use D constructed as above and
show by induction that δ̂D(q0, w) = δ̂E(qD, w)
Basis: δ̂E(q0, ) = ECLOSE(q0) = qD = δ̂(qD, )
51
D 0
Induction:
δ̂E(q0, xa) =
[
p∈δE(δ̂E(q0,x),a)
ECLOSE(p)
=
[
p∈δD(δ̂
D(qD,x),a)
ECLOSE(p)
=
[
p∈δ̂D(qD,xa)
ECLOSE(p)
= δ̂D(qD, xa)
52
DEF
I.H.
CST
DEF
D D D
δ (δ (q ,x),a)
^
E
Regular expressions
An FA (NFA or DFA) is a “blueprint” for con-
tructing a machine recognizing a regular lan-
guage.
A regular expression is a “user-friendly,” declar-
ative way of describing a regular language.
Example: 01∗ + 10∗
Regular expressions are used in e.g.
1. UNIX grep command
2. UNIX Lex (Lexical analyzer generator) and
Flex (Fast Lex) tools.
53
Text/email mining (e.g., for HomeUnion)
3.
grep PATTERN FILE
Operations on languages
Union:
L ∪ M = {w : w ∈ L or w ∈ M}
Concatenation:
L.M = {w : w = xy, x ∈ L, y ∈ M}
Powers:
L0 = {}, L1 = L, Lk+1 = L.Lk
Kleene Closure:
L∗ =
∞
[
i=0
Li
Question: What are ∅0, ∅i, and ∅∗
54
Question: What is {02,03}* ?
Building regex’s
Inductive definition of regex’s:
Basis:  is a regex and ∅ is a regex.
L() = {}, and L(∅) = ∅.
If a ∈ Σ, then a is a regex.
L(a) = {a}.
Induction:
If E is a regex’s, then (E) is a regex.
L((E)) = L(E).
If E and F are regex’s, then E + F is a regex.
L(E + F) = L(E) ∪ L(F).
If E and F are regex’s, then E.F is a regex.
L(E.F) = L(E).L(F).
If E is a regex’s, then E? is a regex.
L(E?) = (L(E))∗.
55
Example: Regex for
L = {w ∈ {0, 1}∗ : 0 and 1 alternate in w}
(01)∗ + (10)∗ + 0(10)∗ + 1(01)∗
or, equivalently,
( + 1)(01)∗( + 0)
Order of precedence for operators:
1. Star
2. Dot
3. Plus
Example: 01∗ + 1 is grouped (0(1)
∗
) + 1
56
*)
Ex. Regex's for L1 = { w | w ε {0,1}*, w contains no consecutive 0's}
L2 = { w | w ε {0,1}*, the number of 0's in w is even}.
Equivalence of FA’s and regex’s
We have already shown that DFA’s, NFA’s,
and -NFA’s all are equivalent.
ε-NFA NFA
DFA
RE
To show FA’s equivalent to regex’s we need to
establish that
1. For every DFA A we can find (construct,
in this case) a regex R, s.t. L(R) = L(A).
2. For every regex R there is an -NFA A, s.t.
L(A) = L(R).
57
Theorem 3.4: For every DFA A = (Q, Σ, δ, q0, F)
there is a regex R, s.t. L(R) = L(A).
Proof: Let the states of A be {1, 2, . . . , n},
with 1 being the start state.
• Let R
(k)
ij be a regex describing the set of
labels of all paths in A from state i to state
j going through intermediate states {1, . . . , k}
only.
i
k
j
58
Note that, i and j don't have to be in {1, ...,k}.
R
(k)
ij will be defined inductively. Note that
L


M
j∈F
R1j
(n)

 = L(A)
Basis: k = 0, i.e. no intermediate states.
• Case 1: i 6= j
R
(0)
ij =
M
{a∈Σ:δ(i,a)=j}
a
• Case 2: i = j
R
(0)
ii =



M
{a∈Σ:δ(i,a)=i}
a


 + 
59
i.e., arc i - j
i.e., arc i - i or ε
Induction:
R
(k)
ij
=
R
(k−1)
ij
+
R
(k−1)
ik

R
(k−1)
kk
∗
R
(k−1)
kj
R kj
(k-1)
R kk
(k-1)
R ik
(k-1)
i k k k k
Zero or more strings in
In In
j
60
does not go through k
goes through k
at least once
Example: Let’s find R for A, where
L(A) = {x0y : x ∈ {1}∗ and y ∈ {0, 1}∗}
1
0
Start 0,1
1 2
R
(0)
11  + 1
R
(0)
12 0
R
(0)
21 ∅
R
(0)
22  + 0 + 1
61
We will need the following simplification rules:
• ( + R)∗ = R∗
• R + RS∗ = RS∗
• ∅R = R∅ = ∅ (Annihilation)
• ∅ + R = R + ∅ = R (Identity)
62
(ε+R)R* = R*
ε+R+R* = R*
R
(0)
11  + 1
R
(0)
12 0
R
(0)
21 ∅
R
(0)
22  + 0 + 1
R
(1)
ij = R
(0)
ij + R
(0)
i1

R
(0)
11
∗
R
(0)
1j
By direct substitution Simplified
R
(1)
11  + 1 + ( + 1)( + 1)∗( + 1) 1∗
R
(1)
12 0 + ( + 1)( + 1)∗0 1∗0
R
(1)
21 ∅ + ∅( + 1)∗( + 1) ∅
R
(1)
22  + 0 + 1 + ∅( + 1)∗0  + 0 + 1
63
Simplified
R
(1)
11 1∗
R
(1)
12 1∗0
R
(1)
21 ∅
R
(1)
22  + 0 + 1
R
(2)
ij = R
(1)
ij + R
(1)
i2

R
(1)
22
∗
R
(1)
2j
By direct substitution
R
(2)
11 1∗ + 1∗0( + 0 + 1)∗∅
R
(2)
12 1∗0 + 1∗0( + 0 + 1)∗( + 0 + 1)
R
(2)
21 ∅ + ( + 0 + 1)( + 0 + 1)∗∅
R
(2)
22  + 0 + 1 + ( + 0 + 1)( + 0 + 1)∗( + 0 + 1)
64
By direct substitution
R
(2)
11 1∗ + 1∗0( + 0 + 1)∗∅
R
(2)
12 1∗0 + 1∗0( + 0 + 1)∗( + 0 + 1)
R
(2)
21 ∅ + ( + 0 + 1)( + 0 + 1)∗∅
R
(2)
22  + 0 + 1 + ( + 0 + 1)( + 0 + 1)∗( + 0 + 1)
Simplified
R
(2)
11 1∗
R
(2)
12 1∗0(0 + 1)∗
R
(2)
21 ∅
R
(2)
22 (0 + 1)∗
The final regex for A is
R
(2)
12 = 1∗0(0 + 1)∗
65
Observations
There are n3 expressions R
(k)
ij
Each inductive step grows the expression 4-fold
R
(n)
ij could have size 4n
For all {i, j} ⊆ {1, . . . , n}, R
(k)
ij uses R
(k−1)
kk
so we have to write n2 times the regex R
(k−1)
kk
We need a more efficient approach:
the state elimination technique
66
but most of them can be removed by annihilation!
The state elimination technique
Let’s label the edges with regex’s instead of
symbols
q
q
p
p
1 1
k m
s
Q
Q
P1
Pm
k
1
11
R
R 1m
R km
R k1
S
67
Now, let’s eliminate state s.
11
R Q1
P1
R 1m
R k1
R km
Q1
Pm
Qk
Qk
P1
Pm
q
q
p
p
1 1
k m
+ S*
+
+
+
S*
S*
S*
For each accepting state q eliminate from the
original automaton all states exept q0 and q.
68
For each q ∈ F we’ll be left with an Aq that
looks like
Start
R
S
T
U
that corresponds to the regex Eq = (R+SU∗T)∗SU∗
or with Aq looking like
R
Start
corresponding to the regex Eq = R∗
• The final expression is
M
q∈F
Eq
69
q
q
Example: A, where L(A) = {W : w = x1b, or w =
x1bc, x ∈ {0, 1}∗, {b, c} ⊆ {0, 1}}
Start
0,1
1 0,1 0,1
A B C D
We turn this into an automaton with regex
labels
0 1
+
0 1
+ 0 1
+
Start
A B C D
1
70
Note that the algorithm also works for NFAs and ε-NFAs.
0 1
+
0 1
+ 0 1
+
Start
A B C D
1
Let’s eliminate state B
0 1
+
D
C
0 1
+
( ) 0 1
+
Start
A
1
Then we eliminate state C and obtain AD
0 1
+
D
0 1
+
( ) 0 1
+
( )
Start
A
1
with regex (0 + 1)∗1(0 + 1)(0 + 1)
71
From
0 1
+
D
C
0 1
+
( ) 0 1
+
Start
A
1
we can eliminate D to obtain AC
0 1
+
C
0 1
+
( )
Start
A
1
with regex (0 + 1)∗1(0 + 1)
• The final expression is the sum of the previ-
ous two regex’s:
(0 + 1)∗1(0 + 1)(0 + 1) + (0 + 1)∗1(0 + 1)
72
From regex’s to -NFA’s
Theorem 3.7: For every regex R we can con-
struct and -NFA A, s.t. L(A) = L(R).
Proof: By structural induction:
Basis: Automata for , ∅, and a.
ε
a
(a)
(b)
(c)
73
ε-NFAs with properties:
* unique start and final
states
* no arcs into the start
state
* no arcs out of the final
state
Induction: Automata for R + S, RS, and R∗
(a)
(b)
(c)
R
S
R S
R
ε ε
ε
ε
ε
ε
ε
ε ε
74
Example: We convert (0 + 1)∗1(0 + 1)
ε
ε
ε
ε
0
1
ε
ε
ε
ε
0
1
ε
ε
1
Start
(a)
(b)
(c)
0
1
ε ε
ε
ε
ε ε
ε
ε
ε
0
1
ε ε
ε
ε
ε ε
ε
75

More Related Content

Similar to 6-Nfa & equivalence with RE.pdf

SMB_2012_HR_VAN_ST-last version
SMB_2012_HR_VAN_ST-last versionSMB_2012_HR_VAN_ST-last version
SMB_2012_HR_VAN_ST-last versionLilyana Vankova
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Variations on the method of Coleman-Chabauty
Variations on the method of Coleman-ChabautyVariations on the method of Coleman-Chabauty
Variations on the method of Coleman-Chabautymmasdeu
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化Akira Tanimoto
 
Dynamical systems solved ex
Dynamical systems solved exDynamical systems solved ex
Dynamical systems solved exMaths Tutoring
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
A Note on PCVB0 for HDP-LDA
A Note on PCVB0 for HDP-LDAA Note on PCVB0 for HDP-LDA
A Note on PCVB0 for HDP-LDATomonari Masada
 
Bch and reed solomon codes generation in frequency domain
Bch and reed solomon codes generation in frequency domainBch and reed solomon codes generation in frequency domain
Bch and reed solomon codes generation in frequency domainMadhumita Tamhane
 
Hierarchical matrices for approximating large covariance matries and computin...
Hierarchical matrices for approximating large covariance matries and computin...Hierarchical matrices for approximating large covariance matries and computin...
Hierarchical matrices for approximating large covariance matries and computin...Alexander Litvinenko
 
Crib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC examsCrib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC examsA Jorge Garcia
 
Conformable Chebyshev differential equation of first kind
Conformable Chebyshev differential equation of first kindConformable Chebyshev differential equation of first kind
Conformable Chebyshev differential equation of first kindIJECEIAES
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfAmayJaiswal4
 
Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...
Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...
Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...inventionjournals
 
Some Examples of Scaling Sets
Some Examples of Scaling SetsSome Examples of Scaling Sets
Some Examples of Scaling SetsVjekoslavKovac1
 

Similar to 6-Nfa & equivalence with RE.pdf (20)

Dfa h11
Dfa h11Dfa h11
Dfa h11
 
SMB_2012_HR_VAN_ST-last version
SMB_2012_HR_VAN_ST-last versionSMB_2012_HR_VAN_ST-last version
SMB_2012_HR_VAN_ST-last version
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Variations on the method of Coleman-Chabauty
Variations on the method of Coleman-ChabautyVariations on the method of Coleman-Chabauty
Variations on the method of Coleman-Chabauty
 
Finite automata
Finite automataFinite automata
Finite automata
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化
 
Dynamical systems solved ex
Dynamical systems solved exDynamical systems solved ex
Dynamical systems solved ex
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
Dft
DftDft
Dft
 
A Note on PCVB0 for HDP-LDA
A Note on PCVB0 for HDP-LDAA Note on PCVB0 for HDP-LDA
A Note on PCVB0 for HDP-LDA
 
Bch and reed solomon codes generation in frequency domain
Bch and reed solomon codes generation in frequency domainBch and reed solomon codes generation in frequency domain
Bch and reed solomon codes generation in frequency domain
 
Hierarchical matrices for approximating large covariance matries and computin...
Hierarchical matrices for approximating large covariance matries and computin...Hierarchical matrices for approximating large covariance matries and computin...
Hierarchical matrices for approximating large covariance matries and computin...
 
O2
O2O2
O2
 
Crib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC examsCrib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC exams
 
Conformable Chebyshev differential equation of first kind
Conformable Chebyshev differential equation of first kindConformable Chebyshev differential equation of first kind
Conformable Chebyshev differential equation of first kind
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
 
Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...
Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...
Necessary and Sufficient Conditions for Oscillations of Neutral Delay Differe...
 
Some Examples of Scaling Sets
Some Examples of Scaling SetsSome Examples of Scaling Sets
Some Examples of Scaling Sets
 

More from shruti533256

More on Emulsion.docx
More on Emulsion.docxMore on Emulsion.docx
More on Emulsion.docxshruti533256
 
More on Virtualization.ppt
More on Virtualization.pptMore on Virtualization.ppt
More on Virtualization.pptshruti533256
 
Virtualization Introduction.ppt
Virtualization Introduction.pptVirtualization Introduction.ppt
Virtualization Introduction.pptshruti533256
 
Virtualization summary b.docx
Virtualization summary b.docxVirtualization summary b.docx
Virtualization summary b.docxshruti533256
 
Virtualization summary a.docx
Virtualization summary a.docxVirtualization summary a.docx
Virtualization summary a.docxshruti533256
 
More on Virtualization 2.pptx
More on Virtualization 2.pptxMore on Virtualization 2.pptx
More on Virtualization 2.pptxshruti533256
 
Virtualization concepts 2.pptx
Virtualization concepts 2.pptxVirtualization concepts 2.pptx
Virtualization concepts 2.pptxshruti533256
 
6- Threaded Interpretation.docx
6- Threaded Interpretation.docx6- Threaded Interpretation.docx
6- Threaded Interpretation.docxshruti533256
 
More on Virtualization 3.pptx
More on Virtualization 3.pptxMore on Virtualization 3.pptx
More on Virtualization 3.pptxshruti533256
 
2-Virtualization in Cloud Computing and Types.docx
2-Virtualization in Cloud Computing and Types.docx2-Virtualization in Cloud Computing and Types.docx
2-Virtualization in Cloud Computing and Types.docxshruti533256
 
4-Taxonomy of virtualization.docx
4-Taxonomy of virtualization.docx4-Taxonomy of virtualization.docx
4-Taxonomy of virtualization.docxshruti533256
 
Course Plan Virtualization concepts.docx
Course Plan Virtualization concepts.docxCourse Plan Virtualization concepts.docx
Course Plan Virtualization concepts.docxshruti533256
 
3-Types of Virtual Machines.docx
3-Types of Virtual Machines.docx3-Types of Virtual Machines.docx
3-Types of Virtual Machines.docxshruti533256
 
1-Introduction to Virtualization.docx
1-Introduction to Virtualization.docx1-Introduction to Virtualization.docx
1-Introduction to Virtualization.docxshruti533256
 
9-Pumping Lemma.pdf
9-Pumping Lemma.pdf9-Pumping Lemma.pdf
9-Pumping Lemma.pdfshruti533256
 
5-DFA and equivalence with RE.pdf
5-DFA and equivalence with RE.pdf5-DFA and equivalence with RE.pdf
5-DFA and equivalence with RE.pdfshruti533256
 
2-Chomsky hierarchy of languages.ppt
2-Chomsky hierarchy of languages.ppt2-Chomsky hierarchy of languages.ppt
2-Chomsky hierarchy of languages.pptshruti533256
 

More from shruti533256 (19)

More on Emulsion.docx
More on Emulsion.docxMore on Emulsion.docx
More on Emulsion.docx
 
More on Virtualization.ppt
More on Virtualization.pptMore on Virtualization.ppt
More on Virtualization.ppt
 
Virtualization Introduction.ppt
Virtualization Introduction.pptVirtualization Introduction.ppt
Virtualization Introduction.ppt
 
Virtualization summary b.docx
Virtualization summary b.docxVirtualization summary b.docx
Virtualization summary b.docx
 
Virtualization summary a.docx
Virtualization summary a.docxVirtualization summary a.docx
Virtualization summary a.docx
 
More on Virtualization 2.pptx
More on Virtualization 2.pptxMore on Virtualization 2.pptx
More on Virtualization 2.pptx
 
Virtualization concepts 2.pptx
Virtualization concepts 2.pptxVirtualization concepts 2.pptx
Virtualization concepts 2.pptx
 
6- Threaded Interpretation.docx
6- Threaded Interpretation.docx6- Threaded Interpretation.docx
6- Threaded Interpretation.docx
 
Overview.ppt
Overview.pptOverview.ppt
Overview.ppt
 
More on Virtualization 3.pptx
More on Virtualization 3.pptxMore on Virtualization 3.pptx
More on Virtualization 3.pptx
 
2-Virtualization in Cloud Computing and Types.docx
2-Virtualization in Cloud Computing and Types.docx2-Virtualization in Cloud Computing and Types.docx
2-Virtualization in Cloud Computing and Types.docx
 
4-Taxonomy of virtualization.docx
4-Taxonomy of virtualization.docx4-Taxonomy of virtualization.docx
4-Taxonomy of virtualization.docx
 
Course Plan Virtualization concepts.docx
Course Plan Virtualization concepts.docxCourse Plan Virtualization concepts.docx
Course Plan Virtualization concepts.docx
 
3-Types of Virtual Machines.docx
3-Types of Virtual Machines.docx3-Types of Virtual Machines.docx
3-Types of Virtual Machines.docx
 
1-Introduction to Virtualization.docx
1-Introduction to Virtualization.docx1-Introduction to Virtualization.docx
1-Introduction to Virtualization.docx
 
5-Emulation.docx
5-Emulation.docx5-Emulation.docx
5-Emulation.docx
 
9-Pumping Lemma.pdf
9-Pumping Lemma.pdf9-Pumping Lemma.pdf
9-Pumping Lemma.pdf
 
5-DFA and equivalence with RE.pdf
5-DFA and equivalence with RE.pdf5-DFA and equivalence with RE.pdf
5-DFA and equivalence with RE.pdf
 
2-Chomsky hierarchy of languages.ppt
2-Chomsky hierarchy of languages.ppt2-Chomsky hierarchy of languages.ppt
2-Chomsky hierarchy of languages.ppt
 

Recently uploaded

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 

Recently uploaded (20)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 

6-Nfa & equivalence with RE.pdf

  • 1. Equivalence of DFA and NFA • NFA’s are usually easier to “program” in. • Surprisingly, for any NFA N there is a DFA D, such that L(D) = L(N), and vice versa. • This involves the subset construction, an im- portant example how an automaton B can be generically constructed from another automa- ton A. • Given an NFA N = (QN, Σ, δN, q0, FN) we will construct a DFA D = (QD, Σ, δD, {q0}, FD) such that L(D) = L(N) . 33
  • 2. The details of the subset construction: • QD = {S : S ⊆ QN}. Note: |QD| = 2|QN|, although most states in QD are likely to be garbage. • FD = {S ⊆ QN : S ∩ FN 6= ∅} • For every S ⊆ QN and a ∈ Σ, δD(S, a) = [ p∈S δN(p, a) 34
  • 3. Let’s construct δD from the NFA on slide 27 0 1 ∅ ∅ ∅ → {q0} {q0, q1} {q0} {q1} ∅ {q2} ?{q2} ∅ ∅ {q0, q1} {q0, q1} {q0, q2} ?{q0, q2} {q0, q1} {q0} ?{q1, q2} ∅ {q2} ?{q0, q1, q2} {q0, q1} {q0, q2} 35
  • 4. Note: The states of D correspond to subsets of states of N, but we could have denoted the states of D by, say, A − F just as well. 0 1 A A A → B E B C A D ?D A A E E F ?F E B ?G A D ?H E F 36
  • 5. We can often avoid the exponential blow-up by constructing the transition table for D only for accessible states S as follows: Basis: S = {q0} is accessible in D Induction: If state S is accessible, so are the states in S a∈Σ δD(S, a). Example: The “subset” DFA with accessible states only. Start { { q q {q 0 0 0 , , q q 1 2 } } 0 1 1 0 0 1 } 37 { }
  • 6. Theorem 2.11: Let D be the “subset” DFA of an NFA N. Then L(D) = L(N). Proof: First we show onby an induction on |w| that δ̂D({q0}, w) = δ̂N(q0, w) Basis: w = . The claim follows from def. 38
  • 7. Induction: δ̂D({q0}, xa) def = δD(δ̂D({q0}, x), a) i.h. = δD(δ̂N(q0, x), a) cst = [ p∈δ̂N(q0,x) δN(p, a) def = δ̂N(q0, xa) Now (why?) it follows that L(D) = L(N). 39
  • 8. Theorem 2.12: A language L is accepted by some DFA if and only if L is accepted by some NFA. Proof: The “if” part is Theorem 2.11. For the “only if” part we note that any DFA can be converted to an equivalent NFA by mod- ifying the δD to δN by the rule • If δD(q, a) = p, then δN(q, a) = {p}. By induction on |w| it will be shown in the tutorial that if δ̂D(q0, w) = p, then δ̂N(q0, w) = {p}. The claim of the theorem follows. 40 How do you convert an NFA to C/C++ code?
  • 9. Exponential Blow-Up There is an NFA N with n + 1 states that has no equivalent DFA with fewer than 2n states Start 0, 1 0, 1 0, 1 0, 1 q q q q0 1 2 n 1 0, 1 L(N) = {x1c2c3 · · · cn : x ∈ {0, 1}∗, ci ∈ {0, 1}} Suppose an equivalent DFA D with fewer than 2n states exists. D must remember the last n symbols it has read. There are 2n bitsequences a1a2 · · · an ∃ q, a1a2 · · · an, b1b2 · · · bn : q = ∈ δ̂ND(q0, a1a2 · · · an), q = ∈ δ̂ND(q0, b1b2 · · · bn), a1a2 · · · an 6= b1b2 · · · bn 41
  • 10. Case 1: 1a2 · · · an 0b2 · · · bn Then q has to be both an accepting and a nonaccepting state. Case 2: a1 · · · ai−11ai+1 · · · an b1 · · · bi−10bi+1 · · · bn Now δ̂N (q0, a1 · · · ai−11ai+1 · · · an0i−1) = δ̂N (q0, b1 · · · bi−10bi+1 · · · bn0i−1) and δ̂N (q0, a1 · · · ai−11ai+1 · · · an0i−1) ∈ FD δ̂N (q0, b1 · · · bi−10bi+1 · · · bn0i−1) / ∈ FD 42 D D D D
  • 11. FA’s with Epsilon-Transitions An -NFA accepting decimal numbers consist- ing of: 1. An optional + or - sign 2. A string of digits 3. a decimal point 4. another string of digits One of the strings (2) are (4) are optional q q q q q q 0 1 2 3 5 4 Start 0,1,...,9 0,1,...,9 ε ε 0,1,...,9 0,1,...,9 ,+,- . . 43 E.g. -12.5 +10.00 5. -.6
  • 12. Example: -NFA accepting the set of keywords {ebay, web} 1 2 3 4 5 6 7 8 Start Σ w e e y b a b 44 We can have an ε-moves for each keyword.
  • 13. An -NFA is a quintuple (Q, Σ, δ, q0, F ) where δ is a function from Q × (Σ ∪ {}) to the powerset of Q. Example: The -NFA from the previous slide E = ({q0, q1, . . . , q5}, {., +, −, 0, 1, . . . , 9} δ, q0, {q5}) where the transition table for δ is +,- . 0, . . . , 9 → q0 {q1} {q1} ∅ ∅ q1 ∅ ∅ {q2} {q1, q4} q2 ∅ ∅ ∅ {q3} q3 {q5} ∅ ∅ {q3} q4 ∅ ∅ {q3} ∅ ?q5 ∅ ∅ ∅ ∅ 45
  • 14. ECLOSE We close a state by adding all states reachable by a sequence · · · Inductive definition of ECLOSE(q) Basis: q ∈ ECLOSE(q) Induction: p ∈ ECLOSE(q) and r ∈ δ(p, ) ⇒ r ∈ ECLOSE(q) 46 or ε-closure
  • 15. Example of -closure 1 2 3 6 4 5 7 ε ε ε ε ε a b For instance, ECLOSE(1) = {1, 2, 3, 4, 6} 47
  • 16. • Inductive definition of δ̂ for -NFA’s Basis: δ̂(q, ) = ECLOSE(q) Induction: δ̂(q, xa) = [ p∈δ(δ̂(q,x),a) ECLOSE(p) Let’s compute on the blackboard in class δ̂(q0, 5.6) for the NFA on slide 43 48 δ(q0,ε) = ECLOSE(q0) = {q0,q1} δ(q0,5) = ECLOSE({q1,q4}) = {q1,q4}, because δ(q0,5) U δ(q1,5) = {q1,q4} δ(q0,5.) = ECLOSE({q2,q3}) = {q2,q3,q5} δ(q0,5.6) = ECLOSE({q3}) = {q3,q5} ^ ^ ^ ^ where δ(δ(q,x),a) = U δ(r,a) r ε δ(q,x) ^ ^
  • 17. Given an -NFA E = (QE, Σ, δE, q0, FE) we will construct a DFA D = (QD, Σ, δD, qD, FD) such that L(D) = L(E) Details of the construction: • QD = {S : S ⊆ QE and S = ECLOSE(S)} • qD = ECLOSE(q0) • FD = {S : S ∈ QD and S ∩ FE 6= ∅} • δD(S, a) = [ {ECLOSE(p) : p ∈ δ(t, a) for some t ∈ S} 49 E
  • 18. Example: -NFA E q q q q q q 0 1 2 3 5 4 Start 0,1,...,9 0,1,...,9 ε ε 0,1,...,9 0,1,...,9 ,+,- . . DFA D corresponding to E Start { { { { { { q q q q q q 0 1 1 , } q 1 } , q 4 } 2, q 3 , q5 } 2} 3 , q5 } 0,1,...,9 0,1,...,9 0,1,...,9 0,1,...,9 0,1,...,9 0,1,...,9 +,- . . . 50 {φ} .,+,− +,− .,+,− +,− .,+,− +,−,.,0,1,...,9
  • 19. Theorem 2.22: A language L is accepted by some -NFA E if and only if L is accepted by some DFA. Proof: We use D constructed as above and show by induction that δ̂D(q0, w) = δ̂E(qD, w) Basis: δ̂E(q0, ) = ECLOSE(q0) = qD = δ̂(qD, ) 51 D 0
  • 21. Regular expressions An FA (NFA or DFA) is a “blueprint” for con- tructing a machine recognizing a regular lan- guage. A regular expression is a “user-friendly,” declar- ative way of describing a regular language. Example: 01∗ + 10∗ Regular expressions are used in e.g. 1. UNIX grep command 2. UNIX Lex (Lexical analyzer generator) and Flex (Fast Lex) tools. 53 Text/email mining (e.g., for HomeUnion) 3. grep PATTERN FILE
  • 22. Operations on languages Union: L ∪ M = {w : w ∈ L or w ∈ M} Concatenation: L.M = {w : w = xy, x ∈ L, y ∈ M} Powers: L0 = {}, L1 = L, Lk+1 = L.Lk Kleene Closure: L∗ = ∞ [ i=0 Li Question: What are ∅0, ∅i, and ∅∗ 54 Question: What is {02,03}* ?
  • 23. Building regex’s Inductive definition of regex’s: Basis: is a regex and ∅ is a regex. L() = {}, and L(∅) = ∅. If a ∈ Σ, then a is a regex. L(a) = {a}. Induction: If E is a regex’s, then (E) is a regex. L((E)) = L(E). If E and F are regex’s, then E + F is a regex. L(E + F) = L(E) ∪ L(F). If E and F are regex’s, then E.F is a regex. L(E.F) = L(E).L(F). If E is a regex’s, then E? is a regex. L(E?) = (L(E))∗. 55
  • 24. Example: Regex for L = {w ∈ {0, 1}∗ : 0 and 1 alternate in w} (01)∗ + (10)∗ + 0(10)∗ + 1(01)∗ or, equivalently, ( + 1)(01)∗( + 0) Order of precedence for operators: 1. Star 2. Dot 3. Plus Example: 01∗ + 1 is grouped (0(1) ∗ ) + 1 56 *) Ex. Regex's for L1 = { w | w ε {0,1}*, w contains no consecutive 0's} L2 = { w | w ε {0,1}*, the number of 0's in w is even}.
  • 25. Equivalence of FA’s and regex’s We have already shown that DFA’s, NFA’s, and -NFA’s all are equivalent. ε-NFA NFA DFA RE To show FA’s equivalent to regex’s we need to establish that 1. For every DFA A we can find (construct, in this case) a regex R, s.t. L(R) = L(A). 2. For every regex R there is an -NFA A, s.t. L(A) = L(R). 57
  • 26. Theorem 3.4: For every DFA A = (Q, Σ, δ, q0, F) there is a regex R, s.t. L(R) = L(A). Proof: Let the states of A be {1, 2, . . . , n}, with 1 being the start state. • Let R (k) ij be a regex describing the set of labels of all paths in A from state i to state j going through intermediate states {1, . . . , k} only. i k j 58 Note that, i and j don't have to be in {1, ...,k}.
  • 27. R (k) ij will be defined inductively. Note that L   M j∈F R1j (n)   = L(A) Basis: k = 0, i.e. no intermediate states. • Case 1: i 6= j R (0) ij = M {a∈Σ:δ(i,a)=j} a • Case 2: i = j R (0) ii =    M {a∈Σ:δ(i,a)=i} a    + 59 i.e., arc i - j i.e., arc i - i or ε
  • 28. Induction: R (k) ij = R (k−1) ij + R (k−1) ik R (k−1) kk ∗ R (k−1) kj R kj (k-1) R kk (k-1) R ik (k-1) i k k k k Zero or more strings in In In j 60 does not go through k goes through k at least once
  • 29. Example: Let’s find R for A, where L(A) = {x0y : x ∈ {1}∗ and y ∈ {0, 1}∗} 1 0 Start 0,1 1 2 R (0) 11 + 1 R (0) 12 0 R (0) 21 ∅ R (0) 22 + 0 + 1 61
  • 30. We will need the following simplification rules: • ( + R)∗ = R∗ • R + RS∗ = RS∗ • ∅R = R∅ = ∅ (Annihilation) • ∅ + R = R + ∅ = R (Identity) 62 (ε+R)R* = R* ε+R+R* = R*
  • 31. R (0) 11 + 1 R (0) 12 0 R (0) 21 ∅ R (0) 22 + 0 + 1 R (1) ij = R (0) ij + R (0) i1 R (0) 11 ∗ R (0) 1j By direct substitution Simplified R (1) 11 + 1 + ( + 1)( + 1)∗( + 1) 1∗ R (1) 12 0 + ( + 1)( + 1)∗0 1∗0 R (1) 21 ∅ + ∅( + 1)∗( + 1) ∅ R (1) 22 + 0 + 1 + ∅( + 1)∗0 + 0 + 1 63
  • 32. Simplified R (1) 11 1∗ R (1) 12 1∗0 R (1) 21 ∅ R (1) 22 + 0 + 1 R (2) ij = R (1) ij + R (1) i2 R (1) 22 ∗ R (1) 2j By direct substitution R (2) 11 1∗ + 1∗0( + 0 + 1)∗∅ R (2) 12 1∗0 + 1∗0( + 0 + 1)∗( + 0 + 1) R (2) 21 ∅ + ( + 0 + 1)( + 0 + 1)∗∅ R (2) 22 + 0 + 1 + ( + 0 + 1)( + 0 + 1)∗( + 0 + 1) 64
  • 33. By direct substitution R (2) 11 1∗ + 1∗0( + 0 + 1)∗∅ R (2) 12 1∗0 + 1∗0( + 0 + 1)∗( + 0 + 1) R (2) 21 ∅ + ( + 0 + 1)( + 0 + 1)∗∅ R (2) 22 + 0 + 1 + ( + 0 + 1)( + 0 + 1)∗( + 0 + 1) Simplified R (2) 11 1∗ R (2) 12 1∗0(0 + 1)∗ R (2) 21 ∅ R (2) 22 (0 + 1)∗ The final regex for A is R (2) 12 = 1∗0(0 + 1)∗ 65
  • 34. Observations There are n3 expressions R (k) ij Each inductive step grows the expression 4-fold R (n) ij could have size 4n For all {i, j} ⊆ {1, . . . , n}, R (k) ij uses R (k−1) kk so we have to write n2 times the regex R (k−1) kk We need a more efficient approach: the state elimination technique 66 but most of them can be removed by annihilation!
  • 35. The state elimination technique Let’s label the edges with regex’s instead of symbols q q p p 1 1 k m s Q Q P1 Pm k 1 11 R R 1m R km R k1 S 67
  • 36. Now, let’s eliminate state s. 11 R Q1 P1 R 1m R k1 R km Q1 Pm Qk Qk P1 Pm q q p p 1 1 k m + S* + + + S* S* S* For each accepting state q eliminate from the original automaton all states exept q0 and q. 68
  • 37. For each q ∈ F we’ll be left with an Aq that looks like Start R S T U that corresponds to the regex Eq = (R+SU∗T)∗SU∗ or with Aq looking like R Start corresponding to the regex Eq = R∗ • The final expression is M q∈F Eq 69 q q
  • 38. Example: A, where L(A) = {W : w = x1b, or w = x1bc, x ∈ {0, 1}∗, {b, c} ⊆ {0, 1}} Start 0,1 1 0,1 0,1 A B C D We turn this into an automaton with regex labels 0 1 + 0 1 + 0 1 + Start A B C D 1 70 Note that the algorithm also works for NFAs and ε-NFAs.
  • 39. 0 1 + 0 1 + 0 1 + Start A B C D 1 Let’s eliminate state B 0 1 + D C 0 1 + ( ) 0 1 + Start A 1 Then we eliminate state C and obtain AD 0 1 + D 0 1 + ( ) 0 1 + ( ) Start A 1 with regex (0 + 1)∗1(0 + 1)(0 + 1) 71
  • 40. From 0 1 + D C 0 1 + ( ) 0 1 + Start A 1 we can eliminate D to obtain AC 0 1 + C 0 1 + ( ) Start A 1 with regex (0 + 1)∗1(0 + 1) • The final expression is the sum of the previ- ous two regex’s: (0 + 1)∗1(0 + 1)(0 + 1) + (0 + 1)∗1(0 + 1) 72
  • 41. From regex’s to -NFA’s Theorem 3.7: For every regex R we can con- struct and -NFA A, s.t. L(A) = L(R). Proof: By structural induction: Basis: Automata for , ∅, and a. ε a (a) (b) (c) 73 ε-NFAs with properties: * unique start and final states * no arcs into the start state * no arcs out of the final state
  • 42. Induction: Automata for R + S, RS, and R∗ (a) (b) (c) R S R S R ε ε ε ε ε ε ε ε ε 74
  • 43. Example: We convert (0 + 1)∗1(0 + 1) ε ε ε ε 0 1 ε ε ε ε 0 1 ε ε 1 Start (a) (b) (c) 0 1 ε ε ε ε ε ε ε ε ε 0 1 ε ε ε ε ε ε ε 75