Questions tagged [context-free-language]

In formal language theory, a context-free language (CFL) is a language generated by some context-free grammar (CFG). The set of regular languages is a subset of the set of context-free languages.

183 questions
0
votes
1 answer

Constructing a CFG

I literally can't find the answer to this: L = {vw | v element of {a,b), w element of {b,c}, number of a's <= number of c's} V --> aV | bV | e W --> bW | cW | e But I cannot think of how to combine the construction of the words v and w after one…
0
votes
0 answers

Language accepted PDA

Suppose we have the following PDA: M= delta(q0, 1, $) = {(q0, X$)} delta(q0,λ, $) = {(q0, λ)} delta(q0, 1, X) = {(q0, XX)} delta(q1, 1, X) = {(q1, λ)} delta(q0, 0, X) = {(q1, X)} delta(q1, 0, $) = {(q0, $)} my…
0
votes
1 answer

Unambiguous Context free Grammar

I was reading through Context Free Grammar, and I came across ambiguous grammar. If the language produced by CFG has more then 1 parse tree, then CFG is an ambiguous grammar. Is there any way by which I can find out or prove that the grammar is…
0
votes
1 answer

Context-free language not closed under intersection

I found this solution on Wikipedia. Shouldn't it say: j>n≥ 0 Because the intersection are elements that are common in both languages. Consider the languages L1 and L2 defined by L1={a^(n)b^(n)c^(j)| n,j ≥ 0} and L2 = {a^(j)b^(n)c^(n): n,j ≥ 0}.…
Jonathan Lam
  • 185
  • 2
  • 3
  • 12
-1
votes
1 answer

Is the language L = { a^n b^j : j ≤ n ≤ 2j − 1 } context-free?

Is the language L = { anbj : j ≤ n ≤ 2j − 1 } context-free? I have no idea how to start with this exercise. I am familiar with the pumping lemma, but I have no idea how I should use it here. It seems to me that this language is context-free and that…
Ronald
  • 157
  • 6
-1
votes
1 answer

CFG for a = b and c = d (length)

I know how to construct the context-free grammars for strings that have same counts of a and b, or have the same counts of c and d: S → ε S → ε S → SASBS S → SCSDS S → SBSAS S → SDSCS A → a C → c B → b …
-1
votes
1 answer

converting CFG to regular expression

Here's a CFG that generates strings of 0s, 1s, or 0s and 1s arranged like this (001, 011) where one of the characters must have a bigger count than the other like in 00011111 or 00000111 for example. S → 0S1 | 0A | 0 | 1B | 1 A → 0A | 0 B → 1B |…
-1
votes
1 answer

What makes this example a context-free language rather than regular language?

I'm having trouble seeing what makes "any number of a's followed by the same number of b's and c's" a context-free language, while "any number of a's followed by any number of b's followed by any number of c's" is a regular language, as I saw…
-1
votes
1 answer

How to remove left recursion from A -> Aα | ε

I think the left-recursion for this grammar is not removable. Correct me if I am wrong. α is Alpha that is a Non-terminal ε is Epsilon.
-1
votes
1 answer

Need help in generating a CFG for a language

I want to match strings that contain "k" number of 0's followed by "k+4" number of 1's where k is greater than or equal to zero I tried the following grammar is this correct? S->0S1|1111
-1
votes
1 answer

Make a grammar unambiguous?

I have the following problem. This grammar is ambiguous: stmt -> if expr then stmt stmt’ | a stmt’ -> else stmt | EPSILON expr -> b I tried to modify it and my result is: stmt -> if expr then stmt’’ | a stmt’’ -> stmt | stmt’ stmt’ -> B else…
-1
votes
1 answer

One Language and Proof How it's ambiguous?

I just took my midterm but couldn't answer this question. How we can show the following language is ambiguous ? L={a n bm c p : n≠m} U {a n bm c p : m≠p} I think this is very hard, Who can Help me with automated tools or ... how we can…
-1
votes
1 answer

Determine if a language is context free

Lets say you have a language L and you want to determine if it is context free. Context free languages intersected with regular languages are context free. Is that enough to prove that L is context free? Meaning, L intersect P = T Where P is a…
John Smith
  • 99
  • 1
  • 2
  • 13
-1
votes
1 answer

CFG and DCFG Decidable problems

Can you guys list the problems that you are aware that are decidable for Context free Language and for Deterministic Context free languages. I did get some info on list of undecidable problems on Stack Overflow and Wiki, but not related to CFG or…
Nikhil Mahajan
  • 54
  • 1
  • 2
  • 12
1 2 3
12
13