Articles of context free grammar

How to construct a context free grammar $G$ such that $L(G) = \{ a^i b^j c^k| j \gt i+k\} $?

How to construct a context free grammar $G$ such that $L(G) = \{ a^i b^j c^k| j \gt i+k\} $? I don’t have much idea how to approach this one. Could some help me to understand how to approach these kinds of problem?

Is $L=\{o^{i}1^{i}o^{j}1^{i} | i,j>0\}$ a context free language?

I need to find and to prove (by the pumping lemma or by building a grammar) if $L=\{o^{i}1^{i}o^{j}1^{i} | i,j>0\}$ is a context free language. I would like to get some help. thanks!

Greibach normal form conversion

I’m trying to convert this into GNF: $S \rightarrow ASaa | bab$ $A \rightarrow Ba | bAB$ $B \rightarrow abba$ So I’m getting this, but I’m not sure understanding and applying correctly the concept of where exactly the variables and terminals should be in this format: $S \rightarrow a A_0 S_0 | b A B […]

Why is it hard to parse unambiguous context-free grammar in linear time?

From this question, I gather that whether unambiguous CF grammar can be parsed in linear time is an open problem. I’d like to know what the major roadblocks to achieve this are. That is, what made the attempts to produce such a parser fail ?

Why can't we use memoization to parse unambiguous context-free grammars in linear time?

This is a follow-up question to Why is it hard to parse unambiguous context-free grammar in linear time? I know that Parsing Expression Grammars (PEG) can be parsed in linear time using a packrat parser. Those parser use memoization to accomplish the linear time complexity: basically each non-terminal can be “expanded” at most once at […]

Are regular languages necessarily deterministic context-free languages?

The original problem Suppose M is DCFL (Deterministic Context Free Language) and N is a regular language. Answer the following questions and justify your answers. a) Is M-N necessarily context-free? b) Is N-M necessarily context-free? My attempt Since DCFLs are closed under complementation, if N is DCFL, then both a and b are true, but […]

Finding an appropriate value to contradict the pumping lemma.

I am trying to prove that $L=${$a^mb^n | n=m^2$} is not a CFL with the help of the pumping lemma for CFL’s. I chose $w=a^mb^{m^2}$ = $a^{m-S}a^Sb^Tb^{m^2-T}$ $\in L$ And now in order to contradict the pumping lemma assumption I am looking for $i$ such that $a^{m-S}a^{S^i}b^{T^i}b^{m^2-T}$ $\notin L$ for $i>=0$. Is it possible to […]

Is $L_1$ context free language?

Let $L = L_1 \cap L_2 $, where $L_1$ and $L_2$ are languages as defined below: $L_1= \left \{ a^m b^mca^nb^m \mid m,n \geq 0 \right \}$ $L_2=\left \{ a^i b^j c^k \mid i,j,k \geq 0 \right \}$ Then L is Not recursive Regular Context free but not regular Recursively enumerable but not context free. […]

Confusion related to context sensitive grammar creation

I was reading this wikipedia article for generating grammar. They have mentioned that for generating null string in the grammar we can have a rule $$S \rightarrow \lambda$$ only if $S$ doesn’t appear on the right of any production rule. However in some examples like the following $L(G) = \{ a^nb^n : n \ge 0 […]

Live Variables in Context Free Grammar

A variable $A$ in a context free grammar $G= \langle V, \Sigma, S, P\rangle$ is live if $A \Rightarrow^* x$ for some $x \in \Sigma^*$. Give a recursive algorithm for finding all live variables in a certain context free grammar. I don’t necessarily need an answer to this. Mostly I am having a very difficult […]