Assignment Five
1. Question One
2. Question Two
3. Question Three
4. Question Four
5. Question Five
\(count(a) \neq count(b) \Rightarrow count(a) > count(b) \vee count(a) < count(b)\)
- More A's than B's = G
- Less A's than B's = L
6. Question Six
This one we can actually create from a DFA!
7. Question Seven
Consider a grammar S with regular expressions in its production's bodies. After replacing any extensions on regular expressions with their corresponding algebraic equivalents as given in 3.3.5, hen, we can transform S into an equivalent grammar by the following rules for nonterminals or terminals:
7.1. Kleene Closure
If we have a match in a production body corresponding to Kleene Closure, then we can transform it into two new productions:
\begin{verbatim} B* \end{verbatim}goes to
\begin{verbatim} A -> ε A -> BA \end{verbatim}7.2. Union
If we have a match in a production body corresponding to the union operator, then we can rewrite it as two new productions:
\begin{verbatim} B | C \end{verbatim}goes to
\begin{verbatim} A -> B A -> C \end{verbatim}7.3. Example(s)
For example, consider the grammar:
\begin{verbatim} N -> (A | B)* A -> aA A -> ε B -> bB B -> ε \end{verbatim}then we can form our first transformation by replacing N (no need to rename since it's already the start symbol):
\begin{verbatim} N -> ε N -> (A | B)N A -> aA A -> ε B -> bB B -> ε \end{verbatim}which is then further reduced when we transform (A | B)
\begin{verbatim} N -> ε N -> DN D -> A D -> B A -> aA A -> ε B -> bB B -> ε \end{verbatim}