SlideShare a Scribd company logo
1 of 7
12.2 The Halting Problem
Godel established that no interesting and consistent axiomatic system is capable
of proving all true statements in the system.
Now we consider the analogous question for computing: are there problems for which
no algorithm exists?
Recall these definitions form Chapters 1and 4:
problem: A description of an input and a desired output.
procedure: A specification of a series of actions.
algorithm: A procedure that is guaranteed to always terminate.
A procedure solves a problem if that procedure produces a correct output for
every possible input. If that procedure always terminates, it is an algorithm.
So, the question can be stated as: are there problems for which no procedure exists that
produces the correct output for every possible problem instance in a finite amount of
time?
A problem is computable if there exists an algorithm that solves the problem. It is
important to remember that in order for an algorithm to be a solution for a problem PP,
it must always terminate (otherwise it is not an algorithm) and must always produce the
correct output for all possible inputs to PP.
If no such algorithm exists, the problem is noncomputable.1 are sometimes used to
mean the same things as computable and noncomputable.}
Alan Turing proved that noncomputable problems exist. The way to show
that uncomputable problems exist is to find one, similarly to the way Godel
showed unprovable true statements exist by finding an unprovable true statement.
The problem Turing found is known as the Halting Problem:2
Halting ProblemHalting Problem
Input: A string representing a Python program.
Output: If evaluating the input program would ever finish, output True.
Otherwise, output False.
Suppose we had a procedure halts that solves the Halting Problem. The input tohalts is a
Python program expressed as a string.
For example, halts('(+ 2 3)') should evaluate to True, halts('while True: pass')
should evaluate to False (the Python pass statement does nothing, but is needed to
make the while loop syntactically correct), and
halts('''''' def fibo(n):
if n == 1 or n == 2: return 1
else: return fibo(n-1) + fibo(n-2) fibo(60)
'''''')
should evaluate to True. From the last
example, it is clear that halts cannot be
implemented by evaluating the expression and
outputting True if it terminates.
The problem is knowing when to give up and output False. As we analyzed inChapter 7,
evaluating fibo(60) would take trillions of years; in theory, though, it eventually finishes
so halts should output True.
This argument is not sufficient to prove that halts is noncomputable. It just shows that
one particular way of implementing halts would not work.
To show that halts is noncomputable, we need to show that it is impossible to implement
a halts procedure that would produce the correct output for all inputs in a finite amount
of time.
Here is another example that suggests (but does not prove) the
impossibility ofhalts (where sumOfTwoPrimes is defined as an algorithm that take a
number as input and outputs True if the number is the sum of two prime numbers
andFalse otherwise):
halts('n = 4; while sumOfTwoPrimes(n): n = n + 2')
This program halts if there exists an even number greater than 2 that is not the sum of
two primes.
We assume unbounded integers even though every actual computer has a limit on the
largest number it can represent.
Our computing model, though, uses an infinite tape, so there is no arbitrary limit
on number sizes.
Knowing whether or not the program halts would settle an open problem known
as Goldbach's Conjecture: every even integer greater than 2 can be written as the sum
of two primes.
Christian Goldbach proposed a form of the conjecture in a letter to Leonhard Euler in
1742. Euler refined it and believed it to be true, but couldn't prove it.
With a halts algorithm, we could settle the conjecture using the expression above: if the
result is False, the conjecture is proven; if the result is True, the conjecture is disproved.
We could use a halts algorithm like this to resolve many other open problems.
This strongly suggests there is no halts algorithm, but does not prove it cannot exist.
Proving Noncomputability. Proving non-existence is requires more than
just showing a hard problem could be solved if something exists.
One way to prove non-existence of an XX, is to show that if an XX exists it leads to a
contradiction. We prove that the existence of a halts algorithm leads to a contradiction,
so nohalts algorithm exists.
We obtain the contradiction by showing one input for which the halts procedure could
not possibly work correctly. Consider this procedure:
Defparadox():
if halts('paradox()'): while True: pass
The body of the paradox procedure is an if expression. The consequent expression is a
never-ending loop.
The predicate expression cannot sensibly evaluate to either True or False:
halts(paradox()) ⇒⇒ True: If the predicate expression evaluates to True, the consequent
block is evaluated producing a never-ending loop. Thus, ifhalts('paradox()') evaluates
to True, the evaluation of an application ofparadox never halts. But, this means the result
of halts('paradox()') was incorrect.
halts(paradox()) ⇒⇒ False: If the predicate expression evaluates to False, the
alternate block is evaluated. It is empty, so evaluation terminates. Thus, the
evaluation of paradox() terminates, contradicting the result ofhalts('paradox()').
Either result for halts('paradox()') leads to a contradiction! The only
sensible thing halts could do for this input is to not produce a value. That means
there is no algorithm that solves the Halting Problem.
Any procedure we define to implement halts must sometimes either produce the wrong
result or fail to produce a result at all (that is, run forever without producing a result).
This means the Halting Problem is noncomputable.
There is one important hole in our proof: we argued that because paradox does not make
sense, something in the definition of paradox must not exist and identified halts as
the component that does not exist. This assumes that everything else we
used to define paradox does exist.
This seems reasonable enough---they are built-in to Python so they seem to exist. But,
perhaps the reason paradox leads to a contradiction is because True does not really exist
or because it is not possible to implement an if expression that strictly follows
the Python evaluation rules.
Although we have been using these and they seems to always work fine, we have
no formal model in which to argue that evaluating True always terminates or that
an if expression means exactly what the evaluation rules say it does.
Our informal proof is also insufficient to prove the stronger claim that no
algorithm exists to solve the halting problem.
All we have shown is that no Python procedure exists that solves halts. Perhaps there is
a procedure in some more powerful programming language in which it is possible
to implement a solution to the Halting Problem. In fact, we will see that no more
powerful programming language exists.
A convincing proof requires a formal model of computing. This is why Alan
Turing developed a model of computation.
All we have shown is that no Python procedure exists that solves halts. Perhaps there is
a procedure in some more powerful programming language in which it is possible
to implement a solution to the Halting Problem. In fact, we will see that no more
powerful programming language exists.
A convincing proof requires a formal model of computing. This is why Alan
Turing developed a model of computation.

