Practice Questions (Lectures) Flashcards

1
Q

Prove that the language
L = {ww: w ∈ {a, b}∗}
is not CF

A
  • We know that L1 =
    {a^ib^ja^ib^j: i, j ≥ 0} is not CF
  • Assume L is CF
  • Then by closure theorem 2, language
    L ∩ a∗b∗a∗b∗ is CF
  • But, language {ww: w ∈ {a, b∗} ∩ abab = {a^ib^ja^ib^j: i, j ≥ 0} is not CF (Thm 4), giving CONTRADICTION
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

L = {w ∈ {a, b}∗ : w has the same number of a’s and b’s}
is context- free

A

Yes, proved by constructing a PDA and applying the Main Theorem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

L = {w ∈ {a, b, c}∗: w has the same number of a’s, b’s and c’s}

L = {a^pb^n: p ∈ Prime, n > p}

are not context-free

A

Yes, proved by PL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Prove that L =
{a^mb^n: m ≥ n}
is CF

A

Construct a grammar G such that
L(G) = {a^mb^n: m≥n}
as follows:

G = (V, Σ, R, S)
where
V = {a, b, S}, Σ = {a, b}
R = {S → aS|aSb|e}

Derivation examples
S ⇒ aS ⇒ aaS ⇒ aaaSb ⇒ aaab

S ⇒ aSb ⇒ aaSbb ⇒ aaaSbbb ⇒ aaabbb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly