{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HALTING_PROBLEM

# HALTING_PROBLEM - X then while 9< 10 do End(loops •...

This preview shows pages 1–2. Sign up to view the full content.

HALTING PROBLEM – given a syntactically correct program P and an input string of characters X (X may or may not be a valid input for P – it doesn't matter). o Question – does P halt when given X? o P may loop forever or halt So, is there an algorithm for the Halting Problem? By way of contradiction, we assume that there exists an algorithm, here called Q, which examines (P, X) to report if P halts or does not halt on input X: input: string X and program P (Note: P, X is just another string of characters to Q.) Q: P halts when given X …Now, build another program, Q', by changing 2 statements of Q: Lemma 1. If Q exists, then Q' exists P halts on X if and only if Q prints "P halts on X"; P halts on X if and only if Q' loops forever; P does not halt on X if and only if Q' halts on (P, X) P X HAL P doesn’t halt when given X P X HAL If P doesn’t halt on X then (no op) If P halts on

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: X then while 9 < 10 do End (loops) • Build one more program, S: o S reads a program P and duplicates P o Then, S calls Q' with (P, P) as input o P cannot accept itself as input if and only if S halts o That is, P accepts itself as input if and only if S loops forever S: Q': • Lemma 2 : If Q' exists, then S exists • • Theorem 3 : If Q exists, then S halts on input P o iff Q' halts on (P, P) o iff Q' writes out "P does not halt on P" o iff P does not halt on P • • Since S is a syntactically correct program, we can replace P with S in Theorem 3. • Theorem 3' : If Q exists, then S halts on input S o iff Q' halts on (S, S) o iff Q' writes out "S does not halt on S" o iff S does not halt on S A contradiction: Thus, Q can not exist. P P HAL if P doesn’t halt on P then (no op) If P halts on P then while 9 < 10 do End (loops) P...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern