Section 1 5 intractable problems
This presentation is the property of its rightful owner.
Sponsored Links
1 / 15

Section 1.5: Intractable problems PowerPoint PPT Presentation


  • 69 Views
  • Uploaded on
  • Presentation posted in: General

Section 1.5: Intractable problems. The Halting Problem. Animation overview. In this animation you will be shown what The Halting Problem is. You will see: what it means to say if a program halts (terminates) examples of programs that do and do not halt.

Download Presentation

Section 1.5: Intractable problems

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Section 1 5 intractable problems

Section 1.5: Intractable problems

The Halting Problem


Animation overview

Animation overview

In this animation you will be shown what The Halting Problem is.

You will see:

  • what it means to say if a program halts (terminates)

  • examples of programs that do and do not halt.

    You will then be shown a proof that it is not possible to write a program that is able to take any other program and say if that program will halt or not.


When you run a program it will do one of two things

When you run a program, it will do one of two things:

  • It will run for a while and then halt (stop).

  • It will run forever (i.e. it will never halt).

    The second of these is not usually a good thing – you would normally want your program to terminate.


Section 1 5 intractable problems

Here is an example of a program

Here is an example of a program

that runs for a while and then

that never stops:

halts:

program printNumbers2

program printNumbers1

X

1

ß

X

0

repeat

ß

repeat

print (X)

print (X)

X

X +2

ß

until X = 6

X

X +2

ß

until X = 6

print (X)

print (X)

end

end

What will this program do when it

runs?

What will this program do when it

runs?

When this program runs it will print

the numbers 1,

3

,

5

, 7, 9,

etc...

no

When this program runs it will print

matter how long this program

runs,

the numbers 0, 2, 4, 6.

for it will never stop as

X

never

becomes equal to 6. It has got

stuck in an infinite loop.


Section 1 5 intractable problems

Explanation

It is fairly easy to tell that the second program will not terminate as it is a fairly simple program. Most programs are far more complex and you cannot tell by just looking at the code if it will terminate or not.

One way of trying to find out if a program terminates or not is to run the program and see. If the program stops running after a while, you know that the program does terminate.

The problem with this though is that if the program has not terminated you have no way of knowing if the program does not terminate, or if it has just not terminated yet (if you leave it running for another second it may terminate).


Section 1 5 intractable problems

Alan Turing – proof by contradiction


Section 1 5 intractable problems

True

…it will return a value of True as printNumbers1 is a program that does halt.


Section 1 5 intractable problems

False

…it will return a value of False as printNumbers2 is a program that doesn’t halt.


Section 1 5 intractable problems

If the program reaches this while loop, it will get stuck in an infinite loop, as x is always going to be less than 1

If a program goes into an infinite loop, it does not halt (terminate)


Conclusion

Conclusion


  • Login