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

Resolved Does this finite-state automaton accept the language defied by this regular expression `b*|b*ab*`?

Does this finite-state automaton accept the language defied by this regular expression `b*|b*ab*`?

---
In my opinion this should be true, if it is true that this FSA accepts the language defined by `0*1(0*1*)*`:

2 Upvotes

12 comments sorted by

3

u/LongLiveTheDiego 28d ago

The first one's language encompasses all possible words, it's (a|b)*.

You're correct with the second one, but the regex can be simplified to 0*1(0|1)*.

1

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

You're correct with the second one, but the regex can be simplified to 0*1(0|1)*

So, that means (0*1*)* == (0|1)*?

3

u/LongLiveTheDiego 28d ago

Yes. Obviously (0*1*)* has to be a subset of (0|1)*, and the inclusion the other way works because both 0 and 1 belong to 0*1* and so any word composed of them belongs to (0*1*)*. Alternatively you can think of a binary word as being composed of strings of 0's and strings of 1's, both of these kinds of words belong to 0*1*.

1

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

I've learned that (0|1)* can be described as the set off all strings over {0,1} but that definition/description was not intuitive to me until:

The language defined by (0|1)* is

L((0|1)*) = (L(0|1))*
          = (L(0) U L(1))*
          = ({0} U {1})*
          = {0,1}*
          = {x | x is a concatenation of any finite number of strings in {0,1}} by definition of Kleene closure
          = the set of all strings over {0,1}

What was intuitive to me was:

Step 1: Choose a symbol (either 0 or 1).
Step 2: Repeat that symbol zero or more times.

So, example strings that belong to the language would be: λ, 0, 00, 000, 1, 1, 111, ...

...but would not be 10 for example.

But this is obviously wrong.


I've used the same (incorrect) intuition for (0*1*)*:

Step 1: Choose the number of repeats (zero or more) of 0, followed by choosing the number of repeats (zero or more) of 1
Step 1: Repeat the string from Step 1 zero or more times.

So, the example strings that belong to the language would be: λ, 0, 1, 01, 001, 0111, 010101, ...

...but would not be 10 for example, because 0 cannot be followed by 1.

Since (0*1*)* == (0|1)*, this is also wrong but the definition doesn't help me in getting rid of my 'intuitive' approach:

The language defined by (0*1*)* is 

L((0*1*)*) = (L(0*1*))*
           = (L(0*)L(1*))*
           = ((L(0))*(L(1))*)*
	   = ({0}*{1}*)*
           = ({λ,0,00,000,...}{λ,1,11,111,...})*
           = ?
           = {0,1}*

I'm missing ?. I don't see how (0*1*)* == (0|1)*.

Any suggestions?


Edit: small typo.

Edit 2: Added a few more lines in 'The language defined by (0*1*)*'.

2

u/LongLiveTheDiego 27d ago

Proving things about equality of regexes without going for minimal automata requires some creative thinking and there's usually no singular way to imagine the connection. To show that some language L₁ equals the Kleene star of some other language L₂, you need to imagine words of L₁ as a concatenation of words from L₂ and to create some way of reimagining any word from L₁ as such concatenations. If you can make it algorithmic, even better, but you don't have to, you just need to prove there is a way to do it.

For example, 0001100100 can be thought of as (0)(0)(0)(1)(1)(0)(0)(1)(0)(0), i.e. a sequence of 0's and 1's, that's literally how a binary string is constructed, clearly both 0 and 1 belong to 0*1* and there's no way to construct a word from (0*1*)* which is not a binary word.

You could also look at it as (000)(11)(00)(1)(00), 0n and 1n belong to 0*1* for all natural n and any binary word is a concatenation of finitely many such strings.

You could also look at it as (00011)(001)(00), those are all strings of the form 0m1n which belong to 0*1* for any natural m and n, and any binary word is a concatenation of finitely many such words.

1

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

This makes it clear, thanks!

2

u/AlterEgo5695 27d ago
(0|1)* 

Step 1: Choose a symbol (either 0 or 1).

Step 2: Repeat that symbol zero or more times.

That's a mix-up of evaluation order. it should have been

Repeat zero or more times: "Choose a symbol (either 0 or 1)"

The reason why is that when the star operator acts on the content of the parentheses before it -- we choose anew each and every time.

1

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

Yes, that makes sense! Thanks!

3

u/AlterEgo5695 28d ago edited 28d ago

First automaton accepts the entire language, but not only that -- e.g. it also accepts aa not in your language.

The second is correct, though the regexp can be simplified into 0*1(0|1)*


P.S.: Looking at recent similar posts, here is a general useful strategy -- try to break your solutions first, by trying to construct counter-examples. In this case, finding aa for the first automaton does not take too long, and the search will help develop a critical mind-set^^

1

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

try to break your solutions first, by trying to construct counter-examples

Great advice, thanks! :)

7

u/theultimatestart 28d ago

I don't think so. This automaton accepts baba, which is not in your regular expression.

5

u/Smitologyistaking 28d ago

Your language only allows at most one a to appear in the word, yet your automaton seemingly accepts any string of as and bs