Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jeff Edmonds York University COSC 4111 Lecture 4 Different ModelsDifferent ModelsDifferent ModelsDifferent Models ReductionsReductionsReductions Simple.

Similar presentations


Presentation on theme: "Jeff Edmonds York University COSC 4111 Lecture 4 Different ModelsDifferent ModelsDifferent ModelsDifferent Models ReductionsReductionsReductions Simple."— Presentation transcript:

1 Jeff Edmonds York University COSC 4111 Lecture 4 Different ModelsDifferent ModelsDifferent ModelsDifferent Models ReductionsReductionsReductions Simple ReductionsSimple ReductionsSimple ReductionsSimple Reductions Rice's TheoremRice's TheoremRice's TheoremRice's Theorem AcceptableAcceptableAcceptable Acceptability CompleteAcceptability CompleteAcceptability CompleteAcceptability Complete Reductions to the Halting Problem The Post Correspondence ProbThe Post Correspondence ProbThe Post Correspondence ProbThe Post Correspondence Prob TilingTilingTiling CFG G Generates ICFG G Generates ICFG G Generates ICFG G Generates I CFG G Generates Every StringCFG G Generates Every StringCFG G Generates Every StringCFG G Generates Every String CFG G Generates Some StringCFG G Generates Some StringCFG G Generates Some StringCFG G Generates Some String CFG L(G)=L(G')CFG L(G)=L(G')CFG L(G)=L(G')CFG L(G)=L(G') Game of LifeGame of LifeGame of LifeGame of Life Hilbert's 10 th ProblemHilbert's 10 th ProblemHilbert's 10 th ProblemHilbert's 10 th Problem

2 Reductions for Undecidability Undecidable problems: Halting Problem = { | TM M halts on input I} = { | Java program J halts on input I} = { | Primitive Recursive Program P halts on input I} = { | Recursive Program P halts on input I} = { | Register Machine halts on input I} = { | Uniform circuit C halts on input I} = { | Quantum Machine M Java halts on input I} = { | Context Sensitive Grammar G generates string input I} = { | Human H halts on input I}  n, circuit computed in time size(n) Every human dies. ? Every primitive recursive program halts.

3 Now that we have established that the Halting Problem is undecidable, we can use it for a jumping off point for more “natural” undecidability results. Reductions for Undecidability

4 ≤ Oracle Alg Assume have an alg. Design an alg. Reductions But there is likely not a fast algorithm for either!!!

5 Reductions I harder I harder yes P harder I harder no I easier I easier yes P easier I easier no Two problems/languages P easier and P harder each with their own definitions of what a legal input is (I easier vs I harder ) and which are yes-inputs and which no-inputs.

6 Reductions I harder I harder yes P harder I harder no I easier I easier yes P easier I easier no We want machines that decide/accept them. Alg harder P harder (I harder ) I harder P easier (I easier ) I easier Alg easier

7 Reductions P easier ≤ comp P harder I harder I harder yes P harder I harder no I easier I easier yes P easier I easier no How do their complexities/difficulties compare? Computable/Decidable Exp Poly NP Co-NP RecognizableCo-Recognizable

8 Reductions P easier ≤ comp P harder I harder I harder yes P harder I harder no I easier I easier yes P easier I easier no It is hard to prove problem is P harder hard. It is easier to prove P easier is easy. by design an algorithm Alg easier for it. But you only need to prove P easier is at least as easy as P harder. Pretend you have an algorithm Alg harder for P harder to use as a subroutine.

9 Reductions P alg ≤ comp P oracle I oracle I oracle yes P oracle I oracle no I alg I alg yes P alg I alg no We often call the algorithm assumed to exist, an Oracle. Given Alg oracle P oracle (I oracle ) I oracle

10 Reductions P alg ≤ comp P oracle I oracle I oracle yes P oracle I oracle no I alg I alg yes P alg I alg no We use Alg oracle as an subroutine in an algorithm Alg alg for solving P alg. Given Alg oracle P oracle (I oracle ) I oracle Build Alg Alg P alg (I alg ) I alg

11 Reductions P alg ≤ comp P oracle I oracle I alg Alg alg is given an input I alg. Given Alg oracle P oracle (I oracle ) I oracle I oracle = InstanceMap(I alg ) Build Alg Alg P alg (I alg ) I alg InstanceMap I oracle It maps it to input I oracle. and gives this to Alg oracle.

12 Reductions P alg ≤ comp P oracle I oracle I alg Alg oracle gives the yes/no answer for his input I oracle. Given Alg oracle P oracle (I oracle ) I oracle I oracle = InstanceMap(I alg ) Build Alg Alg P alg (I alg ) I alg Return same answer yes  yes no  no InstanceMap I oracle yes P oracle I oracle no Alg alg returns the same answer.

13 Reductions P alg ≤ comp P oracle I oracle I alg To ensure Alg alg works, I oracle = InstanceMap(I alg ) must Given Alg oracle P oracle (I oracle ) I oracle I oracle = InstanceMap(I alg ) Build Alg Alg P alg (I alg ) I alg Return same answer yes  yes no  no InstanceMap I oracle yes P oracle I oracle no I alg yes P alg I alg no map yes instances to yes instances and no to no.

14 Reductions P alg ≤ comp P oracle I oracle I alg Must prove Alg alg works. Given Alg oracle P oracle (I oracle ) I oracle I oracle = InstanceMap(I alg ) Build Alg Alg P alg (I alg ) I alg Return same answer yes  yes no  no InstanceMap I oracle yes P oracle I oracle no I alg yes P alg I alg no I alg is a yes input  I oracle is a yes input  Alg oracle says yes  Alg alg says yes

15 Reductions P alg ≤ comp P oracle

16 Reductions Reduction: Design an algorithm for one computational problem, using a supposed algorithm for another problem as a subroutine. Used to create a new algorithm from a known algorithm. Learn that a new problem is likely hard, from knowing a known problem is likely hard. Learn that two problems have a similar “structure.” P alg ≤ comp P oracle

17 GIVEN: Network Flow Oracle BUILD: Matching Oracle Matching ≤ comp Network Flows Who loves who AnnFred SueJohn BethBobMarySam Max matching A network s t Max Flow st Reductions

18 Learn that a new problem is likely hard, from knowing a known problem is likely hard. Reductions Halting Computable Exp Poly

19 Is there an algorithm for P oracle ? Is there an algorithm for P alg ? ? We give an algorithm for P alg using a supposed algorithm for P oracle as a subroutine. Reductions

20 If there is an algorithm for P alg then there is an algorithm for P alg then there is not fast algorithm for P oracle If there is not an algorithm for P alg If there is an algorithm for P oracle If there is not an algorithm for P oracle ? ? We give an algorithm for P alg using a supposed algorithm for P oracle as a subroutine. ? ? ?? Reductions

21 Notation: P alg ≤ comp P oracle P alg is “at least as easy as” P oracle (Modulo polynomial terms.) P oracle is “at least as hard as” P alg (Modulo polynomial terms.) Conclusions: We give an algorithm for P alg using a supposed algorithm for P oracle as a subroutine. Reductions

22 Reductions for Undecidability Halting Problem = { | M halts on I} is undecidable { | M prints “Hi” at some point in computation on I} { | M halts empty string} { | M halts on every input} { | M halts on some input} { | L(M) is regular} { |  I M(I)=M'(I)} There is a fixed TM M * { | M * halts on I} { | based on what M does, not on how it does it} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! { | M prints “Hi” at some point in computation on I}  comp { | M halts on I} Hence, equivalent. { | M halts on I}  comp { | M does not halt on I} ?

23 Reductions for Undecidability GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | M prints “Hi” on I} { | M prints “Hi” on I at some point in computation } M(I) halts Yes, prints “Hi” { | M halts on I} ≤ M'(I) = { M is built in Run M(I), Print(“Hi”) } suppressing any output

24 Reductions for Undecidability GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | M prints “Hi” on I} { | M halts on I} ≤ { | M prints “Hi” on I at some point in computation } M(I) does not halt No “Hi” M'(I) = { M is built in Run M(I), Print(“Hi”) } suppressing any output

25 Reductions for Undecidability { | M halts on I} { | M halts empty string} { | M halts on I} ≤ { | M halts empty string} M(I) halts or not M' I (I’) = { Ignore input I' M & I are built in Run M(I) } Yes or No GIVEN: Oracle for BUILD: Oracle for

26 Reductions for Undecidability { | M halts on I} { | M halts on every input} { | M halts on I} ≤ { | M halts on every input} M(I) halts or not M I (I') = { Ignore input I' M & I are built in Run M(I) } Yes or No GIVEN: Oracle for BUILD: Oracle for

27 Reductions for Undecidability { | M halts on I} { | M halts on some input} { | M halts on I} ≤ { | M halts on some input} M(I) halts or not M I (I') = { Ignore input I' M & I are built in Run M(I) } Yes or No GIVEN: Oracle for BUILD: Oracle for

28 Reductions for Undecidability Wait until we do Rice’s Theorem

29 Reductions for Undecidability { | M halts on I} { | M halts on I} ≤ M(I) halts or not M I (I') = { Ignore input I' M & I are built in Run M(I) Yes or No GIVEN: Oracle for BUILD: Oracle for { | L(M) is regular} But now we care about what M(I) outputs when it halts. suppressing any output Halt and accept }

30 Reductions for Undecidability { | M halts on I} { | L(M) is regular} { | M halts on I} ≤ { | L(M) is regular} M(I) halts L(M I ) = {everything} Yes, L(M I ) is regular GIVEN: Oracle for BUILD: Oracle for M I (I') = { Ignore input I' M & I are built in Run M(I) suppressing any output Halt and accept }

31 Reductions for Undecidability { | M halts on I} { | L(M) is regular} { | M halts on I} ≤ { | L(M) is regular} M(I) does not halt L(M I ) = {nothing} Yes, L(M I ) is regular GIVEN: Oracle for BUILD: Oracle for M I (I') = { Ignore input I' M & I are built in Run M(I) Halt and accept } suppressing any output

