![]() |
![]() |
|
Note:
- For full credit, give short-as-possible strings which are/aren't in the language.
- Task (ii) should be
whichever is fewer.- Task (iii) should have a close-paren before the comma.
hint: Your parse tree for (b) can refer to the parse tree for (a) if you like.
hint for k: If you have two existing CFGs, it's easy to take their union: add a non-terminal that has one rule "generate anything from the first CFG", and one rule "generate anything from the second CFG".
hint for m:
- The # is just another character (which is handy here to demark the two parts of the string).
- Recall the book's grammar for generating palindromes (with a center-mark (
#in this case)); after all such palindromes are just a string concatenated to its reverse. x is a substring of yis the same asy can be expressed as uxw, where u and w are any string.
hint: How many states do you need, to keep track of the parity of #a's? Hint: 2. Likewise for the #b's. To keep track of both simultaneously means 2x2 states.(Make sure your machine accepts aababba.)
That is: specify what the grammar-alphabet V is, what the set of rules R is, and what the start-nonterminal S is.
notation: Recall that if you want to build a set by looping over (say) all \(k\in K\) and union'ing the result, you can use the notation \[ \bigcup_{k\in K} \ldots .\]
Note: These are the same languages as you wrote CFGs for in 11.11.6 — they just re-numbered that part k as part i, here.
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |