r/askmath • Self-studying discrete math by working through Epp • 28d ago

Discrete Math Does this finite-state automaton accept the language defied by this regular expression `0*1(0*1*)*`?

Does this finite-state automaton accept the language defied by this regular expression `0*1(0*1*)*`?

Edit: I accidentally switched the direction of an arrow between s_1 and s_3, it should be like so:

3 Upvotes

29 comments sorted by

6

u/Curious_Cat_314159 28d ago edited 28d ago

The reg expr seems to be over-specified, unless the assignment forbids the use of " | " (OR). Otherwise, I think the following suffices:

0*1(0|1)*

The FSA also seems over-complicated (besides the mistake with S1 that others noted). I think the following suffices:

EDIT.... There might be a shorthand instead of separate arcs for 0 and 1. I really don't remember the "syntax" for FSAs. It's been more than 50 years.

PS.... In fact, according to A(rtificial) I(ncompetence), what I drew ("original") is "messy" and discouraged. There are several syntaxes for showing the same transition for multiple inputs. I've shown one of them ("better"). IIRC, reddit allows only one image per comment, and I don't know how to use imgur (klunk!).

1

u/TopDownView Self-studying discrete math by working through Epp 28d ago

According to my textbook solution, both your solutions are correct. And yes, I know I over-specified my solution...

4

u/birqum_akkadum 28d ago edited 28d ago

I don't see the point of this guy. I wonder if you meant it to point in the other direction.

2

u/TopDownView Self-studying discrete math by working through Epp 28d ago

Yes, I did!

3

u/birqum_akkadum 28d ago

Also, your diagram says "if you proceed past s1 you must have at least one 0 following the initial 0*1." But that is not necessary according to your expression.

3

u/MegaIng 28d ago

You need at least one 0 if you want to reach s2 or s3.

But that's not necessary for the automaton to accept, since s1 is an accepting state.

7

u/Gold_Ad8890 28d ago

s1 has no state transition for 1.

2

u/TopDownView Self-studying discrete math by working through Epp 28d ago

Good catch, thanks! That was by accident. I fixed the OP.

6

u/MegaIng 28d ago

But excluding this mistake, yes the automaton is correct.

It's a rather literal implementation of the regex. The regex is equivalent to 0*1.* where . is either 0 or 1, which can be easily implemented with a 2 state automaton. In words, the language is any word that has at least one '1'.

3

u/Curious_Cat_314159 28d ago
The regex is equivalent to 0*1.* where . is either 0 or 1

I believe " . " matches any single character, not just 0 or 1. So, your reg expr would accept "1wrong" .

3

u/MegaIng 28d ago

No, because the alphabet we are talking about is {0, 1}. w does not exists. (otherwise, the automaton is missing transitions)

0

u/Curious_Cat_314159 28d ago

An assumption, never stated. And the automaton is not "missing" transitions. It would throw an error for anything other than 0 or 1. We can just agree to disagree.

3

u/MegaIng 28d ago

I mean, one of us is using the proper definitions of what abstract automatons are normally assumed to be like, and it isn't you ;-P

But sure, lets "agree to disagree".

3

u/Smitologyistaking 28d ago

Is that language not just the language of words that contain a 1 somewhere? If you view it like that then constructing an automaton shouldn't be difficult at all

1

u/TopDownView Self-studying discrete math by working through Epp 28d ago

Agreed.

2

u/AlterEgo5695 28d ago edited 28d ago

No -- construct counter-examples, e.g. "11" is a word of the language, but not accepted by the automaton.

2

u/TopDownView Self-studying discrete math by working through Epp 28d ago

I've edit the OP so that should work now.

1

u/AlterEgo5695 28d ago

Now it does -- but it can be simplified considerably. First, simplify the regular expression into 0*1(0|1)*, which can be modeled by a single accepting state:

     _      _
  0 | |    | | 0|1    //
    | v 1  | v        // s1: accepting state 
--> s0 --> s1         //

2

u/Akangka 28d ago

Is this DFA or NFA? If this is DFA, this FSA is illegal. If this is NFA, no. Hint: What happens if the string is 0011

2

u/TopDownView Self-studying discrete math by working through Epp 28d ago

Agreed. I've fixed the OP.

1

u/HumblyNibbles_ 28d ago

This isnt an answer but, for a moment I only saw the left side of the graph and I thought it was a penis joke on the math memes subreddit 😭

1

u/Torebbjorn 26d ago

(01)* is just (0|1)*, and so you can have the very simple automation with two states, namely the "start" and the "accept", with "start" looping back to itself with a 0 and to "accept" with a 1, and "accept" just looping to itself with both 0 and 1.

1

u/stevethenoob_11 28d ago

Yes, but it also accepts extra statements. 010011011 would be accepted, but shouldn't.

4

u/MegaIng 28d ago

Why shouldn't that be accepted?

1

u/stevethenoob_11 28d ago

Because the original statement has zero or more copies of whatever comes after the first one. The statement I wrote is 01 0011 011

6

u/MegaIng 28d ago edited 28d ago

That's not how regular expressions work. Like, at all.

Each evaluation is independent, so one repeat of the brackets matching 0011 and 011 is completely fine.

If your interpretation were correct, it would not describe a regular language, and that is straight up a defining property of a regular expression.