Language IN = is - - PowerPoint PPT Presentation

โ–ถ
language in
SMART_READER_LITE
LIVE PREVIEW

Language IN = is - - PowerPoint PPT Presentation

Language IN = is infinite} We will show this is not computable by using to compute 1 Halts? It is


slide-1
SLIDE 1

Language IN๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

  • ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น = ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ

is infinite}

  • We will show this is not computable by using

๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น to compute ๐ผ๐ต๐‘€๐‘ˆ

1

slide-2
SLIDE 2

Language of ๐‘๐‘ฅ๐‘ฆ

  • If โ„ณ(๐‘ฅ)(๐‘ฆ) halts:

โ€“ ๐‘๐‘ฅ๐‘ฆ always returns 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = ฮฃโˆ—, which is infinite

  • If โ„ณ(๐‘ฅ)(๐‘ฆ) doesnโ€™t halt:

โ€“ ๐‘๐‘ฅ๐‘ฆ gets โ€œstuckโ€ in step 1 and never returns โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = โˆ…, which is finite

2

Build this machine: ๐‘๐‘ฅ๐‘ฆ: 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return 1 โ„ณ ๐‘ฅ ๐‘ฆ Halts? It is infinite โ„ณ ๐‘ฅ ๐‘ฆ Doesnโ€™t Halt? It isnโ€™t infinite

slide-3
SLIDE 3

Using ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น to build ๐ผ๐ต๐‘€๐‘ˆ

3

Is L โ„ณ ๐‘ฅ infinite? ๐‘ตโˆž ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t infinite ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฆ halt? โ„ณ ๐‘ฅ ๐‘ฆ does/doesnโ€™t halt Assume we have ๐‘โˆž which computes ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น: We could then build ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆlike this: ๐‘ฅ ๐‘ฆ

Build this machine: ๐‘๐‘ฅ๐‘ฆ: 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return 1

Is L ๐‘๐‘ฅ๐‘ฆ infinite? ๐‘ตโˆž

slide-4
SLIDE 4

Reduction

4

๐ผ๐ต๐‘€๐‘ˆ

Problem know is impossible

๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

Problem we think is impossible ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น solver exists

๐ต ๐ถ

Build (but donโ€™t run) ๐‘๐‘ฅ๐‘ฆ

Assume Reduction Does โ„ณ(๐‘ฅ) halt on input ๐‘ฆ? Is L โ„ณ ๐‘ฅ infinite? ๐‘๐ผ๐ต๐‘€๐‘ˆ computes ๐ผ๐ต๐‘€๐‘ˆ Give ๐‘๐‘ฅ๐‘ฆ to the ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น solver, then answer the same

slide-5
SLIDE 5

Using ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น to build ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

5

Is L โ„ณ ๐‘ฅ finite? ๐‘ต๐‘ฎ๐‘ฑ๐‘ถ๐‘ฑ๐‘ผ๐‘ญ ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t finite ๐‘ตโˆž Is L โ„ณ ๐‘ฅ infinite? ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t infinite Assume we have ๐‘๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น which computes ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น: We could then build ๐‘โˆž which computes ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น like this: ๐‘ฅ Is L โ„ณ ๐‘ฅ finite? ๐‘ต๐‘ฎ๐‘ฑ๐‘ถ๐‘ฑ๐‘ผ๐‘ญ

slide-6
SLIDE 6

Language ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘•

  • ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘• = ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ

is non โˆ’ regular}

  • We will show this is not computable by using

๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘• to compute ๐ผ๐ต๐‘€๐‘ˆ

6

slide-7
SLIDE 7

Language of ๐‘๐‘ฅ๐‘ฆ

  • If โ„ณ(๐‘ฅ)(๐‘ฆ) halts:

โ€“ ๐‘๐‘ฅ๐‘ฆ returns 1 if MAJ ๐‘ง = 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = ๐‘๐ต๐พ(๐‘ง), which is non-regular

  • If โ„ณ(๐‘ฅ)(๐‘ฆ) doesnโ€™t halt:

โ€“ ๐‘๐‘ฅ๐‘ฆ gets โ€œstuckโ€ in step 1 and never returns 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = โˆ…, which isnโ€™t non-regular

