• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:43
CET 13:43
KST 21:43
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
2026 KongFu Cup Announcement3BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains15Weekly Cups (March 2-8): ByuN overcomes PvT block4GSL CK - New online series18
StarCraft 2
General
BGE Stara Zagora 2026 cancelled Blizzard Classic Cup - Tastosis announced as captains BGE Stara Zagora 2026 announced ByuL: The Forgotten Master of ZvT Terran AddOns placement
Tourneys
RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) Sparkling Tuna Cup - Weekly Open Tournament 2026 KongFu Cup Announcement [GSL CK] Team Maru vs. Team herO
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 516 Specter of Death Mutation # 515 Together Forever Mutation # 514 Ulnar New Year
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ BSL 22 Map Contest — Submissions OPEN to March 10 ASL21 General Discussion Are you ready for ASL 21? Hype VIDEO Gypsy to Korea
Tourneys
[Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here! ASL Season 21 Qualifiers March 7-8
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread PC Games Sales Thread No Man's Sky (PS4 and PC)
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
Mexico's Drug War US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine NASA and the Private Sector
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
Formula 1 Discussion 2024 - 2026 Football Thread General nutrition recommendations Cricket [SPORT] TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2985 users

The halting problem

Blogs > petergibbons
Post a Reply
pyaar
Profile Blog Joined August 2010
United States423 Posts
Last Edited: 2011-03-17 05:42:43
March 17 2011 05:27 GMT
#1
It's not often that I learn about things that I'm genuinely intrigued by in high school, but this is an exception. The halting problem, which is, I'm assuming, a staple of computability theory, asks the question, “is it possible to make an algorithm that can, for all cases, tell you whether a given computer program with its input will terminate?” The answer is an emphatic no because of an ingenious counterexample.

Let us suppose that I am on my deathbed, having wasted away my entire life coding a (supposed) solution to the halting problem. I shall from here replace all forms of “halt” with “terminate” since I'm not a silly Brit. This is America.

terminates(prog,input)
#codified product of sweat, blood, junk food and tears goes here
#True if program terminates
#or False if program does not terminate.


Since any program can itself be represented in its most elementary form as binary data, we can check to see if a program terminates with itself as input with this function:

self-terminates(prog)
#if terminates(prog,prog) is True, self-terminates runs forever
#if terminates(prog,prog) is False, self-terminates exits.


Thus if a program terminates when given itself as input, self-terminates goes into an infinite loop. If it does not terminate, self-terminates simply terminates. To say it another way, self-terminates terminates only if the provided program would not terminate on itself.

Now, what if we tried to run the code self-terminates(self-terminates)? If terminates(self-terminates, self-terminates) terminates, then an infinite loop would occur in self-terminates(self-terminates). (Note that the result of this should be what terminates(self-terminates, self-terminates) gives.) To say it another way, if self-terminates terminates on itself, then it must loop indefinitely. The problem is obvious. The only other possible case is that terminates(self-terminates, self-terminates) is false, but it's not: this would mean that self-terminates(self-terminates) would indeed terminate. The halting problem is unsolvable for a general case because of this counterexample.

I tried to make my explanation as simple as possible, but it took me at least an hour to fully wrap my head around this. Even now I'm not even sure if my explanation is correct. If you think you can make sense of more formal discourse on this (because shit, I can't), there's an entire wikipedia article dedicated to this in addition to numerous sites on the web. I've really been enjoying my Artificial Intelligence class.

haxorz
Profile Blog Joined June 2009
United States138 Posts
March 17 2011 05:46 GMT
#2
That's awesome that you think this stuff is interesting. Theoretical CS is pretty sweet.

Out of interest, what high school do you attend? My high school has a really strong CS program but I wish I had more exposure to theoretical results like the halting problem.

Also, the halting problem is actually *decidable* for some programming languages. Your counterexample assumes your language allows you to write such programs. Coincidentally, this very morning I went over a proof of termination for programs in Godel's T for the type theory class I am TAing.
And theres the GG.
pyaar
Profile Blog Joined August 2010
United States423 Posts
Last Edited: 2011-03-17 06:12:17
March 17 2011 06:04 GMT
#3
http://en.wikipedia.org/wiki/Tjhsst I go there. The old AI teacher stepped out this year to work on his doctorate, so a veteran math/CS teacher stepped in for him and has basically made up the course as he's gone along. After he introduced us to Python we began working on genetic algorithms and now we're just starting our study of Turing. I'm having a really good time.

I love abstract stuff like this, but my ability to comprehend this kind of thing is about average when compared to my classmates'. Same thing for BC calc. If I ever go into a CS field it'll be programming

edit: yes, that proof below me is a lot less convoluted. thanks!
Fission
Profile Blog Joined August 2010
Canada1184 Posts
March 17 2011 06:06 GMT
#4
Here's a simple proof of the halting problem that I think is a bit clearer:

The Halting Problem is:

INPUT: A string P and a string I. We will think of P as a program.

OUTPUT: 1, if P halts on I, and 0 if P goes into an infinite loop on I.

Theorem (Turing circa 1940): There is no program to solve the Halting Problem.

Proof: Assume to reach a contradiction that there exists a program Halt(P, I) that solves the halting problem, Halt(P, I) returns True if and only P halts on I. The given this program for the Halting Problem, we could construct the following string/code Z:

Program (String x)

If Halt(x, x) then
Loop Forever
Else Halt.

End.

Consider what happens when the program Z is run with input Z

Case 1: Program Z halts on input Z. Hence, by the correctness of the Halt program, Halt returns true on input Z, Z. Hence, program Z loops forever on input Z. Contradiction.

Case 1: Program Z loops forever on input Z. Hence, by the correctness of the Halt program, Halt returns false on input Z, Z. Hence, program Z halts on input Z. Contradiction.

End Proof.


http://www.comp.nus.edu.sg/~cs5234/FAQ/halt.html

It's cool that you're into this stuff.
haxorz
Profile Blog Joined June 2009
United States138 Posts
March 17 2011 06:08 GMT
#5
I went to tj Class of 2008. I'm a CS junior at CMU right now and am (probably) going to graduate a semester early. I'd be happy to talk to you about college stuff - I wish I had done so when I was in high school. If you wish, we can take this conversation offline so as to not derail your blog.

Who is this veteran teacher who speak of? If I had to guess, I'd say Mr. Steuben.
And theres the GG.
Assault_1
Profile Joined April 2009
Canada1950 Posts
March 17 2011 06:11 GMT
#6
I'm a CS major, but this is probably my least favourite area in cs we studied so far.. I usually don't like it when people say "this has no real-life applications," but I think its true for once in this case.
pyaar
Profile Blog Joined August 2010
United States423 Posts
March 17 2011 06:11 GMT
#7
Oh my goood. I'm going to blow up your PM box at some point—for now I have to finish my Vergil lines. CMU is a school I was really considering, so that's awesome.

Yes, it's Stueben, lol. The guy's strange and amazing. It's terrible that Latimer and Torbert both had to leave the year after I finished APCS since I've heard such great things about them, but Stueben and the new guy, Gabor, are both pretty cool too I guess.
pullarius1
Profile Blog Joined May 2010
United States523 Posts
March 17 2011 06:11 GMT
#8
The best, intuitive way I've heard to get a quick grasp the halting problem and related questions is this: imagine you have a program that does indeed tell you the answer to the halting problem. This would be the singular most powerful program in the world, because for any quantitative problem ever, you can simply make a program along the lines of "Search for Answers to Problem X" and then run that program and input into your Halting Program. For instance you could write a program looking for answers to Fermat's Last Theorem. Run the Halting program on that and, hey, you've proven it affirmatively or negatively. Or maybe write a "Search for Cancer Cure with Peptide A" etc. To boil it down to a simple rule: to ascertain every aspect of a program/machine/language, you have to run it. There are no clever shortcuts.

On a related, more mind-blowing note, you'll eventually get to things called Turing Machines, which end up being models for any sort of digital device you can imagine. Using those, you'll prove that it is actually impossible to determine any meaningful characteristic of programs at all!
@pullarius1
haxorz
Profile Blog Joined June 2009
United States138 Posts
March 17 2011 06:16 GMT
#9
On March 17 2011 15:11 petergibbons wrote:
Oh my goood. I'm going to blow up your PM box at some point—for now I have to finish my Vergil lines. CMU is a school I was really considering, so that's awesome.

Yes, it's Stueben, lol. The guy's strange and amazing. It's terrible that Latimer and Torbert both had to leave the year after I finished APCS since I've heard such great things about them, but Stueben and the new guy, Gabor, are both pretty cool too I guess.


Wow, what a coincidence. I had Steuben for Accelerated Intro CS. And I took Latin all 4 years.
And theres the GG.
pyaar
Profile Blog Joined August 2010
United States423 Posts
March 17 2011 06:17 GMT
#10
Wait a minute. is your last name Hong?
haxorz
Profile Blog Joined June 2009
United States138 Posts
March 17 2011 06:18 GMT
#11
On March 17 2011 15:11 Assault_1 wrote:
I'm a CS major, but this is probably my least favourite area in cs we studied so far.. I usually don't like it when people say "this has no real-life applications," but I think its true for once in this case.


Uh, the people who say that are the opposite of right (read: they are wrong). THIS is the theorem which says that it's actually impossible to test (certain) programs in (certain) languages (see my above post for details) AT ALL. Surely you think it's nice to know that you cannot naively expect every program to terminate?
And theres the GG.
haxorz
Profile Blog Joined June 2009
United States138 Posts
March 17 2011 06:19 GMT
#12
On March 17 2011 15:17 petergibbons wrote:
Wait a minute. is your last name Hong?


