0

I just came across an exercise which is to find a regular expression for the following automata, such that the regular expression and the automata generate the same language.

NFA

One solution presents the following expression:

$\qquad \displaystyle r_A = a^+b^+(c\mid ca^*b^+)^*$

However, can this be true? I think not, because the all words created from the regular expression will have at least one $b$ in it, whereas the automata accepts words without $b$, such as $aaa$.

What is your opinion?

Raphael
  • 72,336
  • 29
  • 179
  • 389
Erik
  • 171
  • 3
  • You already gave the answer, the DFA accepts a, but a is not contained in the language described by the RE. – A.Schulz Jul 21 '12 at 13:56
  • It's pretty clear that the two are a mismatch, for the reason you give. Is there a reason why you doubt yourself? – Niel de Beaudrap Jul 21 '12 at 14:10
  • It's pretty simple indeed. I doubted because it was the officially provided solution in a teaching book. I am going to send the author an e-mail or check the errata if I find them. Thanks! – Erik Jul 21 '12 at 14:26
  • It turns out that it's only slightly incorrect: can you see how? -- I knew a prof who had written a very nice textbook on Abstract Algebra (Keith Nicholson) in its 3rd edition: he seemed to have had lots of problems with trivial errors in the exercises, and was glad to get the feedback. – Niel de Beaudrap Jul 21 '12 at 15:19
  • 1
    I think it should be a+b(c|ca+b)* – Erik Jul 21 '12 at 17:56
  • 1
    Note that this question can be seen as too localized; you should try to formulate a more general question in most cases. Also note that we can use LaTeX here for typesetting maths. – Raphael Jul 23 '12 at 07:41

1 Answers1

2

In general, you can decide equivalence of regular expression and finite automaton using standard algorithms:

  • Construct an NFA from the regular expression,
  • Determinise and minimise both automata,
  • Check for equality (up to isomorphism).

These algorithms and proof that the minimal DFA of any regular language is unique (up to isomorphism) can be found in introductory textbooks.

If the underlying task is to "read off" a regular expression from an automaton, don't guess & proof but rather build the expression algorithmically to save time.

Raphael
  • 72,336
  • 29
  • 179
  • 389
  • You are absolutely right. But sometimes thinking saves time and improves your understanding before doing it the mechanical way ;) – Erik Jul 23 '12 at 14:19
  • 1
    @Erik Maybe I am no longer creative enough for such exercises, but what kind of thinking do you do? Trying inputs at random, hoping to refute correctness? Not very educational. Trying to find an intuitively correct mapping between expression and automaton? If that even exists for moderately complex cases, I doubt it will be worth the time. YMMV. – Raphael Jul 23 '12 at 15:32