First, in my opinion, the regex for L1 = {a^2n b^3m+1 | n>=1, m>=0}
is NOT what you gave but is: aa(aa)*b(bbb)*
. The reason is that a^2n, n > 1
means that there are at least 2 a
and a pair number of a
.
Now, the regular expression for "Any string except for aa(aa)*b(bbb)*"
is:
^(?!^aa(aa)*b(bbb)*$).*$
more details here: Regex101
Explanations
aa(a)*b(bbb)*
the regex you DON'T want to match
^
represents begining of line
(?!)
negative lookahead: should NOT match what's in this group
$
represents end of line
EDIT
Yes, a complement for aa(aa)*b(bbb)*
is "Any string but the ones that match aa(aa)*b(bbb)*"
.
Now you need to find a regex that represents that with the syntax that you can use. I gave you a regex in this answer that is correct and matches "Any string but the ones that match aa(aa)*b(bbb)*"
, but if you want a mathematical representation following the pattern you gave for L1, you'll need to find something simpler.
Without any negative lookahead, that would be:
L2 = ^((b+.*)|((a(aa)*)?b*)|a*((bbb)*|bb(bbb)*)|(.*a+))$
Test it here at Regex101
Good luck with the mathematical representation translation...