Given the language below, how do i find a regular expression for the language
L = {a ^n b ^m | n => 1, m =>1, nm =>3}
Given the language below, how do i find a regular expression for the language
L = {a ^n b ^m | n => 1, m =>1, nm =>3}
n>=1 and m>=1 and nm>=3 is true for each of the following:
n=1,m>=3
n>=3,m=1
n>=2,m>=2
So L = { abbb, abbbb, abbbbb, ... } U { aaab, aaaab, aaaaab, ... } U { a^n b^m | n>=2,m>=2 }
This regex should be equivalent to L:
((abbb(b*)) | (aaa(a*)b) | (aa(a*)bb(b*)))
There is probably a much more succinct answer than this.
Write down a set of example words of the language. Get a feel for them. Look for patterns. Look for common prefixes / suffixes / substrings.
abbb
abbbb
abbbbb
aabb
aabbb
aabbbb
aaab
aaabb
aaabbb
aaaab
aaaabb
aaaabbb
For example: notice that all words start with a and end with b. So, your regular expression looks something like a...b. What does the ... part look like?
bb
bbb
bbbb
ab
abb
abbb
aa
aab
aabb
aaa
aaab
aaabb
This kinda looks like either an a followed by either at least one a or a b possibly followed by zero or more bs. Or simply a series of more than two bs.
a(a+|b)b*|b{2,}
You could also say it is either a series of at least two as or a series of at least two bs or a series of as followed by bs. I'm not going to write down that expression.
This is homework, after all, so I'll leave it to you to desugar this and put it together with the first result. (BTW: all the shortcuts I used are just syntactic sugar and they do not make regular expressions more powerful. I.e. there is a simple syntactic transformation that turns them into standard regular expression.)
[I just hope I'm right and don't make an ass of myself :-)]