- 77 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Lecture 3 Goals:' - kadeem

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

- Lecture 3
- Goals:
- Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string.
- Algorithm to convert an NFA to an equivalent DFA.

q1

q2

NondeterminismNondeterministic machines have option to make multiple moves from a state on an input.

A nondeterministic finite automaton

has transition rules/possibilities like

q2

1

q1

q3

1

A Nondeterministic Automaton

0,1

0,1

0,

1

1

q1

q2

q3

q4

This automaton accepts “0110”, because there is a possible path that leads to an

accepting state, namely: q1 q1 q2 q3 q4 q4

A Nondeterministic Automaton

0,1

0,1

0,

1

1

q1

q2

q3

q4

The string 1 gets rejected: on “1” the

automaton can only reach: {q1,q2,q3}.

NFA – computation tree

For any (sub)string w, the nondeterministicautomaton can be in a set of possible states.

If the final set contains an accepting state, then the automaton accepts the string.

“The automaton processes the input in a parallel fashion. Its computational path is no longer a line, but a tree.”

Nondeterministic FA (definition)

- A nondeterministic finite automaton (NFA) M is defined by a 5-tuple M=(Q,,,q0,F), with
- Q: finite set of states
- : finite alphabet
- : transition function :QP(Q)
- q0Q: start state
- FQ: set of accepting states

Nondeterministic :QP(Q)

The function :QP(Q) is the crucial difference. It means: “When reading symbol “a” while in state q,one can go to one of the states in (q,a) Q.”

The in = {} provides null-transitions: moves in which a state transition occurs without reading the next input symbol.

Equivalence of NFAs and DFAs

Obvious Fact: If L is a language accepted by a DFA then there is an NFA that also accepts it.

This is because every DFA is an NFA.

Theorem:If L is a language accepted by an NFA then there is a DFA that also accepts it.

Proof is constructive. We describe an algorithm to convert an NFA to an equivalent DFA.

Proof idea:First consider an NFA M without e-moves. We are to design a DFA M’ that simulates it. Since NFA can be one of many states after reading an input, the simulating DFA will have as its states the subsets of states of M.

q

a

p

a

r

a

{q, r, s}

{p}

a

s

Will be an accepting state so long as at least one of the states is an accepting state in the original NFA.

{ r, x, m, p}

Converting an e-free NFA to a DFA:

Let M = (Q,,,q0,F) be an NFA. The equivalent DFA is M’ = (P (Q), , ’, {q0}, F’) where

’ (A, a) = all states reachable from some state in A on input a.

(If A = { q1 , … , qm } then,

’ (A, a) = (q1, a) U (q2, a) U … U (qm, a) )

F’ = { A | A F }

We can show that L(M) = L(M’).

Example 1:

Equivalent DFA

NFA

0

0

1

0

0

1

1

1

{a}

{b}

{c}

a

b

0

0

1,0

0

1

1

1

{a,b}

{a,c}

{b,c}

c

0

1

0

{a,b,c}

0,1

e-closure: For a set of states R, e-closure(R) is defined as the set of states reachable from states in R by a sequence of e-moves.

0

0

1

1

2

e

1

1

If R = {1, 3}, what is

e-closure(R)?

3

0

Converting an NFA M with e-moves to a DFA:

Suppose we have computed e-closure of every state in M. To accept a string a1 … am, M can first perform a sequence of e-moves, then move on a1, then perform a sequence of e-moves, then move on a2, etc. Finally, after a move on am, it can perform another sequence of e-moves and reach an accepting state.

Recall the subset construction we described above to convert an e-free NFA to a DFA. What changes do we need to make it work for NFA with e-moves?

Download Presentation

Connecting to Server..