I want to construct a regular expression for strings over the alphabet {a, b, c} that don’t contain the contiguous substring "baa". I tried to follow the same procedure as in all the words that don't have both substring bba and abb, where the goal was to find a regular expression that matches all words that do not contain both "bba" and "abb" as substrings. However, I got stuck at some point and could not get the correct answer. Here are the steps I followed:
Here is how I tried to solve it
- I constructed an NFA that accepts all words that contain contiguous substring "baa"
- I constructed the complement of NFA by turning middle states into final states and final states into middle ones. Here it is.
- I simplified the NFA by adding a new final state and eliminates some states.
- I tried to write a regular expression for the simplified NFA, but I realized that it still accepts words that contain contiguous "baa" as a substring
Can someone tell me where I went wrong and how to fix it? Is there a better way to approach this problem? Thanks in advance.