FORMAL LANGUAGE & AUTOMATA THEORY

100406
Back to FORMAL LANGUAGE & AUTOMATA THEORY

Module 3: Context-Sensitive Languages

  1. Q1c. The language: L = \{ a^m b^n c^{m+n} \mid m,n \ge 1 \} is: (i) regular (ii) context-free but not regular (iii) context-sensitive but not context-free (iv) type-0 but not context-sensitive20212m

    Module 3: Context-Sensitive Languages

    The language:

    L={ambncm+n∣m,n≥1} L = \{ a^m b^n c^{m+n} \mid m,n \ge 1 \}

    is:

    (i) regular
    (ii) context-free but not regular
    (iii) context-sensitive but not context-free
    (iv) type-0 but not context-sensitive

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (ii) Context-free but not regular

    Explanation

    L={ambncm+n∣m,n≥1}L = \{ a^m b^n c^{m+n} \mid m,n \ge 1 \}.

    Not Regular

    Use Pumping Lemma. Let pp be pumping length, w=apbpc2p∈Lw = a^p b^p c^{2p} \in L. Pumping yy in aa segment breaks m+nm+n balance.

    Context-Free

    PDA construction:

    1. Push aa’s (m times) → stack =Am= A^m.
    2. Push bb’s (n times) → stack =AmBn= A^m B^n (or same symbol).
    3. For each cc, pop one symbol. Accept if empty after m+nm+n cc’s and no extra input.

    Alternatively grammar:
    S→aSc∣aTcS \rightarrow a S c \mid a T c
    T→bTc∣bcT \rightarrow b T c \mid b c

    This generates ambncm+na^m b^n c^{m+n}.

    Not context-sensitive requirement beyond; CFL suffices, but not regular. Not Type-0/1 only.

    Final Answer

    Context-free but not regular → Option (ii).

  2. Q1d. The language \{ a^n b^n c^{n+m} \mid m, n \ge 1 \} is: (i) regular (ii) context-free but not regular (iii) context-sensitive but not context-free (iv) type 0 but not context-sensitive20232m

    Module 3: Context-Sensitive Languages

    The language {anbncn+m∣m,n≥1}\{ a^n b^n c^{n+m} \mid m, n \ge 1 \} is:

    (i) regular
    (ii) context-free but not regular
    (iii) context-sensitive but not context-free
    (iv) type 0 but not context-sensitive

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (iii) Context-sensitive but not context-free (and hence not regular)

    Explanation

    L={anbncn+m∣m,n≥1}={anbnck∣k=n+m>n}L = \{ a^n b^n c^{n+m} \mid m,n \ge 1 \} = \{ a^n b^n c^{k} \mid k = n+m > n \}.

    Not Context-Free

    Assume LL is CFL, let pp be pumping length. Take w=apbpcp+1∈Lw = a^p b^p c^{p+1} \in L (n=p,m=1n=p, m=1). By pumping lemma for CFL, w=uvxyzw = uvxyz with ∣vxy∣≤p|vxy|\le p, ∣vy∣>0|vy|>0. Pumping must stay within first pp aa's or bb's or cc's. Any pumping changes counts and breaks condition #c>#a=#b \#_c > \#_a = \#_b (or breaks anbna^n b^n). Formal proof shows LL not CFL. Equivalent to anbncna^n b^n c^n (which is not CFL) with extra cmc^m tail; intersection with regular a∗b∗c∗a^*b^*c^* does not help but L∩a∗b∗cpL \cap a^*b^*c^p style shows non-CFL.

    Context-Sensitive

    It is accepted by Linear Bounded Automaton. Grammar is context-sensitive:

    S→aSBC∣aBCS \rightarrow a S B C \mid a B C
    CB→BCCB \rightarrow BC
    aB→aba B \rightarrow a b
    bB→bbb B \rightarrow b b
    bC→bcb C \rightarrow b c
    cC→ccc C \rightarrow c c

    This is Type-1 (CSG) but not Type-2. It is decidable but not CFL.

    Final Answer

    CSL but not CFL → Option (iii). Also not regular; ultimately Type-1 in Chomsky hierarchy.

  3. Q1e. Which production is not allowed in a CSG? (i) AB \rightarrow BA (ii) A \rightarrow \epsilon (iii) A \rightarrow a (iv) a B \rightarrow a b20252m

    Module 3: Context-Sensitive Languages

    Which production is not allowed in a CSG?

    (i) AB→BAAB \rightarrow BA
    (ii) A→ϵA \rightarrow \epsilon
    (iii) A→aA \rightarrow a
    (iv) aB→aba B \rightarrow a b

    View this question on its own page →
    Worked Solution

    Answer

    Correct Option: (ii) A→ϵA \rightarrow \epsilon

    Explanation

    Context-Sensitive Grammar (CSG, Type-1): Production α→β\alpha \rightarrow \beta where α,β∈(V∪T)∗\alpha,\beta \in (V\cup T)^* and ∣α∣≤∣β∣|\alpha| \le |\beta| (non-contracting), except possibly S→ϵS \rightarrow \epsilon with SS not appearing on RHS.

    Check each:

    • (i) AB→BAAB \rightarrow BA : ∣α∣=2|\alpha|=2, ∣β∣=2|\beta|=2 → 2≤22 \le 2 allowed (context-sensitive, length-preserving).
    • (ii) A→ϵA \rightarrow \epsilon : ∣α∣=1|\alpha|=1, ∣β∣=0|\beta|=0 → 1≤01 \le 0 false, contracting, not allowed in CSG (unless A=SA=S and SS is start with special ϵ\epsilon rule).
    • (iii) A→aA \rightarrow a : 1≤11 \le 1 allowed.
    • (iv) aB→abaB \rightarrow ab : 2≤22 \le 2 allowed (context aa).

    Hence only A→ϵA \rightarrow \epsilon violates the monotonicity condition.

    Final Answer

    Not allowed: A→ϵA \rightarrow \epsilon → Option (ii).

  4. Q6a. Prove that every context-free language is context-sensitive, but the converse is not true. Support your answer with a suitable language example.20257m

    Module 3: Context-Sensitive Languages

    Prove that every context-free language is context-sensitive, but the converse is not true. Support your answer with a suitable language example.

    View this question on its own page →
  5. Q6b. Given the following context-sensitive grammar: S \rightarrow aSBC | abc CB \rightarrow BC aB \rightarrow ab bB \rightarrow bb bC \rightarrow bc cC \rightarrow cc Identify the language generated by the grammar. Derive the string aabbcc step by step.20257m

    Module 3: Context-Sensitive Languages

    Given the following context-sensitive grammar:
    S→aSBC∣abcS \rightarrow aSBC | abc
    CB→BCCB \rightarrow BC
    aB→abaB \rightarrow ab
    bB→bbbB \rightarrow bb
    bC→bcbC \rightarrow bc
    cC→cccC \rightarrow cc

    Identify the language generated by the grammar. Derive the string aabbcc step by step.

    View this question on its own page →
  6. Q7a. Define a Linear Bounded Automaton (LBA). Design an LBA that accepts the language L = \{a^n b^n c^n | n \ge 1\}. Explain how tape length is restricted.20257m

    Module 3: Context-Sensitive Languages

    Define a Linear Bounded Automaton (LBA). Design an LBA that accepts the language L={anbncn∣n≥1}L = \{a^n b^n c^n | n \ge 1\}. Explain how tape length is restricted.

    View this question on its own page →