1

Are both regular expressions correct for the following automaton? enter image description here

$$(\lambda+ a a^*b(ab)^*)(\lambda + b(a+b)^*)\\ \ \\ (a a^*b)^*(\lambda + b(a+b)^*)$$

The first one is the solution provided by the teacher. The second one is my solution that I found by the algorithm where we use a generalized transition graph and remove states (and where we can only have 1 final state). enter image description here

John L.
  • 38,985
  • 4
  • 33
  • 90
Ronald
  • 89
  • 5
  • We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. – D.W. Aug 23 '22 at 19:50

1 Answers1

2

There are general algorithms to determine whether two regular expressions represent the same language. A classic approach is described here.


The expression given by your teacher, $E=(\lambda+ a a^*b(ab)^*)(\lambda + b(a+b)^*)$ does not correspond to the DFA shown. For example, string $aba^2b$ is accepted by the DFA. However, it is not in $E$.

By distributive law, $(\lambda+ a a^*b(ab)^*)(\lambda + b(a+b)^*) = \lambda+ a a^*b(ab)^* + b(a+b)^* + aa^*b(ab)^*b(a+b)^*$

  • $aba^2b\not = \lambda$
  • A string in $a a^*b(ab)^*$ does not contain $a^2$ after the first $b$.
  • A string in $b(a+b)^*$ starts with $b$
  • A string in $(a a^*b(ab)^*)b(a+b)^*$ contains $b^2$ since a string in $(a a^*b(ab)^*)$ must end with $b$.

Your solution, $F=(a a^*b)^*(\lambda + b(a+b)^*)$ is correct. The correctness is justified by the methodical procedure you have done.

For this simple case, we can also verify it by straightforward reasoning, which is basically paraphrasing the procedure.

An accepted string either ends up in state $q_1$ or $q_0$.

  • A string ends up in state $q_1$ iff the DFA will transition from $q_1$ to $q_2$ and back to $q_1$ zero or more times, each time reading one or more $a$s followed by one $b$. That means $(aa^*b)^*$

  • A string ends up in state $q_0$ iff the DFA will reach $q_1$, then transition from $q_1$ to $q_0$, then loop at $q_0$ zero or more times.

    • Reaching $q_1$ entails $(aa^*b)^*$.
    • Transitioning from $q_1$ to $q_0$ entails one $b$.
    • Looping at $q_0$ entails $(a+b)^*$.

    Concatenating three pieces together, we get $(a a^*b)^*b(a+b)^*$.

John L.
  • 38,985
  • 4
  • 33
  • 90