SlideShare a Scribd company logo
Deterministic Finite State Automata (DFA)
0

1

1

0

0

……..

Finite
Control
•
•
•
•

One-way, infinite tape, broken into cells
One-way, read-only tape head.
Finite control, I.e., a program, containing the position of the read head,
current symbol being scanned, and the current “state.”
A string is placed on the tape, read head is positioned at the left end,
and the DFA will read the string one symbol at a time until all symbols
have been read. The DFA will then either accept or reject.
1
•

The finite control can be described by a transition diagram:

•

Example #1:

1
0
q1

q0

1

0
1
q0
•
•

0
q0

0
q1

1
q0

1
q0

q0

One state is final/accepting, all others are rejecting.
The above DFA accepts those strings that contain an even number of
0’s
2
•

Example #2:
a
c

q0

c
q0

a

•

q2

b

a

q0

c

q1

b

q0

a/b/c

a

c
q1

a
q0

c
q2

b
q2

c
q0

accepted
q2
rejected

q1

Accepts those strings that contain at least two c’s

3
Inductive Proof (sketch):
Base: x a string with |x|=0. state will be q0 => rejected.
Inductive hypothesis: |x|=k, rejected -in state q0 (x must have 0 c),
OR, rejected – in state q1 (x must have 1 c),
OR, accepted – in state q2 (x already with 2 c’s)
Inductive step: String xp, for p = a, b and c
q0 and, xa or xb: q0->q0 rejected, as should be (no c)
q0 and, xc: q0 -> q1 rejected, as should be (1 c)
q1 and xa or xb: q1 -> q1 rejected, …
q1 and xc: q1-> q2 accepted, as should be ( 2 c’s now)
q2 and xa, or xb, or xc: q2 -> q2 accepted, (no change in c)

4
Formal Definition of a DFA
•

A DFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
Q
Σ
q0
F
δ

A finite set of states
A finite input alphabet
The initial/starting state, q0 is in Q
A set of final/accepting states, which is a subset of Q
A transition function, which is a total function from Q x Σ to Q
δ: (Q x Σ) –> Q
δ(q,s) = q’

δ is defined for any q in Q and s in Σ, and
is equal to some state q’ in Q, could be q’=q

Intuitively, δ(q,s) is the state entered by M after reading symbol s while in
state q.

5
•

For example #1:
1
Q = {q0, q1}

0

Σ = {0, 1}
Start state is q0

q1

q0

1

0

F = {q0}
δ:
q0

0
q1

1
q0

q1

q0

q1

6
•

For example #2:
a

Q = {q0, q1, q2}
Σ = {a, b, c}
Start state is q0

q0

F = {q2}

b

δ:
q0

b
q0

q1

q1

q2

q2

q1

c

q2

b

q2

q2

c

c
q1

q1

•

a
q0

a/b/c

a

q2

Since δ is a function, at each step M has exactly one option.

7
Extension of δ to Strings
δ^ : (Q x Σ*) –> Q
δ^(q,w) – The state entered after reading string w having started in state q.

Formally:
1) δ^(q, ε) = q, and
2) For all w in Σ* and a in Σ
δ^(q,wa) = δ (δ^(q,w), a)

8
•

Recall Example #1:

1
0
q1

q0

1

0
•
•

What is δ^(q0, 011)? Informally, it is the state entered by M after
processing 011 having started in state q 0.
Formally:
δ^(q0, 011)

= δ (δ^(q0,01), 1)
= δ (δ ( δ^(q0,0), 1), 1)
= δ (δ (δ (δ^(q0, λ), 0), 1), 1)
= δ (δ (δ(q0,0), 1), 1)
= δ (δ (q1, 1), 1)
= δ (q1, 1)
= q1

by rule #2
by rule #2
by rule #2
by rule #1
by definition of δ
by definition of δ
by definition of δ
9
•

Note that:
δ^ (q,a) = δ(δ^(q, ε), a)
= δ(q, a)

•

by definition of δ^, rule #2
by definition of δ^, rule #1

Therefore:
δ^ (q, a1a2…an) = δ(δ(…δ(δ(q, a1), a2)…), an)

•

Hence, we can use δ in place of δ^:
δ^(q, a1a2…an) = δ(q, a1a2…an)
10
•

Recall Example #2:

1
q0

1

1
0

0
q2

q1
0

•

What is δ(q0, 011)? Informally, it is the state entered by M after
processing 011 having started in state q 0.

•

Formally:
δ(q0, 011)

by rule #2

= δ (δ (δ(q0,0), 1), 1)

by rule #2

= δ (δ (q1, 1), 1)

by definition of δ

= δ (q1, 1)

by definition of δ

= q1
•

= δ (δ(q0,01), 1)

by definition of δ

Is 011 accepted? No, since δ(q0, 011) = q1 is not a final state.

11
•

Recall Example #2:

1
q0

1

1
0

0
q2

q1
0

•

What is δ(q1, 10)?
δ(q1, 10)

by rule #2

= δ (q1, 0)

by definition of δ

= q2
•

= δ (δ(q1,1), 0)

by definition of δ

Is 10 accepted? No, since δ(q0, 10) = q1 is not a final state. The fact that
δ(q1, 10) = q2 is irrelevant!

12
Definitions for DFAs
•

Let M = (Q, Σ, δ,q0,F) be a DFA and let w be in Σ*. Then w is accepted by M
iff δ(q0,w) = p for some state p in F.

•

Let M = (Q, Σ, δ,q0,F) be a DFA. Then the language accepted by M is the set:
L(M) = {w | w is in Σ* and δ(q0,w) is in F}

•

Another equivalent definition:
L(M) = {w | w is in Σ* and w is accepted by M}

•

Let L be a language. Then L is a regular language iff there exists a DFA M
such that L = L(M).

•

Let M1 = (Q1, Σ1, δ1, q0, F1) and M2 = (Q2, Σ2, δ2, p0, F2) be DFAs. Then M1 and
M2 are equivalent iff L(M1) = L(M2).

13
•

Notes:
– A DFA M = (Q, Σ, δ,q0,F) partitions the set Σ* into two sets: L(M) and
Σ* - L(M).
– If L = L(M) then L is a subset of L(M) and L(M) is a subset of L.
– Similarly, if L(M1) = L(M2) then L(M1) is a subset of L(M2) and L(M2) is a subset of
L(M1).
– Some languages are regular, others are not. For example, if
L1 = {x | x is a string of 0's and 1's containing an even
number of 1's} and
L2 = {x | x = 0n1n for some n >= 0}
then L1 is regular but L2 is not.

•

Questions:
– How do we determine whether or not a given language is regular?
– How could a program “simulate” a DFA?
14
•

Give a DFA M such that:
L(M) = {x | x is a string of 0’s and 1’s and |x| >= 2}

0/1
q0

0/1

q1

0/1

q2

Prove this by induction

15
•

Give a DFA M such that:
L(M) = {x | x is a string of (zero or more) a’s, b’s and c’s such
that x does not contain the substring aa}
b/c

a/b/c
a

q0

b/c

q1

a

q2

16
•

Give a DFA M such that:
L(M) = {x | x is a string of a’s, b’s and c’s such that x
contains the substring aba}

b/c

a

a/b/c

a
q0

c

b

q1

q2

a

q3

b/c

17
•

Give a DFA M such that:
L(M) = {x | x is a string of a’s and b’s such that x
contains both aa and bb}
a
a

q1

b
q2

a
q0

a

a

q3

b

a/b
q7

b
b

b
q4

b

q5

a
b

q6

a

18
•

Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+.
For {}:

For {ε}:

0/1

0/1
q0

q0

For Σ*:

0/1

q1

For Σ+:
0/1

0/1
q0

q0

0/1

q1

19
Nondeterministic Finite State
Automata (NFA)
•

An NFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
Q
Σ
q0
F
δ

A finite set of states
A finite input alphabet
The initial/starting state, q0 is in Q
A set of final/accepting states, which is a subset of Q
A transition function, which is a total function from Q x Σ to 2 Q
δ: (Q x Σ) –> 2Q
δ(q,s)

-2Q is the power set of Q, the set of all subsets of Q
-The set of all states p such that there is a transition
labeled s from q to p

δ(q,s) is a function from Q x S to 2Q (but not to Q)

20
•

Example #1: some 0’s followed by some 1’s
0

Q = {q0, q1, q2}
Σ = {0, 1}
Start state is q0

q0

0/1

1
0

q1

1

q2

F = {q2}
δ:
q0

0
{q0, q1}

1

{}

{}
q1

{q1, q2}

{q2}

{q2}

q2

21
•

Example #2: pair of 0’s or pair of 1’s
Q = {q0, q1, q2 , q3 , q4}
Σ = {0, 1}
Start state is q0

q0

q1
q2
q3

0
{q0, q3}

1
{q0, q1}

{}

q3

0

q4

q2

{}

{q4}

q1

1

{q2}

{q4}

0/1

{q2}

{q2}

q0

0
1

F = {q2, q4}
δ:

0/1

0/1

{q4}
22
•

Notes:
– δ(q,s) may not be defined for some q and s (why?).
– Informally, a string is said to be accepted if there exists a path to some
state in F.
– The language accepted by an NFA is the set of all accepted strings.

•

Question: How does an NFA find the correct/accepting path for a
given string?
– NFAs are a non-intuitive computing model.
– We are primarily interested in NFAs as language defining devices, i.e., do
NFAs accept languages that DFAs do not?
– Other questions are secondary, including practical questions such as
whether or not there is an algorithm for finding an accepting path through
an NFA for a given string,

23
•

Determining if a given NFA (example #2) accepts a given string (001)
can be done algorithmically:

q0

0

q0
q3

0

q0

1

q0
q1

q4

•

q3

q4

accepted

Each level will have at most n states

24
•

Another example (010):

q0

0

q0
q3

1

q0
q1

0

q0
q3
not accepted

•

All paths have been explored, and none lead to an accepting state.

25
•

Question: Why non-determinism is useful?
–Non-determinism = Backtracking
–Non-determinism hides backtracking
–Programming languages, e.g., Prolog, hides backtracking => Easy to
program at a higher level: what we want to do, rather than how to do it
–Useful in complexity study
–Is NDA more “powerful” than DFA, i.e., accepts type of languages that any
DFA cannot?

26
•

Let Σ = {a, b, c}. Give an NFA M that accepts:
L = {x | x is in Σ* and x contains ab}
a/b/c
q0

a/b/c
a

q1

b

q2

Is L a subset of L(M)?
Is L(M) a subset of L?
•
•

Is an NFA necessary? Could a DFA accept L? Try and give an
equivalent DFA as an exercise.
Designing NFAs is not trivial: easy to create bug
27
•

Let Σ = {a, b}. Give an NFA M that accepts:
L = {x | x is in Σ* and the third to the last symbol in x is b}
a/b
q0

b

q1

a/b

q2

a/b

q3

Is L a subset of L(M)?
Is L(M) a subset of L?
•

Give an equivalent DFA as an exercise.

28
Extension of δ to Strings and Sets of States
•

What we currently have:

δ : (Q x Σ) –> 2Q

•

What we want (why?):

δ : (2Q x Σ*) –> 2Q

•

We will do this in two steps, which will be slightly different from the
book, and we will make use of the following NFA.
0
q0

0

1

q1

0

1
q3
0

0

q2
0
q4

1
29
Extension of δ to Strings and Sets of States
•

Step #1:
Given δ: (Q x Σ) –> 2Q define δ#: (2Q x Σ) –> 2Q as follows:
1) δ#(R, a) =

•

δ(q, a)

q∈R

for all subsets R of Q, and symbols a in Σ

Note that:
δ#({p},a) =  δ(q, a)
= δ(p, a)
q∈ p }
{

•

by definition of δ#, rule #1 above

Hence, we can use δ for δ#
δ({q0, q2}, 0)
δ({q0, q1, q2}, 0)

These now make sense, but previously
they did not.
30
•

Example:
δ({q0, q2}, 0) = δ(q0, 0) U δ(q2, 0)
= {q1, q3} U {q3, q4}
= {q1, q3, q4}

δ({q0, q1, q2}, 1) = δ(q0, 1) U δ(q1, 1) U δ(q2, 1)
= {} U {q2, q3} U {}
= {q2, q3}

31
•

Step #2:
Given δ: (2Q x Σ) –> 2Q define δ^: (2Q x Σ*) –> 2Q as follows:
δ^(R,w) – The set of states M could be in after processing string w, having
starting from any state in R.
Formally:
2) δ^(R, ε) = R
3) δ^(R,wa) = δ (δ^(R,w), a)

•

Note that:
δ^(R, a)

•

for any subset R of Q
for any w in Σ*, a in Σ, and
subset R of Q

= δ(δ^(R, ε), a)
= δ(R, a)

by definition of δ^, rule #3 above
by definition of δ^, rule #2 above

Hence, we can use δ for δ^
δ({q0, q2}, 0110)
δ({q0, q1, q2}, 101101)

These now make sense, but previously
they did not.

32
•

Example:

1
q0

0
0

1

q1

0

1

q2

1

q3
What is δ({q0}, 10)?
Informally: The set of states the NFA could be in after processing 10,
having started in state q0, i.e., {q1, q2, q3}.
Formally:

δ({q0}, 10) = δ(δ({q0}, 1), 0)
= δ({q0}, 0)
= {q1, q2, q3}
Is 10 accepted? Yes!

33
•

Example:
What is δ({q0, q1}, 1)?
δ({q0 , q1}, 1)

= δ({q0}, 1) U δ({q1}, 1)
= {q0} U {q2, q3}
= {q0, q2, q3}

What is δ({q0, q2}, 10)?
δ({q0 , q2}, 10) = δ(δ({q0 , q2}, 1), 0)
= δ(δ({q0}, 1) U δ({q2}, 1), 0)
= δ({q0} U {q3}, 0)
= δ({q0,q3}, 0)
= δ({q0}, 0) U δ({q3}, 0)
= {q1, q2, q3} U {}

34
•

Example:
δ({q0}, 101)

= δ(δ({q0}, 10), 1)
= δ(δ(δ({q0}, 1), 0), 1)
= δ(δ({q0}, 0), 1)
= δ({q1 , q2, q3}, 1)
= δ({q1}, 1) U δ({q2}, 1) U δ({q3}, 1)
= {q2, q3} U {q3} U {}
= {q2, q3}

Is 101 accepted? Yes!

35
Definitions for NFAs
•

Let M = (Q, Σ, δ,q0,F) be an NFA and let w be in Σ*. Then w is
accepted by M iff δ({q0}, w) contains at least one state in F.

•

Let M = (Q, Σ, δ,q0,F) be an NFA. Then the language accepted by M
is the set:
L(M) = {w | w is in Σ* and δ({q0},w) contains at least one state in F}

•

Another equivalent definition:
L(M) = {w | w is in Σ* and w is accepted by M}

36
Equivalence of DFAs and NFAs
•

Do DFAs and NFAs accept the same class of languages?
– Is there a language L that is accepted by a DFA, but not by any NFA?
– Is there a language L that is accepted by an NFA, but not by any DFA?

•

Observation: Every DFA is an NFA.

•

Therefore, if L is a regular language then there exists an NFA M such
that L = L(M).

•

It follows that NFAs accept all regular languages.

•

But do NFAs accept more?
37
•

Consider the following DFA: 2 or more c’s
a

Q = {q0, q1, q2}
Σ = {a, b, c}
Start state is q0

q0

F = {q2}

b

δ:
q0

a
q0

b
q0

q1

q1

q2

q2

q1

c

q2

b

q2

q2

c

c
q1

q1

a/b/c

a

q2

38
•

An Equivalent NFA:
a

Q = {q0, q1, q2}
Σ = {a, b, c}
Start state is q0

q0

F = {q2}

b

δ:
q0

a
{q0}

b
{q0}

{q1}

{q1}

{q2}

{q2}

q1

c

q2

b

{q2}

q2

c

c
{q1}

q1

a/b/c

a

{q2}

39
•

Lemma 1: Let M be an DFA. Then there exists a NFA M’ such that
L(M) = L(M’).

•

Proof: Every DFA is an NFA. Hence, if we let M’ = M, then it
follows that L(M’) = L(M).
The above is just a formal statement of the observation from the
previous slide.

40
•

Lemma 2: Let M be an NFA. Then there exists a DFA M’ such that L(M) =
L(M’).

•

Proof: (sketch)
Let M = (Q, Σ, δ,q0,F).
Define a DFA M’ = (Q’, Σ, δ’,q’0,F’) as:
Q’ = 2Q
= {Q0, Q1,…,}

Each state in M’ corresponds to a
subset of states from M

where Qu = [qi0, qi1,…qij]
F’ = {Qu | Qu contains at least one state in F}
q’0 = [q0]
δ’(Qu, a) = Qv iff δ(Qu, a) = Qv

41
•

Example: empty string or start and end with 0
0/1
Q = {q0, q1}

0

Σ = {0, 1}
Start state is q0

q0

0

q1

F = {q1}
δ:
q0

0
{q1}
{q0, q1}

1

{}

{q1}

q1

42
•

Construct DFA M’ as follows:

1

0/1
[]

1

0

[q0]

[q1]

0
1
[q0, q1]

0
δ({q0}, 0) = {q1}
δ({q0}, 1) = {}
δ({q1}, 0) = {q0, q1} =>
δ({q1}, 1) = {q1}
δ({q0, q1}, 0) = {q0, q1}
δ({q0, q1}, 1) = {q1} =>
δ({}, 0) = {}
δ({}, 1) = {}

=>
δ’([q0], 0) = [q1]
=>
δ’([q0], 1) = [ ]
δ’([q1], 0) = [q0, q1]
=>
δ’([q1], 1) = [q1]
=>
δ’([q0, q1], 0) = [q0, q1]
δ’([q0, q1], 1) = [q1]
=>
δ’([ ], 0) = [ ]
=>
δ’([ ], 1) = [ ]

43
•

Theorem: Let L be a language. Then there exists an DFA M such
that L = L(M) iff there exists an NFA M’ such that L = L(M’).

•

Proof:
(if) Suppose there exists an NFA M’ such that L = L(M’). Then by
Lemma 2 there exists an DFA M such that L = L(M).
(only if) Suppose there exists an DFA M such that L = L(M). Then by
Lemma 1 there exists an NFA M’ such that L = L(M’).

•

Corollary: The NFAs define the regular languages.

44
•

Note: Suppose R = {}
δ(R, 0)

= δ(δ(R, ε), 0)
= δ(R, 0)
=  δ(q, 0)
= {}
q∈
R

•

Since R = {}

Exercise - Convert the following NFA to a DFA:
Q = {q0, q1, q2}
Σ = {0, 1}
Start state is q0
F = {q0}

δ:

0

q0

{q0, q1}

{}

q1

{q1}

{q2}

{q2}

{q2}

q2

1

45
NFAs with ε Moves
•

An NFA-ε is a five-tuple:
M = (Q, Σ, δ, q0, F)
Q
Σ
q0
F
δ

A finite set of states
A finite input alphabet
The initial/starting state, q0 is in Q
A set of final/accepting states, which is a subset of Q
A transition function, which is a total function from Q x Σ U {ε} to 2 Q
δ: (Q x (Σ U {ε})) –> 2Q
δ(q,s)

•

-The set of all states p such that there is a
transition labeled a from q to p, where a
is in Σ U {ε}
Sometimes referred to as an NFA-ε other times, simply as an NFA.
46
•

Example:

q3
1
0

0
ε

q0

δ:
q0

0
{q0}

1
{}

0/1
ε

1

ε
{q1}

q1

q2

0

- A string w = w1w2…wn is processed
as w = ε*w1ε*w2ε* … ε*wnε*

q1

{q1, q2} {q0, q3}

{q2}

q3

{q2}

{}

{}

q2

{q2}

{}

{}

- Example: all computations on 00:
0 ε 0
q 0 q 0 q1 q2
:
47
Informal Definitions
•

Let M = (Q, Σ, δ,q0,F) be an NFA-ε.

•

A String w in Σ* is accepted by M iff there exists a path in M from q0 to a state
in F labeled by w and zero or more ε transitions.

•

The language accepted by M is the set of all strings from Σ * that are accepted
by M.

48
ε-closure
•

Define ε-closure(q) to denote the set of all states reachable from q by zero or
more ε transitions.

•

Examples: (for the previous NFA)
ε-closure(q0) = {q0, q1, q2} ε-closure(q2) = {q2}
ε-closure(q1) = {q1, q2}
ε-closure(q3) = {q3}

•

ε-closure(q) can be extended to sets of states by defining:
ε-closure(P) =  ε-closure(q)
q∈
P

•

Examples:
ε-closure({q1, q2}) = {q1, q2}
ε-closure({q0, q3}) = {q0, q1, q2, q3}

49
Extension of δ to Strings and Sets of States
•

What we currently have:

δ : (Q x (Σ U {ε})) –> 2Q

•

What we want (why?):

δ : (2Q x Σ*) –> 2Q

•

As before, we will do this in two steps, which will be slightly different
from the book, and we will make use of the following NFA.
q3
1
0

0
ε

q0

0/1
ε

1

q1

0

q2
50
•

Step #1:
Given δ: (Q x (Σ U {ε})) –> 2Q define δ#: (2Q x (Σ U {ε})) –> 2Q as
follows:
1) δ#(R, a) =  δ(q, a) for all subsets R of Q, and symbols a in Σ U {ε}
q∈R

•

Note that:
δ#({p},a) =  δ(q, a) by definition of δ#, rule #1 above
= δ(p, a)
q∈ p }
{

•

Hence, we can use δ for δ#
δ({q0, q2}, 0)
previously
δ({q0, q1, q2}, 0)

These now make sense, but
they did not.

51
•

Examples:
What is δ({q0 , q1, q2}, 1)?
δ({q0 , q1, q2}, 1) = δ(q0, 1) U δ(q1, 1) U δ(q2, 1)
= { } U {q0, q3} U {q2}
= {q0, q2, q3}

What is δ({q0, q1}, 0)?
δ({q0 , q1}, 0) = δ(q0, 0) U δ(q1, 0)
= {q0} U {q1, q2}
= {q0, q1, q2}
52
•

Step #2:
Given δ: (2Q x (Σ U {ε})) –> 2Q define δ^: (2Q x Σ*) –> 2Q as follows:
δ^(R,w) – The set of states M could be in after processing string w,
having starting from any state in R.
Formally:
2) δ^(R, ε) = ε-closure(R)
3) δ^(R,wa) = ε-closure(δ(δ^(R,w), a))

•

- for any subset R of Q
- for any w in Σ*, a in Σ, and
subset R of Q

Can we use δ for δ^?
53
•

Consider the following example:
δ({q0}, 0) = {q0}
δ^({q0}, 0) = ε-closure(δ(δ^({q0}, ε), 0))
By rule #3
= ε-closure(δ(ε-closure({q0}), 0))
By rule #2
= ε-closure(δ({q0, q1, q2}, 0))
By ε-closure
= ε-closure(δ(q0, 0) U δ(q1, 0) U δ(q2, 0))
By rule #1
= ε-closure({q0} U {q1, q2} U {q2})
= ε-closure({q0, q1, q2})
= ε-closure({q0}) U ε-closure({q1}) U ε-closure({q2})
= {q0, q1, q2} U {q1, q2} U {q2}
= {q0, q1, q2}

•

So what is the difference?
δ(q0, 0)
δ^(q0 , 0)

- Processes 0 as a single symbol, without ε transitions.
54
- Processes 0 using as many ε transitions as are possible.
•

Example:
δ^({q0}, 01) = ε-closure(δ(δ^({q0}, 0), 1))

By rule #3

= ε-closure(δ({q0, q1, q2}), 1)

Previous slide

= ε-closure(δ(q0, 1) U δ(q1, 1) U δ(q2, 1))

By rule #1

= ε-closure({ } U {q0, q3} U {q2})
= ε-closure({q0, q2, q3})
= ε-closure({q0}) U ε-closure({q2}) U ε-closure({q3})
= {q0, q1, q2} U {q2} U {q3}
= {q0, q1, q2, q3}

55
Definitions for NFA-ε Machines
•

Let M = (Q, Σ, δ,q0,F) be an NFA-ε and let w be in Σ*. Then w is
accepted by M iff δ^({q0}, w) contains at least one state in F.

•

Let M = (Q, Σ, δ,q0,F) be an NFA-ε. Then the language accepted by
M is the set:
L(M) = {w | w is in Σ* and δ^({q0},w) contains at least one state in F}

•

Another equivalent definition:
L(M) = {w | w is in Σ* and w is accepted by M}

56
Equivalence of NFAs and NFA-εs
•

Do NFAs and NFA-ε machines accept the same class of languages?
– Is there a language L that is accepted by a NFA, but not by any NFA -ε?
– Is there a language L that is accepted by an NFA-ε, but not by any DFA?

