We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
a
courses Tutorials JobsractceContests oS
Halting Problem in Theory of Computation
Last Updated : 20 Nov, 2019
To understand better the halting problem, we must know Decidability,
Undecidability and Turing machine, decision problems and also a theory named
as Computability theory and Computational complexity theory.
Some important terms:
+ Computability theory —
The branch of theory of computation that studies which problems are
computationally solvable using different model. In computer science, the
computational complexity, or simply complexity of an algorithm is the
amount of resources required for running it.
* Decision problems —
A decision problem has only two possible outputs (yes or no) on any input.
In computability theory and computational complexity theory, a decision
problem is a problem that can be posed as a yes-no question of the input
values. Like is there any solution to a particular problem? The answer would
be either a yes or no. A decision problem is any arbitrary yes/no question on
an infinite set of inputs.
* Turing machine -
A Turing machine is a mathematical model of computation. A Turing
machine is a general example of a CPU that controls all data manipulation
done by a computer. Turing machine can be halting as well as non halting
and it depends on algorithm and input associated with the algorithm.
Now, lets discuss Halting problem:
The Halting problem - Given a program/algorithm will ever halt or not?
Halting means that the program on certain input will accept it and halt or reject
it and halt and it would never ao into an infinite loon. Basically haltina means
We use cookies to ensure you have the best browsing experience on our website. By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy,will halt or not. In terms of Turing machine, will it terminate when run on some
machine with some particular given input string.
Ox Ox
The answer is no we cannot design a generalized algorithm which can
appropriately say that given a program will ever halt or not?
The only way is to run the program and check whether it halts or not.
We can refrain the halting problem question in such a way also: Given a
program written in some programming language(c/c++/java) will it ever get into
an infinite loop(loop never stops) or will it always terminate(halt)?
This is an undecidable problem because we cannot have an algorithm which
will tell us whether a given program will halt or not in a generalized way i.e by
having specific program/algorithm.ln general we can't always know that's why
we can’t have a general algorithm. The best possible way is to run the program
and see whether it halts or not.n this way for many programs we can see that
it will sometimes loop and always halt.
Proof by Contradiction —
Problem statement: Can we design a machine which if given a program can
find out if that program will always halt or not halt on a particular input?
Solution: Let us assume that we can design that kind of machine called as
HM/P, |) where HM is the machine/program, P is the program and | is the input.
On taking input the both arguments the machine HM will tell that the program
P either halts or not.
We use cookies to ensure you have the best browsing experience on our website. By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy,Aptitude Engineering Mathematics Discrete Mathematics Operating System DBMS Computer Networks
GRU UY BO HE USHNOUH UF Ge BrUgrar Cinyay snuNH Hr une Hyurs:
HM (Pl) cM (x)
{Halt 4
if(HM(X,X)==Halt)
or loop forever;
May not Halt else
} return;
In the program CM(X) we call the function HM(X), which we have already
defined and to HM() we pass the arguments (X, X), according to the definition
of HM() it can take two arguments i.e one is program and another is the
input.Now in the second program we pass X as a program and X as input to the
function HM().We know that the program HM() gives two output either “Halt”
or “Not Halt”.But in case second program, when HM(X, X) will halt loop body
tells to go in loop and when it doesn’t halt that means loop, it is asked to
return.
Now we take one more situation where the program CM is passed to CM()
function as an argument. Then there would be some impossibility, ie., a
condition arises which is not possible
HM CPD om 09
Hat
#(H 009 ==HALT)
or loop forever,
May notis
rou
‘cmjem.cm)
mijou,ei) nave H(C.)=NOT MALT
We use cookies to ensure you have the best browsing experience on our website. By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy,
DIt is impossible for outer function to halt if its code (inner body) is in loop and
also it is impossible for outer non halting function to halt even after its inner
code is halting. So the both condition is non halting for CM machine/program
even we had assumed in the beginning that it would halt.So this is the
contradiction and we can say that our assumption was wrong and this
problem, ie., halting problem is undecidable.
This is how we proved that halting problem is undecidable.
Get 30% additional discount on all GfG Courses. Get your training certificate this
summer and skill up. Avail 30%
count now!
"GeeksforGeeks helped me ace the GATE exam! Whenever | had any doubt
regarding any topic, GFG always helped me and made my concepts quiet
clear." - Anshika Modi | AIR 21
Choose GeeksforGeeks as your perfect GATE 2025 Preparation partner with
these newly launched programs
|ATE iT
GATE DS & Al
GATE Offline (Delhi/NCR)
Over 125,000+ students already trust us to be their GATE Exam guide. Join
them & let us help you in opening the GATE to top-tech IITs & NITs!
B Bhu... + Follow at
Previous Article Next Article
Turing Machine for subtraction | Set 2 Turing Machine as Comparator
Similar Reads
We use cookies to ensure you have the best browsing experience on our website. By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy,Theory of Computation - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to.
gain flexibility, speed, accuracy, and understanding of the level of questions generally asked.
Smin read
Introduction of Theory of Computation
Automata theory (also known as Theory Of Computation) is a theoretical branch of Computer
Science and Mathematics, which mainty deals with the logic of computation with respect to...
3min read
Decidable and Undecidable problems in Theory of Computation
Prerequisite - Turing Machine A problem is said to be Decidable if we can always construct a
corresponding algorithm that can answer the problem correctly. We can intuitively.
4min read
Relationship between grammar and language in Theory of Computation
A grammar is a set of production rules which are used to generate strings of a language. In
this article, we have discussed how to find the language generated by a grammar and vice.
4min read
Theory of Computation | Regular languages and finite automata | Question 2
What is the complement of the language accepted by the NFA shown below? (A) A (B) B (C)
C (D) D Answer: (8) Explanation: Quiz of this QuestionPlease comment below if you find.
Lminread
(Cen more atcies)
Article Tags : GATECS Theory of Computation
We use cookies to ensure you have the best browsing experience on our website. By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy,oS GeeksforGeeks
SS ScSaumnoccctest
A143, th Floor, Sovereign Corporate
Tower, Sector-136, Noida, Uttar Pradesh -
201305
Company
About Us
Legal
careers
InMedia
Contact Us
Advertise with us
FG Corporate Solution
Placement Training Program
Languages
Python
Java
or
Pue
Gotang
sau
R Language
Android Tutorial,
Data Science & ML
Data Science With Python
Data Science For Beginner
Machine Learning Tutorial
MuMaths
Data Visualisation Tutorial
Pandas Tutorial
NumPy Tutorial
Explore
Job-A-Thon Hiring Challenge
HackeAThon
66 Weekly Contest
Offline Clases (Delhi/NCR)
DSAin JAVAVCH+
Master System Design
Master cP
GeeistorGeeks Videos
Geeks Community
DSA
Data Stru
Algorithms
DSA for Beginners
Basic DSA Problems
DSA Roadmap
DSAInterview Questions
Competitive Programming
Web Technologies
Hem
css
JavaScript
Typescript
Reacts5
Nextus
Nodeds
We use cookies to ensure you have the best browsing experience on our website. By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy PolicyPython Tutorial
Django Tutoriat
Python Projects
Python Tkinter
Web Scraping
‘Opency Tutorial
Python Interview Question
DevOps
Git
ws,
Docker
Kubernetes
Azure
cP
Devops Roadmap
School Subjects
Mathematics
Physics
Chemistry
Biology
Social Science
English Grammar
Databases
sou
MySQL
PostgreSQL
PL/SQL.
MongoDB
Competitive Exams
JEEAdvanced
UGCNET
vupsc
ssc oct
sal Po
SB! Clerk
laps Po
We use cookies to ensure you have the best browsing experience on our website, By using our
hon Programming Examples
Computer Science
GATE CS Notes
Operating Systems
Computer Network
Database Management System
Sofware Engineering
Digital Logic Design
Engineering Maths
system Des
High Leve Design
Low Level Design
UML Diagrams
Interview Guide
Design Patterns
‘OoAD
‘system Design Bootcamp
Interview Questions
Commerce
Accountancy
Business Studies
Economics
Management
HR Management
Finance
Income Tax
Preparation Corner
Company.Wise Recruitment Process
Resume Templates
Aptitude Preparation
Puzzles
Company-Wise Preparation
Companies
colleges
More Tutorials
Software Development
Software Testing
Product Management
Project Management
Line
Brcel
All cheat Shoate
site, you acknowledge that you have read and understood our Cookie Policy & Privacy PolicyTyping Test
Image Ecitor
Code Formatters
Code Converters
Currency Converter
Random Number Generator
Random Password Generator
@GeeksforGeeks, Sane
Write an Article
Improve an Article
Pick Topics to Write
Share your Experiences
Internships
aya Edu All rights reserved
We use cookies to ensure you have the best browsing experience on our website, By using our
site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy