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: Recall: , = 1 if (as a TM description, call it ) accepts , 0 otherwise Why would


slide-1
SLIDE 1

CS3102 Theory of Computation

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

Warm up: Recall:

  • ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ ๐‘ฅ, ๐‘ฆ = 1 if ๐‘ฅ (as a TM description, call it

โ„ณ ๐‘ฅ ) accepts ๐‘ฆ, 0 otherwise Why would ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ be a useful function to implement?

slide-2
SLIDE 2

Last Time

  • An uncomputable problem

โ€“ ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ ๐‘ฅ, ๐‘ฆ = 1 if ๐‘ฅ (as a TM description, call it โ„ณ ๐‘ฅ ) accepts ๐‘ฆ, 0 otherwise โ€“ First attempt to solve:

  • Try running โ„ณ(๐‘ฅ), see what happens

โ€“ Challenge: โ„ณ(๐‘ฅ) could not accept for two reasons

  • โ„ณ ๐‘ฅ halts and returns 0
  • โ„ณ ๐‘ฅ runs forever (how long do we wait to see?)

2

slide-3
SLIDE 3

Proving ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ is uncomputable

  • Proof by contradiction:

โ€“ Assume (toward contradiction) that there is an always- halting Turing machine to compute ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ โ€“ Show that we could use that Turing machine to build an impossible Turing machine

  • Whatโ€™s the impossible machine?

โ€“ ๐‘‡๐‘“๐‘š๐‘”๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข= The set of all Turing machine descriptions that donโ€™t accept themselves โ€“ ๐‘ฆ โˆˆ ๐‘‡๐‘“๐‘š๐‘”๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข if and only if โ„ณ ๐‘ฆ ๐‘ฆ = 0

3

slide-4
SLIDE 4

Using ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ to build ๐‘‡๐‘“๐‘š๐‘”๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข

4

Does โ„ณ ๐‘ฅ ๐‘ฆ = 1? ๐‘ต๐’ƒ๐’…๐’… ๐‘ฅ ๐‘ฆ โ„ณ ๐‘ฅ ๐‘ฆ == 1? ๐‘ต๐’•๐’” Does โ„ณ ๐‘ฅ ๐‘ฅ = 0? Does โ„ณ ๐‘ฅ ๐‘ฆ = 1? ๐‘ต๐’ƒ๐’…๐’… ๐‘ฅ โ„ณ ๐‘ฅ 1 == 0? Assume we have ๐‘๐‘๐‘‘๐‘‘ which computes ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡: We could then build ๐‘๐‘ก๐‘  which computes ๐‘‡๐‘“๐‘š๐‘”๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข like this:

slide-5
SLIDE 5

Can ๐‘๐‘‡๐‘† exist?

  • Let ๐‘ฅ๐‘‡๐‘† be the description of ๐‘๐‘‡๐‘†

โ€“ โ„ณ ๐‘ฅ๐‘‡๐‘† = ๐‘๐‘‡๐‘†

  • What should be ๐‘๐‘‡๐‘† ๐‘ฅ๐‘‡๐‘† ?

โ€“ If ๐‘๐‘‡๐‘† ๐‘ฅ๐‘‡๐‘† = 1:

  • Since ๐‘๐‘‡๐‘† computes ๐‘‡๐‘“๐‘š๐‘”๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข we conclude that ๐‘ฅ๐‘‡๐‘† is rejected by whatever

machine it describes.

  • Since ๐‘ฅ๐‘‡๐‘† describes ๐‘๐‘‡๐‘†, it must have been that ๐‘๐‘‡๐‘† ๐‘ฅ๐‘‡๐‘† = 0

โ€“ If ๐‘๐‘‡๐‘† ๐‘ฅ๐‘‡๐‘† = 0:

  • Since ๐‘๐‘‡๐‘† computes ๐‘‡๐‘“๐‘š๐‘”๐‘†๐‘“๐‘˜๐‘“๐‘‘๐‘ข we conclude that ๐‘ฅ๐‘‡๐‘† is accepted by whatever

machine it describes.

  • Since ๐‘ฅ๐‘ก๐‘  describes ๐‘๐‘‡๐‘†, it must have been that ๐‘๐‘‡๐‘† ๐‘ฅ๐‘‡๐‘† = 1

โ€“ Thereโ€™s no answer that makes sense!

  • Conclusion: ๐‘๐‘‡๐‘† canโ€™t be an always-halting Turing machine, so ๐‘๐‘๐‘‘๐‘‘

canโ€™t exist

5

slide-6
SLIDE 6

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 ๐‘๐‘—๐‘›๐‘ž

6

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

Proving Other Problems are Uncomputable

  • Reduction

โ€“ Convert some problem into a known uncomputable one (using only computable steps)

7

slide-8
SLIDE 8

Proof by Reduction

Shows how two different problems relate to each other

slide-9
SLIDE 9

Reduction Proofs

reduces to

that can solve B

can be used to make

that can solve A

The name โ€œreducesโ€ is confusing: it is in the opposite direction of the making ๐‘ฉ is not a harder problem than ๐‘ช ๐‘ฉ โ‰ค ๐‘ช

Opening a door Lighting a fire Alcohol, wood, matches Keg cannon battering ram

๐ถ ๐‘Œ ๐‘ ๐ต

slide-10
SLIDE 10

Proof of Impossibility by Reduction

  • 1. X isnโ€™t possible

(e.g., X = some way to open the door)

  • 2. Assume Y is possible

(Y = some way to light a fire)

  • 3. Show how to use Y to perform X.
  • 4. X isnโ€™t possible, but Y could be used to perform X

conclusion: Y must not be possible either

๐‘Œ ๐‘ ๐‘Œ ๐‘

slide-11
SLIDE 11

Proof of Impossibility by Reduction

  • 1. Take ๐‘Œ that does not exist.

e.g., ๐‘Œ = Some TM that computes ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡

  • 2. Assume ๐‘ exists.

๐‘ = Some TM that computes ๐ถ

  • 3. Show how to use ๐‘ to perform ๐‘Œ.
  • 4. ๐‘Œ doesnโ€™t exist, but ๐‘ could be used to make ๐‘Œ
  • conclusion: ๐‘ must not exist either, so ๐ถ is

impossible

๐‘Œ ๐‘ ๐‘Œ ๐‘

slide-12
SLIDE 12

MacGyverโ€™s Reduction

12

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

Converse?

that can solve ๐‘ช (Lighting a fire)

can be used to make

that can solve ๐‘ฉ (opening a door)

๐‘ฉ is not harder to solve than ๐‘ช ๐‘ฉ reduces to ๐‘ช Does this mean ๐‘ช is equally as hard as ๐‘ฉ? No! Solving ๐‘ is only one way to solve ๐‘Œ There may be an easier way

๐‘ ๐‘Œ

๐‘ฉ โ‰ค ๐‘ช ๐‘ฉ = ๐‘ช

slide-14
SLIDE 14

Common Reduction Traps

  • Be careful: the direction matters a great deal

โ€“ Using a solver for ๐ถ to solve ๐ต shows ๐ต is not harder than ๐ถ

  • The transformation must use only things you can do:

โ€“ Otherwise it may be that ๐ถ exists, but some other step doesnโ€™t! โ€“ Example:

  • A witch/wizard could open the door by waving a wand and casting

a magic spell

  • MacGyver canโ€™t do magic, and is in a room that cannot be opened
  • Can we conclude that MacGyver canโ€™t wave a wand?

___ Reduces to ___ ๐ถ ๐ต

slide-15
SLIDE 15

What โ€œCan Doโ€ Means

  • Tools used in a reduction are limited by what you are

proving

  • Undecidability:

โ€“ You are proving something about all TMs: โ€“ The transformation โ€œcan doโ€ things a terminating TM โ€œcan doโ€

Spoiler alert!

  • Complexity:

โ€“ You are proving something about time required: โ€“ The time it takes to do the transformation is limited

slide-16
SLIDE 16

Example

  • ๐ผ๐ต๐‘€๐‘ˆ ๐‘ฅ, ๐‘ฆ = 1 if โ„ณ ๐‘ฅ