More Related Content

What's hot

Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statementFarshidKhan
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loopFarshidKhan
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Editor IJARCET
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
Skiena algorithm 2007 lecture01 introduction to algorithms
Skiena algorithm 2007 lecture01 introduction to algorithmsSkiena algorithm 2007 lecture01 introduction to algorithms
Skiena algorithm 2007 lecture01 introduction to algorithmszukun
 
5. using variables, data, expressions and constants
5. using variables, data, expressions and constants5. using variables, data, expressions and constants
5. using variables, data, expressions and constantsCtOlaf
 
Wade not in unknown waters. Part three.
Wade not in unknown waters. Part three.Wade not in unknown waters. Part three.
Wade not in unknown waters. Part three.PVS-Studio
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniyaTutorialsDuniya.com
 
Conditionalstatement
ConditionalstatementConditionalstatement
ConditionalstatementRaginiJain21
 
05 Conditional statements
05 Conditional statements05 Conditional statements
05 Conditional statementsmaznabili
 
バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装EinosukeIida
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02CIMAP
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 

What's hot (20)

Python Programming Homework Help
Python Programming Homework HelpPython Programming Homework Help
Python Programming Homework Help
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Skiena algorithm 2007 lecture01 introduction to algorithms
Skiena algorithm 2007 lecture01 introduction to algorithmsSkiena algorithm 2007 lecture01 introduction to algorithms
Skiena algorithm 2007 lecture01 introduction to algorithms
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Invariant-Free Clausal Temporal Resolution
Invariant-Free Clausal Temporal ResolutionInvariant-Free Clausal Temporal Resolution
Invariant-Free Clausal Temporal Resolution
 
5. using variables, data, expressions and constants
5. using variables, data, expressions and constants5. using variables, data, expressions and constants
5. using variables, data, expressions and constants
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Wade not in unknown waters. Part three.
Wade not in unknown waters. Part three.Wade not in unknown waters. Part three.
Wade not in unknown waters. Part three.
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
 
Ch6
Ch6Ch6
Ch6
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
 
Conditionalstatement
ConditionalstatementConditionalstatement
Conditionalstatement
 
05 Conditional statements
05 Conditional statements05 Conditional statements
05 Conditional statements
 
バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装バンディット問題の理論とアルゴリズムとその実装
バンディット問題の理論とアルゴリズムとその実装
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02
 
Mp neuron
Mp neuronMp neuron
Mp neuron
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 

Similar to the halting_problem

proving non-computability
proving non-computabilityproving non-computability
proving non-computabilityRajendran
 
