0

I am having a really tough time on this conversion problem. I have read, re-read and watched videos but I am pretty sure the answer I am coming up with is not correct.here is the diagram of the NFA

I have a feeling I am missing some steps. This is the expression I end up with:

(ab*(aUb)a*)Ua*

I've shared my steps in this image. (https://i.stack.imgur.com/e9xVZ.jpg)

  • Hi! Looks like you're missing something because it's possible to have more than one group of b with this NFA, but your regexp doesn't allow that. – Stef Jun 19 '23 at 22:34
  • For instance the word "abaab" is accepted by the NFA (by just circling around the NFA clockwise) but not by your regexp. – Stef Jun 19 '23 at 22:35
  • BTW there are lots of similar questions at https://cs.stackexchange.com so it might be a better place to ask if you have other similar questions in the future. – Stef Jun 20 '23 at 12:04

1 Answers1

1

I don't want to do your homework work you. You won't learn anything. But I think this paper gives a very clear explanation of how to convert an NFA to a regexp.

Step by step, you create an NFA whose edges are labeled with regexps rather than tokens, and you rip out states until you've got just a single edge going from the input state to the output state.

  1. Create a new unique initial state with an edge labelled ε going to the original initial state(s).
  2. Create a new unique final state with an edge labelled ε going from all final states to this new final state.
  3. One by one, delete internal states: Pick a state q. Look at the states that have an edge into q, in1, in2, in3... Look at the states that have an edge coming out of q, out1, out2, out3. Let the state q have a self loop of Rq (may be empty). For each pair ini, and outj, replace ini -> q -> outj with Rini(Rq*)Routj. Repeat.

https://courses.engr.illinois.edu/cs374/fa2017/extra_notes/01_nfa_to_reg.pdf has an good example.

Frank Yellin
  • 9,127
  • 1
  • 12
  • 22
  • I found this document today and will use it to help solve the problem. Thanks for also bringing it to the attention on this post for others to help. Some of the other examples I found online weren’t as complex which is why I felt the need to ask on here. – comp_sci_noob Jun 20 '23 at 23:09