Re: NFA behaviour with "empty string"





niclane wrote:
Hi,

I'm just looking for some clarification regarding how the "empty
string" label is processed by NFAs. It looks like I don't quiet
understand it correctly so I have these questions that come from the
book Intro to the Theory of Computation by Sipser:

Q1] In Example 1.56 it provides the following transformation for a
regular expression (i used @ for the accepting state):

a.b
transforms to
-> O - a -> 0 - "empty" -> O - b -> @

why is the middle "empty" transition necessary? wouldn't the NFA
function without it?

In this case, yes, it would. In general, though, with a and b replaced by arbitrary regular expressions, it might not. I suggest you look at Sipser's explanation in the "proof idea" of Theorem 1.47. As an example of where this "merge the final state of the first with the start state of the second" scheme fails, consider

FA1: start p1
     accept p2
     transitions
         p1,a -> p2
         p2,b -> p2

Clearly, L(FA1) = ab*

FA2: start q1
     accept q2
     transitions
         q1,a -> q1
         q1,b -> q2

We see L(FA2) = a*b

Now if we simply merged p2 and q1 in the hope of getting a FA for
(ab*).(a*b) we'd have

FA3: start p1
     accept q2
     (merged state s = p2 = q1)
     transitions
         p1,a -> s
         s,b -> s     // from FA1
         s,a -> s     // from FA2
         s,b -> q2

I'll leave it to you to show that L(FA3) isn't ab*a*b.

Q2] In Example 1.35 the book says that figure 1.36 accepts "empty",a,baba and baa. I don't see how "empty" or a are accepted. The NFA is:

has states q1,q2,q3
has start state of q1
has accept state of q1
has trasitions of the following:
q1,b -> q2
q2,a -> q2
q2,(a,b) -> q3
q1,"empty" -> q3
q3,a -> q1

How can it accept "empty" if "empty" goes to q3 but q3 is not an accept
state? how can it accept a for that matter?

You're conflating the two meanings of "empty" above. The rule

   q1, "empty" -> q3

should be understood as meaning that the NFA is allowed to change states
from q1 to q3 without reading any input symbols (which is why the NFA
accepts a. Starting in q1, it changes state to q3 without reading
any input. Then in q3 it reads the input character, a, and changes
state back to q1, which is an accept state.

On the other hand, you surely know that a finite automaton accepts a
string w if, after having read all of the input, it is in a final state.
In your example, since the start state is an accept state, it will
accept the empty *string*, since it can be in the accept state after
having read all of the (no) characters in the empty string. In your
example, if the NFA is given the empty string as input, it can be in
either of states q1 or q3. Since q1 is an accept state, the automaton
accepts the empty string.

This is a common misunderstanding, caused in part by the fact that
almost all authors use the same symbol to represent the empty string
and the "spontaneous" transition from one state to another without
consuming any input symbols.


Regards,

Rick

.



Relevant Pages

  • Re: Ugly loop
    ... Right now I wrote a rather ugly loop to create an NFA from a sequential string: ... (link source c target)) ... finally (progn (add-state nfa target) ...
    (comp.lang.lisp)
  • Re: combining millions of different regular expressions
    ... match a given string with all of them some how. ... i know that any regular expression can be transformed to a state ... merged state machine will have an optimal structure to improve the ... If you build a NFA instead of a DFA then space might be ...
    (comp.theory)
  • Re: proving string has atmost k length whose NFA has k states
    ... string with atmost k-1 length for the NFA with k states but not able to ... show string has atmost k states. ... The problem states: ... Let N be an NFA with k states that recognizes some language A. ...
    (comp.theory)
  • Re: proving string has atmost k length whose NFA has k states
    ... show string has atmost k states. ... I would be glad if i get some hints. ... The problem states: ... Let N be an NFA with k states that recognizes some language A. ...
    (comp.theory)
  • Re: Attachments to MAPI Message
    ... :> Do this before assigning the attachments to the message. ... :> String, _ ... :> 'is provided for sign-on. ... The default is an empty string. ...
    (microsoft.public.vb.controls.internet)