views:

55

answers:

3

Hey all,

I feel bad about asking a question so simple, but I can't figure this out for the life of me. I need to construct a NFA based on some languages, and the only one I can't figure out is this one:

L = (10)*

Note that I am not asking for any help concerning the FSM, but only some clarification on what the language represents. Most of the other languages were presented to me in a more understandable fashion:

L = {w | w contains an even number of 0's } 

I'm thinking it's just a regular expression, and after some perusing of the regex cheat sheet, my only guess is that it matches for the group 10 0 or more times, but that clearly doesn't seem right because everything would match.

Any help is greatly appreciated.

+1  A: 

Could this be of use? http://xenon.stanford.edu/~xusch/regexp/analyzer.html

alt text

Chris
So I was correct in my guess that it just matches the group '10' 0 or more times? If this is the case, all strings will match?
prelic
That's what "Zero or more times" sounds like to me as well (unless there is a negative amount of occurences somehow?), but I know very little about Regex, hence the analyzer. You're better off listening to bzlm I think.
Chris
While those regex tools will usually help a lot (and are correct in this case), they're generally targeted toward Perl-compatible regular expressions, which go well beyond the regular expressions dealt with in language theory. It works here, but just keep in mind that it might not always be able to help.
Michael Madsen
+4  A: 

These strings are in the language (10)*:

<empty string>
10
1010
101010
10101010
(etc.)

These strings are not in the language (10)*:

0
1
01
11
010
01010
101
10101
(etc.)

Does that help?

Jim Lewis
Thanks for clearing that up, I see where my logic was off.
prelic
+2  A: 

Your belief about the meaning is basically correct, but it's not everything that would match.

Unlike your usual regex libraries, when we're dealing with language theory like this, a regular expression must match the entire string. So, ε (empty string) is in the language, 10 is in the language, 1010 is in the language, and so on - everything that consists entirely of the string "10" repeated 0 or more times.

01, however, is not in the language; the string does not consist of the string "10" repeated 0 or more times. 1 is also not in the language, you're missing the final 0.

I don't know if you've covered this part yet, but if you convert that regex to an NFA (or a DFA, non-determinism isn't required for this one) you'd basically get this (slightly simplified, if I remember my conversion algorithm correctly, but it's a pretty trivial change from the algorithm to this):

  1
 ┌─┐
 │ ↓
→a b
 ↑ │
 └─┘
  0

where a is an accepting state, and b is not.

Does this help you see why it doesn't match everything?

Michael Madsen
Got it, thanks for the detailed response.
prelic
You deserve a badge for that pretty drawing. :)
bzlm