retagged by
808 views
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$?

1 Answer

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.

selected by
Position:
Show:

Related questions

0 0 votes
0 0 answers
462
462 views
Vedantthakkar asked Feb 24, 2024
462 views
Consider a regular language R and a context free language C. Let the PDA that recognizes C be called P=(QP,∑,Γ,δP,q0P,FP), and the DFA that reconginzes R be (QR,∑,δ...
1 1 vote
1 1 answer
582
582 views
vedantk asked Jan 10, 2024
582 views
If it’s DCFL then also construct the DPDA ?
1 1 vote
1 1 answer
559
559 views
1 1 vote
2 2 answers
1.4k
1.4k views
ggwon asked Dec 29, 2022
1,395 views
L = {$a^{n+m}b^{n}a^{m} | n,m \geq 0$}Is the above language DCFL or CFL ?