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
1
vote
1 answer

Is L = {a^mb^nc^k | if (m=n) then (n=k) } CFL or not?

I see that in this language , by the time we are deciding m=n; then we have no b's left; so we can't sompare them with c's.So, i think it should NOT be CFL. But below solution shows that it is CFL In the above given solution, is L2 CFL correct ?
1
vote
0 answers

Generating Grammar from Language

While there are enormous resources to convert a CFG(Context Free Grammar) to language, there isn't any resource to create a CFG out of a given sentence. Basically, I am trying to use the grammar to do a CKY parsing and generate tree. Currently, If…
1
vote
2 answers

Construct a grammar over {a,b} whose language is

Construct a grammar over {a,b} whose language is {a^m b^n | 0 <= n <= m <= 3n} I am not sure how to go about this problem, I started out by doing n >= 0 m >= n 3n >= m S -> a S b | a S bb
raywrigh
  • 11
  • 2
1
vote
2 answers

Describe the language generated by this context-free grammar

I have the following grammar, S -> Sb S -> aaSb S -> b The typical derivations in this grammar are S => Sb => [aaSb]b => [aa[b]b]b => aabbb for n = 1 S => Sb => [aaSb]b => [aa[aaSb]b]b => [aa[aabb]b]b => aaaabbbb for n = 2 Edit: So I claimed…
1
vote
1 answer

I have seen two questions, and I don't know how to answer this

Is the language of strings which are not of the form t#t, where t is an arbitrary string over {0,1} a CFL? I don't know to solve this. Another question is that: Is the set consisting of: production rules of Grammers that are CFGs, itself a regular…
1
vote
1 answer

Proving that the set difference of a CFG and a regular language is also context free

I need help proving the set difference between a context free grammar A and a regular language, B, is a context free language. I'm trying to prove by example like this: Let A = {a^n b^n | n >= 1} Let B = {w {a,b}* | w has atleast three a's } Then…
1
vote
0 answers

How to prove a Language is NOT Context Free

I've been watching a lot of videos about how to prove this and I am getting mixed information about how to do so. In the case of contradiction, I am getting two different approaches and I want to know which is correct. Example: L = {a^n b^n+1…
msc
  • 67
  • 8
1
vote
1 answer

How to convert cfg to pda with 2 states?

i'm running into some problem for my research in computer science theories... Can any one explain me the algorithm that how we can convert a context-free grammar(cfg) to corresponding push down automata(pda) With just 2 state ?
1
vote
1 answer

Constructing a linear grammar for the language

I find difficulties in constructing a Grammar for the language especially with linear grammar. Can anyone please give me some basic tips/methodology where i can construct the grammar for any language ? thanks in advance I have a doubt whether the…
1
vote
3 answers

Context-free grammar for L = {2^x ∗ 2^y ∗ 2^z = 2^(x+y+z) | x, y, z > 0}

The title explains it. I have trouble with synchronizing the left side of the "equation" with the right one, as whenever I generate a 2 on the left, one on the right has to appear. Could it be that this language isn't context-free? Thanks in…
Nanuna
  • 11
  • 2
1
vote
1 answer

What does CFG production rule look like in code?

There is so much info out there but non of this really helps a noob like me. I read a lot of articles about context-free-languages and pushdown automation. Now im trying to understand how certain things might look in code. Lets assume we defined a…
Asperger
  • 3,064
  • 8
  • 52
  • 100
1
vote
1 answer

Is this context free language regular?

If I have a language {0,1} defined by the following context-free grammar with start variable S, is it a regular language? S→TS, S→1T, S→1S T→TT, T→0T1, T→1T0 T→ε Is this language regular? It seems to me that this language cannot be regular because…
Archeofuturist
  • 215
  • 5
  • 18
1
vote
1 answer

Context free and regular language with push-down automata and infinite elements

I was doing my HW assignment for my theory class and came across a problem that I don't really even know where to begin. We are covering the section of Push-Down automata. "Let L1 be a context-free language and L2 be regular. Show that there exists…
1
vote
1 answer

Why regular languages should not have unit rules Variable -> Variable?

I was reading about regular languages. I did not understand one thing. Why Variable -> Variable is not allowed ? What is the reasoning behind it ? What happens if there is such a rule ? What kind of grammar does it become ?
1
vote
0 answers

Check if word is part of contextfree language

Good evening to all! As a fan of regular expressions in Perl, I came up with a question, which I could not answer by googling and searching for myself. So let me give you a minimal example of my problem: I have two…
Otterbein
  • 544
  • 3
  • 12