2 2 votes Are grammars with $S \to SS$ productions always ambiguous? Also, how can the production be represented in form of a formula? For example, $S \to aSb \mid \varepsilon$ can be written as $S = a^n b^n$ What would be the formula for $S \to aSb \mid SS \mid \varepsilon$? Theory of Computation context-free-language + – Abhishekcs10 808 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 2 2 votes I think this grammar is unambiguous (Note: proving unambiguity for an arbitrary CFG is undecidable!): $$\begin{align} S &\to SS \mid aA \mid bB\\[1em] A &\to aA \mid \alpha\\[1em] B &\to bB \mid \beta \end{align}$$ About converting a grammar to a formula, the grammar is a formula! If you want a formula of the type $a^x b^y c^z$, it is neither always obvious nor always possible! For example, the $S \to aSb \mid SS \mid \varepsilon$ can't be put into a nice looking formula. It describes balanced parenthesis, where $a$ is the opening paren, and $b$ is the closing paren. Pragy Agarwal answered Jan 13, 2016 • selected Jan 13, 2016 by Abhishekcs10 Pragy Agarwal comment Share Follow See all 2 Comments 2 2 Comments reply Abhishekcs10 commented Jan 13, 2016 reply Follow flag Thank you for the explanation :) ....i found a representation for above grammar as (a^n.b^n)^* and is it correct..?? 1 1 replyShare Pragy Agarwal commented Jan 13, 2016 i edited by Pragy Agarwal Jan 13, 2016 reply Follow flag You mean for this? $S \to aSb \mid SS \mid \varepsilon$. Nopes. $(aaa(ab)(ab)bbb)$ can be derived from $S$, right? (Ignoring the parens). $(a^n b^n)^*$ doesn't contain it! 2 2 replyShare Please log in or register to add a comment.