CS3102 Theory of Computation - - PowerPoint PPT Presentation

โ–ถ
cs3102 theory of
SMART_READER_LITE
LIVE PREVIEW

CS3102 Theory of Computation - - PowerPoint PPT Presentation

CS3102 Theory of Computation www.cs.virginia.edu/~njb2b/cstheory/s2020 Warm up: How might we try to show that this language is not computable: = is infinite} How to show things arent


slide-1
SLIDE 1

CS3102 Theory of Computation

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

Warm up: How might we try to show that this language is not computable: ๐ฝ๐‘œ๐‘”๐‘—๐‘œ๐‘—๐‘ข๐‘“ = ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is infinite}

slide-2
SLIDE 2

How to show things arenโ€™t computable

  • 1. Ask โ€œcan I have an always-halting Turing

machine ๐‘๐‘ž for language/function/problem ๐‘„?โ€

  • 2. Show that, if ๐‘๐‘ž exists, it can be used to

make an impossible machine ๐‘๐‘—๐‘›๐‘ž

2

How do we know a machine is impossible? Option 1: It contradicts itself (e.g. ๐‘๐‘‡๐‘†) Option 2: Someone has done this before (e.g. ๐‘๐‘๐‘‘๐‘‘)

slide-3
SLIDE 3

Proving Other Problems are Uncomputable

  • Reduction

โ€“ Convert some problem into a known uncomputable one (using only computable steps) โ€“ Show how you can use a solution to one problem to help you to solve another

3

slide-4
SLIDE 4

Non-Computable Problems

4

slide-5
SLIDE 5

MacGyverโ€™s Reduction

5

Opening a door Problem know is impossible Lighting a fire Problem we think is impossible Alcohol, wood, matches Solution for ๐‘ช

๐ต ๐ถ

Keg cannon battering ram Solution for ๐‘ฉ

Aim duct at door, insert keg

If

Put fire under the Keg

Reduction

slide-6
SLIDE 6

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

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

is finite 0 if ๐‘€ โ„ณ ๐‘ฅ is infinite

  • To show ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น is uncomputable

โ€“ Show how to use a TM for ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น to solve ๐ผ๐ต๐‘€๐‘ˆ

  • ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น โ‰ฅ ๐ผ๐ต๐‘€๐‘ˆ
  • ๐ผ๐ต๐‘€๐‘ˆ reduces to ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

6

slide-7
SLIDE 7

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

7

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

Problem know is impossible

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

Problem we think is impossible ๐‘

๐‘”๐‘—๐‘œ๐‘—๐‘ข๐‘“ computes ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

๐ต ๐ถ

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

Assume Reduction Does โ„ณ(๐‘ฅ) halt on input ๐‘ฆ? Is L โ„ณ ๐‘ฅ finite? ๐‘๐ผ๐ต๐‘€๐‘ˆ computes ๐ผ๐ต๐‘€๐‘ˆ Give ๐‘๐‘ฅ๐‘ฆ as input to ๐‘

๐‘”๐‘—๐‘œ๐‘—๐‘ข๐‘“ answer opposite

slide-8
SLIDE 8

Whatโ€™s the Language of ๐‘๐‘ฅ๐‘ฆ?

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

โ€“ ๐‘๐‘ฅ๐‘ฆ always returns 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = ฮฃโˆ— (all strings) โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ is infinite

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

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

8

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

slide-9
SLIDE 9

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

9

Is L โ„ณ ๐‘ฅ finite? ๐‘ต๐‘ฎ๐‘ฑ๐‘ถ๐‘ฑ๐‘ผ๐‘ญ ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t finite ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฆ halt? โ„ณ ๐‘ฅ 1 ! = 1 Assume we have ๐‘๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น which computes ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น: We could then build ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆlike this: ๐‘ฅ ๐‘ฆ

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

Is L ๐‘๐‘ฅ๐‘ฆ finite? ๐‘ต๐‘ฎ๐‘ฑ๐‘ถ๐‘ฑ๐‘ผ๐‘ญ

slide-10
SLIDE 10

Showing ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น is not computable

  • Use _____ to build _____.

10

slide-11
SLIDE 11

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

11

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

๐‘โˆž computes ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

๐ต ๐ถ

Assume Reduction Is L โ„ณ ๐‘ฅ finite? Is L โ„ณ ๐‘ฅ infinite? ๐‘๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น computes ๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

slide-12
SLIDE 12

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

12

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

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

๐ต ๐ถ

Assume Reduction Is L โ„ณ ๐‘ฅ infinite? Is L โ„ณ ๐‘ฅ finite? ๐‘โˆž computes ๐ฝ๐‘‚๐บ๐ฝ๐‘‚๐ฝ๐‘ˆ๐น

slide-13
SLIDE 13

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

13

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

slide-14
SLIDE 14

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

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

is not regular}

  • We will show this is not computable by using

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

  • Idea: given an input for ๐ผ๐ต๐‘€๐‘ˆ, ๐‘ฅ and ๐‘ฆ, build

a machine ๐‘๐‘ฅ๐‘ฆ such that ๐‘€(๐‘๐‘ฅ๐‘ฆ) is regular if and only if โ„ณ(๐‘ฅ)(๐‘ฆ) runs forever.

14

slide-15
SLIDE 15

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

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

โ€“ ๐‘๐‘ฅ๐‘ฆ returns 1 if ๐‘Œ๐‘ƒ๐‘† ๐‘ง = 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = ๐‘Œ๐‘ƒ๐‘†(๐‘ง), which is not regular

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

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

15

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

slide-16
SLIDE 16

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

16

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 ๐‘Œ๐‘ƒ๐‘†(๐‘ง)

Is L ๐‘๐‘ฅ๐‘ฆ non- regular? ๐‘ต๐‘ถ๐‘บ

slide-17
SLIDE 17

Language ๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข๐‘ก101

  • ๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข๐‘ก101 = ๐‘ฅ โ„ณ ๐‘ฅ

101 = 0}

  • We will show this is not computable by using

๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข๐‘ก101 to compute ๐ผ๐ต๐‘€๐‘ˆ

  • Idea: given an input for ๐ผ๐ต๐‘€๐‘ˆ, ๐‘ฅ and ๐‘ฆ, build

a machine ๐‘๐‘ฅ๐‘ฆ such that 101 โˆˆ ๐‘€(๐‘›๐‘ฅ๐‘ฆ) if and only if โ„ณ(๐‘ฅ)(๐‘ฆ) runs forever.

17

slide-18
SLIDE 18

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

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

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

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

โ€“ ๐‘๐‘ฅ๐‘ฆ gets โ€œstuckโ€ in step 2 and never returns 1 โ€“ ๐‘€ ๐‘๐‘ฅ๐‘ฆ = โˆ…, so it does reject 101

18

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

slide-19
SLIDE 19

Using ๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข๐‘ก101 to build ๐ผ๐ต๐‘€๐‘ˆ

19

Does โ„ณ(๐‘ฅ) reject 101? ๐‘ต๐‘บ๐Ÿ๐Ÿ๐Ÿ ๐‘ฅ โ„ณ(๐‘ฅ) does/doesnโ€™t reject 101 ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฆ halt? โ„ณ(๐‘ฅ)(๐‘ฆ) does/doesnโ€™t halt Assume we have ๐‘๐‘†101 which computes ๐‘‚๐‘๐‘œ๐‘†๐‘“๐‘•: We could then build ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆlike this: ๐‘ฅ ๐‘ฆ

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

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

slide-20
SLIDE 20

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.

20

slide-21
SLIDE 21

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?

21

slide-22
SLIDE 22

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:

22

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

slide-23
SLIDE 23

Proof of Riceโ€™s Theorem

  • Let ๐‘„ be a semantic property of a Turing machine
  • Assume ๐‘โˆ… (a machine whose language is โˆ…) has property ๐‘„ (otherwise

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

  • Let ๐‘๐บ๐ต๐‘€๐‘‡๐น be a machine that doesnโ€™t have property ๐‘„
  • Idea:

โ€“ If โ„ณ(๐‘ฅ)(๐‘ฆ) halts, ๐‘€ ๐‘๐‘ฅ๐‘ฆ = ๐‘€ ๐‘๐บ๐ต๐‘€๐‘‡๐น โ€“ If โ„ณ(๐‘ฅ)(๐‘ฆ) doesnโ€™t halt, ๐‘€ ๐‘๐‘ฅ๐‘ฆ = L ๐‘โˆ… = โˆ… โ€“ ๐‘€(๐‘๐‘ฅ๐‘ฆ) has property ๐‘„ if and only if โ„ณ ๐‘ฅ ๐‘ฆ runs forever

23

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

slide-24
SLIDE 24

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

24

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-25
SLIDE 25

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

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

โ€“ ๐‘๐บ๐‘๐‘š๐‘ก๐‘“ canโ€™t exist

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

โ€“ It applies to ๐‘โˆ…, ยฌ๐‘„ applies to all machines

25

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

slide-26
SLIDE 26

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 ๐œ?

26

slide-27
SLIDE 27

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

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

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

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

27

slide-28
SLIDE 28

๐‘ƒ๐‘ค๐‘“๐‘ ๐‘ฅ๐‘ ๐‘—๐‘ข๐‘“โˆ‡

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

w โ„ณ ๐‘ฅ overwrites โˆ‡ on input ๐œ}

  • Is ๐‘ƒ๐‘ค๐‘“๐‘ ๐‘ฅ๐‘ ๐‘—๐‘ข๐‘“โˆ‡ computable?

28