~/tedtes/writing/math-foundations-for-reasoning-models

~/writing/math-foundations-for-reasoning-models $ ls

Computation as State Transition

Halting Problem

The halting problem asks whether there is a general algorithm that can decide if any program will stop or run forever.

~/writing/math-foundations-for-reasoning-models $ cat topic.md

What Is the Halting Problem?

Definition

The halting problem asks whether there is a general algorithm that can decide if another computation will eventually stop.

Input:

program description + program input

Question:

Will this program eventually halt on this input?

Output:

yes or no

The halting problem asks whether stopping behavior can be decided in general.


What Does Halt Mean?

A computation halts when it stops producing new configurations.

Example:

3 -> 2 -> 1 -> 0 -> stop

This halts.

Another computation may continue forever:

0 -> 1 -> 0 -> 1 -> ...

This does not halt.

Halting means execution reaches a stopping point.


Specific Cases Can Be Easy

Some halting questions are easy.

Example:

Program:
subtract 1 until x = 0

Input:
3

Execution:

3 -> 2 -> 1 -> 0 -> stop

This halts.

Another example:

Program:
repeat forever

This does not halt.

The halting problem is not saying every individual case is impossible to analyze.


The General Question

The difficult question is whether one algorithm can decide halting for every possible program and input.

Imagined algorithm:

Halts(program, input) -> yes or no

It must always answer correctly.

It must answer for all valid program-input pairs.

It cannot run forever while trying to decide.

The halting problem asks for a universal yes-or-no decider.


Why Running The Program Is Not Enough

One idea is:

Run the program and see if it stops.

This works if the program eventually stops.

But if the program keeps running, waiting does not tell us whether:

  • it will stop much later
  • it will never stop

Example:

Program still running after 1 hour

This does not prove it will run forever.

It may halt after 2 hours.

Or after 2 years.

Or never.

Observing a running computation is not a general halting decision procedure.


The Key Impossibility

There is no algorithm that correctly decides halting for every possible program and input.

In other words, this cannot exist:

Halts(program, input)

if it is required to:

  • always finish
  • always return yes or no
  • always be correct
  • work for every program and input

The halting problem is undecidable in general.


The Contradiction Idea

Suppose a perfect halting decider exists.

Call it:

Halts(program, input)

It returns:

yes -> the program halts on that input
no  -> the program runs forever on that input

Now define a new program:

Trouble(program):
  if Halts(program, program) says yes:
    run forever
  otherwise:
    halt

This program does the opposite of what the halting decider predicts for a program running on itself.

The contradiction comes from using the decider's answer to reverse the behavior.


Running Trouble On Itself

Now ask:

Trouble(Trouble)

There are two possibilities.

Case 1

Halts(Trouble, Trouble) says yes

That means Trouble(Trouble) should halt.

But by definition, if the decider says yes, Trouble runs forever.

Contradiction.

Case 2

Halts(Trouble, Trouble) says no

That means Trouble(Trouble) should run forever.

But by definition, if the decider says no, Trouble halts.

Contradiction.

Both cases fail.

So the perfect halting decider cannot exist.

A general halting decider leads to contradiction.


What This Does Not Mean

The halting problem does not mean:

No program's behavior can ever be known.

Many programs can be analyzed.

It also does not mean:

Computation is useless.

Most practical programs are designed with known stopping behavior.

The result is narrower and more precise:

There is no single algorithm that decides halting for every possible program and input.

The limit is about a completely general decision procedure.


Why This Matters

The halting problem shows that computability has limits.

Some questions are:

  • clearly defined
  • about symbolic procedures
  • expressible as yes-or-no problems

but still not computable in general.

This matters because it prevents a false belief:

If a problem is precise, then some algorithm must solve it.

That is not always true.

Precision does not guarantee computability.


Final Summary

  • The halting problem asks whether a program will stop or run forever on a given input.
  • Some individual halting cases are easy to answer.
  • The general question asks for one decider that works for every program-input pair.
  • Running the program is not enough because non-halting cannot be confirmed by waiting.
  • A perfect general halting decider would lead to contradiction.
  • Therefore, the halting problem is undecidable in general.
  • This does not make computation useless.
  • It shows that rule-based computation has precise limits.

~/writing/math-foundations-for-reasoning-models $ open

Continue the series.

Why Computation Does Not Require Awareness