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.
Questions tagged [context-free-language]
183 questions
1
vote
1 answer
construction of a^(2^i) language grammar
I'm kind a stuck with automaton and grammars problem. I've searched a lot but without any success.
Is it even possible to construct a grammar generating this language L?
L = { a(2i) | i >= 0}
Can anyone provide me with simple solution?

petrbel
- 2,428
- 5
- 29
- 49
1
vote
1 answer
The complement of the language L={a^n b^n | n !=100}
I dont need a proof, since this is an objective exam question and allowed 2 mins only. The options are regular or cfl or csl. I dont understand how to tackle this.
If we I write it as
(a^n b^n | n<100) UNION (a^n b^n | n>100)
Now call first part…

Gate Aspirant
- 21
- 1
- 3
0
votes
0 answers
Recognize the type of the given formal language
Yesterday i did my exam of formal languages and there was a question which asked you to recognize what type of language was this:
X={a,b,c}
L={w€X*|#(a,w) + #(c,w) = 3n, n>=0}
where #(x,w) is the number of occurency of the symbol x€X in the word…

Juj_11
- 1
- 2
0
votes
0 answers
CFGs for languages L1 and L2 where #a's > #b's and #a's >= #b's
Regarding the language L2 where the #a's >= #b's I thought of the following:
S -> SaSbS
S -> SbSaS
S -> SaS
S -> ε
When it comes to L1 I thought of utilising L2 in the following way and give an infinite degree of freedom to the number of a's:
S ->…

RookieCookie
- 302
- 3
- 12
0
votes
0 answers
concatenation of a context-free language
If A is a language over {1,2,3}. Using A and the string variables p and q, we mathematically define the language B over {0,1,2,3}:
B = { p0q1 | p is empty or is a string in A, and q consists of one or more 2}
What is the smallest language class that…

kiwi kiwi
- 21
- 1
0
votes
1 answer
what is the Context-Free Grammar for the following language?
Here is the language and I want to create a context-free grammar for it:
b(bc+a)*a(a+b)*c*
Here is my answer but I don't know if it's right or not:
S → bAaB
A → bcA | aA | epsilon
B → cB | aB | epsilon

zephyrus
- 1
0
votes
0 answers
Context-Free grammar with numbers
I am currently looking at context free grammars, I have the grammar: 'S->3, S->4, S->(S+S)', what words would be accepted by the language generated by this grammar? I'm guessing '3' and '4', but the main thing I'm wondering is what the (S+S)…

pythonoob
- 35
- 4
0
votes
1 answer
Can this language be expressed with a regular expression?
The given language is:
B = { aibic2m | i ≥ 0, m ≥ 0 } ∪ { arbsc2t | r ≥ 4, s ≥ 4, t ≥ 0}
My Prof has provided a regular expression for this language which is:
a4a* b4b* (c2)* + (epsilon + ab + a2b2 + a3b3)(c2)*
I believe that this is incorrect and…

RipLearning
- 11
- 2
0
votes
0 answers
languages, pumping-lemma and myhill-nerode-equivalence-classes
Is it possible that a context-free-language has infinite myhill-nerode-classes or is there a way to narrow down (in terms of chomsky hierachy) which kind of classes can or can't have infinite myhill-nerode-classes?
I have a problem where I should…

SmallBrainStudent
- 11
- 3
0
votes
0 answers
Is there any way to count the production of specific rules in order in a context free grammar?
Is there any way to use a counter in context-free grammars?
I need to add a module number (for example starting from M1:0, M1:1, ... , M1:K representing the module number) and I want to count every block productions in order. The following…

S.EB
- 1,966
- 4
- 29
- 54
0
votes
0 answers
Specification of DFA accepting ≡∪∈N
Why it is impossible to specify a single DFA that accepts ≡∪∈N, although an individual machine can be constructed for each ?

Aries
- 1
0
votes
1 answer
CFG for L = {a^mb^nc^k: k = m×n}
Can we write CFG for this language? I searched multiple websites but I couldn't find any answers.

Alex
- 13
- 2
0
votes
0 answers
Confused with creating a Context-Free Grammar rule
I'm kind of confused as to whether or not my answer is correct. I'm not asking anyone to give me the right answer if I'm wrong but rather I would like to know if my understanding for this topic is correct because if it is not, then if possible I…
user17565317
0
votes
1 answer
description of the language accepted by S->SS|bS|a
I want to know what language is generated by this CFG
S → SS | bS | a
I have obtained some strings but cannot find a pattern
abbaaaa
aaaaaaa
ba
aaaaa
aaaaaaabaaaabbaa
babaaabaaaba
bbbababaababaa
baabaa
baa
aaaaaabbaaabbba

cmgchess
- 7,996
- 37
- 44
- 62
0
votes
1 answer
Is it possible for an ambiguous CFG to convert into GNF?
So I was studying how to convert CFG to GNF and I tried to do it using my letters in my name so the production rule would be like:-
A->AkS|SA
S->AtA
Where S,A are Non Terminals and k,t are terminals
but this is an ambigous CFG, so can we convert it…

Saneet Kaul
- 11