PM me.
And theres the GG.
munchmunch
Profile Joined October 2010
Canada789 Posts
March 17 2011 06:50 GMT
#13
On March 17 2011 15:18 haxorz wrote:
Show nested quote +
On March 17 2011 15:11 Assault_1 wrote:
I'm a CS major, but this is probably my least favourite area in cs we studied so far.. I usually don't like it when people say "this has no real-life applications," but I think its true for once in this case.


Uh, the people who say that are the opposite of right (read: they are wrong). THIS is the theorem which says that it's actually impossible to test (certain) programs in (certain) languages (see my above post for details) AT ALL. Surely you think it's nice to know that you cannot naively expect every program to terminate?


To put it more simply, no program can (perfectly) detect infinite loops. When I was 13 or so, I thought that interpreters/compilers should have a button to detect infinite loops, saving me the trouble of debugging them. So I've always thought of the halting problem as having real-world applications.
qrs
Profile Blog Joined December 2007
United States3637 Posts
March 17 2011 07:42 GMT
#14
On March 17 2011 15:11 pullarius1 wrote:
The best, intuitive way I've heard to get a quick grasp the halting problem and related questions is this: imagine you have a program that does indeed tell you the answer to the halting problem. This would be the singular most powerful program in the world, because for any quantitative problem ever, you can simply make a program along the lines of "Search for Answers to Problem X" and then run that program and input into your Halting Program. For instance you could write a program looking for answers to Fermat's Last Theorem. Run the Halting program on that and, hey, you've proven it affirmatively or negatively. Or maybe write a "Search for Cancer Cure with Peptide A" etc.
Very oversimplified, in my opinion, because all a "Halting Program" is guaranteed to do is return an answer in some finite time--it could be a billion years. If time weren't a practical consideration, then brute force search would more or less be "the most powerful program in the world".
To boil it down to a simple rule: to ascertain every aspect of a program/machine/language, you have to run it. There are no clever shortcuts.
This is oversimplified to the point of being wrong (imo). The point of the halting theorem is that you can't "ascertain every aspect of [every] program/machine/language" at all--including by running it. It's not that there are no shortcuts to discovering that a given program halts on a given input--it's that there is no way at all.
'As per the American Heart Association, the beat of the Bee Gees song "Stayin' Alive" provides an ideal rhythm in terms of beats per minute to use for hands-only CPR. One can also hum Queen's "Another One Bites The Dust".' —Wikipedia
Please log in or register to reply.
Live Events Refresh
WardiTV Team League
12:00
Group B
WardiTV286
IntoTheiNu 2
Liquipedia
RSL Revival
10:00
Season 4: Group D
ByuN vs SHIN
Maru vs Krystianer
Tasteless1186
IndyStarCraft 225
Rex146
LiquipediaDiscussion
Sparkling Tuna Cup
10:00
Weekly #123
Creator vs GeraldLIVE!
Classic vs TBD
CranKy Ducklings100
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 1294
IndyStarCraft 225
Rex 144
StarCraft: Brood War
Sea 50398
Calm 11039
firebathero 2737
Horang2 2227
GuemChi 1566
Jaedong 1314
BeSt 442
Mini 276
actioN 249
Soma 242
[ Show more ]
Last 234
Rush 232
EffOrt 221
Stork 198
Mind 78
ToSsGirL 67
Dewaltoss 56
Backho 54
Hm[arnc] 48
sorry 47
Sea.KH 44
JulyZerg 43
Barracks 34
IntoTheRainbow 31
GoRush 22
ivOry 12
ajuk12(nOOB) 8
Icarus 7
SilentControl 7
Nal_rA 7
Dota 2
Gorgc5021
XaKoH 294
canceldota108
Counter-Strike
byalli658
zeus391
x6flipin370
edward70
Super Smash Bros
Mew2King107
Heroes of the Storm
Khaldor295
MindelVK10
Other Games
B2W.Neo2049
Liquid`RaSZi234
Fuzer 166
Organizations
Dota 2
PGL Dota 2 - Main Stream18382
Other Games
gamesdonequick851
ComeBackTV 281
StarCraft: Brood War
lovetv 17
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• 3DClanTV 72
• musti20045 24
• Adnapsc2 10
• CranKy Ducklings SOOP5
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 1599
Upcoming Events
Patches Events
4h 18m
BSL
7h 18m
GSL
19h 18m
Wardi Open
23h 18m
Monday Night Weeklies
1d 4h
WardiTV Team League
1d 23h
PiGosaur Cup
2 days
Kung Fu Cup
2 days
OSC
3 days
The PondCast
3 days
[ Show More ]
KCM Race Survival
3 days
WardiTV Team League
3 days
Replay Cast
4 days
KCM Race Survival
4 days
WardiTV Team League
4 days
Korean StarCraft League
5 days
uThermal 2v2 Circuit
6 days
BSL
6 days
Liquipedia Results

Completed

Proleague 2026-03-13
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

CSL Elite League 2026
ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.