Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recall last lecture and Nondeterministic TMs

Similar presentations


Presentation on theme: "Recall last lecture and Nondeterministic TMs"β€” Presentation transcript:

1 Recall last lecture and Nondeterministic TMs
Ola Svensson

2 Computational Complexity

3 Turing Machines

4 The goals A model that can compute anything computable
A model so simple and clean so that we can prove interesting results

5 A Turing machine 𝑀 is described by a tuple (Ξ“, 𝑄, 𝛿)
A finite alphabet Ξ“ containing (⊳,∎, 0, 1, …) start symbol blank symbol

6 A Turing machine 𝑀 is described by a tuple (Ξ“, 𝑄, 𝛿)
A finite alphabet Ξ“ containing (⊳,∎, 0, 1, …) A finite set 𝑄 of states containing π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ and π‘ž β„Žπ‘Žπ‘™π‘‘ A function 𝛿: Ξ“ 2 ×𝑄→ Ξ“ Γ— 𝐿,𝑆,𝑅 π‘˜ ×𝑄 describing rules of each step: IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

7 Example Start configuration of 𝑀 on input π‘₯ Input: ⊳ 1 ∎ …
∎ … Work/output: ⊳ ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

8 Example Input: ⊳ 1 ∎ … Work/output: ⊳ ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input
∎ … Work/output: ⊳ ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

9 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

10 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

11 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

12 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

13 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

14 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž οƒŸ Hey, don’t miss this! IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

15 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž IF THEN Input
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

16 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž IF THEN Input
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

17 Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž β„Žπ‘Žπ‘™π‘‘
∎ … Work/output: ⊳ 1 ∎ … State: π‘ž β„Žπ‘Žπ‘™π‘‘ What do we compute? IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right Stay Left π‘ž 1 π‘ž β„Žπ‘Žπ‘™π‘‘

18 Efficiency and Running Time
Let 𝑓: 0,1 βˆ— β†’ 0,1 βˆ— and let 𝑇:β„•β†’β„• Let 𝑀 be a Turing machine

19 Efficiency and Running Time
Let 𝑓: 0,1 βˆ— β†’ 0,1 βˆ— and let 𝑇:β„•β†’β„• Let 𝑀 be a Turing machine We say that 𝑀 computes 𝑓 if for every π‘₯∈ 0,1 βˆ— , whenever 𝑀 is initialized to the start configuration on input π‘₯, then it halts with f(π‘₯) written on its output type.

20 Efficiency and Running Time
Let 𝑓: 0,1 βˆ— β†’ 0,1 βˆ— and let 𝑇:β„•β†’β„• Let 𝑀 be a Turing machine We say that 𝑀 computes 𝑓 if for every π‘₯∈ 0,1 βˆ— , whenever 𝑀 is initialized to the start configuration on input π‘₯, then it halts with f(π‘₯) written on its output type. We say that 𝑀 computes 𝑓 in T n -time if its computation on every input π‘₯ requires at most T( π‘₯ ) steps.

21 Efficiency and Running Time
Let 𝑓: 0,1 βˆ— β†’ 0,1 βˆ— and let 𝑇:β„•β†’β„• Let 𝑀 be a Turing machine We say that 𝑀 computes 𝑓 if for every π‘₯∈ 0,1 βˆ— , whenever 𝑀 is initialized to the start configuration on input π‘₯, then it halts with f(π‘₯) written on its output type. We say that 𝑀 computes 𝑓 in T n -time if its computation on every input π‘₯ requires at most T( π‘₯ ) steps. DTIME(f(n)) = Set of languages that can be decided by a TM in time 𝑐⋅𝑓(𝑛)

22 Robustness of definition of Turing Machine
The size of the alphabet doesn’t really matter The number of tapes do not really matter (up to a square in the running time) It is able to simulate all other realistic models with polynomial slow down (except potentially quantum computers that still need to be built) Church-Turing Thesis: Any computable function can be computed by a Turing machine

23

24 Universal Turing Machine
Every binary string represents some Turing machine (write down 𝛿) A Turing machine has infinitely many representations (pad with ones) There exists a TM π‘ˆ such that for every π‘₯, π›Όβˆˆ 0,1 βˆ— π‘ˆ π‘₯, 𝛼 = M 𝛼 (π‘₯) Moreover, if 𝑀 𝛼 halts on input π‘₯ within 𝑇 steps then π‘ˆ(π‘₯,𝛼) halts within πΆβ‹…π‘‡β‹…π‘™π‘œπ‘”(𝑇) steps where 𝐢 is a number independent of π‘₯ . (𝐢 depends on the number of states, alphabet, and tapes of 𝑀 𝛼 ).

25 DIAGONALIZATION

26 Cantor’s argument The set of infinite binary strings are uncountable
𝑠 1 =(𝟎, 0, 0, 0, 0, 0, 0, … 𝑠 2 =(0, 𝟏, 0, 1, 0, 1, 0, … 𝑠 3 =(0, 1, 𝟏, 0, 1, 1, 0, … 𝑠 4 =(1, 1, 1, 𝟎, 1, 1, 0, … 𝑠 5 =(0, 0, 1, 0, 𝟏, 0, 1, … 𝑠 6 =(0, 0, 1, 0, 0, 𝟏, 1, … 𝑠 7 =(0, 0, 1, 0, 0, 1, 𝟎, … … 𝑠=(1, 0, 0, 1, 0, 0, 1, … s is different from any string in the enumeration so it is not part of the enumeration

27 Halting Problem The output of 𝑀 𝛼 3 ( 𝛼 5 ) (? if doesn’t halt) 𝜢 𝟏
𝜢 𝟐 𝜢 πŸ‘ 𝜢 πŸ’ 𝜢 πŸ“ 𝜢 πŸ” 𝟎 1 𝟏 ? … 𝐿= { 𝛼 1 , 𝛼 2 , 𝛼 𝛼 5 , 𝛼 6 , …} The set of strings 𝛼 for which M 𝛼 𝛼 =0 or ?

28 Halting Problem The output of 𝑀 𝛼 3 ( 𝛼 5 ) (? if doesn’t halt) 𝜢 𝟏
𝜢 𝟐 𝜢 πŸ‘ 𝜢 πŸ’ 𝜢 πŸ“ 𝜢 πŸ” 𝟎 1 𝟏 ? … 𝐿= { 𝛼 1 , 𝛼 2 , 𝛼 𝛼 5 , 𝛼 6 , …} The set of strings 𝛼 for which M 𝛼 𝛼 =0 or ? Suppose a TM M decides L. Let 𝛼 be its encoding. Then we get a contradiction on input 𝛼 since π›ΌβˆˆπΏβ‡” 𝑀 𝛼 𝛼 =0

29 Deterministic Time Hierarchy
The output of 𝑀 𝛼 3 ( 𝛼 5 ) (? if does not halt in 𝒏 𝟏.πŸ’ steps) 𝜢 𝟏 𝜢 𝟐 𝜢 πŸ‘ 𝜢 πŸ’ 𝜢 πŸ“ 𝜢 πŸ” 𝟎 1 𝟏 ? … 𝐿= { 𝛼 1 , 𝛼 2 , 𝛼 𝛼 5 , 𝛼 6 , …} The set of strings 𝛼 for which M 𝛼 𝛼 =0 or ?

30 Deterministic Time Hierarchy
The output of 𝑀 𝛼 3 ( 𝛼 5 ) (? if does not halt in 𝒏 𝟏.πŸ’ steps) 𝜢 𝟏 𝜢 𝟐 𝜢 πŸ‘ 𝜢 πŸ’ 𝜢 πŸ“ 𝜢 πŸ” 𝟎 1 𝟏 ? … 𝐿= { 𝛼 1 , 𝛼 2 , 𝛼 𝛼 5 , 𝛼 6 , …} The set of strings 𝛼 for which M 𝛼 𝛼 =0 or ? Suppose a TM M decides L in time n. Let 𝛼 be its encoding. Then we get a contradiction on input 𝛼 since π›ΌβˆˆπΏβ‡” 𝑀 𝛼 𝛼 =0

31 Diagonalization The proof technique used two things about TMs
They can be encoded efficiently There is a TM that can emulate any other without increasing running time or space too much Otherwise, they treated TMs as ”black boxes” We will show today that such a proof cannot alone resolve P vs NP

32 Nondeterministic Turing Machines

33 Nondeterministic Turing machines (NDTMs)
Same definition as TMs except that NDTM has two transition functions 𝛿 0 and 𝛿 1 and a special state called π‘ž π‘Žπ‘π‘π‘’π‘π‘‘ When NDTM computes a function we envision that at each computational step it makes an arbitrary choice as to which of its two transition functions to apply For every input π‘₯, we say that M π‘₯ =1 if there exists some sequences of these choices (called nondeterministic choices) that would make M reach π‘ž π‘Žπ‘π‘π‘’π‘π‘‘ on input π‘₯ Otherwise if every sequence of choices makes 𝑀 halt without reaching π‘ž π‘Žπ‘π‘π‘’π‘π‘‘ then we say 𝑀 π‘₯ =0 We say that 𝑀 runs in 𝑇 𝑛 -time if for every input π‘₯∈ 0,1 βˆ— and every sequence of nondeterministic choices, 𝑀 reaches either the halting state or π‘ž π‘Žπ‘π‘π‘’π‘π‘‘ within 𝑇( π‘₯ ) steps NTIME(f(n)) = Set of languages that can be decided by a NDTM in time 𝑐⋅𝑓(𝑛)

34 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

35 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

36 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

37 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

38 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

39 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

40 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .

41 If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .
Example What language do we accept? Input: ⊳ 1 ∎ … Work/output: ⊳ 1 ∎ … State: π‘ž οƒŸ Now normal deterministic execution… IF THEN Input symbol read Work (output) tape read Current state Move input head New work (output) symbol Move work head New state ⊳/0/1 ∎ π‘ž π‘ π‘‘π‘Žπ‘Ÿπ‘‘ Right 0 for 𝛿 0 1 for 𝛿 1 Stay Left π‘ž Once we reach state π‘ž, we run β€œnormal” TM to check if number on work tape divides input. If then move to π‘ž π‘Žπ‘π‘’π‘π‘‘ . If not move to π‘ž β„Žπ‘Žπ‘™π‘‘ .


Download ppt "Recall last lecture and Nondeterministic TMs"

Similar presentations


Ads by Google