•

Observation: Every NFA is an NFA-ε.

•

Therefore, if L is a regular language then there exists an NFA-ε M
such that L = L(M).

•

It follows that NFA-ε machines accept all regular languages.

•

But do NFA-ε machines accept more?
57
•

Lemma 1: Let M be an NFA. Then there exists a NFA-ε M’ such
that L(M) = L(M’).

•

Proof: Every NFA is an NFA-ε. Hence, if we let M’ = M, then it
follows that L(M’) = L(M).
The above is just a formal statement of the observation from the
previous slide.

58
•

Lemma 2: Let M be an NFA-ε. Then there exists a NFA M’ such
that L(M) = L(M’).

•

Proof: (sketch)
Let M = (Q, Σ, δ,q0,F) be an NFA-ε.
Define an NFA M’ = (Q, Σ, δ’,q0,F’) as:
F’ = F U {q0} if ε-closure(q0) contains at least one state from F
F’ = F otherwise
δ’(q, a) = δ^(q, a)

•

- for all q in Q and a in Σ

Notes:
– δ’: (Q x Σ) –> 2Q is a function
– M’ has the same state set, the same alphabet, and the same start state as M
59
– M’ has no ε transitions
•

Example:

q3
1
0

0
ε

q0

•

0/1
ε

1

q1

0

q2

Step #1:
– Same state set as M
– q0 is the starting state

q0

q3

q1

q2
60
•

Example:

q3
1
0

0
ε

q0

•

0/1
ε

1

q1

0

q2

Step #2:
– q0 becomes a final state

q0

q3

q1

q2

61
•

Example:

q3
1
0

0
ε

q0

•

0/1
ε

1

q1

0

q2

Step #3:
q3
0
q0

0

q1

q2

0
62
•

Example:

q3
1
0

0
ε

q0

•

0/1
ε

q1

1

0

q2

Step #4:
q3
1

0/1
0/1

q0

q1

q2

0/1
63
•

Example:

q3
1
0

0

0/1

ε

q0

•

ε

q1

1

q2

0

Step #5:
q3
1

0/1

0
0/1

q0

q1

0

q2

0/1
64
•

Example:

q3
1
0

0

0/1

ε

q0

•

ε

q1

1

q2

0

Step #6:
q3
1

0/1

1

0/1
0/1
1

q0

q1

0/1

q2

0/1
65
•

Example:

q3
1
0

0

0/1

ε

q0

•

ε

q1

1

q2

0

Step #7:
q3
1

0/1

1

0/1
0/1
1

q0

q1

0/1

0
q2

0/1
66
•

Example:

q3
1
0

0

0/1

ε

q0

•

ε

q1

1

q2

0

Step #8:
– Done!

q3
1

0/1

1

0/1
0/1
1

q0

q1

0/1

0/1
q2

0/1
67
•

Theorem: Let L be a language. Then there exists an NFA M such
that L= L(M) iff there exists an NFA-ε M’ such that L = L(M’).

•

Proof:
(if) Suppose there exists an NFA-ε M’ such that L = L(M’). Then by
Lemma 2 there exists an NFA M such that L = L(M).
(only if) Suppose there exists an NFA M such that L = L(M). Then by
Lemma 1 there exists an NFA-ε M’ such that L = L(M’).

•

Corollary: The NFA-ε machines define the regular languages.

68

More Related Content

What's hot

Top 10 Tips for Getting a Good Night's Sleep
Top 10 Tips for Getting a Good Night's SleepTop 10 Tips for Getting a Good Night's Sleep
Top 10 Tips for Getting a Good Night's Sleep
Dana-Farber Cancer Institute
 
Habits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit Summit
Habits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit SummitHabits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit Summit
Habits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit Summit
Habit Summit
 
Back of the Napkin / Blah-Blah-Blah Seminar
Back of the Napkin / Blah-Blah-Blah SeminarBack of the Napkin / Blah-Blah-Blah Seminar
Back of the Napkin / Blah-Blah-Blah Seminar
Dan Roam
 
Clickbait: A Guide To Writing Un-Ignorable Headlines
Clickbait: A Guide To Writing Un-Ignorable HeadlinesClickbait: A Guide To Writing Un-Ignorable Headlines
Clickbait: A Guide To Writing Un-Ignorable Headlines
Venngage
 
Workshop on time and workload management
Workshop on time and workload managementWorkshop on time and workload management
Workshop on time and workload management
Sahil Jain
 
10 Productivity Hacks Backed By Science
10 Productivity Hacks Backed By Science10 Productivity Hacks Backed By Science
10 Productivity Hacks Backed By Science
When I Work
 
Kill procrastination
Kill procrastinationKill procrastination
Kill procrastination
Brady Gilchrist
 
How to Manage Change Effectively
How to Manage Change EffectivelyHow to Manage Change Effectively
How to Manage Change Effectively
INSEAD
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
10 Things your Audience Hates About your Presentation
10 Things your Audience Hates About your Presentation10 Things your Audience Hates About your Presentation
10 Things your Audience Hates About your Presentation
Stinson
 
The battle for attention
The battle for attentionThe battle for attention
The battle for attention
Newsworks
 
The State of Sales & Marketing at the 50 Fastest-Growing B2B Companies
The State of Sales & Marketing at the 50 Fastest-Growing B2B CompaniesThe State of Sales & Marketing at the 50 Fastest-Growing B2B Companies
The State of Sales & Marketing at the 50 Fastest-Growing B2B Companies
Mattermark
 
Our Business Team Composition In Circular Format
Our Business Team Composition In Circular FormatOur Business Team Composition In Circular Format
Our Business Team Composition In Circular Format
SlideTeam
 
IQ Work Hacks - Productivity
IQ Work Hacks - ProductivityIQ Work Hacks - Productivity
IQ Work Hacks - Productivity
InterQuest Group
 
What You Should Learn from Larry Page
What You Should Learn from Larry PageWhat You Should Learn from Larry Page
What You Should Learn from Larry Page
JamesAltucher
 
Ram naresh roy a modern approach to operations management 2007
Ram naresh roy a modern approach to operations management  2007Ram naresh roy a modern approach to operations management  2007
Ram naresh roy a modern approach to operations management 2007
Alok C
 
Why You Need Someone Like me on Your Project
Why You Need Someone Like me on Your ProjectWhy You Need Someone Like me on Your Project
Why You Need Someone Like me on Your Project
Étienne Garbugli
 
Learning How to Learn
Learning How to LearnLearning How to Learn
Learning How to Learn
Nitten Bbinhhani
 
10 Steps To Be More Productive
10 Steps To Be More Productive10 Steps To Be More Productive
10 Steps To Be More Productive
MaidPro Central CT
 
Why Are You Attracted to That Person?
Why Are You Attracted to That Person? Why Are You Attracted to That Person?
Why Are You Attracted to That Person?
SlideShop.com
 

What's hot (20)

Top 10 Tips for Getting a Good Night's Sleep
Top 10 Tips for Getting a Good Night's SleepTop 10 Tips for Getting a Good Night's Sleep
Top 10 Tips for Getting a Good Night's Sleep
 
Habits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit Summit
Habits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit SummitHabits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit Summit
Habits at Work - Merci Victoria Grace, Growth, Slack - 2016 Habit Summit
 
Back of the Napkin / Blah-Blah-Blah Seminar
Back of the Napkin / Blah-Blah-Blah SeminarBack of the Napkin / Blah-Blah-Blah Seminar
Back of the Napkin / Blah-Blah-Blah Seminar
 
Clickbait: A Guide To Writing Un-Ignorable Headlines
Clickbait: A Guide To Writing Un-Ignorable HeadlinesClickbait: A Guide To Writing Un-Ignorable Headlines
Clickbait: A Guide To Writing Un-Ignorable Headlines
 
Workshop on time and workload management
Workshop on time and workload managementWorkshop on time and workload management
Workshop on time and workload management
 
10 Productivity Hacks Backed By Science
10 Productivity Hacks Backed By Science10 Productivity Hacks Backed By Science
10 Productivity Hacks Backed By Science
 
Kill procrastination
Kill procrastinationKill procrastination
Kill procrastination
 
How to Manage Change Effectively
How to Manage Change EffectivelyHow to Manage Change Effectively
How to Manage Change Effectively
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
10 Things your Audience Hates About your Presentation
10 Things your Audience Hates About your Presentation10 Things your Audience Hates About your Presentation
10 Things your Audience Hates About your Presentation
 
