170 likes | 317 Views
CSCI 3130: Formal languages and automata theory Tutorial 9. Chin. Reminder. Homework 5 is due at next Tuesday! No tutorial next week! :D This is the last one. Undecidable problems for CFGs. ALL CFG = {< G> : G is a CFG that generates all strings} ALL CFG is undecidable Reduction
E N D
CSCI 3130: Formal languagesand automata theoryTutorial 9 Chin
Reminder • Homework 5 is due at next Tuesday! • No tutorial next week! :D • This is the last one.
Undecidable problems for CFGs • ALLCFG = {<G>: G is a CFG that generates all strings} • ALLCFG is undecidable • Reduction • ATM = {<M, w>: M is a TM that does not accept w} = {<M, w>: M rejects or loops on input w} • ATM is unrecognizable ⇒ ATM is undecidable • If ALLCFG is decidable then ATM is decidable. • Contradiction.
Undecidable problems for CFGs • ALLCFG = {<G>: G is a CFG that generates all strings} • ALLCFG is undecidable • Suppose it is decidable, then there exists a universal TM H string H(string <G>) { // G is a CFG if G generates all strings, return “accept”; if G does not generates all strings, return “reject”; } • Consider the following TM U (dependent on <M> and w) string U(string <M>, string w){ If M does not accept w, return <G> that generates all strings If M accepts w, return <G> that does not generate all strings } • If we can simulate H(U(<M>,w)), then U decides ATM and so ATM is decidable.
Undecidable problems for CFGs • ALLCFG = {<G>: G is a CFG that generates all strings} • ALLCFG is undecidable • Consider the following TM U (dependent on <M, w>) string U(string <M>, string w){ If M does not accept w, return <G> that generates all strings If M accepts w, return <G> that does not generate all strings } • We construct U as follows instead: string U(string <M>, string w){ If M does not accept w, construct <G> that generates all strings If M accepts w, construct <G> that generates all strings except the computation history of M(w) return H(<G>) } • How to construct <G>? We need to construct <G> so that even if M loops on w, <G> generates all strings.
Undecidable problems for CFGs • Computation history • #q0ab%ab#xq1b%ab# . . . #xx%xx☐qa# • Each #xxxxxx# tells you the configuration of the TM in each step qacc q1 … … a a b b a b ☐ ☐ abq1a a/bR q1 qacc abbqacc
Undecidable problems for CFGs • Computation history • Suppose the current configuration is #xbq1xab# • What does the next configuration look like? • The head must be one symbol left or one symbol right #xbq1xab# • Only these 3 symbols can change • Use this fact to design a PDA that generates the computation history (see lecture notes). • Convert the PDA to <G>.
Undecidable problems for CFGs • PCP = {<T>: T is a collection of tiles that contains a top-bottom match} • PCP is undecidable • AMB = {<G>: G is an ambiguous CFG} • AMB is undecidable • If AMB is decidable, PCP is decidable. Contradiction.
Undecidable problems for CFGs T G (CFG) (collection of tiles) a, b, c, 1, 2, 3 Terminals: Variables: S, T, B 1 2 3 Productions: bab cc c ab a ab T → cT2 T → aT3 S → T | B T → babT1 T → c2 T → a3 T → bab1 B → abB2 B → abB3 B → ccB1 B → ab2 B → ab3 B → cc1
Undecidable problems for CFGs • EQCFG= {<G1, G2>: G1and G2 are two CFGs that describe the same language} • Is it decidable?
Undecidable problems for CFGs • EQCFG = {<G1, G2>: G1 and G2 are two CFGs that descript the same language} • EQCFG is undecidable. • Same idea as EQTM • If EQCFG is decidable, ALLCFG is also decidable. • Let G1 to be a CFG that generates all inputs.
Undecidable problems for CFGs • EQCFG = {<G1, G2>: G1 and G2 are two CFGs that descript the same language} • If EQCFG is decidable, there exists a TM H such that string H(string <G1>, string <G2>) { if G1 and G2 are equal, return “accept”; if G1 and G2 are not equal, return “reject”; } • Let G1 to be a CFG that generates all inputs. We construct U as follows string U(string <G>) { G1 := a CFG that generates all inputs // hardcode return H(G1, G); } • Given a CFG <G>, U(<G>) returns accept if G generates all strings, rejects if G does not. • Hence ALLCFG is decidable. Contradiction.
Post Correspondence Problem • PCP1 : PCP over the alphabet S = {1}. • The alphabet of a tile is the set of symbols that appear on the tiles. • Is PCP1 decidable?
Post Correspondence Problem • PCP1 : PCP over the alphabet S = {1}. • The alphabet of a tile is the set of symbols that appear on the tiles. • PCP1 is decidable. • 3 – 1 = 2 • 2 – 5 = -3 • Find x, y such that 2x – 3y = 0. Easy. • If exists two tiles like above, accept. Otherwise reject. 111 1 11 11111
Post Correspondence Problem • PCP2 : PCP over the alphabet S = {0, 1}. • The alphabet of a tile is the set of symbols that appear on the tiles. • Is PCP2 decidable?
Post Correspondence Problem • PCP2 : PCP over the alphabet S = {0, 1}. • The alphabet of a tile is the set of symbols that appear on the tiles. • PCP2 is undecidable. • If PCP2 is decidable, then PCP is also decidable. • Represent the alphabet in PCP in binary form.
End • Questions?