๐‘ฆ halts 0 if โ„ณ ๐‘ฅ ๐‘ฆ runs forever

โ€“ Does the machine halt on this input?

  • To show ๐ผ๐ต๐‘€๐‘ˆ is uncomputable:

โ€“ Show how to use a TM for ๐ผ๐ต๐‘€๐‘ˆ to solve an uncomputable problem

  • Show ๐ผ๐ต๐‘€๐‘ˆ โ‰ฅ ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡
  • Show ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ reduces to ๐ผ๐ต๐‘€๐‘ˆ

16

slide-17
SLIDE 17

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

17

๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡

Problem know is impossible

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

Problem we think is impossible ๐‘โ„Ž๐‘๐‘š๐‘ข computes ๐ผ๐ต๐‘€๐‘ˆ

๐ต ๐ถ

Assume Reduction Does โ„ณ(๐‘ฅ) accept ๐‘ฆ? Does โ„ณ(๐‘ฅ) halt on input ๐‘ฆ? ๐‘๐‘๐‘‘๐‘‘ computes ๐ต๐ท๐ท๐น๐‘„๐‘ˆ

slide-18
SLIDE 18

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

18

Does โ„ณ ๐‘ฅ ๐‘ฆ halt? ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ ๐‘ฅ ๐‘ฆ โ„ณ ๐‘ฅ ๐‘ฆ does/doesnโ€™t halt ๐‘ต๐’ƒ๐’…๐’… Does โ„ณ ๐‘ฅ ๐‘ฅ = 1? โ„ณ ๐‘ฅ 1 == 1 Assume we have ๐‘๐ผ๐ต๐‘€๐‘ˆ which computes ๐ผ๐ต๐‘€๐‘ˆ: We could then build ๐‘๐‘๐‘‘๐‘‘ which computes ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ like this: Does โ„ณ ๐‘ฅ ๐‘ฆ halt? ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ ๐‘ฅ ๐‘ฆ

If it halts: Return โ„ณ(๐‘ฅ) If it doesnโ€™t halt: Return 0

slide-19
SLIDE 19

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

19

๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡

Problem know is impossible

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

Problem we think is impossible ๐‘โ„Ž๐‘๐‘š๐‘ข computes ๐ผ๐ต๐‘€๐‘ˆ

๐ต ๐ถ

Give ๐‘ฅ, ๐‘ฆ as inputs to ๐ผ๐ต๐‘€๐‘ˆ

Assume Reduction Does โ„ณ(๐‘ฅ) accept ๐‘ฆ? Does โ„ณ(๐‘ฅ) halt on input ๐‘ฆ? ๐‘๐‘๐‘‘๐‘‘ computes ๐ต๐ท๐ท๐น๐‘„๐‘ˆ If โ„ณ ๐‘ฅ ๐‘ฆ halts, return โ„ณ ๐‘ฅ ๐‘ฆ Else return 0

slide-20
SLIDE 20

Conclusion

  • ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡ is not computable
  • If ๐ผ๐ต๐‘€๐‘ˆ was computable, an implementation

could be used to compute ๐ต๐ท๐ท๐น๐‘„๐‘ˆ๐‘‡

  • So it must be that ๐ผ๐ต๐‘€๐‘ˆ is not computable

20

slide-21
SLIDE 21

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

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

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

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

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

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

21

slide-22
SLIDE 22

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

22

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

Problem know is impossible

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

Problem we think is impossible ๐‘

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

๐ต ๐ถ

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

slide-23
SLIDE 23

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

23

Is L โ„ณ ๐‘ฅ finite? ๐‘ต๐‘ฎ๐‘ฑ๐‘ถ๐‘ฑ๐‘ผ๐‘ญ ๐‘ฅ ๐‘€ โ„ณ ๐‘ฅ is/isnโ€™t finite ๐‘ต๐‘ฐ๐‘ฉ๐‘ด๐‘ผ Does โ„ณ ๐‘ฅ ๐‘ฅ = 1? โ„ณ ๐‘ฅ 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-24
SLIDE 24

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

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

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

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

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

24

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

slide-25
SLIDE 25

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

25

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

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 ๐‘

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