a10 - CpSc 421 Homework 10 Solutions 1. (Sipser problem...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CpSc 421 Homework 10 Solutions 1. (Sipser problem 5.21, 20 points ) Let AMBIG CFG = { [ G ] | G is an ambiguis CFG } (where [ G ] denotes a string that represents the grammar). Show that AMBIG CFG is undecidable. Hint: You can use a reduction from PCP. Given an instance P = ± t 1 b 1 , t 2 b 2 , . . . t k b k ² , of the Post Correspondence Problem, construct a CFG G with the rules S T | B T t 1 T a 1 | . . . | t k T a k | t 1 a 1 | . . . | t k a k B b 1 B a 1 | . . . | b k B a k | b 1 a 1 | . . . | b k a k , where a 1 , . . . , a k are new terminal symbols. Prove that this reduction works. Solution: If P is solvable, then G is ambiguous. Let i 1 , i 2 , . . . i n be a solution to P . Let w = t i 1 t i 2 ··· t i n a i n ··· a i 2 a i 1 = b i 1 b i 2 ··· b i n a i n ··· a i 2 a i 1 The string w has two derivations: S S T -→ T T t i 1 T a i 1 -→ t i 1 T a i 1 T t i 2 T a i 2 -→ t i 1 t i 2 T a i 2 a i 1 T →··· -→ t i 1 t i 2 . . . T ··· a i 2 a i 1 T t in a in -→ t i 1 t i 2 ··· t i n a i n ··· a i 2 a i 1 and S S B -→ B B b i 1 B a i 1 -→ b i 1 B a i 1 B b i 2 B a i 2 -→ b i 1 b i 2 B a i 2 a i 1 B →··· -→ b i 1 b i 2 . . . B ··· a i 2 a i 1 B b in a in -→ b i 1 b i 2 ··· b i n a i n ··· a i 2 a i 1 Thus, G is ambibuous. If G is ambiguous, then P is solvable. Let G T be the same grammar as G except that it has T as the start variable and likewise for G B . G T is unambiguous. This is because the string of a i ’s at the end of any string derived from G T describes the sequence of steps taken in the derivation. Thus, two strings can have the same suffix of a i ’s iff they have the same derivation. This means that if G T generates x and y and x = y , then x and y have the same derivation. Therefore, G T is unambiguous.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
G B is unambiguous. The proof is equivalent to that for
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

a10 - CpSc 421 Homework 10 Solutions 1. (Sipser problem...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online