Lecture 3
This presentation is the property of its rightful owner.
Sponsored Links
1 / 16

Lecture 3 Goals: PowerPoint PPT Presentation


  • 47 Views
  • Uploaded on
  • Presentation posted in: General

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. . q 1. q 2. Nondeterminism. Nondeterministic machines have option to make multiple moves from a state on an input.

Download Presentation

Lecture 3 Goals:

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

  • 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.


Nondeterminism

q1

q2

Nondeterminism

Nondeterministic 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

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 automaton1

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

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

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 :QP(Q)

    • q0Q: start state

    • FQ: set of accepting states


Nondeterministic q p q

Nondeterministic :QP(Q)

The function :QP(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.


Non deterministic finite automata nfas

Non-deterministic Finite Automata (NFAs)

Example 2:

0

0

1

1

2

1

1

Does this NFA

accept 11011?

3

0


Lecture 3 goals

0

0

1

1

2

1

1

1

1

e

3

2

3

0

0

e

3

3

2

0

1

1

1

1


Equivalence of nfas and dfas

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.


Lecture 3 goals

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}


Lecture 3 goals

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’).


Lecture 3 goals

Conversion of an NFA to a DFA

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


Lecture 3 goals

Dealing with e-moves

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


Lecture 3 goals

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?


Lecture 3 goals

Example:

0 1 2

e e


  • Login