This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 360 Introduction to the Theory of Computing Spring 2008 Assignment 3 Solutions 1. [6 points] Prove that the language A = { x # y : x is a prefix of y } is not contextfree. Solution. It is assumed that the alphabet Σ = { , 1 , # } and that for each x # y ∈ A we have x,y ∈ { , 1 } * . Suppose toward a contradiction that A is contextfree and let n be the pumping length of A . Consider the string n 10 n #0 n 10 n ∈ A . The pumping lemma for contextfree languages tells us that there exist strings a,b,c,d,e with: • n 10 n #0 n 10 n = abcde •  bcd  ≤ n • bd negationslash = ε • For every i ≥ we have ab i cd i e ∈ A We show that any strings a,b,c,d,e satisfying the first three conditions cannot also satisfy the fourth, which yields the desired contradiction. For each such a,b,c,d,e , let ℓ =  bd  . Exactly one of the following holds: a contains # . Choose i = 0 and write ab cd e = x # y . Then  x  = 2 n + 1 and  y  = 2 n + 1 − ℓ . In particular,  x  >  y  , implying that x is not a prefix of y and so ab cd e negationslash∈ A . e contains # . Choose i = 2 and write ab 2 cd 2 e = x # y . Then  x  = 2 n + 1 + ℓ and  y  = 2 n + 1 . Once again,  x  >  y  , implying that x is not a prefix of y and so ab 2 cd 2 e negationslash∈ A . bd contains # . Choose i = 2 . Then ab 2 cd 2 e contains two occurrences of # and so ab 2 cd 2 e negationslash∈ A . c contains # . Choose i = 2 and write ab 2 cd 2 e = x # y . As  bcd  ≤ n , it holds that x = 0 n 10 n + p and y = 0 n + q 10 n for some p,q not both zero. If p > then x has n + p > n occurrences of after its 1 , but y has only n occurrences of after its 1 . In particular, x is not a prefix of y and so ab 2 cd 2 e negationslash∈ A . If q > then y has n + q > n occurrences of before its 1 , but x has only n occurrences of before its 1 . In particular, x is not a prefix of y and so ab 2 cd 2 e negationslash∈ A . 2. [4 points] Consider the following Turing machine, whose input alphabet is Σ = { 1 } ....
View
Full
Document
 Spring '08
 JohnWatrous

Click to edit the document details