{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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.

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

View Full Document
G B is unambiguous. The proof is equivalent to that for G T .
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern