Context Free Languages

Pumping Lemma

1. Pumping Lemma

Prove that the following languages are not context-free.

1.1. $ L=\{a^nb^{2n}c^n \ | \ n \geq 0\} $

1.2. $ L=\{a^n \ | \ n \text{ is a prime number}\} $

1.3. $ L=\{ww \ | \ w \in \{0,1\}^*\} $

2. Simple parser based on PDAs.

2.1. Write a PDA which accepts the language described below:

<expr> ::= <expr> + <expr> | <expr> * <expr> | (<expr>) | <number>
<number> ::= [0-9]+

2.2. Define classes: $\texttt{Expr}$, as well as the following classes which extend expressions: $\texttt{Plus}$, $\texttt{Mult}$, $\texttt{Par}$, $\texttt{Number}$. Add the $\texttt{__str__()}$ function for each class.

2.3. Based on the written PDA, implement a parser in Python for expressions. The parser should return an $\texttt{Expr}$ object.

2.4. Write a procedure which evaluates expressions. What is the natural way to implement it?