lecture-8.md (3595B)
1 +++ 2 title = "Lecture 8" 3 template = "page-math.html" 4 +++ 5 6 # Pumping lemma for context-free languages 7 Let L be context-free language. 8 9 There exists m > 0 st for every word w ∈ L with |w| ≥ m, w = uwxyz. Constraints |vxy| ≤ m, |vy| ≥ 1, $uv<sup>ixy</sup>iz \in L$ for every i ≥ 0. 10 11 As a formula: 12 - ∃ m > 0. 13 - ∀w ∈ L with |w| ≥ m: 14 - ∃u,v,x,y,z with w = uvxyz, |vxy| ≤ m, |vy| ≥ 1 15 - ∀i ≥ 0, $uv<sup>ixy</sup>iz ∈ L$ 16 17 ## Using the lemma 18 Contradiction of the lemma for specific values of m, u, v, x, y, or z is not sufficient. 19 20 To contradict the lemma, prove the negation, i.e. show that ∃i ≥ 0, $uv<sup>ixy</sup>iz \notin L$. 21 22 As a 'game': 23 1. Given is language L, want to prove L is not context-free. 24 2. Opponent picks m. 25 3. We choose word w ∈ L with |w| ≥ m 26 4. Opponent picks u,v,x,y,z with w = uvxyz, |vxy| ≤ m, |vy| ≥ 1 27 5. If we can find i ≥ 0 such that $uv<sup>ixy</sup>iz \notin L$, then we win. 28 6. If we can always win, then L does not fulfil pumping lemma. 29 30 # Properties of context-free languages 31 If L₁ and L₂ are context-free, then so are $L_1 \cup L_2$, $L_{1}<sup>{R}$, $L_{1}L_{2}$, $L_{1}</sup>{*}$. 32 33 Proof: 34 1. Let $G_i$ be CFG with start variable $S_i$ st $L_i = L(G_i)$ for i = 1,2. Let G₁ and G₂ have no common variables. 35 2. Then for... 36 - $L_1 \cup L_2$: add rules S → S₁ | S₂ and pick S as start variable. 37 - $L_{1}<sup>{R}$: reverse all right-hand sides (i.e. $x \rightarrow y$ becomes $x \rightarrow y</sup>R$). 38 - $L_{1}L_{2}$: add S → S₁S₂ and pick S as start variable. 39 - $L_{1}^{*}$: add S → S₁S | λ and pick S as start variable 40 41 $L_1 \cap L_2$ and $L_1 \setminus L_2$ are context-free if $L_1$ is context-free and $L_2$ is _regular_. 42 43 $L \setminus \{ \lambda \}$ is context-free if L is context-free. 44 45 $\{a<sup>n b</sup>n | n \geq 1000 \}$ is context-free. 46 47 # Turing machines 48 Turing machines can read and write input word. Input is written on tape with a read-write-head. 49 50 In each step, the head: 51 1. Reads a symbol from the tape 52 2. Overwrites the symbol 53 3. Moves one place left or right. 54 55 Tape is two-sided infinite, i.e. unlimited memory (now if only that worked with actual computers). 56 57 Initial tape consists of word and blank symbols: □ □ □ input word □ □ □ 58 59 Finite set of states Q, finite tape alphabet Γ, final accepting states. 60 61 Transition function δ: Q × Γ → Q × Γ × {L,R}. It's partial, δ(q,a) may be undefined. 62 63 δ(q,a) = (q', b, X) means: 64 - if head reads a from tape in state q 65 - then: 66 1. A is overwritten by b 67 2. Head moves 1 position: left if X = L, right if X = R 68 3. Machine switches to state q' 69 70 configuration: a word vqw (q a state, v,w from the tape alphabet) 71 - machine is in state q 72 - tape content is vw, surrounded by □ 73 - head stands on first symbol of w 74 75 A halting state is a configuration where a transition on the next symbol is undefined. In other words, a configuration $vqw$ with $q \in F$. Formally, a configuration $vqaw$ or $vq\lambda$ st $\delta(q,a)$ or $\delta(q,\square)$ is undefined. 76 77 An execution can be infinite! 78 79 some example computations: 80 - $vqaw \vdash vbq'w$ if $\delta (q,a) = (q', b, R)$ 81 - $vq\lambda \vdash vbq'\lambda$ if $\delta(q, \square) = (q', b, R)$ 82 - $\lambda qaw \vdash \lambda q'\square bw$ if $\delta(q,a) = (q',b,L)$ 83 - $\lambda q \lambda \vdash \lambda q' \square b \lambda$ if $\delta(q, \square) = (q',b,L)$ 84 85 Language is recursively enumerable if it's accepted by a (deterministic) Turing machine. 86 87 Church-Turing thesis: every computation of a computer can be simulated by a deterministic Turing machine.