Provide context-free grammars for the following languages :
(a) {(a^n)(b^m) | n ≥ (2^m)}.
(b) {(a^i)(b^j)(c^k)(d^l)| i + j = k + l}.
(a). {(a^n)(b^m) | n ≥ (2^m)}
S -> aaSb | aS | λ
(b) If this solution seems strange, it may seem less so if you tackle this problem first. We introduce two non-terminals, L1 and L2 - the first will produce all legal strings with more a's than d's, and the second will produce more d's than a's. For the first we give the production rules
L1→aL1d
L1→M1
M1→aM1c
M1→N1
N1→bN1c
Similarly,
L2→aL2d
L2→M2
M2→bM2d
M2→N2
N2→bN2c
Clearly distinguishing between N1 and N2 is unnecessary, but I think it makes the presentation more readable. Finally, to formally put this into a proper CFG we add in
S→L1
S→L2
N1→ε
N2→ε
where S is the start symbol, and εε is the empty string
Provide context-free grammars for the following languages : (a) {(a^n)(b^m) | n ≥ (2^m)}. (b) {(a^i)(b^j)(c^k)(d^l)| i...
Give context-free grammars that generate the following languages. { anw | w in { a, b }*, |w| = 2n, n > 0 } { an bm | n, m ≥ 0; n < 2m } { anx an y | n > 0, x,y in { a, b }* } { ai bj ck | i, j, k ≥ 0; j = i + k }
Formal Languages & Automata Theory 1411372
Pages 133,134
Problems: 7(a,b), 8 (b,c)
5.1 CoNTEXT-FREE GRAMMARS 133 EXERGISES 7. Find context-free grammars for the following languages (with n 2 0, m 0) (a) L = {a"b"": n < m + 3).
Question 3 (5 Points) Find context free grammars L = a"b",n is a multiple of three Find context-free grammars for the following languages (with n 2 0, m 2 0) ** L = {a"bm : n < m+3}. (a) (b) L= {a"bm : n = m - 1}. L = {a"bm 2m}. L {a"b" 2n < m < 3n}. (c) (d)
Can someone do PART C ONLY (k=n+m) please??
Thanks!!
12. Find context-free grammars for the following languages (with n2 0, m 2 0, k 20): (a) L = {anlynck : n = m or m k). (b) L = {anbmck : n = 111 or 111 # k}
Construct context-free grammars that generate each of these languages: A. tw E 10, 1 l w contains at least three 1s B. Hw E 10, 1 the length of w is odd and the middle symbol is 0 C. f0, 1 L fx l x xR (x is not a palindrome) m n. F. w E ta, b)* w has twice as many b's as a s G. a b ch 1, J, k20, and 1 or i k
2. (10 points) Use the pumping lemma for context free grammars
to show the following languages are not context-free.
(a) (5 points)
.
(b) (5 points)
L = {w ◦ Reverse(w) ◦ w | w ∈ {0,1}∗}.
I free grammar for this language L. lemma for context free grammars to show t 1. {OʻPOT<)} L = {w • Reverse(w) w we {0,1}*). DA+hattha follaurino lano
3.) a. Explain the difference between context free and context sensitive languages and grammars. Provide an example of a context free language and a context sensitive language (that is not Context free) b. Explain the differences in the grammar representation (i.e. specifically state what grammar constructs are allowed in a Context Sensitive Grammar as compared to a Context Free Grammar)
Give context-free grammars that generate the following languages (E = {a,b}). (a) (1 point) L1 = {w | W contains at least two b's} (b) (1 point) L2 = {w/w = wf, w is a palindrome} (c) (1 point) L3 = {w w contains less a's than b's}. (d) (1 point) LA = {w w = ayn+1, n > 2} (e) (1 points) Ls = {w w = a";2(m+n)cm, m, n >0}; (S = {a,b,c}).
Write the context-free grammars which generate the following languages: a. ?={?∈{?,?}∗ | ? is an odd length string}
Give context-free grammars for the following languages: (b) {w € {a,b}* : na(w) # 2n6(w)}