I want to, for each of the following languages on Τ={a, b, c}, construct the corresponding regular expression and regular grammar:
- All strings containing exactly three a’s.
- All strings containing at most three b’s.
How can I do this?
I want to, for each of the following languages on Τ={a, b, c}, construct the corresponding regular expression and regular grammar:
How can I do this?
You may always use unions, concatenations and Kleene stars in addition to the given symbols (unless the task explicitly forbids it). So if you don't know how those work, read up on those first. Afterwards, here's a hint to the first task: take any string that contains three or more b
's, say, acbaacbbaacbacb
. Each character is either one of the first three b
's or not: xxbxxxbbxxxxxxx
. So the structure of such a string is a sequence of any characters (or maybe none if it starts with a b
), and then a b
, then more other characters (maybe), then another b
, more characters (maybe), the third b
, and finally more characters (maybe). How do you express "any character", and how do you express the alternating sequence of b
's and "any character, zero or more times"?