32 Reductions for Undecidability { | M halts on I} { | L(M) is regular} { | M halts on I} ≤ { | L(M) is regular} GIVEN: Oracle for L(M I ) = No, L(M I ) is not regular BUILD: Oracle for 0n1n0n1n M(I) does not halt M I accepts 0 n 1 n, but “computes” no language M I (I') = { If I’ has the form 0 n 1 n halt and accept else run M(I) halt and accept } suppressing any output

33 Reductions for Undecidability { | M halts on I} { | L(M) is regular} { | M halts on I} ≤ { | L(M) is regular} GIVEN: Oracle for L(M I ) = Yes, L(M I ) is regular BUILD: Oracle for {everything} M(I) halts M I (I') = { If I’ has the form 0 n 1 n halt and accept else run M(I) halt and accept } suppressing any output

34 Reductions for Undecidability { | M halts on I} { |  I M(I)=M'(I)} { | M halts on I} ≤ { |  I M(I)=M'(I)} M(I) halts or not Same or different GIVEN: Oracle for BUILD: Oracle for M I (I') = M' = ? { Ignore input I' M & I are built in Run M(I) Halt and accept } suppressing any output

35 Reductions for Undecidability If M halts on I M I halts on and accepts every input M I and M' have the same results on every input Oracle says yes We say yes { | M halts on I} ≤ { |  I M(I)=M'(I)} M'(I') halts and accepts M I (I') = M' = ? { Ignore input I' M & I are built in Run M(I) Halt and accept } suppressing any output

36 Reductions for Undecidability If M does not halt on I M I does not halt on every input M I and M' have different results on some input Oracle says no We say no { | M halts on I} ≤ { |  I M(I)=M'(I)} M I (I') = M' = ? { Ignore input I' M & I are built in Run M(I) Halt and accept } suppressing any output M'(I') halts and accepts

37 Reductions for Undecidability { | M halts on I} { |  I M(I) = M'(I)} { | M halts on I} ≤ { |  I M(I)=M'(I)} M(I) halts or not Yes or No GIVEN: Oracle for BUILD: Oracle for M I (I') = M' = ? { Ignore input I' M & I are built in Run M(I) Halt and accept } suppressing any output M'(I') halts and accepts

38 Reductions for Undecidability { | M halts on I} { | M * halts on I} { | M halts on I} ≤ { | M * halts on I} where M * is a special TM M(I) halts or not Need to tell oracle about M and I I' = M* is the universal TM simulates M on I. Yes or No GIVEN: Oracle for BUILD: Oracle for

39 Reductions for Undecidability { | M halts on I} ≤ P = { | L(M) has property … ie based on what M does, not on how it does it} If L(M) =L(M'), then MP iff MP' P ≠ {everything} P ≠ {nothing} Rice’s Theorem P is undecidable. Eg P = { | L(M) is regular} Eg P = { | M(010) = yes and M(1001) = no or M(101) = no }

40 Reductions for Undecidability { | M halts on I} ≤ (Else switch to P) Assume M yes P Let M empty = just say no. L(M empty ) = {nothing} Assume M empty  P, Proof: P = { | L(M) has property … ie based on what M does, not on how it does it} If L(M) =L(M'), then MP iff MP' P ≠ {everything} P ≠ {nothing} Rice’s Theorem P is undecidable.

41 Reductions for Undecidability GIVEN: Oracle for BUILD: Oracle for { | M halts on I} P { | M halts on I} ≤ M(I) halts M'(I') = { Run M(I) Run M yes (I') respond as M yes (I') does } Yes P = { | based on what M does, not on how it does it} L(M') = L(M yes ) M yes P  M' P

42 Reductions for Undecidability GIVEN: Oracle for BUILD: Oracle for { | M halts on I} P { | M halts on I} ≤ M(I) does not halt M'(I') = { Run M(I) Run M yes (I') respond as M yes (I') does } No P = { | based on what M does, not on how it does it} L(M') = {nothing} = L(M empty ) M empty P  M' P

43 Reductions for Undecidability { | M halts on I} { | M prints “Hi” on I} ≤ { | M halts on I} { | M prints “Hi” on I at some point in computation } M(I) prints “Hi” on I M'(I) = { Run M(I) if “Hi” is printed halt Loop forever } Yes halts GIVEN: Oracle for BUILD: Oracle for Other direction

44 Reductions for Undecidability GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | M prints “Hi” on I} ≤ { | M halts on I} { | M prints “Hi” on I at some point in computation } M(I) does not print “Hi” M'(I) = { Run M(I) if “Hi” is printed halt Loop forever } No, does not halt

45 Halting Problem = { | M halts on I} is undecidable { | M prints “Hi” at some point in computation on I} { | M halts empty string} { | M halts on every input} { | M halts on some input} { | L(M) is regular} { |  I M(I)=M'(I)} There is a fixed TM M * { | M * halts on I} { | based on what M does, not on how it does it} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! { | M prints “Hi” at some point in computation on I}  comp { | M halts on I} Hence, equivalent. { | M halts on I}  comp { | M does not halt on I} ? Reductions for Acceptability

46 { | M does not halt on I} { | M halts on I} ≤ { | M does not halt on I} No: Does not halt Yes: Does not halt. GIVEN: Oracle for BUILD: Oracle for { | M halts on I} Reductions for Acceptability

47 { | M halts on I} { | M prints “Hi” on I} ≤ { | M does not halt on I} Yes: Does halt No: Does halt. GIVEN: Oracle for BUILD: Oracle for { | M halts on I} Wait! Is this allowed? Reductions for Acceptability

48 P alg ≤ comp P oracle Karp Reduction: Yes  Yes & No  No Cook Reduction: Design any algorithm for P alg using a supposed algorithm for P oracle as a subroutine. Reductions for Acceptability Wait! Is this allowed?

49 Yes instance  Halt and answer “yes” No instance  Run forever or answer “no” Acceptable Yes instance  Run forever or answer “yes” No instance  Halt and answer “no” Computable Yes instance  Halt and answer “yes” No instance  Halt and answer “no” Co-Acceptable Halting   Halting Reductions for Acceptability

50 P alg ≤ comp P oracle Karp Reduction: Yes  Yes & No  No Cook Reduction: Design any algorithm for P alg using a supposed algorithm for P oracle as a subroutine. Reductions for Acceptability We will only consider reductions of this simple form. Because they preserve acceptable/co-acceptable

51 Yes instance  Halt and answer “yes” No instance  Run forever or answer “no” Acceptable Yes instance  Run forever or answer “yes” No instance  Halt and answer “no” Co-Acceptable Halting Reductions for Acceptability   Halting { | M prints “Hi” on I} { | M halts empty string} { | M halts on every input} { | M halts on some input}  TM M * { | M * halts on I} Halting

52 Yes instance  Halt and answer “yes” No instance  Run forever or answer “no” Acceptable Yes instance  Run forever or answer “yes” No instance  Halt and answer “no” Co-Acceptable Halting Reductions for Acceptability   Halting { | L(M) is regular} { |  I M(I)=M'(I)} Halting ≤   Halting ≤

53 Yes instance  Halt and answer “yes” No instance  Run forever or answer “no” Acceptable Halting Acceptability Complete Def n : Problem P complete is Acceptability Complete iff P complete  Acceptability  P  Acceptability, P ≤ comp P complete I.e. P complete is one of the hardest problems in Acceptability. If we had an algorithm for Pcomplete, then we would have one for every problem in Acceptability. Claim: Halting is Acceptability Complete. P complete

54 Yes instance  Halt and answer “yes” No instance  Run forever or answer “no” Acceptable Halting Acceptability Complete Claim: Halting is Acceptability Complete. Halting  Acceptability  P  Acceptability, There is a TM M P such that We must now prove P ≤ comp Halting

55 Reductions for Undecidability I I  P M I (I’) = { Run M P (I) If halt and accept halt and accept else run forever } Halts GIVEN: Oracle for BUILD: Oracle for ≤ { | M halts on I} P P { | M halts on I}

56 Reductions for Undecidability I I  P M I (I’) = { Run M P (I) If halt and accept halt and accept else run forever } Runs forever GIVEN: Oracle for BUILD: Oracle for ≤ { | M halts on I} P P { | M halts on I}

57 Yes instance  Halt and answer “yes” No instance  Run forever or answer “no” Acceptable Halting Acceptability Complete Claim: Halting is Acceptability Complete. Halting  Acceptability  P  Acceptability, There is a TM M P such that We proved P ≤ comp Halting

58 Acceptable Halting Acceptability Complete Claim: They all are Acceptability Complete. They  Acceptability  P  Acceptability, We proved P ≤ comp Halting ≤ comp These problems { | M prints “Hi” on I} { | M halts empty string} { | M halts on every input} { | M halts on some input}  TM M * { | M * halts on I}

59 Acceptable Halting Acceptability Complete Claim: This is Acceptability Hard, but not Complete. This  Acceptability  P  Acceptability, We proved P ≤ comp Halting ≤ comp This problem { | L(M) is regular} { |  I M(I)=M'(I)}

60 Reductions for Undecidability Now that we have established that the Halting Problem and its friends are undecidable, we can use it for a jumping off point for more “natural” undecidability results.

61 The Post Correspondence Problem The input is a finite collection of dominoes A solution is a finite sequence of the dominoes (with repeats) b ca a ab ca a abc c a ab So that the combined string on the top is the same as that on the bottom a b c a a a b c PCP = { | P is a collection of dominoes with a solution} b ca, a ab, ca a, abc c P = PCP is undecidable

62 GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | Dominos P has a solution} { | M halts on I} ≤ { | Dominos P has a solution} Yes M(I) halts Dominos in P mimic the rules of the TM M on input I Yes, there is a solution The Post Correspondence Problem

63 Encode configuration of the TM as a string giving the contents of the tape and the current state inserted where the head is.Encode configuration of the TM as a string giving the contents of the tape and the current state inserted where the head is. 10q i 10010 The Post Correspondence Problem Consider some configuration of a TM 1 011 0 1 0 q

64 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # I The Post Correspondence Problem Consider some configuration of a TM 1 011 0 1 0 q TM accepts by halting in the accept state with the tape empty

65 Encode the halting computation of M on I as the string of configuration separated by ‘#’Encode the halting computation of M on I as the string of configuration separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # The Post Correspondence Problem Consider some configuration of a TM 1 011 0 1 0 q M halts on I iff there is such a computation string iff the dominoes P has a solution with this string as with this string as the combined string on the top and on the bottom

66 The first domino in P isThe first domino in P is The Post Correspondence Problem Consider some configuration of a TM 1 011 0 1 0 q # #q start 0110010# I Lets temporarily assume that the domino solution must start with this domino.Lets temporarily assume that the domino solution must start with this domino. The loop invariant is that in the only domino solutionThe loop invariant is that in the only domino solution the combined string so far on the top the first t TM configurations consists of the first t TM configurations and on the bottom the first t+1. and on the bottom the first t+1.

67 The Post Correspondence Problem Consider some configuration of a TM 1 011 0 1 0 q Transition  (q i,1) = Transition  (q i,1) = #10q i 11010# Config: TM is in state q i and sees a 1. c 011 0 1 0 qjqjqjqj #10q j 11010# #10q j c1010# #10cq j 1010# Related domino: qi1cqjqi1cqjqi1cqjqi1cqj

68 Transition  (q i,1) = Transition  (q i,1) = #10q i 11010# Config: TM is in state q i and sees a 1. c 011 0 1 0 qjqjqjqj #10q j 11010# #10q j c1010# #1q j 0c1010# Related dominoes: 0q i 1 q j 0c 1q i 1 q j 1c & Consider some configuration of a TM 1 011 0 1 0 q The Post Correspondence Problem

69 Related dominoes: Consider some configuration of a TM 1 011 0 1 0 q Add and removing trailing blanks: Add and removing trailing blanks: Start a new configuration: Start a new configuration: Copy unchanged characters: Copy unchanged characters:## q accept ## # Accepting: Accepting: The Post Correspondence Problem,0011, & bb #b##b##b##b# b##b##b##b##&

70 The Post Correspondence Problem The loop invariant is that in the only domino solutionThe loop invariant is that in the only domino solution the combined string so far on the top the first t TM configurations consists of the first t TM configurations and on the bottom the first t+1. and on the bottom the first t+1. …0# …0#10q i 1001b#

71 The Post Correspondence Problem For the top string to match the bottom string this t+1 st configuration must be produced by dominoes on the top.For the top string to match the bottom string this t+1 st configuration must be produced by dominoes on the top. …0# …0#10q i 1001b# 0 1 qi1qi1qi1qi10 0 1 b#

72 The Post Correspondence Problem With transition  (q i,1) = the only way to match the “q i 1” on top is with the domino With transition  (q i,1) = the only way to match the “q i 1” on top is with the domino Then the remain characters can be copied down. Then the remain characters can be copied down. …0# …0#10q i 1001b# 0 1 qi1qi1qi1qi10 0 1 b# 0qj0qj0qj0qj 0 1 0 0 1 b#

73 The Post Correspondence Problem This maintains the loop invariant that in the only domino solutionThis maintains the loop invariant that in the only domino solution the combined string so far on the top the first t TM configurations consists of the first t TM configurations and on the bottom the first t+1. and on the bottom the first t+1. …0# …0#10q i 1001b# 0011 qi10qjqi10qjqi10qjqi10qj …0#10q i 1001b#100q j 001b# 00 00 11 bb ##

74 The Post Correspondence Problem The TM is allowed to use as much tape as it likes. The extra cells are assumed to initially contain blanks. The TM is allowed to use as much tape as it likes. The extra cells are assumed to initially contain blanks. Towards this end, suppose you would like to insert a blank at the end of this configuration before the #. Towards this end, suppose you would like to insert a blank at the end of this configuration before the #. …0# …0#10q i 1001b# 0 1 qi1qi1qi1qi10 0 1 b# 0qj0qj0qj0qj 0 1 0 0 1 b# …0# …0#10q i 1001b# 01 qi1qi1qi1qi10 0 1b 0qj0qj0qj0qj 01 0 0 1b # b#b#b#b# This also maintains the loop invariant This also maintains the loop invariant …0#10q i 1001b# …0#10q i 1001b#100q j 001bb#

75 The Post Correspondence Problem The TM is expected to leave the tape containing only blanks before it halts. The TM is expected to leave the tape containing only blanks before it halts. Suppose towards that goal, you would like to delete that last trailing blank. Suppose towards that goal, you would like to delete that last trailing blank. …0# …0#10q i 1001b# 0 1 qi1qi1qi1qi10 0 1 b# 0qj0qj0qj0qj 0 1 0 0 1 b# …0# …0#10q i 1001b# 0 1 qi1qi1qi1qi10 01 0qj0qj0qj0qj 0 1 0 01 b## This also maintains the loop invariant This also maintains the loop invariant …0#10q i 1001b# …0#10q i 1001b#100q j 001# Hence the LI is always maintained.

76 The Post Correspondence Problem …0#q accept # Suppose the TM halts and accepts after t+1 time steps,Suppose the TM halts and accepts after t+1 time steps, then the first t+1 TM configurations end like this: The loop invariant is that in the only domino solutionThe loop invariant is that in the only domino solution the combined string so far on the top the first t TM configurations consists of the first t TM configurations and on the bottom the first t+1. and on the bottom the first t+1.

77 The Post Correspondence Problem …0#q accept # …0# We know that this loop invariant has been maintainedWe know that this loop invariant has been maintained Hence, we know that the only domino solution ends like this:Hence, we know that the only domino solution ends like this: The loop invariant is that in the only domino solutionThe loop invariant is that in the only domino solution the combined string so far on the top the first t TM configurations consists of the first t TM configurations and on the bottom the first t+1. and on the bottom the first t+1.

78 The Post Correspondence Problem …0# …0#q accept # q accept ## # …0#q accept ## And this completes the solution with And this completes the solution with the combined string on the top being the same as that on the bottom. To this we can add a last domino to complete the solutionTo this we can add a last domino to complete the solution

79 The Post Correspondence Problem …0#q accept ## Of course such a solution is impossible, if TM M does not halt and accept input I Of course such a solution is impossible, if TM M does not halt and accept input I. Consider some configuration of a TM 1 011 0 1 0 q

80 The first domino in P isThe first domino in P is The Post Correspondence Problem Consider some configuration of a TM 1 011 0 1 0 q # #q start 0110010# I Lets temporarily assume that the domino solution must start with this domino.Lets temporarily assume that the domino solution must start with this domino. We now need to consider the problem with this restriction removed.We now need to consider the problem with this restriction removed.

81 The Post Correspondence Problem Consider these dominoes Consider these dominoes## q accept ## #, 00 11, bb #b##b##b##b# b##b##b##b## qi1cqjqi1cqjqi1cqjqi1cqj 0q i 1 q j 0c 1q i 1 q j 1c # #q start 0110010#,,,,, &,,, A solution is a finite sequence of the dominoes (with repeats) so that the combined string on the top is the same as that on the bottom Can you find a nice easy solution?00

82 The Post Correspondence Problem Insert *s into the dominoes Insert *s into the dominoes *#*##*#**#*##*#* *q accept *#*#* #*, *0 0* *1 1*, *b b* *#b*#**#b*#**#b*#**#b*#* *b*##**b*##**b*##**b*##* *q i *1 c*q j * *0*q i *1 q j 0c* *1*q i *1 q j *1*c* *# *#*q start *0*1*1*0*0*1*0*#*,,,,, &,,, A solution is a finite sequence of the dominoes (with repeats) so that the combined string on the top is the same as that on the bottom Can you now find a nice easy solution? This first domino must go first because it is the only one with its first character on top and bottom the same.

83 The Post Correspondence Problem Insert *s into the dominoes Insert *s into the dominoes *#*##*#**#*##*#* *q accept *#*#* #*, *0 0* *1 1*, *b b* *#b*#**#b*#**#b*#**#b*#* *b*##**b*##**b*##**b*##* *q i *1 c*q j * *0*q i *1 q j 0c* *1*q i *1 q j *1*c* *# *#*q start *0*1*1*0*0*1*0*#*,,,,, &,,, A solution is a finite sequence of the dominoes (with repeats) so that the combined string on the top is the same as that on the bottom The rest of the proof is the same, producing: *#*q start *0*1*1*0*0*1*0*#*1*…q 3 *0*1*0*0* …. *#*q accept *#*

84 GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | Dominos P has a solution} { | M halts on I} ≤ { | Dominos P has a solution} Yes M(I) halts Dominos in P mimic the rules of the TM M on input I Yes, there is a solution The Post Correspondence Problem Done

85 Tiling Problem The input is a finite collection of tiles A solution is a tiling of a finite square with these tiles without rotating them. (with repeats) Tiling = { | τ is a collection tiles with a solution} Tiling is undecidable

86 GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | Tiles τ have a solution} { | M halts on I} ≤ { | Tiles τ have a solution} Yes M(I) halts <τ><τ> Tiles in τ mimic the rules of the TM M on input I Yes, there is a solution Tiling Problem

87 Encode configuration of the TM as a string giving the contents of the tape and the current state inserted where the head is.Encode configuration of the TM as a string giving the contents of the tape and the current state inserted where the head is. 10q i 10010 Tiling Problem Consider some configuration of a TM 1 011 0 1 0 q

88 Encode the halting computation of M on I with time T as a list configurations on separate lines padded with blanks to form a square.Encode the halting computation of M on I with time T as a list configurations on separate lines padded with blanks to form a square. ################### ################### #q start 0110010bbbbbbb# #1q 3 010010bbbbbbbbb# #10q 7 10010bbbbbbbbb# #100q 6 0010bbbbbbbbb# #10 …. bbbbbbbbbbbb# #q accept bbbbbbbbbbbbb# ################### ################### Tiling Problem Consider some configuration of a TM 1 011 0 1 0 q Form a collection of tiles to capture the ways that these characters can fit together.Form a collection of tiles to capture the ways that these characters can fit together.

89 Context Free Grammars Halting Problem = { | M halts on I} is undecidable { | CFG generates I} { | CFG G generates every string} { | CFG G generates no string} { | L(G) = L(G’)} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! ? O(n 3 ) time

90 T  AB  CA  TT A  AA  BT  a B  TA  BC  b  e C  CB  AC  c  d Ask Little Bird: For first rule For the split. Input: T  a 1 a 2 a 3..... a n b d a b a e a a d b T C A CFG G Generates I (Parsing)

91 T  AB  CA  TT A  AA  BT  a B  TA  BC  b  e C  CB  AC  c  d Ask left friend: Instance: C  baeaadb Solution: Left parsing Input: T  a 1 a 2 a 3..... a n b a e a a d b C T b d a A A A B A C C B ACT AB CFG G Generates I (Parsing)

92 T  AB  CA  TT A  AA  BT  a B  TA  BC  b  e C  CB  AC  c  d Ask right friend: Instance: A  bda Solution: Right parsing Input: T  a 1 a 2 a 3..... a n A B T C A b d a T C b a e a a d b CFG G Generates I (Parsing)

93 T  AB  CA  TT A  AA  BT  a B  TA  BC  b  e C  CB  AC  c  d Combine: Instance: Bird’s Answer Left Friend’s Answer Right Friend’s Answer Input: T  a 1 a 2 a 3..... a n A A B A C C B ACT AB B T C A T b d a b a e a a d b C A CFG G Generates I (Parsing)

94 T’  a i a i+1..... a j  non-terminals T’ &  i,j  [1,n] sub-Instances: Running time =  ( # of sub-instances × # bird answers ) =  ( # of non-terminals × n 2 gives: First rule and split × # of rules · n ) Done CFG G Generates I (Parsing)

95 Halting Problem = { | M halts on I} is undecidable { | CFG generates I} { | CFG G generates every string} { | CFG G generates no string} { | L(G) = L(G’)} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! ? O(n 3 ) time Undecidable CFG Generates Everything

96 GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | CFG G generates every string} { | M halts on I} ≤ { | CFG G generates every string} No, M(I) does not halt Grammar G rules mimic the rules of the TM M on input I Yes, there is a parsing of everything CFG Generates Everything

97 GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | CFG G generates every string} { | M halts on I} ≤ { | CFG G generates every string} Yes, M(I) does halt Grammar G rules mimic the rules of the TM M on input I No, the string corresponding to the computation cant be parsed CFG Generates Everything

98 Encode configuration of the TM as a string giving the contents of the tape and the current state inserted where the head is.Encode configuration of the TM as a string giving the contents of the tape and the current state inserted where the head is. 10q i 10010 CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q

99 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # I CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q TM accepts by halting in the accept state with the tape empty

100 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q Can a CFG generate this string? Can a CFG generate this string?Linked because must be the same string α # α Linked because must be the same string No

101 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q Can a CFG generate every string but this string? Can a CFG generate every string but this string? α # β α≠β α≠β Yes

102 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q M halts on I  there is such a computation string  CFG can generate every string but this string  CFG does not generate every string  Oracle says no

103 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q M does not halt on I  there is no such a computation string  CFG can generate every string  Oracle says yes

104 Encode the halting computation of M on I as the string of configurations separated by ‘#’Encode the halting computation of M on I as the string of configurations separated by ‘#’ #q start 0110010#1q 3 010010#10q 7 10010#100q 6 0010#10 …. #q accept # CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q A string is not this string if at least one of: A string is not this string if at least one of: It does not start with #q start I# It does not start with #q start I# It does not end with #q accept # It does not end with #q accept # Some time step #10q 7 10010#100q 6 0010# is not according to the TM M. Some time step #10q 7 10010#100q 6 0010# is not according to the TM M.

105 CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q {0,1} * #10q 7 10010#100q 6 0010# {0,1} * Some time step is not according to the TM M. Some time step is not according to the TM M. This is correct, but we need it to be wrong Not according to the TM M if at least one of: Not according to the TM M if at least one of: Not (#{0,1} * q i {0,1} * ) * # Not (#{0,1} * q i {0,1} * ) * # Transition rule incorrect. Transition rule incorrect. Early unchanged tape not copied correctly Early unchanged tape not copied correctly Late unchanged tape not copied correctly Late unchanged tape not copied correctly

106 CFG Generates Everything Consider some configuration of a TM 1 011 0 1 0 q {0,1} * #10q 7 10010#100q 6 0010# {0,1} * Early unchanged tape not copied correctly Early unchanged tape not copied correctly {0,1} * # {0,1} i 0 {0,1} * {q i }{0,1} * # {0,1} i 1{0,1} * {q i }{0,1} * #{0,1} * Linked because same size S’  A# B 1A {q i } A # A S’  A# B 1A {q i } A # A A  CA | ε C  0 | 1 A  CA | ε C  0 | 1 B  CBC B  CBC  0A{q i }A#  0A{q i }A# B A The rest is similar

107 GIVEN: Oracle for BUILD: Oracle for { | M halts on I} { | CFG G generates every string} { | M halts on I} ≤ { | CFG G generates every string} No, M(I) does not halt Grammar G rules mimic the rules of the TM M on input I Yes, there is a parsing of everything CFG Generates Everything

108 Halting Problem = { | M halts on I} is undecidable { | CFG generates I} { | CFG G generates every string} { | CFG G generates no string} { | L(G) = L(G’)} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! ? O(n 3 ) time Undecidable O(~n) time CFG G Generates Some String

109 Input: CFG G Output: Whether generates any string Algorithm by example G = S  abAcdSaaAef | acAadBddAa | cCdAe A  aaAbbBb | baBcd B  aaBssSsa | funwow | aAbCc C  ccCcSdAd | efCghAqSr | bBbAbBb Does this G generate any string?

110 CFG G Generates Some String G = S  abAcdSaaAef | acAadBddAa | cCdAe A  aaAbbBb | baBcd B  aaBssSsa | funwow | aAbCc C  ccCcSdAd | efCghAqSr | bBbAbBb We only care if G generates some string. We don’t care which. Delete all terminals G 2 = S  ASA | ABA | CA A  AB | B B  BS | ε | AC C  CSA | CAS | BAB G generates some string iff G 2 generates ε.

111 CFG G Generates Some String Does G 2 generate ε? We need a parsing that gets rid of all non-terminals. Non-terminal B can be replaced with ε. Why ever use the rule B  AC instead of B  ε G 2 = S  ASA | ABA | CA A  AB | B B  BS | ε | AC C  CSA | CAS | BAB G 2 generates ε iff G 3 generates ε. G 3 = S  ASA | ABA | CA A  AB | B B  ε C  CSA | CAS | BAB

112 CFG G Generates Some String Does G 3 generate ε? Lets just plug in B  ε G 3 generates ε iff G 4 generates ε. G 4 = S  ASA | AA | CA A  A | ε C  CSA | CAS | A G 3 = S  ASA | ABA | CA A  AB | B B  ε C  CSA | CAS | BAB

113 CFG G Generates Some String Does G 4 generate ε? Why use A  A instead of A  ε Lets just plug in A  ε G 4 generates ε iff G 5 generates ε. G 5 = S  S | ε | C C  CS | CS | ε G 4 = S  ASA | AA | CA A  A | ε C  CSA | CAS | A

114 CFG G Generates Some String Does G 5 generate ε? Yes using S  ε Hence, G generates some string! G 5 = S  S | ε | C C  CS | CS | ε

115 CFG G Generates Some String Input: CFG G Output: Whether generates any string Algorithm by another example G = S  abAcdSaaAef | acAadBddAa | cCdAe A  aaAbbBb | baBcd B  aaBssSsa | aAbCc C  ccCcSdAd | efCghAqSr | bBbAbBb Does this G generate any string?

116 CFG G Generates Some String G = S  abAcdSaaAef | acAadBddAa | cCdAe A  aaAbbBb | baBcd B  aaBssSsa | aAbCc C  ccCcSdAd | efCghAqSr | bBbAbBb We only care if G generates some string. We don’t care which. Delete all terminals G 2 = S  ASA | ABA | CA A  AB | B B  BS | AC C  CSA | CAS | BAB G generates some string iff G 2 generates ε.

117 CFG G Generates Some String Does G 2 generate ε? The number non-terminals in our string never goes down G 2 does not generate ε. Hence, G does not generate any strings! G 2 = S  ASA | ABA | CA A  AB | B B  BS | AC C  CSA | CAS | BAB

118 Halting Problem = { | M halts on I} is undecidable { | CFG generates I} { | CFG G generates every string} { | CFG G generates no string} { | L(G) = L(G’)} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! ? O(n 3 ) time Undecidable O(~n) time Undecidable L(G) = L(G’)

119 GIVEN: Oracle for BUILD: Oracle for { | CFG G generates every string} { | L(G) = L(G’)} { | CFG G generates every string} ≤ { | L(G) = L(G’)} Yes, G generates every string G’ = S  AS | ε A  0| 1 Yes, L(G) = L(G’) L(G) = L(G’)

120 Context Free Grammars Halting Problem = { | M halts on I} is undecidable { | CFG generates I} { | CFG G generates every string} { | CFG G generates no string} { | L(G) = L(G’)} Will prove: ≥ comp { | M halts on I} Hence, all are undecidable! O(n 3 ) time Undecidable O(~n) time Undecidable

121 Game of Life The Game of Life: Grid of square cells, each live or dead. The initial pattern is the seed of the system. At each step in time, every live cell # live neighbours {2,3}  dies every dead cell # live neighbours = 3  comes alive

122 Game of Life The Game of Life: Grid of square cells, each live or dead. The initial pattern is the seed of the system. At each step in time, every live cell # live neighbours {2,3}  dies every dead cell # live neighbours = 3  comes alive Life Problem: Input: An initial configuration Output: Does it go on forever? Undecidable! I would love to see the proof.

123 Hilbert’s 10 th Problem Input: a multi-variate polynomial 2x 2 y 8 z 3 + 7x 3 y 2 - 8x 4 y 2 z 5 = 0 Output: Does it have integer values giving zero? Undecidable! Proof not hard. Maybe we will cover it.

124 The End


Download ppt "Jeff Edmonds York University COSC 4111 Lecture 4 Different ModelsDifferent ModelsDifferent ModelsDifferent Models ReductionsReductionsReductions Simple."

Similar presentations


Ads by Google