7

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return MAJ(๐‘ง) โ„ณ ๐‘ฅ ๐‘ฆ Halts? It is non-regular โ„ณ ๐‘ฅ ๐‘ฆ Doesnโ€™t Halt? It isnโ€™t non-regular

slide-8
SLIDE 8

Using ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘• to build ๐ผ๐ต๐‘€๐‘ˆ

8

Is L โ„ณ ๐‘ฅ non- regular? ๐‘ต๐‘ถ๐‘บ ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t non-regular ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฆ halt? โ„ณ(๐‘ฅ)(๐‘ฆ) does/doesnโ€™t halt Assume we have ๐‘๐‘‚๐‘† which computes ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘•: We could then build ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆlike this: ๐‘ฅ ๐‘ฆ

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return MAJ(๐‘ง)

Is L โ„ณ ๐‘ฅ non- regular? ๐‘ต๐‘ถ๐‘บ

slide-9
SLIDE 9

Reduction

9

๐ผ๐ต๐‘€๐‘ˆ ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘•

๐ต ๐ถ

Describe that machine ๐‘๐‘ฅ๐‘ฆ

Assume Reduction ๐‘๐ผ๐ต๐‘€๐‘ˆ computes ๐ผ๐ต๐‘€๐‘ˆ Give ๐‘๐‘ฅ๐‘ฆ to the ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘• solver, then answer the same ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘• solver exists Does โ„ณ(๐‘ฅ) halt on input ๐‘ฆ? Is L โ„ณ ๐‘ฅ non- regular?

slide-10
SLIDE 10

Using ๐‘†๐‘“๐‘• to build๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘•

10

Is L โ„ณ ๐‘ฅ regular? ๐‘ต๐‘†๐‘“๐‘• ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t Regular ๐‘ต๐‘ถ๐‘บ Is L โ„ณ ๐‘ฅ non-regular? ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t non- regular Assume we have ๐‘๐‘†๐‘“๐‘• which computes ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘•: We could then build ๐‘๐‘‚๐‘† which computes๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘• like this: ๐‘ฅ Is L โ„ณ ๐‘ฅ regular? ๐‘ต๐‘†๐‘“๐‘•

slide-11
SLIDE 11

Language ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101

  • ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 = ๐‘ฅ โ„ณ ๐‘ฅ

101 = 1}

  • We will show this is not computable by

using๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 to compute ๐ผ๐ต๐‘€๐‘ˆ

11

slide-12
SLIDE 12

Building ๐‘๐‘ฅ๐‘ฆ

  • If โ„ณ(๐‘ฅ)(๐‘ฆ) halts:

โ€“ ๐‘๐‘ฅ๐‘ฆ returns 1 if ๐‘ง == 101 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = {101}, so it does accept 101

  • If โ„ณ(๐‘ฅ)(๐‘ฆ) doesnโ€™t halt:

โ€“ ๐‘๐‘ฅ๐‘ฆ gets โ€œstuckโ€ in step 1 and never returns 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = โˆ…, so it doesnโ€™t accept 101

12

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return ๐‘ง == 101 โ„ณ ๐‘ฅ ๐‘ฆ Halts? It does accept 101 โ„ณ ๐‘ฅ ๐‘ฆ Doesnโ€™t Halt? It doesnโ€™t accept101

slide-13
SLIDE 13

Using ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 to build ๐ผ๐ต๐‘€๐‘ˆ

13

Does โ„ณ(๐‘ฅ) accept 101? ๐‘ต๐‘ฉ๐Ÿ๐Ÿ๐Ÿ ๐‘ฅ โ„ณ(๐‘ฅ) does/doesnโ€™t accept 101 ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฆ halt? โ„ณ(๐‘ฅ)(๐‘ฆ) does/doesnโ€™t halt Assume we have ๐‘

๐ต101

which computes๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101: We could then build ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆlike this: ๐‘ฅ ๐‘ฆ

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return ๐‘ง == 101

Does โ„ณ(๐‘ฅ) accept 101? ๐‘ต๐‘ฉ๐Ÿ๐Ÿ๐Ÿ

slide-14
SLIDE 14

๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 Reduction

14

๐ผ๐ต๐‘€๐‘ˆ ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101

๐ต ๐ถ

Describe that machine ๐‘๐‘ฅ๐‘ฆ

Assume Reduction ๐‘๐ผ๐ต๐‘€๐‘ˆ computes ๐ผ๐ต๐‘€๐‘ˆ Give ๐‘๐‘ฅ๐‘ฆ to the ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 solver, then answer the same ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 solver exists Does โ„ณ(๐‘ฅ) halt on input ๐‘ฆ? Is 101 โˆˆ L โ„ณ ๐‘ฅ ?

slide-15
SLIDE 15

Using๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข101 to build ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101

15

Is 101 โˆ‰ L โ„ณ ๐‘ฅ ? ๐‘ต๐‘†101 ๐‘ฅ 101 isnโ€™t/is in ๐‘€ โ„ณ ๐‘ฅ ๐‘ต๐ต101 Is 101 โˆˆ L โ„ณ ๐‘ฅ ? 101 is/isnโ€™t in ๐‘€ โ„ณ ๐‘ฅ Assume we have ๐‘๐‘†101 which computes ๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข101: We could then build ๐‘

๐ต101

which computes ๐ต๐‘‘๐‘‘๐‘“๐‘ž๐‘ข101 like this: ๐‘ฅ Is 101 โˆ‰ L โ„ณ ๐‘ฅ ? ๐‘ต๐‘†101

slide-16
SLIDE 16

Computability and non-computability closed under complement

  • If ๐‘€ is computable, then ๐‘€๐‘‘ is computable

16

Is ๐‘ฅ โˆˆ L? ๐‘ต๐‘ด ๐‘ฅ ๐‘ฅ is/isnโ€™t in ๐‘€ Assume we have ๐‘๐‘€ which computes ๐‘€: ๐‘ต๐‘€๐‘‘ Is ๐‘ฅ โˆ‰ L? We could then build ๐‘๐‘€๐‘‘ which computes ๐‘€๐‘‘ like this: ๐‘ฅ Is ๐‘ฅ โˆˆ L? ๐‘ต๐‘ด ๐‘ฅ isnโ€™t/is in ๐‘€

slide-17
SLIDE 17

Complement Reduction

17

๐‘€๐‘‘ ๐‘€

๐ต ๐ถ

Donโ€™t change ๐‘ฅ

If Reduction ๐‘€๐‘‘ solver exists Give ๐‘ฅ to the ๐‘€ solver, then answer the

  • pposite

๐‘€ solver exists ๐‘ฅ โˆ‰ ๐‘€? ๐‘ฅ โˆˆ ๐‘€? ๐‘€ solver doesnโ€™t exist ๐‘€๐‘‘ solver doesnโ€™t exist

slide-18
SLIDE 18

Sematic Property

  • Turing machines ๐‘, ๐‘โ€ฒ are Functionally Equivalent if

โˆ€๐‘ฆ โˆˆ ฮฃโˆ—, ๐‘ ๐‘ฆ == ๐‘ ๐‘ฆโ€ฒ

โ€“ i.e. they compute the same function/language

  • A Semantic Property of a Turing machine is one that

depends only on the input/output behavior of the machine

โ€“ Formally, if ๐‘„ is semantic, then for machine ๐‘, ๐‘โ€ฒ that are functionally equivalent, ๐‘„ ๐‘ == ๐‘„ ๐‘โ€ฒ โ€“ If ๐‘, ๐‘โ€ฒ have the same input/output behavior, and ๐‘„ is a semantic property, then either bother ๐‘ and ๐‘โ€ฒ have property ๐‘„, or neither of them do.

18

slide-19
SLIDE 19

Examples

  • These properties are Semantic:

โ€“ Is the language of this machine finite? โ€“ Is the language of this machine Regular? โ€“ Does this machine reject 101? โ€“ Does this machine return 1001 for input 001? โ€“ Does this machine only ever return odd numbers? โ€“ Is the language of this machine computable?

  • These properties are not Semantic:

โ€“ Does this machine ever overwrite cell 204 of its tape? โ€“ Does this machine use more than 3102 cells of its tape on input 101? โ€“ Does this machine take at least 2020 transitions for input ๐œ? โ€“ Does this machine ever overwrite the ๐›ผ symbol?

19

slide-20
SLIDE 20

Riceโ€™s Theorem

  • For any Semantic property ๐‘„ of Turing Machines,

either:

โ€“ Every Turing machine has property ๐‘„ โ€“ No Turing machines have property ๐‘„ โ€“ ๐‘„ is uncomputable

  • In other words:

โ€“ If ๐‘„ is semantic, and computable, then one of these two machines computes it:

20

๐‘„ is โ€œtrivialโ€ Return 1 Return 0

slide-21
SLIDE 21

Proof of Riceโ€™s Theorem

  • Let ๐‘„ be a semantic property of a Turing machine
  • Assume ๐‘โˆ… (a machine whose language is โˆ…) doesnโ€™t have property ๐‘„

(otherwise substitute ยฌ๐‘„, then answer opposite)

  • Let ๐‘๐‘„ be a machine that does have property ๐‘„
  • Idea:

โ€“ If โ„ณ(๐‘ฅ)(๐‘ฆ) halts, ๐‘€ ๐‘๐‘ฅ๐‘ฆ = ๐‘€ ๐‘โ„Ž๐‘๐‘ก ๐‘„ โ€“ If โ„ณ(๐‘ฅ)(๐‘ฆ) doesnโ€™t halt, ๐‘€ ๐‘๐‘ฅ๐‘ฆ = L ๐‘โˆ… = โˆ… โ€“ ๐‘€(๐‘๐‘ฅ๐‘ฆ) has property ๐‘„ if and only if โ„ณ ๐‘ฅ ๐‘ฆ halts

21

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return ๐‘โ„Ž๐‘๐‘ก ๐‘„(๐‘ง) โ„ณ ๐‘ฅ ๐‘ฆ Halts? It has property ๐‘„ โ„ณ ๐‘ฅ ๐‘ฆ Doesnโ€™t Halt? It doesnโ€™t have property ๐‘„

slide-22
SLIDE 22

Using ๐‘„ to build ๐ผ๐ต๐‘€๐‘ˆ

22

Does โ„ณ(๐‘ฅ) have property ๐‘„? ๐‘ต๐‘ธ ๐‘ฅ โ„ณ(๐‘ฅ) does/doesnโ€™t have property ๐‘„ ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฆ halt? โ„ณ(๐‘ฅ) does/doesnโ€™t have property ๐‘„ Assume we have ๐‘๐‘„ which computes ๐‘„: We could then build ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆlike this: ๐‘ฅ ๐‘ฆ

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return ๐‘โ„Ž๐‘๐‘ก ๐‘„(๐‘ง)

Does โ„ณ(๐‘ฅ) have property ๐‘„? ๐‘ต๐‘ธ

slide-23
SLIDE 23

What if ๐‘„ is โ€œtrivialโ€?

  • If ๐‘„ applies to all Turing machines:

โ€“ It applies to ๐‘โˆ…, so weโ€™ll consider ยฌ๐‘„ which applies to no Turing machines

  • If ๐‘„ applies to no Turing machines:

โ€“ ๐‘๐ผ๐‘๐‘ก ๐‘„ canโ€™t exist

23

Build this machine: ๐‘๐‘ฅ๐‘ฆ(๐‘ง): 1) run โ„ณ(๐‘ฅ)(๐‘ฆ) 2) return ๐‘๐ผ๐‘๐‘ก ๐‘„(๐‘ง)

slide-24
SLIDE 24

Using Riceโ€™s Theorem

  • These properties are Semantic:

โ€“ Is the language of this machine finite? โ€“ Is the language of this machine Regular? โ€“ Does this machine reject 101? โ€“ Does this machine return 1001 for input 001? โ€“ Does this machine only ever return odd numbers? โ€“ Is the language of this machine computable?

  • These properties are not Semantic:

โ€“ Does this machine ever overwrite cell 204 of its tape? โ€“ Does this machine use more than 3102 cells of its tape on input 101? โ€“ Does this machine take at least 2020 transitions for input ๐œ? โ€“ Does this machine ever overwrite the ๐›ผ symbol on input ๐œ?

24

slide-25
SLIDE 25

๐‘‡๐‘ข๐‘“๐‘ž๐‘ก2020

  • ๐‘‡๐‘ข๐‘“๐‘ž๐‘ก2020 =

{๐‘ฅ|โ„ณ ๐‘ฅ takes at least 2020 steps}

  • Is ๐‘‡๐‘ข๐‘“๐‘ž๐‘ก2020 computable?

25

