Prove that language $L = \{a^ibi+jc^j \;|\; 1 \leq i \leq j\}$ is not context-free.
Suppose, for contradiction,
-
$p$ is the “pumping length”. - For every word
$z ∈ L$ ,$z = uvwxy$ , s.t. -
$\abs{vwx} \leq p$ . -
$\abs{vx} \geq 1$ . -
$uv^nwx^ny ∈ L$ .
Consider
It is easy to see none of the above can be pumped: if
Another two possible decompositions are:
-
$v = a^r$ and$x = b^s$ . However, again, if we pump$as$ , i.e.$r ≠ 0$ , then eventually there will be more$as$ than$cs$ . And similarly for$bs$ . When we pump$as$ and$bs$ together, eventually there will be more$as$ than$cs$ , again, contradicting$i \leq j$ . - Thus the only case worth considering is where
$v = b^r$ and$x = c^s$ . Consider the word $z = a^pb2pc^p ∈ L$ with this decomposition. If either$r = 0$ or$s = 0$ , we proceed as above, however, if$r = s ≠ 0$ , then it must be the case that for all words $z’ = a^pbp+p-r+r*icp-r+r*i$,$z’ ∈ L$ . but it is not the case for$i=0$ . Since $\abs{a^p} > \abs{cp-r}$ contrary to the required$i \leq j$ .
These are all the possible decompositions of
Prove that context-free languages are not closed under
Recall the definition of
\begin{align*}
max(L) = \{u \in L \;|\; \forall v \in \Sigma^*: uv \in L \implies v = \epsilon\} \;.
\end{align*}
Let’s take
\begin{align*}
&S \to X \;|\; Y \\
&X \to aXC \;|\; C \\
&C \to bCc \;|\; Cc \;|\; bBCc \;|\; c \\
&B \to bB \;|\; b \\
&Y \to AZ \\
&A \to aA \;|\; \epsilon \\
&Z \to bZc \;|\; Q \\
&Q \to cQ \;|\; c \;.
\end{align*}
However, the
Prove
Recall that we proved language $M = \{a^kb^ic^jdj-ie^k \;|\; 1 \leq i \leq j, k \geq 2\}$ to be context-free. We can define homomorophism:
\begin{equation*}
h(x) = \begin{cases}
aa &\for x=a \\
b &\for x=b \lor x=c \lor x=d \\
c &\for x=e
\end{cases} \;.
\end{equation*}
Now, $M’ = h(M) = \{a2kbi+j+j-ic^k\}$, where
Next, we can intersect
Prove or disprove each of the following statements:
-
$L$ is a irregular context-free language.$G$ is a context-sensitive language.$L ∩ G$ is not context-free. -
$L_1$ and$L_2$ are irregular context-free languages s.t.$L_1 ∩ L_2 ≠ ∅$ .$L_1 ∩ L_2$ is irregular context-free language. -
$L$ is a regular language over$Σ$ .$G$ is a context-sensitive language. Define substitution$f$ s.t.$∀ σ ∈ Σ: f(σ) = G$ .$f(L)$ is context-sensitive.
An interesection of a context-free and a context-sensitive languages may be
context-free. For instance,
An interesection of two context-free languages isn’t necessarily irregular.
For instance
The language
Let
\begin{align*}
L' = \{w \;|\; \abs{w} \equiv 0 \pmod{2}
\;\land\; \abs{w} \geq 4
\;\land\; \textbf{Sub}(w)\}
\end{align*}
Where
\begin{equation*}
w = \begin{cases}
x\textbf{a}y\textbf{z}z &\for xpyqz \in L
\land p \neq \textbf{a}
\land q \neq \textbf{z} \\
x\textbf{z}y\textbf{a}z &\for xpyqz \in L
\land p \neq \textbf{z}
\land q \neq \textbf{a}
\end{cases} \\
\abs{p} = \abs{q} = 1
\end{equation*}
- Provided
$L$ is regular, we can bring its grammar$G$ to Greibach normal form. - Now, for every rule of the form
$A → xA_1A_2A_3… A_n$ we introduce new rules:$A → aA’_1A’_2A’_3… A’_n$ whenever$x ≠ a$ and$A’ → zA”_1A”_2A”_3… A”_n$ whenever$x ≠ z$ . - We replace the rules of the form
$A → x$ with$A” → x$ .
The resulting grammar
Now, we can take