The battle for attention
The battle for attentionThe battle for attention
The battle for attention
 
The State of Sales & Marketing at the 50 Fastest-Growing B2B Companies
The State of Sales & Marketing at the 50 Fastest-Growing B2B CompaniesThe State of Sales & Marketing at the 50 Fastest-Growing B2B Companies
The State of Sales & Marketing at the 50 Fastest-Growing B2B Companies
 
Our Business Team Composition In Circular Format
Our Business Team Composition In Circular FormatOur Business Team Composition In Circular Format
Our Business Team Composition In Circular Format
 
IQ Work Hacks - Productivity
IQ Work Hacks - ProductivityIQ Work Hacks - Productivity
IQ Work Hacks - Productivity
 
What You Should Learn from Larry Page
What You Should Learn from Larry PageWhat You Should Learn from Larry Page
What You Should Learn from Larry Page
 
Ram naresh roy a modern approach to operations management 2007
Ram naresh roy a modern approach to operations management  2007Ram naresh roy a modern approach to operations management  2007
Ram naresh roy a modern approach to operations management 2007
 
Why You Need Someone Like me on Your Project
Why You Need Someone Like me on Your ProjectWhy You Need Someone Like me on Your Project
Why You Need Someone Like me on Your Project
 
Learning How to Learn
Learning How to LearnLearning How to Learn
Learning How to Learn
 
10 Steps To Be More Productive
10 Steps To Be More Productive10 Steps To Be More Productive
10 Steps To Be More Productive
 
Why Are You Attracted to That Person?
Why Are You Attracted to That Person? Why Are You Attracted to That Person?
Why Are You Attracted to That Person?
 

Viewers also liked

Herpetic esophagitis
Herpetic esophagitisHerpetic esophagitis
Herpetic esophagitis
Prof. Ahmed Mohamed Badheeb
 
Music Video Evaluation
Music Video EvaluationMusic Video Evaluation
Music Video Evaluation
AnnaSubbotina
 
Legacy of sound sydney
Legacy of sound sydneyLegacy of sound sydney
Legacy of sound sydney
jeemjohns
 
F2 rangel irayda mipresentacion
F2 rangel irayda mipresentacionF2 rangel irayda mipresentacion
F2 rangel irayda mipresentacion
irayda2
 
[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014
[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014
[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014
Symposiums Controversias en Psiquiatría
 
Las habilidades son las que te hacen rico, no la teoría.
Las habilidades son  las que te hacen rico, no la teoría.Las habilidades son  las que te hacen rico, no la teoría.
Las habilidades son las que te hacen rico, no la teoría.
Federico Bongiorno
 
Giới thiệu dự án
Giới thiệu dự ánGiới thiệu dự án
Giới thiệu dự ánnhomhopestar
 
DESTINOS VISITADOS
DESTINOS VISITADOSDESTINOS VISITADOS
DESTINOS VISITADOS
Federico Bongiorno
 
Waste Segregation at Source
Waste Segregation at SourceWaste Segregation at Source
Waste Segregation at Source
srinagesh mondreti
 
يناير 2013سلامتك 23
يناير 2013سلامتك 23يناير 2013سلامتك 23
يناير 2013سلامتك 23
Prof. Ahmed Mohamed Badheeb
 
история
историяистория
историяyankaaa
 

Viewers also liked (12)

Herpetic esophagitis
Herpetic esophagitisHerpetic esophagitis
Herpetic esophagitis
 
Music Video Evaluation
Music Video EvaluationMusic Video Evaluation
Music Video Evaluation
 
انتحار الاطفال
انتحار الاطفالانتحار الاطفال
انتحار الاطفال
 
Legacy of sound sydney
Legacy of sound sydneyLegacy of sound sydney
Legacy of sound sydney
 
F2 rangel irayda mipresentacion
F2 rangel irayda mipresentacionF2 rangel irayda mipresentacion
F2 rangel irayda mipresentacion
 
[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014
[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014
[ENG] 3rd International Symposium on Controversies in Psychiatry. Mexico 2014
 
Las habilidades son las que te hacen rico, no la teoría.
Las habilidades son  las que te hacen rico, no la teoría.Las habilidades son  las que te hacen rico, no la teoría.
Las habilidades son las que te hacen rico, no la teoría.
 
Giới thiệu dự án
Giới thiệu dự ánGiới thiệu dự án
Giới thiệu dự án
 
DESTINOS VISITADOS
DESTINOS VISITADOSDESTINOS VISITADOS
DESTINOS VISITADOS
 
Waste Segregation at Source
Waste Segregation at SourceWaste Segregation at Source
Waste Segregation at Source
 
يناير 2013سلامتك 23
يناير 2013سلامتك 23يناير 2013سلامتك 23
يناير 2013سلامتك 23
 
история
историяистория
история
 

Similar to Finite automata examples

FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
RohitPaul71
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
ssuser47f7f2
 
Finite automata
Finite automataFinite automata
Finite automata
Rajesh Yaramadi
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
Akila Krishnamoorthy
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
parmeet834
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Resumen material MIT
Resumen material MITResumen material MIT
Resumen material MIT
Rawel Luciano
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
Rushabh2428
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
Rajendran
 
Theory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsTheory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite Acceptors
Rushabh2428
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
parmeet834
 
Automata
AutomataAutomata
TuringMachines.ppt
TuringMachines.pptTuringMachines.ppt
TuringMachines.ppt
SrinivasaRaoBendi2
 
Nfa egs
Nfa egsNfa egs
Nfa egs
ankitamakin
 
Graph representation of DFA’s Da
Graph representation of DFA’s DaGraph representation of DFA’s Da
Graph representation of DFA’s Da
parmeet834
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Rushabh2428
 
Dfa
DfaDfa
F_Autómatas_MIT_2010--------------------
F_Autómatas_MIT_2010--------------------F_Autómatas_MIT_2010--------------------
F_Autómatas_MIT_2010--------------------
MIGUELANGEL2672
 
Push down automata
Push down automataPush down automata
Push down automata
Ratnakar Mikkili
 
6-Nfa & equivalence with RE.pdf
6-Nfa & equivalence with RE.pdf6-Nfa & equivalence with RE.pdf
6-Nfa & equivalence with RE.pdf
shruti533256
 

Similar to Finite automata examples (20)

FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
Finite automata
Finite automataFinite automata
Finite automata
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Resumen material MIT
Resumen material MITResumen material MIT
Resumen material MIT
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Theory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsTheory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite Acceptors
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
 
Automata
AutomataAutomata
Automata
 
TuringMachines.ppt
TuringMachines.pptTuringMachines.ppt
TuringMachines.ppt
 
Nfa egs
Nfa egsNfa egs
Nfa egs
 
Graph representation of DFA’s Da
Graph representation of DFA’s DaGraph representation of DFA’s Da
Graph representation of DFA’s Da
 
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping LemmaTheory of Computation Regular Expressions, Minimisation & Pumping Lemma
Theory of Computation Regular Expressions, Minimisation & Pumping Lemma
 
Dfa
DfaDfa
Dfa
 
F_Autómatas_MIT_2010--------------------
F_Autómatas_MIT_2010--------------------F_Autómatas_MIT_2010--------------------
F_Autómatas_MIT_2010--------------------
 
Push down automata
Push down automataPush down automata
Push down automata
 
6-Nfa & equivalence with RE.pdf
6-Nfa & equivalence with RE.pdf6-Nfa & equivalence with RE.pdf
6-Nfa & equivalence with RE.pdf
 

Recently uploaded

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 

Recently uploaded (20)

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 

Finite automata examples

  • 1. Deterministic Finite State Automata (DFA) 0 1 1 0 0 …….. Finite Control • • • • One-way, infinite tape, broken into cells One-way, read-only tape head. Finite control, I.e., a program, containing the position of the read head, current symbol being scanned, and the current “state.” A string is placed on the tape, read head is positioned at the left end, and the DFA will read the string one symbol at a time until all symbols have been read. The DFA will then either accept or reject. 1
  • 2. • The finite control can be described by a transition diagram: • Example #1: 1 0 q1 q0 1 0 1 q0 • • 0 q0 0 q1 1 q0 1 q0 q0 One state is final/accepting, all others are rejecting. The above DFA accepts those strings that contain an even number of 0’s 2
  • 4. Inductive Proof (sketch): Base: x a string with |x|=0. state will be q0 => rejected. Inductive hypothesis: |x|=k, rejected -in state q0 (x must have 0 c), OR, rejected – in state q1 (x must have 1 c), OR, accepted – in state q2 (x already with 2 c’s) Inductive step: String xp, for p = a, b and c q0 and, xa or xb: q0->q0 rejected, as should be (no c) q0 and, xc: q0 -> q1 rejected, as should be (1 c) q1 and xa or xb: q1 -> q1 rejected, … q1 and xc: q1-> q2 accepted, as should be ( 2 c’s now) q2 and xa, or xb, or xc: q2 -> q2 accepted, (no change in c) 4
  • 5. Formal Definition of a DFA • A DFA is a five-tuple: M = (Q, Σ, δ, q0, F) Q Σ q0 F δ A finite set of states A finite input alphabet The initial/starting state, q0 is in Q A set of final/accepting states, which is a subset of Q A transition function, which is a total function from Q x Σ to Q δ: (Q x Σ) –> Q δ(q,s) = q’ δ is defined for any q in Q and s in Σ, and is equal to some state q’ in Q, could be q’=q Intuitively, δ(q,s) is the state entered by M after reading symbol s while in state q. 5
  • 6. • For example #1: 1 Q = {q0, q1} 0 Σ = {0, 1} Start state is q0 q1 q0 1 0 F = {q0} δ: q0 0 q1 1 q0 q1 q0 q1 6
  • 7. • For example #2: a Q = {q0, q1, q2} Σ = {a, b, c} Start state is q0 q0 F = {q2} b δ: q0 b q0 q1 q1 q2 q2 q1 c q2 b q2 q2 c c q1 q1 • a q0 a/b/c a q2 Since δ is a function, at each step M has exactly one option. 7
  • 8. Extension of δ to Strings δ^ : (Q x Σ*) –> Q δ^(q,w) – The state entered after reading string w having started in state q. Formally: 1) δ^(q, ε) = q, and 2) For all w in Σ* and a in Σ δ^(q,wa) = δ (δ^(q,w), a) 8
  • 9. • Recall Example #1: 1 0 q1 q0 1 0 • • What is δ^(q0, 011)? Informally, it is the state entered by M after processing 011 having started in state q 0. Formally: δ^(q0, 011) = δ (δ^(q0,01), 1) = δ (δ ( δ^(q0,0), 1), 1) = δ (δ (δ (δ^(q0, λ), 0), 1), 1) = δ (δ (δ(q0,0), 1), 1) = δ (δ (q1, 1), 1) = δ (q1, 1) = q1 by rule #2 by rule #2 by rule #2 by rule #1 by definition of δ by definition of δ by definition of δ 9
  • 10. • Note that: δ^ (q,a) = δ(δ^(q, ε), a) = δ(q, a) • by definition of δ^, rule #2 by definition of δ^, rule #1 Therefore: δ^ (q, a1a2…an) = δ(δ(…δ(δ(q, a1), a2)…), an) • Hence, we can use δ in place of δ^: δ^(q, a1a2…an) = δ(q, a1a2…an) 10
  • 11. • Recall Example #2: 1 q0 1 1 0 0 q2 q1 0 • What is δ(q0, 011)? Informally, it is the state entered by M after processing 011 having started in state q 0. • Formally: δ(q0, 011) by rule #2 = δ (δ (δ(q0,0), 1), 1) by rule #2 = δ (δ (q1, 1), 1) by definition of δ = δ (q1, 1) by definition of δ = q1 • = δ (δ(q0,01), 1) by definition of δ Is 011 accepted? No, since δ(q0, 011) = q1 is not a final state. 11
  • 12. • Recall Example #2: 1 q0 1 1 0 0 q2 q1 0 • What is δ(q1, 10)? δ(q1, 10) by rule #2 = δ (q1, 0) by definition of δ = q2 • = δ (δ(q1,1), 0) by definition of δ Is 10 accepted? No, since δ(q0, 10) = q1 is not a final state. The fact that δ(q1, 10) = q2 is irrelevant! 12
  • 13. Definitions for DFAs • Let M = (Q, Σ, δ,q0,F) be a DFA and let w be in Σ*. Then w is accepted by M iff δ(q0,w) = p for some state p in F. • Let M = (Q, Σ, δ,q0,F) be a DFA. Then the language accepted by M is the set: L(M) = {w | w is in Σ* and δ(q0,w) is in F} • Another equivalent definition: L(M) = {w | w is in Σ* and w is accepted by M} • Let L be a language. Then L is a regular language iff there exists a DFA M such that L = L(M). • Let M1 = (Q1, Σ1, δ1, q0, F1) and M2 = (Q2, Σ2, δ2, p0, F2) be DFAs. Then M1 and M2 are equivalent iff L(M1) = L(M2). 13
  • 14. • Notes: – A DFA M = (Q, Σ, δ,q0,F) partitions the set Σ* into two sets: L(M) and Σ* - L(M). – If L = L(M) then L is a subset of L(M) and L(M) is a subset of L. – Similarly, if L(M1) = L(M2) then L(M1) is a subset of L(M2) and L(M2) is a subset of L(M1). – Some languages are regular, others are not. For example, if L1 = {x | x is a string of 0's and 1's containing an even number of 1's} and L2 = {x | x = 0n1n for some n >= 0} then L1 is regular but L2 is not. • Questions: – How do we determine whether or not a given language is regular? – How could a program “simulate” a DFA? 14
  • 15. • Give a DFA M such that: L(M) = {x | x is a string of 0’s and 1’s and |x| >= 2} 0/1 q0 0/1 q1 0/1 q2 Prove this by induction 15
  • 16. • Give a DFA M such that: L(M) = {x | x is a string of (zero or more) a’s, b’s and c’s such that x does not contain the substring aa} b/c a/b/c a q0 b/c q1 a q2 16
  • 17. • Give a DFA M such that: L(M) = {x | x is a string of a’s, b’s and c’s such that x contains the substring aba} b/c a a/b/c a q0 c b q1 q2 a q3 b/c 17
  • 18. • Give a DFA M such that: L(M) = {x | x is a string of a’s and b’s such that x contains both aa and bb} a a q1 b q2 a q0 a a q3 b a/b q7 b b b q4 b q5 a b q6 a 18
  • 19. • Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+. For {}: For {ε}: 0/1 0/1 q0 q0 For Σ*: 0/1 q1 For Σ+: 0/1 0/1 q0 q0 0/1 q1 19
  • 20. Nondeterministic Finite State Automata (NFA) • An NFA is a five-tuple: M = (Q, Σ, δ, q0, F) Q Σ q0 F δ A finite set of states A finite input alphabet The initial/starting state, q0 is in Q A set of final/accepting states, which is a subset of Q A transition function, which is a total function from Q x Σ to 2 Q δ: (Q x Σ) –> 2Q δ(q,s) -2Q is the power set of Q, the set of all subsets of Q -The set of all states p such that there is a transition labeled s from q to p δ(q,s) is a function from Q x S to 2Q (but not to Q) 20
  • 21. • Example #1: some 0’s followed by some 1’s 0 Q = {q0, q1, q2} Σ = {0, 1} Start state is q0 q0 0/1 1 0 q1 1 q2 F = {q2} δ: q0 0 {q0, q1} 1 {} {} q1 {q1, q2} {q2} {q2} q2 21
  • 22. • Example #2: pair of 0’s or pair of 1’s Q = {q0, q1, q2 , q3 , q4} Σ = {0, 1} Start state is q0 q0 q1 q2 q3 0 {q0, q3} 1 {q0, q1} {} q3 0 q4 q2 {} {q4} q1 1 {q2} {q4} 0/1 {q2} {q2} q0 0 1 F = {q2, q4} δ: 0/1 0/1 {q4} 22
  • 23. • Notes: – δ(q,s) may not be defined for some q and s (why?). – Informally, a string is said to be accepted if there exists a path to some state in F. – The language accepted by an NFA is the set of all accepted strings. • Question: How does an NFA find the correct/accepting path for a given string? – NFAs are a non-intuitive computing model. – We are primarily interested in NFAs as language defining devices, i.e., do NFAs accept languages that DFAs do not? – Other questions are secondary, including practical questions such as whether or not there is an algorithm for finding an accepting path through an NFA for a given string, 23
  • 24. • Determining if a given NFA (example #2) accepts a given string (001) can be done algorithmically: q0 0 q0 q3 0 q0 1 q0 q1 q4 • q3 q4 accepted Each level will have at most n states 24
  • 25. • Another example (010): q0 0 q0 q3 1 q0 q1 0 q0 q3 not accepted • All paths have been explored, and none lead to an accepting state. 25
  • 26. • Question: Why non-determinism is useful? –Non-determinism = Backtracking –Non-determinism hides backtracking –Programming languages, e.g., Prolog, hides backtracking => Easy to program at a higher level: what we want to do, rather than how to do it –Useful in complexity study –Is NDA more “powerful” than DFA, i.e., accepts type of languages that any DFA cannot? 26
  • 27. • Let Σ = {a, b, c}. Give an NFA M that accepts: L = {x | x is in Σ* and x contains ab} a/b/c q0 a/b/c a q1 b q2 Is L a subset of L(M)? Is L(M) a subset of L? • • Is an NFA necessary? Could a DFA accept L? Try and give an equivalent DFA as an exercise. Designing NFAs is not trivial: easy to create bug 27
  • 28. • Let Σ = {a, b}. Give an NFA M that accepts: L = {x | x is in Σ* and the third to the last symbol in x is b} a/b q0 b q1 a/b q2 a/b q3 Is L a subset of L(M)? Is L(M) a subset of L? • Give an equivalent DFA as an exercise. 28
  • 29. Extension of δ to Strings and Sets of States • What we currently have: δ : (Q x Σ) –> 2Q • What we want (why?): δ : (2Q x Σ*) –> 2Q • We will do this in two steps, which will be slightly different from the book, and we will make use of the following NFA. 0 q0 0 1 q1 0 1 q3 0 0 q2 0 q4 1 29
  • 30. Extension of δ to Strings and Sets of States • Step #1: Given δ: (Q x Σ) –> 2Q define δ#: (2Q x Σ) –> 2Q as follows: 1) δ#(R, a) = • δ(q, a) q∈R for all subsets R of Q, and symbols a in Σ Note that: δ#({p},a) =  δ(q, a) = δ(p, a) q∈ p } { • by definition of δ#, rule #1 above Hence, we can use δ for δ# δ({q0, q2}, 0) δ({q0, q1, q2}, 0) These now make sense, but previously they did not. 30
  • 31. • Example: δ({q0, q2}, 0) = δ(q0, 0) U δ(q2, 0) = {q1, q3} U {q3, q4} = {q1, q3, q4} δ({q0, q1, q2}, 1) = δ(q0, 1) U δ(q1, 1) U δ(q2, 1) = {} U {q2, q3} U {} = {q2, q3} 31
  • 32. • Step #2: Given δ: (2Q x Σ) –> 2Q define δ^: (2Q x Σ*) –> 2Q as follows: δ^(R,w) – The set of states M could be in after processing string w, having starting from any state in R. Formally: 2) δ^(R, ε) = R 3) δ^(R,wa) = δ (δ^(R,w), a) • Note that: δ^(R, a) • for any subset R of Q for any w in Σ*, a in Σ, and subset R of Q = δ(δ^(R, ε), a) = δ(R, a) by definition of δ^, rule #3 above by definition of δ^, rule #2 above Hence, we can use δ for δ^ δ({q0, q2}, 0110) δ({q0, q1, q2}, 101101) These now make sense, but previously they did not. 32
  • 33. • Example: 1 q0 0 0 1 q1 0 1 q2 1 q3 What is δ({q0}, 10)? Informally: The set of states the NFA could be in after processing 10, having started in state q0, i.e., {q1, q2, q3}. Formally: δ({q0}, 10) = δ(δ({q0}, 1), 0) = δ({q0}, 0) = {q1, q2, q3} Is 10 accepted? Yes! 33
  • 34. • Example: What is δ({q0, q1}, 1)? δ({q0 , q1}, 1) = δ({q0}, 1) U δ({q1}, 1) = {q0} U {q2, q3} = {q0, q2, q3} What is δ({q0, q2}, 10)? δ({q0 , q2}, 10) = δ(δ({q0 , q2}, 1), 0) = δ(δ({q0}, 1) U δ({q2}, 1), 0) = δ({q0} U {q3}, 0) = δ({q0,q3}, 0) = δ({q0}, 0) U δ({q3}, 0) = {q1, q2, q3} U {} 34
  • 35. • Example: δ({q0}, 101) = δ(δ({q0}, 10), 1) = δ(δ(δ({q0}, 1), 0), 1) = δ(δ({q0}, 0), 1) = δ({q1 , q2, q3}, 1) = δ({q1}, 1) U δ({q2}, 1) U δ({q3}, 1) = {q2, q3} U {q3} U {} = {q2, q3} Is 101 accepted? Yes! 35
  • 36. Definitions for NFAs • Let M = (Q, Σ, δ,q0,F) be an NFA and let w be in Σ*. Then w is accepted by M iff δ({q0}, w) contains at least one state in F. • Let M = (Q, Σ, δ,q0,F) be an NFA. Then the language accepted by M is the set: L(M) = {w | w is in Σ* and δ({q0},w) contains at least one state in F} • Another equivalent definition: L(M) = {w | w is in Σ* and w is accepted by M} 36
  • 37. Equivalence of DFAs and NFAs • Do DFAs and NFAs accept the same class of languages? – Is there a language L that is accepted by a DFA, but not by any NFA? – Is there a language L that is accepted by an NFA, but not by any DFA? • Observation: Every DFA is an NFA. • Therefore, if L is a regular language then there exists an NFA M such that L = L(M). • It follows that NFAs accept all regular languages. • But do NFAs accept more? 37
  • 38. • Consider the following DFA: 2 or more c’s a Q = {q0, q1, q2} Σ = {a, b, c} Start state is q0 q0 F = {q2} b δ: q0 a q0 b q0 q1 q1 q2 q2 q1 c q2 b q2 q2 c c q1 q1 a/b/c a q2 38
  • 39. • An Equivalent NFA: a Q = {q0, q1, q2} Σ = {a, b, c} Start state is q0 q0 F = {q2} b δ: q0 a {q0} b {q0} {q1} {q1} {q2} {q2} q1 c q2 b {q2} q2 c c {q1} q1 a/b/c a {q2} 39
  • 40. • Lemma 1: Let M be an DFA. Then there exists a NFA M’ such that L(M) = L(M’). • Proof: Every DFA is an NFA. Hence, if we let M’ = M, then it follows that L(M’) = L(M). The above is just a formal statement of the observation from the previous slide. 40
  • 41. • Lemma 2: Let M be an NFA. Then there exists a DFA M’ such that L(M) = L(M’). • Proof: (sketch) Let M = (Q, Σ, δ,q0,F). Define a DFA M’ = (Q’, Σ, δ’,q’0,F’) as: Q’ = 2Q = {Q0, Q1,…,} Each state in M’ corresponds to a subset of states from M where Qu = [qi0, qi1,…qij] F’ = {Qu | Qu contains at least one state in F} q’0 = [q0] δ’(Qu, a) = Qv iff δ(Qu, a) = Qv 41
  • 42. • Example: empty string or start and end with 0 0/1 Q = {q0, q1} 0 Σ = {0, 1} Start state is q0 q0 0 q1 F = {q1} δ: q0 0 {q1} {q0, q1} 1 {} {q1} q1 42
  • 43. • Construct DFA M’ as follows: 1 0/1 [] 1 0 [q0] [q1] 0 1 [q0, q1] 0 δ({q0}, 0) = {q1} δ({q0}, 1) = {} δ({q1}, 0) = {q0, q1} => δ({q1}, 1) = {q1} δ({q0, q1}, 0) = {q0, q1} δ({q0, q1}, 1) = {q1} => δ({}, 0) = {} δ({}, 1) = {} => δ’([q0], 0) = [q1] => δ’([q0], 1) = [ ] δ’([q1], 0) = [q0, q1] => δ’([q1], 1) = [q1] => δ’([q0, q1], 0) = [q0, q1] δ’([q0, q1], 1) = [q1] => δ’([ ], 0) = [ ] => δ’([ ], 1) = [ ] 43
  • 44. • Theorem: Let L be a language. Then there exists an DFA M such that L = L(M) iff there exists an NFA M’ such that L = L(M’). • Proof: (if) Suppose there exists an NFA M’ such that L = L(M’). Then by Lemma 2 there exists an DFA M such that L = L(M). (only if) Suppose there exists an DFA M such that L = L(M). Then by Lemma 1 there exists an NFA M’ such that L = L(M’). • Corollary: The NFAs define the regular languages. 44
  • 45. • Note: Suppose R = {} δ(R, 0) = δ(δ(R, ε), 0) = δ(R, 0) =  δ(q, 0) = {} q∈ R • Since R = {} Exercise - Convert the following NFA to a DFA: Q = {q0, q1, q2} Σ = {0, 1} Start state is q0 F = {q0} δ: 0 q0 {q0, q1} {} q1 {q1} {q2} {q2} {q2} q2 1 45
  • 46. NFAs with ε Moves • An NFA-ε is a five-tuple: M = (Q, Σ, δ, q0, F) Q Σ q0 F δ A finite set of states A finite input alphabet The initial/starting state, q0 is in Q A set of final/accepting states, which is a subset of Q A transition function, which is a total function from Q x Σ U {ε} to 2 Q δ: (Q x (Σ U {ε})) –> 2Q δ(q,s) • -The set of all states p such that there is a transition labeled a from q to p, where a is in Σ U {ε} Sometimes referred to as an NFA-ε other times, simply as an NFA. 46
  • 47. • Example: q3 1 0 0 ε q0 δ: q0 0 {q0} 1 {} 0/1 ε 1 ε {q1} q1 q2 0 - A string w = w1w2…wn is processed as w = ε*w1ε*w2ε* … ε*wnε* q1 {q1, q2} {q0, q3} {q2} q3 {q2} {} {} q2 {q2} {} {} - Example: all computations on 00: 0 ε 0 q 0 q 0 q1 q2 : 47
  • 48. Informal Definitions • Let M = (Q, Σ, δ,q0,F) be an NFA-ε. • A String w in Σ* is accepted by M iff there exists a path in M from q0 to a state in F labeled by w and zero or more ε transitions. • The language accepted by M is the set of all strings from Σ * that are accepted by M. 48
  • 49. ε-closure • Define ε-closure(q) to denote the set of all states reachable from q by zero or more ε transitions. • Examples: (for the previous NFA) ε-closure(q0) = {q0, q1, q2} ε-closure(q2) = {q2} ε-closure(q1) = {q1, q2} ε-closure(q3) = {q3} • ε-closure(q) can be extended to sets of states by defining: ε-closure(P) =  ε-closure(q) q∈ P • Examples: ε-closure({q1, q2}) = {q1, q2} ε-closure({q0, q3}) = {q0, q1, q2, q3} 49
  • 50. Extension of δ to Strings and Sets of States • What we currently have: δ : (Q x (Σ U {ε})) –> 2Q • What we want (why?): δ : (2Q x Σ*) –> 2Q • As before, we will do this in two steps, which will be slightly different from the book, and we will make use of the following NFA. q3 1 0 0 ε q0 0/1 ε 1 q1 0 q2 50
  • 51. • Step #1: Given δ: (Q x (Σ U {ε})) –> 2Q define δ#: (2Q x (Σ U {ε})) –> 2Q as follows: 1) δ#(R, a) =  δ(q, a) for all subsets R of Q, and symbols a in Σ U {ε} q∈R • Note that: δ#({p},a) =  δ(q, a) by definition of δ#, rule #1 above = δ(p, a) q∈ p } { • Hence, we can use δ for δ# δ({q0, q2}, 0) previously δ({q0, q1, q2}, 0) These now make sense, but they did not. 51
  • 52. • Examples: What is δ({q0 , q1, q2}, 1)? δ({q0 , q1, q2}, 1) = δ(q0, 1) U δ(q1, 1) U δ(q2, 1) = { } U {q0, q3} U {q2} = {q0, q2, q3} What is δ({q0, q1}, 0)? δ({q0 , q1}, 0) = δ(q0, 0) U δ(q1, 0) = {q0} U {q1, q2} = {q0, q1, q2} 52
  • 53. • Step #2: Given δ: (2Q x (Σ U {ε})) –> 2Q define δ^: (2Q x Σ*) –> 2Q as follows: δ^(R,w) – The set of states M could be in after processing string w, having starting from any state in R. Formally: 2) δ^(R, ε) = ε-closure(R) 3) δ^(R,wa) = ε-closure(δ(δ^(R,w), a)) • - for any subset R of Q - for any w in Σ*, a in Σ, and subset R of Q Can we use δ for δ^? 53
  • 54. • Consider the following example: δ({q0}, 0) = {q0} δ^({q0}, 0) = ε-closure(δ(δ^({q0}, ε), 0)) By rule #3 = ε-closure(δ(ε-closure({q0}), 0)) By rule #2 = ε-closure(δ({q0, q1, q2}, 0)) By ε-closure = ε-closure(δ(q0, 0) U δ(q1, 0) U δ(q2, 0)) By rule #1 = ε-closure({q0} U {q1, q2} U {q2}) = ε-closure({q0, q1, q2}) = ε-closure({q0}) U ε-closure({q1}) U ε-closure({q2}) = {q0, q1, q2} U {q1, q2} U {q2} = {q0, q1, q2} • So what is the difference? δ(q0, 0) δ^(q0 , 0) - Processes 0 as a single symbol, without ε transitions. 54 - Processes 0 using as many ε transitions as are possible.
  • 55. • Example: δ^({q0}, 01) = ε-closure(δ(δ^({q0}, 0), 1)) By rule #3 = ε-closure(δ({q0, q1, q2}), 1) Previous slide = ε-closure(δ(q0, 1) U δ(q1, 1) U δ(q2, 1)) By rule #1 = ε-closure({ } U {q0, q3} U {q2}) = ε-closure({q0, q2, q3}) = ε-closure({q0}) U ε-closure({q2}) U ε-closure({q3}) = {q0, q1, q2} U {q2} U {q3} = {q0, q1, q2, q3} 55
  • 56. Definitions for NFA-ε Machines • Let M = (Q, Σ, δ,q0,F) be an NFA-ε and let w be in Σ*. Then w is accepted by M iff δ^({q0}, w) contains at least one state in F. • Let M = (Q, Σ, δ,q0,F) be an NFA-ε. Then the language accepted by M is the set: L(M) = {w | w is in Σ* and δ^({q0},w) contains at least one state in F} • Another equivalent definition: L(M) = {w | w is in Σ* and w is accepted by M} 56
  • 57. Equivalence of NFAs and NFA-εs • Do NFAs and NFA-ε machines accept the same class of languages? – Is there a language L that is accepted by a NFA, but not by any NFA -ε? – Is there a language L that is accepted by an NFA-ε, but not by any DFA? • Observation: Every NFA is an NFA-ε. • Therefore, if L is a regular language then there exists an NFA-ε M such that L = L(M). • It follows that NFA-ε machines accept all regular languages. • But do NFA-ε machines accept more? 57
  • 58. • Lemma 1: Let M be an NFA. Then there exists a NFA-ε M’ such that L(M) = L(M’). • Proof: Every NFA is an NFA-ε. Hence, if we let M’ = M, then it follows that L(M’) = L(M). The above is just a formal statement of the observation from the previous slide. 58
  • 59. • Lemma 2: Let M be an NFA-ε. Then there exists a NFA M’ such that L(M) = L(M’). • Proof: (sketch) Let M = (Q, Σ, δ,q0,F) be an NFA-ε. Define an NFA M’ = (Q, Σ, δ’,q0,F’) as: F’ = F U {q0} if ε-closure(q0) contains at least one state from F F’ = F otherwise δ’(q, a) = δ^(q, a) • - for all q in Q and a in Σ Notes: – δ’: (Q x Σ) –> 2Q is a function – M’ has the same state set, the same alphabet, and the same start state as M 59 – M’ has no ε transitions
  • 60. • Example: q3 1 0 0 ε q0 • 0/1 ε 1 q1 0 q2 Step #1: – Same state set as M – q0 is the starting state q0 q3 q1 q2 60
  • 68. • Theorem: Let L be a language. Then there exists an NFA M such that L= L(M) iff there exists an NFA-ε M’ such that L = L(M’). • Proof: (if) Suppose there exists an NFA-ε M’ such that L = L(M’). Then by Lemma 2 there exists an NFA M such that L = L(M). (only if) Suppose there exists an NFA M such that L = L(M). Then by Lemma 1 there exists an NFA-ε M’ such that L = L(M’). • Corollary: The NFA-ε machines define the regular languages. 68