# Lecture 05

## Pushdown Automata

Thesis II "Solving" $$\neq$$ recognizing a language with a finite automata

E.g.

1. $$L=\{0^n1^n:n\geq 1\}$$
2. $$L=\{w\in\{(,)\}^*:w$$ is a matching string of parentheses$$\}$$
3. $$L=\{w\in\{0,1\}^*:w=w^R\}$$
------  ----  -------
|word|<-|FA|->|stack|
------  ----  -------

Definition For any set of symbols $$S$$, the set $$S_{\epsilon}=S\cup\{\epsilon\}$$, where $$\epsilon\not\in S$$

Definition A (non-deterministic) pushdown automata is a 6-tuple ($$Q,\Sigma,\Gamma,\delta, F, q_0$$) where

• $$Q=$$ finite set of states
• $$\Sigma=$$ input alphabet
• $$\Gamma=$$ stack alphabet
• $$F=$$ set of accepting states
• $$q_0$$ initial state
• $$\delta:Q\times\Sigma_{\epsilon}\times\Gamma_{\epsilon}\rightarrow\mathcal{P}(Q\times\Gamma_{\epsilon})$$

Definition A PDA $$M$$ accepts $$w\in\Sigma^n$$ if there exists $$c\geq n$$ and $$w_1,...,w_m\in\Sigma_{\epsilon}$$ and states $$r_0,...,r_m\in Q$$ and string $$s_0,...,s_m\in\Gamma^*$$ such that

1. $$r_0=q_0$$, $$s_0=\epsilon$$
2. $$r_m\in F$$
3. $$s=w_1w_2...w_m$$
4. $$\forall i\in[m], \exists a,b\in\Gamma_{\epsilon}, t\in\Gamma^*$$ such that $$(r_i,b)\in\delta(r_{i-1}, w_i, a)$$ and $$s_i=bt$$ and $$s_{i-1}=at$$

E.g.

1. $$L=\{0^n1^n:n\geq 1\}$$

Definition The PDA $$M$$ recognizes the language $$L$$ is $$L=\{w:M$$ accepts $$w\}$$

## Context-free Language

Definition $$L$$ is a context-free language if it is recognized by some PDA

Thesis II' "Solving"=recognizable by PDA

Definition A context-free grammar is a 4-tuple ($$V,\Sigma, R, S$$) where

• $$V=$$ finite set of variables
• $$\Sigma=$$ finite set of terminal symbols
• $$R=$$ finite set of rules $$V\rightarrow(V\cup\Sigma)^*$$
• $$S=$$ start variable

Definition $$uAv$$ yields $$uWv$$ in $$G$$ for some $$u,v,w,\in(V\cup\Sigma)^*$$, $$A\in V$$ if the rule $$A\rightarrow W$$ is in $$R$$ ($$uAv\Rightarrow uWv$$)

Definition $$u\Rightarrow^*v$$ ($$u$$ derives $$v$$) in $$G$$ for $$u,v\in(V\cup\Sigma)^*$$ if there is a sequence $$u_0,...,u_m\in(V\cup\Sigma)^*$$ such that $$u=u_0,\forall i\in[m]$$ $$u_{i-1}$$ yields $$u$$ in $$G$$ and $$v=u_m$$.

E.g.

1. $$L=\{0^n1^n:n\geq 1\}$$
• $$S\rightarrow 01|0S1$$
2. $$L=\{w\in\{(,)\}^*:w$$ is a matching string of parentheses$$\}$$
• $$S\rightarrow (S)|SS|\epsilon$$
3. $$L=\{w\in\{0,1\}^*:w=w^R\}$$
• $$S\rightarrow 0S0|1S1|\epsilon|0|1$$