B. Cook, Podelski, and Rybalchenko have done both practical and theoretical
work on proving that programs terminate.
They use Ramsey's Theorem (Yeah!). Jon Katz
send me their paper. After some emails with them and others I wrote an exposition.
Their papers are
here
(I used Transition Invariants (LICS 2004) and Proving Program Termination (CACM 2011), though there are others on that page that are relevant.)
My exposition is
here.
This post will briefly describe what they do. For more detail see
either their papers or my exposition.
If w is a variable in a program and A is a set then
w = input(A);
means that w gets SOME value in A, supplied by the user.
Consider the following program
w = input(N);
x = input(N);
y = input(N);
While w>0 and x>0 and y>0
control = input(1,2)
if control = 1 then
x=input(x+1,x+2,...)
y=input(y+1,y+2,...)
w=w1
else
if control = 2 then
y=input(y+1,y+2,...)
x=x1
A Proof that the Program terminates that does NOT use Ramsey's Theorem
How would you prove that it terminates?
One way is to (1) find a map f : NxNxN > L where L is a well founded order,
(2) show that in each iteration of the loop
f(x,y,z) decreases, (3) show that if f(x,y,z) bottoms out then the program
has halted (perhaps earlier than this point).
For this program the key is not the function f, which will just be
f(w,x,y)=(w,x,y) but the ordering. We map to the ordering
(N x N x N, <
_{lex}).
In every iteration either
(1) w decreases, so (w,x,y) decreases even though x and y may get
much larger, or
(2) w stays the same and x decreases, so (w,x,y) decreases even though
y may get much larger.
Hence (w,x,y) decreases. Hence, eventually, one of the components is 0,
and then the program halts.
A Proof that the Program Halts that Uses Ramsey's Theorem.
Assume, by way of contradiction, that there is a way the user could
supply initial w,x,y and also controls in every iteration, so that
the program runs forever. Let the infinite sequence of states of the
program be:
(w_{1},x_{1},y_{1}), (w_{2},x_{2},y_{2}), ..., (w_{i},x_{i},y_{i}),..., (w_{j},x_{j},y_{j}), ...
Claim: Either
w
_{i} < w
_{j} or x
_{i} < x
_{j}.
If between steps i and j we ever have control=1 then w will decrease.
If we only have control=2 then x will decrease.
We now color all (i,j) as follows: if w decreased then color it W,
if w did not decrease but x did then color it X.
By Ramsey's theorem there is a homogeneous subset.
i_{1} < i_{2} < i_{3} ...
If the color is W then we have
w_{i1} > w_{i2} > w_{i3} > ...
AHHA so w must eventually be 0 and the program terminates, contradiction.
Similar for if the color is X.
What to make of all of this?

In the first proof we only had to prove things about ONE step of
the program (YEAH!) but we had to deal with a complicated well founded
ordering (BOO!).

In the Second proof we had to prove things about ANY sequence of steps
of the program (BOO!) but only had to deal with a simple well founded
ordering (YEAH).

There are examples in my exposition and in their papers where the
Ramsey approach really does give an easier proof.

We didn't use the full strength of Ramsey's theorem (Henceforth RT).
Note that
the coloring is transitive: if i < j < k and
(i,j) is RED and (j,k) is RED then (i,k) is RED.
We used RT restricted to Transitive colorings.
We call this the Transitive Ramsey Theorem or TRT.
TRT for 2 colors is actually the ErdosSzekeres theorem
(See here
for six or more proofs, article title Variations on the Monotone....)
TRT for c colors is a natural (and easy) generalization
of the ErdosSzekeres theorem.
(I included the proof of this in my exposition for completeness, however,
if someone has a reference please leave a comment.)

Is RT actually stronger than TRT?
There are three ways to ask this question, and in all three
the answer is yes. See my exposition.