Questions tagged [context-free]

Questions about the set of languages (equivalently) described by context-free grammars or accepted by (non-deterministic) pushdown automata.

1715 questions
7
votes
2 answers

Examples of Context Free Languages

I'm having a hard time thinking of context free languages. The only example I've been able to think of is $0^n1^n$, but I'm having a hard time thinking of any others. Can I get some examples?
user67794
  • 71
  • 1
  • 4
6
votes
0 answers

Is it decidable if this zipping operation gives a context-free language?

Motivation Consider the following languages, are they context-free? $\{x \# y: x \neq y\}$ $\{x y: |x|=|y|, x \neq y\}$ $\{x \# y: |x|=|y|, x \neq y\}$ $\{x y: |x|=|y|,d(x,y)>1\}$ $\{x x\}$ The first three are explained here, the fourth one is…
sdcvvc
  • 3,491
  • 18
  • 28
4
votes
1 answer

Complement of CFL is Recursive

If CFL are not closed under complementation, it means that if a language '$L$' is CFL then its compliment $L^C$ is not CFL. Then how can we discuss about $L^C$ being recursive? My doubt arose because I think if a language cannot be decided CFL or…
Vidhi
  • 75
  • 7
4
votes
1 answer

Does Reverse Polish Notation have an LL grammar?

Let L be the language of all arithmetic expressions written in Reverse Polish Notation, containing only binary operators. $\Sigma(L) = \{n, o\}$, n := number, o := operator. Is there an LL grammar G so that L(G) = L?
Tim Diels
  • 151
  • 5
3
votes
1 answer

Is the Complement of the Language $L=\{wxw^r|w \in (a+b)^+, x \in (a+b) \}$ Context free?

I know that the Context-free languages are not closed under compliment. Given $L=\{wxw^r| w \in(a+b)^+,x \in (a+b)\}$ and this is a Context free language. I think it's compliment will contain words of the form $ww$ which comes under CSL.So, I think…
user3767495
  • 329
  • 1
  • 5
  • 13
3
votes
1 answer

$L$ is a context free language so prefix$(L)$ is also a context free language

In case $L$ is context free language. $L_1 \setminus L_2 = \{x\in \Sigma ^* : \exists y\in L_2$ s.t $xy\in L_1 \}$ when $L_2$ is regular, is a context free language, thus using $L_1 = L$ ,$L_2 = \Sigma ^*$ one conclude that prefix$(L)$ is context…
user5721565
  • 249
  • 2
  • 9
3
votes
1 answer

Compute context free grammars for twice the amount

$$\{ a^{k}b^{j} : k = 2j , k \geq 0\}$$ I'm trying to wrap my head around CFG's but I am having trouble. From this language, there should be twice as many a's than b's. Here is my attempt. $$S \to aSb \ | \ a Sa \ | \ \epsilon $$ $$S \Rightarrow aSb…
mrtaz
  • 133
  • 3
3
votes
1 answer

Solving the emptiness problem for a CFG in Chomsky normal form (linear)

Given a CFG in Chomsky normal form, is there an algorithm that solves the emptiness problem in linear runtime? I thought about using depth search here, but I think it's a little bit above linear runtime.
Julian
  • 133
  • 4
3
votes
1 answer

Designing context free grammar for a language with range restriction on repetition of alphabets

I am having issue with designing contex free grammar for the following language: $L = \{0^n 1^m \, | \, 2n \leq m \leq 3n \}$ I can design for the individual cases i.e. for $m \geq 2n$ and $m \leq 3n$ but don't know how should i combine both. Or is…
3
votes
1 answer

Unambiguous but nondeterministic context-free language?

Whenever deterministic context-free languages are discussed, the webpage/textbook would always give a side note saying that although deterministic context-free languages are never ambiguous, unambiguous context-free languages may still be…
ithisa
  • 357
  • 2
  • 9
2
votes
1 answer

How do you describe a language that is generated by Context Free Grammer

I am familiar with describing Regular Expressions but when it comes to describing CFG I get confused. Do you describe it in words like you would regular expressions or do you do something like this ? this is the CFG I am trying to describe S -> SS…
Dana
  • 355
  • 2
  • 5
  • 13
2
votes
2 answers

What does this context-free grammar generate?

The grammar is $$ S\to aSb\ |\ bSa\ |\ SS\ |\ \epsilon. $$ I think this generates the set of strings with equal numbers of $a$'s and $b$'s based on examples I've done. Is this correct?
redundant6939
  • 69
  • 1
  • 4
2
votes
1 answer

Would it be possible that the intersection of two non-context-free languages is context-free?

Assume two languages $L_1$ and $L_2$, both of which are non-context-free. Let $L = L_1 \cap L_2$. Could $L$ be context-free?
ylorn
  • 51
  • 4
2
votes
1 answer

Is the union of two CFLs minus their intersection a CFL?

I've seen the classical proofs of CFLs are not closed under intersection or complement, but I haven't been able to wrap my head around this. Intuitively, I think that this would be not a CFL but I can't think of any counterexamples.
2
votes
2 answers

Union of non-context free languages

For two languages over the same alphabet, if neither of them is context-free, can their union still be context-free? If not, does one of the languages need to be context-free for this to happen? Do both need to be context-free?
Ayaz Vural
  • 21
  • 2
1
2 3 4 5 6 7 8