slide-26
SLIDE 26

๐‘ƒ๐‘ค๐‘“๐‘ ๐‘ฅ๐‘ ๐‘—๐‘ข๐‘“๐›ผ

  • ๐‘ƒ๐‘ค๐‘“๐‘ ๐‘ฅ๐‘ ๐‘—๐‘ข๐‘“๐›ผ =

w โ„ณ ๐‘ฅ overwrites ๐›ผ on input ๐œ}

  • Is ๐‘ƒ๐‘ค๐‘“๐‘ ๐‘ฅ๐‘ ๐‘—๐‘ข๐‘“๐›ผ computable?

26

slide-27
SLIDE 27

CS3102 Theory of Computation

www.cs.virginia.edu/~njb2b/cstheory/s2020

Warm up: To measure the โ€œcostโ€ of computing something, what would units should we use?

slide-28
SLIDE 28

Units

28

slide-29
SLIDE 29

Computing Cost

  • What do we actually care about with

computing cost?

29

slide-30
SLIDE 30

Notions of function โ€œdifficultyโ€

  • Can an algorithm for function ๐‘” be implemented using this

computing model?

โ€“ NAND-CIRC: answer is YES iff ๐‘” is finite โ€“ FSA: answer is YES if function doesnโ€™t require โ€œmemoryโ€ โ€“ TM: Answer is NO for ๐ผ๐ต๐‘€๐‘ˆ๐‘ˆ๐‘, ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น, โ€ฆ (and many other things)

  • How efficient is an algorithm for function ๐‘” implemented using

this computing model?

โ€“ NAND-CIRC: How many gates? โ€“ FSA: (we never talked about this) โ€“ TM: How many transitions are required (time)? How many tape cells are required (space)?

30

slide-31
SLIDE 31

Larger inputs = More time

  • Run time is not measured by a number, but a

function.

  • Running time: ๐‘ˆ ๐‘œ is a function mapping naturals to
  • naturals. We say ๐บ: 0,1 โˆ— โ†’ 0,1 โˆ— is computable in

๐‘ˆ ๐‘œ time if there exists a TM ๐‘ s.t. for every large ๐‘œ and ever input ๐‘ฆ โˆˆ 0,1 ๐‘œ, ๐‘ halts after at most ๐‘ˆ ๐‘œ steps and outputs ๐บ ๐‘ฆ .

  • ๐‘ˆ๐ฝ๐‘๐น ๐‘ˆ ๐‘œ

represents the set of boolean functions computable within ๐‘ˆ ๐‘œ time

31

slide-32
SLIDE 32

Examples

  • How long will ๐‘Œ๐‘ƒ๐‘† take on a Turing Machine?

โ€“ We have an even state and an odd state โ€“ For each bit, move right, switch states if 1 โ€“ Halt when you get to end of input

  • How long will ๐‘๐ต๐พ take on a Turing Machine?

โ€“ Find a zero, cross it off โ€“ Go to beginning โ€“ Find a one, cross it off โ€“ Go to beginning โ€“ Halt when no more 0s or no more 1s

32

slide-33
SLIDE 33

More time gives more functions

33

๐‘ˆ๐ฝ๐‘๐น ๐‘œ ๐‘ˆ๐ฝ๐‘๐น 10๐‘œ ๐‘ˆ๐ฝ๐‘๐น ๐‘œ3 ๐‘ˆ๐ฝ๐‘๐น 2๐‘œ

slide-34
SLIDE 34

Different computing Models may have Different Running Times

  • So far: a TM uses a tape. Can only visit a

neighboring cell from the current one.

34

slide-35
SLIDE 35

1960s

35

A tape was probably a reasonable memory model

slide-36
SLIDE 36

Today

36

Can look up two locations without visiting all locations between. โ€œRandomโ€ access (RAM)

slide-37
SLIDE 37

RAM Machine

  • We can go directly to a certain index in the tape

To transition: 1. Have a second tape to keep track of current location (increment each time we move right, decrement for left) 2. Have a third tape to record the target location 3. Move until the two tapes match

1. Maybe we need another tape to do this?

(details not important, but if you want them, see 7.2 in text) Important observation: Tape-machine takes more steps than a RAM machine (if a RAM-TM computes ๐‘” in ๐‘ˆ(๐‘œ) time, a tape TM can compute ๐‘” in ๐‘ˆ ๐‘œ

4

time, see theorem 12.5 for details)

37

slide-38
SLIDE 38

Finding Running Times

  • We will find running times for the following:

โ€“ Shortest Path in a graph โ€“ Longest Path in a graph โ€“ 3SAT โ€“ 2SAT

38

slide-39
SLIDE 39

Graphs

39

10 2 6 11 9 5 8 3 7 3 1 8 12 9 A B C D E F G I H

Definition: ๐ป = (๐‘Š, ๐น)

๐‘ฅ ๐‘“ = weight of edge ๐‘“

๐‘Š = {๐ต, ๐ถ, ๐ท, ๐ธ, ๐น, ๐บ, ๐ป, ๐ผ, ๐ฝ} ๐น = { ๐ต, ๐ถ , ๐ต, ๐ท , ๐ถ, ๐ท , โ€ฆ }

slide-40
SLIDE 40

Adjacency List Representation

40

10 2 6 11 9 5 8 3 7 3 1 8 12 9 A B C D E F G I H A B C D E F G H I B C A C E A B D F C E F B D G H C D G E F H I E G I G H

Tradeoffs Space: Time to list neighbors: Time to check edge (๐ต, ๐ถ):

๐‘Š + ๐น ๐ธ๐‘“๐‘•๐‘ ๐‘“๐‘“(๐ต) ๐ธ๐‘“๐‘•๐‘ ๐‘“๐‘“(๐ต)

slide-41
SLIDE 41

Adjacency Matrix Representation

41

10 2 6 11 9 5 8 3 7 3 1 8 12 9 A B C D E F G I H A B C D E F G H I

Tradeoffs Space: Time to list neighbors: Time to check edge (๐ต, ๐ถ):

๐‘Š2 ๐‘Š ๐‘ƒ(1) A B C D E F G H I 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-42
SLIDE 42

Definition: Path

42

10 2 6 11 9 5 8 3 7 3 1 8 12 9 A B C D E F G I H

A sequence of nodes (๐‘ค1, ๐‘ค2, โ€ฆ , ๐‘ค๐‘™) s.t. โˆ€1 โ‰ค ๐‘— โ‰ค ๐‘™ โˆ’ 1, ๐‘ค๐‘—, ๐‘ค๐‘—+1 โˆˆ ๐น Simple Path: A path in which each node appears at most once Cycle: A path of > 2 nodes in which ๐‘ค1 = ๐‘ค๐‘™

slide-43
SLIDE 43

Shortest Path

  • Given an unweighted graph, start node ๐‘ก and

an end node ๐‘ข, how long is shortest path from ๐‘ก to ๐‘ข?

43

A B C D E F G I H Shortest path from A to E has length 2

slide-44
SLIDE 44

Breadth First Search

44

Find a path from ๐‘ก to ๐‘ข Keep a queue ๐‘… of nodes โ„Ž๐‘๐‘ž๐‘ก = 0 ๐‘…. ๐‘“๐‘œ๐‘Ÿ๐‘ฃ๐‘“๐‘ฃ๐‘“((๐‘ก, โ„Ž๐‘๐‘ž๐‘ก)) While ๐‘… is not empty and ๐‘ค ! = ๐‘ข: ๐‘ค, โ„Ž๐‘๐‘ž๐‘ก = ๐‘…. ๐‘’๐‘“๐‘Ÿ๐‘ฃ๐‘“๐‘ฃ๐‘“() for each โ€œunvisitedโ€ ๐‘ฃ โˆˆ ๐‘Š s.t. ๐‘ค, ๐‘ฃ โˆˆ ๐น: ๐‘…. ๐‘“๐‘œ๐‘Ÿ๐‘ฃ๐‘“๐‘ฃ๐‘“((๐‘ฃ, โ„Ž๐‘๐‘ž๐‘ก + 1))

Running time: ๐‘ƒ ๐‘Š + ๐น

slide-45
SLIDE 45

Longest Path

  • Given a start node ๐‘ก and an end node ๐‘ข, how

long is longest path from ๐‘ก to ๐‘ข?

45

slide-46
SLIDE 46

Longest Path

Enumerate all possible sequences of nodes check if itโ€™s a path print the length of the longest one Running time: ๐‘œ!

46