All Exams Test series for 1 year @ ₹349 only
Question

Which of the following statements is true ?

The correct answer is

The union of two context free languages is context free.

Understanding Context-Free Language Properties

This question asks about fundamental properties of context-free languages (CFLs). CFLs are a class of formal languages that can be generated by context-free grammars or recognized by pushdown automata. Understanding their closure properties is crucial in the study of formal language theory.

Analyzing Each Statement

Statement 1: The union of two context free languages is context free.

This statement claims that if we take two languages, both of which are context-free, their union will also be a context-free language. This is a known closure property of context-free languages. If $L_1$ and $L_2$ are CFLs, there exist context-free grammars $G_1 = (V_1, \Sigma, P_1, S_1)$ and $G_2 = (V_2, \Sigma, P_2, S_2)$ generating $L_1$ and $L_2$ respectively. We can construct a new context-free grammar $G$ for $L_1 \cup L_2$.

Let $G = (V, \Sigma, P, S)$, where:

  • $V = V_1 \cup V_2 \cup \{S\}$, where $S$ is a new start symbol not in $V_1$ or $V_2$.
  • $\Sigma$ is the alphabet (same for both languages).
  • $P = P_1 \cup P_2 \cup \{S \to S_1, S \to S_2\}$.

This new grammar $G$ generates any string derivable from $S_1$ (which are strings in $L_1$) or any string derivable from $S_2$ (which are strings in $L_2$). Thus, $L(G) = L(G_1) \cup L(G_2) = L_1 \cup L_2$. Since we can construct a context-free grammar for $L_1 \cup L_2$, the union of two context-free languages is context-free.

Therefore, this statement is true.

Statement 2: The intersection of two context free languages is context free.

This statement asserts that the intersection of two CFLs is always a CFL. This is false. Context-free languages are not closed under intersection. A classic counterexample involves the language $\{a^n b^n c^m \mid n, m \ge 0\}$, which is context-free, and the language $\{a^m b^n c^n \mid n, m \ge 0\}$, which is also context-free. The intersection of these two languages is $\{a^n b^n c^n \mid n \ge 0\}$. This resulting language is famously not context-free; it is a context-sensitive language.

Therefore, this statement is false.

Statement 3: The complement of a context free language is context free.

This statement suggests that if $L$ is a CFL, its complement $\overline{L}$ (all strings over the alphabet that are not in $L$) is also a CFL. This is also false. Context-free languages are not closed under complementation. If they were closed under complement and also under union (which they are), then by De Morgan's laws ($\overline{L_1 \cap L_2} = \overline{L_1} \cup \overline{L_2}$), they would also be closed under intersection ($L_1 \cap L_2 = \overline{\overline{L_1} \cup \overline{L_2}}$). However, as shown in Statement 2, CFLs are not closed under intersection. Therefore, they cannot be closed under complementation.

Therefore, this statement is false.

Statement 4: If a language is context free, it can always be accepted by a deterministic pushdown automaton.

This statement claims that any CFL can be accepted by a deterministic pushdown automaton (DPDA). This is false. Deterministic pushdown automata accept a strict subset of context-free languages, known as deterministic context-free languages (DCFLs). There are context-free languages that are inherently non-deterministic, meaning they cannot be accepted by any DPDA. A common example of such a language is the set of even-length palindromes over an alphabet $\{a, b\}$, i.e., $\{ww^R \mid w \in \{a, b\}^*\}$. While this language is context-free and accepted by a non-deterministic PDA, it cannot be accepted by a DPDA because the DPDA cannot know where the middle of the string is without reading the entire string and potentially backtracking, which deterministic PDAs cannot do.

Therefore, this statement is false.

Summary of Context-Free Language Closure Properties

Here's a quick overview of the closure properties of context-free languages under common operations:

Operation Closed? Explanation
Union Yes As shown in the analysis of Statement 1.
Concatenation Yes If $L_1, L_2$ are CFLs, $L_1 L_2$ is a CFL. Construct $G$ with start symbol $S \to S_1 S_2$.
Kleene Star Yes If $L$ is a CFL, $L^*$ is a CFL. Construct $G$ with start symbol $S \to S_1 S \mid \epsilon$.
Intersection No Counterexample: $\{a^n b^n c^m\} \cap \{a^m b^n c^n\} = \{a^n b^n c^n\}$.
Complement No Follows from non-closure under intersection and De Morgan's laws.
Intersection with a Regular Language Yes This is a useful property; important not to confuse with intersection of two CFLs.

