0% found this document useful (0 votes)
50 views

Informal Proof of Correctness: 2014/2/3 CSC 3130 Formal Languages and Automata Theory 1

This document discusses the conversion between regular expressions (REs), non-deterministic finite automata (NFAs), and epsilon-NFAs (c-NFAs) with epsilon transitions. It provides an informal proof that NFAs and c-NFAs accept the same languages. The document also discusses constructing a deterministic finite automaton (DFA) from an NFA and a c-NFA from a RE through induction on the structure of the RE.

Uploaded by

theresa.painter
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Informal Proof of Correctness: 2014/2/3 CSC 3130 Formal Languages and Automata Theory 1

This document discusses the conversion between regular expressions (REs), non-deterministic finite automata (NFAs), and epsilon-NFAs (c-NFAs) with epsilon transitions. It provides an informal proof that NFAs and c-NFAs accept the same languages. The document also discusses constructing a deterministic finite automaton (DFA) from an NFA and a c-NFA from a RE through induction on the structure of the RE.

Uploaded by

theresa.painter
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

2014/2/3 CSC 3130 Formal Languages and Automata Theory 1

Informal Proof of Correctness


Each state in the DFA represents a set of
states in the original NFA.
After reading an input string e, the DFA is in
a state that represents the set of all states the
original NFA could be in after reading e.
If a string e is accepted by the NFA, e has a
path in the NFA leading to a final states.

2014/2/3 CSC 3130 Formal Languages and Automata Theory 2
Informal Proof of Correctness
(contd)
Then, e will also have a path in the DFA
leading to a state containing a final state of
the NFA. The opposite is also true.
Since any state in the DFA that includes a
final state of the NFA is a final state, the
DFA and the NFA will accept the same set
of strings.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 3
Note on NFA DFA
Sometimes we do not need to consider all
possible subsets of the states in the original
NFA (especially when the original NFA is
complicated). We can construct the states in
the DFA one by one whenever needed,
starting from the initial state {q
0
} where q
0

is the initial state of the original NFA.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 4
Example
Construct a DFA equivalent to this NFA:
Start
0,1
q
0
q
1
0
q
2
1
2014/2/3 CSC 3130 Formal Languages and Automata Theory 5
NFA with c-Transitions (c-NFA)
There exist c-transitions that allow state
changes without consuming any input
symbol.
Similar to NFA, an input is accepted if there
is a path leading from the start state to a
final state after the whole string is read.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 6
Examples of c-NFA
q
0
q
1
q
2
q
3
a,b
c c c
q
1
q
2
q
3
q
4
b a y
q
5
q
6
q
7
q
8
b a c
q
9
k
c
c
b,c
a-z,
q
0
Start
Start
2014/2/3 CSC 3130 Formal Languages and Automata Theory 7
DFA, NFA and c-NFA
= =
?
DFA NFA c-NFA
2014/2/3 CSC 3130 Formal Languages and Automata Theory 8
c-NFA and NFA
NFA c-NFA
Trivial
Constructive
Proof
2014/2/3 CSC 3130 Formal Languages and Automata Theory 9
c-NFA NFA
Given any c-NFA M=(Q,E,o,q
0
,F) recognizing
a language L over E, we can construct an NFA
N=(Q,E,o,q
0
,F) that also recognizes L:
o (q
i
,a) = q
j
iff there is a path from q
i
to q
j
using
exactly one edge labeled a and zero or more edges
labeled c in M.
F = F {q
0
} if a final state is reachable from q
0

using some c-transitions in M. Otherwise, F = F.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 10
Example of c-NFA NFA
q
0
q
1
q
2
c,b
a
M N
Start
q
0
q
1
q
2
a,b
a,b
a,b
Start
a,b
c
a,b
a,b
c
2014/2/3 CSC 3130 Formal Languages and Automata Theory 11
Informal Proof of Correctness
In the c-NFA, the acceptance of the string
a
1
a
2
a
n

causes it to go through a sequence of states:
q
0
q
1
q
2
q
m

where m > n. Some c-transitions may be in the sequence:
q
0
... q
i
1
... q
i
2
q
i
n


where q
i
n
=q
m
. In the NFA, each sequence of states of the
form:
q
i
k
... q
i
k+1
will be represented by a single transition q
i
k
q
i
k+1

because of the way we construct the NFA.

c c c c c c a
1
a
2

c c a
k+1

a
k+1
2014/2/3 CSC 3130 Formal Languages and Automata Theory 12
Informal Proof of Correctness
(contd)
Therefore, every path in the c-NFA M will have a
corresponding path in the constructed NFA N, and
vice versa.
If a string e is accepted by the c-NFA, e has a path
in M leading to a final state. The corresponding path
in the constructed NFA will also lead to a final state
(since F _ F). The opposite is also true.
Therefore, the original c-NFA will accept the same
set of strings as the constructed NFA.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 13
c-Closures
In an c-NFA, the ECLOSE(q) of a state q is
the set of states that can be reached from q
by following a path whose edges are all
labeled by c.
q
0
q
1
q
2
q
3
b
c c
c
a
c
b
Start
ECLOSE(q
1
) = {q
1
,

q
3
}
ECLOSE(q
2
) = {q
1
,

q
2
,

q
3
}
2014/2/3 CSC 3130 Formal Languages and Automata Theory 14
c-NFA NFA
The transition function o(q
i
,a) in the NFA
can also be constructed systematically:
Find ECLOSE(q
i
) in M.
Find the set of states S reachable from the
states in ECLOSE(q
i
) using exactly one
a-transition in M. S = o(q
k
,a).
Find Y = ECLOSE(q
k
). Put o(q
i
,a) = Y.
q
k
eS
q
k
eECLOSE(q
i
)
2014/2/3 CSC 3130 Formal Languages and Automata Theory 15
Class Discussion
c-NFA
Construct an NFA equivalent to this c-NFA:
q
0
q
1
q
2
c,b
b
a
Start
c
2014/2/3 CSC 3130 Formal Languages and Automata Theory 16
DFA, NFA and c-NFA
= = DFA NFA c-NFA
2014/2/3 CSC 3130 Formal Languages and Automata Theory 17
Regular Expression (RE)
Let E be an alphabet, a RE over E can be
defined recursively as:
| = {} is a RE
c = {c} is a RE
a e E, a = {a} is a RE
If r, s are RE over E denoting the set R, S
over E, then (r+s), (rs) and (r*) are RE over
E denoting RS, RS and R* respectively.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 18
Regular Expression (RE)
Note:
If R is a set of strings, R* denotes the set
of all strings formed by concatenating
zero or more strings from R.
We can neglect the parentheses assuming
that * has a higher precedence than
concatenation and concatenation has a
higher precedence than +
e.g., (0((1*) + 1)) = 0(1* + 1)
2014/2/3 CSC 3130 Formal Languages and Automata Theory 19
Examples of RE
01* = {0, 01, 011, 0111, ..}
(01*)(01) = {001, 0101, 01101, 011101, ..}
(0+1)* = {c, 0, 1, 00, 01, 10, 11, ..}, i.e., all
strings of 0 and 1
(0+1)*00(0+1)* = {00, 1001, ..}, i.e., all 0
and 1 strings containing a 00
2014/2/3 CSC 3130 Formal Languages and Automata Theory 20
More Examples of RE
(1+10)* = all strings starting with 1 and
containing no 00
(0+1)*011 = all strings ending with 011
0*1* = all strings with no 0 after 1
00*11* = all strings with at least one 0
and one 1, and no 0 after 1

2014/2/3 CSC 3130 Formal Languages and Automata Theory 21
Class Discussion
What languages do the following RE
represent?
(1+01+001)*(c+0+00)
((0+1)(0+1)+(0+1)(0+1)(0+1))*
((0+1)(0+1))*+((0+1)(0+1)(0+1))*
2014/2/3 CSC 3130 Formal Languages and Automata Theory 22
Class Discussion
Construct a RE over E={0,1} such that
It contains all strings that have two
consecutive 0s.
It contains all strings except those with
two consecutive 0s.
It contains all strings with an even
number of 0s.

2014/2/3 CSC 3130 Formal Languages and Automata Theory 23
DFA, NFA, c-NFA and RE
= = DFA NFA c-NFA = RE
RE can describe all the languages represented by
DFA, NFA or c-NFA.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 24
c-NFA and RE
RE
Constructive
Proof
Constructive
Proof
c-NFA
Both constructive proofs are based on induction.
DFA
2014/2/3 CSC 3130 Formal Languages and Automata Theory 25
An Example of RE c-NFA
c-NFA for 0

c-NFA for 1

c-NFA for 0+1
Start q
0
q
1
0
Start q
0
q
1
1
Start q
0
q
1
c
c c
c
q
2
q
3
0
q
4
q
5
1
2014/2/3 CSC 3130 Formal Languages and Automata Theory 26
| = {} is a RE,


c = {c } is a RE,


a e E, a = {a} is a RE,

Proof of RE c-NFA (Base Cases)
Start q
0 c-NFA for |
Start q
0 c-NFA for c
Start q
0
c-NFA for a q
1
a
2014/2/3 CSC 3130 Formal Languages and Automata Theory 27
If r and s are RE represented by c-NFA, M
r
and
M
s
, respectively, the c-NFA for r+s, rs and r* can
be constructed as:
Proof of RE c-NFA (Induction)
Start q
0
c-NFA for r+s
q
1
c
M
r

M
s

c c
c
q
0
is connected to
the start states of M
r

and M
s
, labeled by c.
All final states of M
r
and
M
s
are connected to q
1
,
labeled by c. q
1
becomes
the only final state.
2014/2/3 CSC 3130 Formal Languages and Automata Theory 28
Proof of RE c-NFA (Induction)
Start
q
0 c-NFA for rs
q
1
c
M
r

M
s

c c
q
0
is connected to
the start state of
M
r
, labeled by c.
Final states of M
r
are
connected to the

start
state of M
s
, labeled
by c.
Final states of M
s
are
connected to q
1
, labeled
by c. q
1
becomes the
only final state.
Start
q
0 c-NFA for r*
q
1
c
M
r

c
c
q
0
is connected to
the start state of
M
r
, labeled by c.
Final states of M
r
are
connected to q
1
, labeled
by c. q
1
becomes the
only final state.
c
2014/2/3 CSC 3130 Formal Languages and Automata Theory 29
Class Discussion
Construct an c-NFA for the RE 1*(0+1) over {0,1}
according to the above base cases and inductive steps.

You might also like