0
$\begingroup$

The question asks to write down a regular expression $r$ indicating the language of all the words above $\Sigma = \{a, b\}$ , in which the number of $a$ is even and there is no sub-word $aab$ in them.

I am aware of the fact that there is an algorithm that converts a finite automaton into a regular expression.

I want to know if there is a systematic way of working that does not use this algorithm and will give an appropriate regular expression.

I have written $r = b^*(aa)^* + (b^*ab^+ab)^*(aa)^*$

This is an incorrect answer.

I tried to fix it, but I feel like I'm just adding expressions and can't understand how to work on the problem thoroughly.

$\endgroup$
3
  • 3
    $\begingroup$ Writing a finite automaton and converting it into a regular expression is a systematic way of solving this kind of problem. I don't think "doesn't use this algorithm" is a helpful requirement, because what constitutes "different enough" that you consider it a different approach? It's too hard to predict what you'll accept and what you'd reject, before answering. I suggest you spend some time reflecting on why you don't like that existing algorithm, what about it is unsatisfactory, and then use that to articulate some specific requirement that you have for a systematic process. $\endgroup$
    – D.W.
    Commented Mar 2 at 20:42
  • $\begingroup$ Hello! @D.W. From what I wrote, it is implied that an algorithm that converts a finite automaton into a regular expression is unique. Well this post cs.stackexchange.com/questions/2016/… show that there are several methods. The main difficulty for me is that I know only one such algorithm - Transitive closure method. $\endgroup$
    – Daniel
    Commented Mar 3 at 19:32
  • $\begingroup$ It reminds me a lot of the Floyd–Warshall algorithm. Using the transitive closure method is very long and tedious, and if you do it with pen and paper there is a very high chance of making mistakes. However, there is indeed a systematic way to solve this kind of problems - it's unique and it's the use of an automaton. Thanks for the help ! $\endgroup$
    – Daniel
    Commented Mar 3 at 19:34

2 Answers 2

4
$\begingroup$

The only systematic ways to find regular expression I know of are using automata. As D.W. mentionned in his comment, I am not sure why you are rejecting this method.

A non-systematic approach for this language could be as follow.

The language of words without $aab$ as substring can be represented with the regular expression $(ab\mid b)^*a^*$.

To ensure that a word has an even number of $a$'s, we must consider two cases:

  • either the longest suffix of $a$'s is of even length, so there must be an even number of substring $ab$. This corresponds to $(abb^*ab\mid b)^*(aa)^*$
  • or the longest suffix of $a$'s is of odd length, so there must be an odd number of substring $ab$. This corresponds to $(abb^*ab\mid b)^*abb^*a(aa)^*$.

Combining the two regular expressions, we get: $$(abb^*ab\mid b)^*(\varepsilon\mid abb^*a)(aa)^*$$

$\endgroup$
1
  • $\begingroup$ Hello! @Nathaniel. Thank you very much for the answer. The solution you provided is what I was looking for. But as you wrote, this is "A non-systematic approach". Thank you !! $\endgroup$
    – Daniel
    Commented Mar 3 at 19:37
1
$\begingroup$

Hint: Here is an automaton for this language

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much !! $\endgroup$
    – Daniel
    Commented Mar 3 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.