1

Find a regular expression for the language accepted by the following automata.

  1. Eliminate q1

    q0: ab
    q2: ba*
    q0 to q2: b+aa
    q2 to q0 : bb
    
  2. Eliminate q2

    q0: ab+b+aa(ba)*
    

automaton diagram

(not sure if my way is right)

Fulla
  • 79
  • 7

1 Answers1

1

There are two rules:

  1. if X -> s and Y -> rXt then you can replace the latter with Y -> rst.
  2. if X -> sX | r then you can replace this with X -> s*r.

A regular grammar for this DFA is the following:

(q0) -> b(q2) | a(q1) | (q3)
(q1) -> b(q0) | a(q2)
(q2) -> b(q1)
(q3) -> lambda

We can begin eliminating states. (q3) is easy to get rid of:

(q0) -> b(q2) | a(q1) | lambda
(q1) -> b(q0) | a(q2)
(q2) -> b(q1)

We can get rid of (q2) pretty easily:

(q0) -> bb(q1) | a(q1) | lambda
(q1) -> b(q0) | ab(q1)

We need to get rid of the self-reference in the productions for (q1):

(q0) -> (bb+a)(q1) | lambda
(q1) -> (ab)*b(q0)

Now, we can get rid of (q1):

(q0) -> (bb+a)(ab)*b(q0) | lambda

Now, let's get rid of the self-reference:

 (q0) -> ((bb+a)(ab)*b)*

So, the regular expression ((bb+a)(ab)*b)* should work. This gets us back to state (q0) and (q3), the accepting state, is in the lambda-closure of (q0). Trying a few terms suggests we have found a good expression.

Patrick87
  • 27,682
  • 3
  • 38
  • 73
  • I thought you cant eliminate the final and initial state until the very end, and you did eliminate q3 first step... i am confused – Fulla Jun 03 '19 at 17:36
  • @Fulla I think what I did is basically implicitly using the fact that states q0 and q3 are equivalent in the sense of the lambda-closure sense and so I treated them as the same state. The alternative might be to write the other kind of regular grammar (where the terminal symbols are on the right) and the corresponding reduction rules and then derive something for q3 directly that way. That might be a little clearer, then you'd be solving for q3 directly rather than for q0 and making the separate leap to considering q0 as accepting due to being in the lambda closure. – Patrick87 Jun 03 '19 at 20:40