compatibility and complexity in the IS.ppt
compatibility and complexity in the IS.pptcompatibility and complexity in the IS.ppt
compatibility and complexity in the IS.pptMuhammadAbdullah311866
 
Partial compute function
Partial compute functionPartial compute function
Partial compute functionRajendran
 
Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)mailund
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problemsJyotsna Suryadevara
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxmonicafrancis71118
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notesProf. Dr. K. Adisesha
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMSTanya Makkar
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 introchidabdu
 
Accord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer HumankindAccord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer HumankindPVS-Studio
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
Undecidable Problem
Undecidable ProblemUndecidable Problem
Undecidable ProblemMGoodhew
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codeAlgorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codehamza javed
 

Similar to the halting_problem (20)

proving non-computability
proving non-computabilityproving non-computability
proving non-computability
 
compatibility and complexity in the IS.ppt
compatibility and complexity in the IS.pptcompatibility and complexity in the IS.ppt
compatibility and complexity in the IS.ppt
 
Partial compute function
Partial compute functionPartial compute function
Partial compute function
 
Chapter08.pptx
Chapter08.pptxChapter08.pptx
Chapter08.pptx
 
Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
TIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMSTIME EXECUTION   OF  DIFFERENT SORTED ALGORITHMS
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
 
Accord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer HumankindAccord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
Accord.Net: Looking for a Bug that Could Help Machines Conquer Humankind
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
UNIT -IV DAA.pdf
UNIT  -IV DAA.pdfUNIT  -IV DAA.pdf
UNIT -IV DAA.pdf
 
Undecidable Problem
Undecidable ProblemUndecidable Problem
Undecidable Problem
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codeAlgorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
 
chapter 2.pptx
chapter 2.pptxchapter 2.pptx
chapter 2.pptx
 
OCT-20
OCT-20OCT-20
OCT-20
 

More from Rajendran

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower boundsRajendran
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsRajendran
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower boundsRajendran
 
Red black tree
Red black treeRed black tree
Red black treeRajendran
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theoremRajendran
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theoremRajendran
 
Master method
Master method Master method
Master method Rajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisRajendran
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisRajendran
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of QuicksortRajendran
 
Np completeness
Np completenessNp completeness
Np completenessRajendran
 
computer languages
computer languagescomputer languages
computer languagesRajendran
 

More from Rajendran (20)

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
 
Red black tree
Red black treeRed black tree
Red black tree
 
Hash table
Hash tableHash table
Hash table
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
Master method
Master method Master method
Master method
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Hash tables
Hash tablesHash tables
Hash tables
 
Lower bound
Lower boundLower bound
Lower bound
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
 
Np completeness
Np completenessNp completeness
Np completeness
 
computer languages
computer languagescomputer languages
computer languages
 

Recently uploaded

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 

