Noncomputable procedure computes its digits . Sets (Procedure - - PowerPoint PPT Presentation

noncomputable
SMART_READER_LITE
LIVE PREVIEW

Noncomputable procedure computes its digits . Sets (Procedure - - PowerPoint PPT Presentation

MathematicsforComputerScience Computablestringsin{0,1} MIT 6.042J/18.062J An infinite string s in {0,1} is computable iff some Noncomputable procedure computes its digits . Sets (Procedure applied to argument n returns nth digit


slide-1
SLIDE 1

halting.1 Albert R Meyer, March 4, 2015

Mathematics for Computer Science

MIT 6.042J/18.062J

Noncomputable Sets

halting.2 Albert R Meyer, March 4, 2015

Computable strings in {0,1}ω

An infinite string s in {0,1}ω is computable iff some procedure computes its digits. (Procedure applied to argument n returns nth digit of s.)

halting.3 Albert R Meyer, March 4, 2015

Only countably many finite ASCII strings. Procedures can be expressed in ASCII, so only countably many procedures. {ASCII}* is countable (List them in

  • rder of length.)

halting.4 Albert R Meyer, March 4, 2015

So only countably many computable infinite binary strings.

Noncomputable strings in {0,1}ω But {0,1}ω is uncountable, so there must be noncomputable strings in {0,1}ω —in fact, uncountably many!

1

slide-2
SLIDE 2

The Halting Problem The Halting Problem

There is no test procedure for halting of arbitrary procedures. The Halting Problem is not decidable by computational procedures

String procedure P takes a String argument: P("no") returns 2 P("albert") returns "meyer" P("&&%99!!") causes an error P("what now?") runs forever.

Albert R Meyer, March 4, 2013 halting.6 Albert R Meyer, March 4, 2015 halting.5

The Halting Problem The Halting Problem

Let s be an ASCII string defining Ps. Say s HALTS iff Ps(s) returns something. Suppose there was a procedure Q that decided HALTS: Q(s) returns "yes” if s HALTS returns "no” otherwise

Albert R Meyer, March 4, 2013 halting.7 Albert R Meyer, March 4, 2013 halting.8

2

slide-3
SLIDE 3

halting.9 Albert R Meyer, March 4, 2013

The Halting Problem

Modify Q to Q': Q'(s) returns "yes” if Q(s) returns "no" Q'(s) returns nothing if Q(s) returns "yes”

halting.10 Albert R Meyer, March 4, 2013

The Halting Problem

So s HALTS iff Q'(s) returns nothing

halting.11 Albert R Meyer, March 4, 2013

The Halting Problem

Let t be the text for Q’ So by def of HALTS:

t HALTS iff Q'(t) returns

and by def of Q’:

Q'(t) returns iff NOT(t HALTS)

halting.12 Albert R Meyer, March 4, 2013

The Halting Problem CONTRADICTION:

t HALTS iff NOT(t HALTS)

There can't be such a Q: it is impossible to write a procedure that decides whether strings HALT

3

slide-4
SLIDE 4

The Type-checking Problem The Type-checking Problem

There is no string procedure that type-checks perfectly, because: Suppose C was a type-checking procedure: for program text s C(s) returns “yes” if s would cause a run-time type error returns “no” otherwise. Use C to get a HALTS Tester H:

to compute H(s), construct a new program text, s’, that acts like a slightly modified interpreter for s. Namely:

Albert R Meyer, March 4, 2013 halting.13 Albert R Meyer, March 4, 2013 halting.14

The Type-checking Problem The Type-checking Problem

  • s’ skips any command that

would cause s to make a run-time type error.

  • s’ purposely makes a type-

error when it finds that s HALTS. Then compute C(s’) and return the same value.

So s HALTS iff s’ makes run-time type error iff C(s’) = “yes” iff H(s) = “yes”

Albert R Meyer, March 4, 2013 halting.15 Albert R Meyer, March 4, 2013 halting.16

4

slide-5
SLIDE 5

No run-time properties are decidable The Type-checking Problem

H solves the Halting Problem, a contradiction. So C must not error check correctly.

Albert R Meyer, March 4, 2013 halting.18

The same reasoning shows that there is no perfect checker for essentially any property of procedure

  • utcomes.

Albert R Meyer, March 4, 2013 halting.19

5

slide-6
SLIDE 6

MIT OpenCourseWare https://ocw.mit.edu

6.042J / 18.062J Mathematics for Computer Science

Spring 2015 For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.