Download presentation

Presentation is loading. Please wait.

Published byAnn Parson Modified over 2 years ago

1
David Evans http://www.cs.virginia.edu/evans CS200: Computer Science University of Virginia Computer Science Class 27: Modeling Computation

2
26 March 2004CS 200 Spring 20042 Halting Problem Define a procedure halts? that takes a procedure and an input evaluates to #t if the procedure would terminate on that input, and to #f if would not terminate. (define (halts? procedure input) … )

3
26 March 2004CS 200 Spring 20043 Informal Proof (define (contradict-halts x) (if (halts? contradict-halts null) (loop-forever) #t)) If contradict-halts halts, the if test is true and it evaluates to (loop-forever) - it doesn’t halt! If contradict-halts doesn’t halt, the if test if false, and it evaluates to #t. It halts!

4
26 March 2004CS 200 Spring 20044 Proof by Contradiction 1.Show X is nonsensical. 2.Show that if you have A and B you can make X. 3.Show that you can make A. 4.Therefore, B must not exist. X = contradict-halts A = a Scheme interpreter that follows the evaluation rules B = halts?

5
26 March 2004CS 200 Spring 20045 Virus Detection Problem Problem 7. Melissa Problem Input: A Word macro (like a program, but embedded in an email message) Output: true if the macro will forward the message to people in your address book; false otherwise. How can we show it is undecidable?

6
26 March 2004CS 200 Spring 20046 Proof by Contradiction 1.Show X is nonsensical. 2.Show that if you have A and B you can make X. 3.Show that you can make A. 4.Therefore, B must not exist. X = halts? A = a Scheme interpreter that follows the evaluation rules B = is-virus?

7
26 March 2004CS 200 Spring 20047 Undecidability Proof Suppose we could define is-virus? that decides the Melissa problem. Then: (define (halts? P input) (if (is-virus? ‘(begin (P input) virus-code)) #t #f)) Since it is a virus, we know virus-code was evaluated, and P must halt (assuming P wasn’t a virus). Its not a virus, so the virus-code never executed. Hence, P must not halt.

8
26 March 2004CS 200 Spring 20048 Undecidability Proof Suppose we could define is-virus? that decides the Melissa problem. Then: (define (halts? P input) (is-virus? ‘(begin ((vaccinate P) input) virus-code)) Where (vaccinate P) evaluates to P with all mail commands replaced with print commands (to make sure (is-virus? P input) is false.

9
26 March 2004CS 200 Spring 20049 Proof If we had is-virus? we could define halts? We know halts? is undecidable Hence, we can’t have is-virus? Thus, we know is-virus? is undecidable

10
26 March 2004CS 200 Spring 200410 How convincing is our Halting Problem proof? (define (contradict-halts x) (if (halts? contradict-halts null) (loop-forever) #t)) If contradict-halts halts, the if test is true and it evaluates to (loop-forever) - it doesn’t halt! If contradict-halts doesn’t halt, the if test if false, and it evaluates to #t. It halts! This “proof” assumes Scheme exists and is consistent!

11
26 March 2004CS 200 Spring 200411 Modeling Computation For a more convincing proof, we need a more precise (but simple) model of what a computer can do Another reason we need a model: Does ( n ) really make sense without this?

12
26 March 2004CS 200 Spring 200412 How should we model a Computer? Apollo Guidance Computer (1969) Colossus (1944) IBM 5100 (1975) Cray-1 (1976)

13
26 March 2004CS 200 Spring 200413 Modeling Computers Input –Without it, we can’t describe a problem Output –Without it, we can’t get an answer Processing –Need some way of getting from the input to the output Memory –Need to keep track of what we are doing

14
26 March 2004CS 200 Spring 200414 Modeling Input Engelbart’s mouse and keypad Punch Cards Altair BASIC Paper Tape, 1976

15
26 March 2004CS 200 Spring 200415 Simplest Input Non-interactive: like punch cards and paper tape One-dimensional: just a single tape of values, pointer to one square on tape 0011001000 How long should the tape be? Infinitely long! We are modeling a computer, not building one. Our model should not have silly practical limitations (like a real computer does).

16
26 March 2004CS 200 Spring 200416 Modeling Output Blinking lights are cool, but hard to model Output is what is written on the tape at the end of a computation Connection Machine CM-5, 1993

17
26 March 2004CS 200 Spring 200417 Charge PS6 due Monday Friday: –Finite state machines with infinite tape

Similar presentations

OK

What Every Biologist, Chemist, and Poet Should Know about Computer Science David Evans UVaCompBio 25 April 2011 www.cs.virginia.edu/evans.

What Every Biologist, Chemist, and Poet Should Know about Computer Science David Evans UVaCompBio 25 April 2011 www.cs.virginia.edu/evans.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on microsoft surface technology Ppt on tb treatment Ppt on total parenteral nutrition guidelines Ppt on hindu religion songs Ppt on layers of the atmosphere Ppt on series and parallel circuits Ppt on intelligent manufacturing solutions Ppt on eia report oil Ppt on pricing policy of htc Ppt on acid bases and salts for class 7