Recently uploaded (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 

the halting_problem

  • 1. 12.2 The Halting Problem Godel established that no interesting and consistent axiomatic system is capable of proving all true statements in the system. Now we consider the analogous question for computing: are there problems for which no algorithm exists? Recall these definitions form Chapters 1and 4: problem: A description of an input and a desired output. procedure: A specification of a series of actions. algorithm: A procedure that is guaranteed to always terminate. A procedure solves a problem if that procedure produces a correct output for every possible input. If that procedure always terminates, it is an algorithm. So, the question can be stated as: are there problems for which no procedure exists that produces the correct output for every possible problem instance in a finite amount of time? A problem is computable if there exists an algorithm that solves the problem. It is important to remember that in order for an algorithm to be a solution for a problem PP, it must always terminate (otherwise it is not an algorithm) and must always produce the correct output for all possible inputs to PP. If no such algorithm exists, the problem is noncomputable.1 are sometimes used to mean the same things as computable and noncomputable.}
  • 2. Alan Turing proved that noncomputable problems exist. The way to show that uncomputable problems exist is to find one, similarly to the way Godel showed unprovable true statements exist by finding an unprovable true statement. The problem Turing found is known as the Halting Problem:2 Halting ProblemHalting Problem Input: A string representing a Python program. Output: If evaluating the input program would ever finish, output True. Otherwise, output False. Suppose we had a procedure halts that solves the Halting Problem. The input tohalts is a Python program expressed as a string. For example, halts('(+ 2 3)') should evaluate to True, halts('while True: pass') should evaluate to False (the Python pass statement does nothing, but is needed to make the while loop syntactically correct), and halts('''''' def fibo(n): if n == 1 or n == 2: return 1 else: return fibo(n-1) + fibo(n-2) fibo(60) '''''') should evaluate to True. From the last example, it is clear that halts cannot be implemented by evaluating the expression and outputting True if it terminates. The problem is knowing when to give up and output False. As we analyzed inChapter 7, evaluating fibo(60) would take trillions of years; in theory, though, it eventually finishes so halts should output True.
  • 3. This argument is not sufficient to prove that halts is noncomputable. It just shows that one particular way of implementing halts would not work. To show that halts is noncomputable, we need to show that it is impossible to implement a halts procedure that would produce the correct output for all inputs in a finite amount of time. Here is another example that suggests (but does not prove) the impossibility ofhalts (where sumOfTwoPrimes is defined as an algorithm that take a number as input and outputs True if the number is the sum of two prime numbers andFalse otherwise): halts('n = 4; while sumOfTwoPrimes(n): n = n + 2') This program halts if there exists an even number greater than 2 that is not the sum of two primes. We assume unbounded integers even though every actual computer has a limit on the largest number it can represent. Our computing model, though, uses an infinite tape, so there is no arbitrary limit on number sizes. Knowing whether or not the program halts would settle an open problem known as Goldbach's Conjecture: every even integer greater than 2 can be written as the sum of two primes. Christian Goldbach proposed a form of the conjecture in a letter to Leonhard Euler in 1742. Euler refined it and believed it to be true, but couldn't prove it.
  • 4. With a halts algorithm, we could settle the conjecture using the expression above: if the result is False, the conjecture is proven; if the result is True, the conjecture is disproved. We could use a halts algorithm like this to resolve many other open problems. This strongly suggests there is no halts algorithm, but does not prove it cannot exist. Proving Noncomputability. Proving non-existence is requires more than just showing a hard problem could be solved if something exists. One way to prove non-existence of an XX, is to show that if an XX exists it leads to a contradiction. We prove that the existence of a halts algorithm leads to a contradiction, so nohalts algorithm exists. We obtain the contradiction by showing one input for which the halts procedure could not possibly work correctly. Consider this procedure: Defparadox(): if halts('paradox()'): while True: pass The body of the paradox procedure is an if expression. The consequent expression is a never-ending loop. The predicate expression cannot sensibly evaluate to either True or False: halts(paradox()) ⇒⇒ True: If the predicate expression evaluates to True, the consequent block is evaluated producing a never-ending loop. Thus, ifhalts('paradox()') evaluates to True, the evaluation of an application ofparadox never halts. But, this means the result of halts('paradox()') was incorrect.
  • 5. halts(paradox()) ⇒⇒ False: If the predicate expression evaluates to False, the alternate block is evaluated. It is empty, so evaluation terminates. Thus, the evaluation of paradox() terminates, contradicting the result ofhalts('paradox()'). Either result for halts('paradox()') leads to a contradiction! The only sensible thing halts could do for this input is to not produce a value. That means there is no algorithm that solves the Halting Problem. Any procedure we define to implement halts must sometimes either produce the wrong result or fail to produce a result at all (that is, run forever without producing a result). This means the Halting Problem is noncomputable. There is one important hole in our proof: we argued that because paradox does not make sense, something in the definition of paradox must not exist and identified halts as the component that does not exist. This assumes that everything else we used to define paradox does exist. This seems reasonable enough---they are built-in to Python so they seem to exist. But, perhaps the reason paradox leads to a contradiction is because True does not really exist or because it is not possible to implement an if expression that strictly follows the Python evaluation rules. Although we have been using these and they seems to always work fine, we have no formal model in which to argue that evaluating True always terminates or that an if expression means exactly what the evaluation rules say it does. Our informal proof is also insufficient to prove the stronger claim that no algorithm exists to solve the halting problem.
  • 6. All we have shown is that no Python procedure exists that solves halts. Perhaps there is a procedure in some more powerful programming language in which it is possible to implement a solution to the Halting Problem. In fact, we will see that no more powerful programming language exists. A convincing proof requires a formal model of computing. This is why Alan Turing developed a model of computation.
  • 7. All we have shown is that no Python procedure exists that solves halts. Perhaps there is a procedure in some more powerful programming language in which it is possible to implement a solution to the Halting Problem. In fact, we will see that no more powerful programming language exists. A convincing proof requires a formal model of computing. This is why Alan Turing developed a model of computation.