Based on our analysis, the only true statement is that the union of two context-free languages is context free.

Revision Table: Context-Free Languages

Concept Definition/Property Relevance
Context-Free Language (CFL) Language generated by a Context-Free Grammar (CFG) or accepted by a Pushdown Automaton (PDA). Foundation of the question.
Context-Free Grammar (CFG) A grammar $G=(V, \Sigma, P, S)$ where productions are of the form $A \to \beta$ with $A \in V$ and $\beta \in (V \cup \Sigma)^*$. Formal definition for generating CFLs.
Pushdown Automaton (PDA) A finite automaton extended with a stack; used to recognize CFLs. Formal definition for recognizing CFLs. Non-deterministic PDAs accept all CFLs.
Deterministic Pushdown Automaton (DPDA) A type of PDA where transitions are unique for each state, input symbol, and top of stack symbol. Accepts a strict subset of CFLs (DCFLs).
Closure Property Whether a class of languages remains within the class after applying an operation. Key concept tested in the question (union, intersection, complement).

Additional Information: Chomsky Hierarchy and Language Classes

Context-free languages are part of the Chomsky Hierarchy, a classification of formal languages by their generative power. The hierarchy consists of four levels (Type 0 to Type 3):

  • Type 0: Recursively Enumerable Languages
    Accepted by Turing machines. Most general class. Closed under union, concatenation, Kleene star, intersection. Not closed under complement.
  • Type 1: Context-Sensitive Languages (CSLs)
    Generated by context-sensitive grammars. Accepted by linear bounded automata. Closed under union, concatenation, Kleene star, intersection, complement. $\{a^n b^n c^n\}$ is a classic example of a language in this class that is not context-free.
  • Type 2: Context-Free Languages (CFLs)
    Generated by context-free grammars. Accepted by pushdown automata. Closed under union, concatenation, Kleene star. Not closed under intersection or complement.
  • Type 3: Regular Languages (RLs)
    Generated by regular grammars. Accepted by finite automata. Closed under all common operations: union, concatenation, Kleene star, intersection, complement, difference, etc. Regular languages are a proper subset of deterministic context-free languages, which are a proper subset of context-free languages.

Understanding this hierarchy helps place context-free languages in perspective and clarifies their relationships with other language classes regarding closure properties and accepting automata.

Was this answer helpful?

Important Questions from Context Free Languages - Teaching

  1. Consider the following statements about Context Free Language (CFL):

    Statement I: CFL is closed under homomorphism.

    Statement II: CFL is closed under complement.

    Which of the following is correct?

  2. Match List-I with List-II:

    Where L1: Regular language

    L2: Context-free language

    L3: Recursive language

    L4: Recursively enumerable language

    List-1

    List-2

    (a) L' 3 U L 4

    (i) Context-free language

    (b) L' 2 U L 3

    (ii) Recursively enumerable language

    (c) L 1* ∩ L 2

    (iii) Recursive language

    Choose the correct from those given below: 

  3. How can the decision algorithm be constructed for deciding whether context-free language L is finite?

    (a) By Constructing redundant CFG in CNF generating language L

    (b) By constructing non-redundant CFG G in CNF generating language L

    (c) By constructing non-redundant CFG in CNF generating language L-{∧} (∧ stands for null)

    Which of the following is correct?

  4. Consider the following statements with respect to the language L = {a nb n|n≥ 0}

    S 1: L 2is context free language

    S 2: L kis context-free language for any given k ≥ 1

    S 3: L̅ and L* are context free languages

    Which one of the following is correct?

  5. Consider the following languages:

    \({L_1} = \left\{ {{a^n}{b^n}{c^m}} \right\} \cup \left\{ {{a^n}{b^m}{c^m}} \right\},\;n,\;m \ge 0\)

    \({L_2} = \{ w{w^R}|w \in \left\{ {a,\;b} \right\}*\}\) Where R represents reversible operation.

    Which one of the following is (are) inherently ambiguous language(s)?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App