An Application of Ramsey’s Theorem to Proving Programs Terminate
Exposition by William Gasarch
1
Introduction
We describe an application of Ramsey’s Theorem to proving programs terminate, by which
we mean terminate on any input. This paper is self contained; it does not require knowledge
of either Ramsey’s Theorem or Programming Languages.
Our account is based on the articles of B. Cook, Podelski, and Rybalchenko [10, 22]
and Lee, Jones, and BenAmram [20]. Many other papers [8, 9, 21, 23, 24] have used the
techniques I present here. Termination checkers that use the methods of B. Cook, Podelski,
and Rybalchenko include Loopfrog [18], and Terminator [7]. Termination checkers that use
the methods of Lee, Jones, and BenAmram include ACL2 [1], AProVE [2], ARMC [27], and
Julia [3].
Convention 1.1
The statement
The Program Terminates
means that it terminates no mat
ter what the user does. The user will be supplying inputs as the program runs; hence we
are saying that the user cannot come up with some (perhaps bizarre) inputs that make the
program run forever.
In the summary below we refer to Programs 1,2,3 and 4 which appear later in the paper.
1. Section 3: We prove Program 1 terminates.
This proof uses a simple well founded
ordering. We then state Theorem 3.2 that encapsulates this kind of proof.
2. Section 4: We prove Program 2 terminates. This proof uses a complicated well founded
ordering and Theorem 3.2.
3. Section 5: We prove Program 2 terminates using Ramsey’s Theorem. We then state
Theorems 5.6 and Theorem 5.7 which encapsulates this kind of proof. This proof of
termination is easier than the proof is Section 4 in some ways, but more complicated
in other ways.
4. Section 6: We prove Program 2 terminates using Theorem 5.6 and hence using Ram
sey’s Theorem; however, we prove the premise of Theorem 5.6 using matrices. We then
state and prove Theorems 6.4 and 6.5 that encapsulates this kind of proof. We discuss
how this approach can be made into an algorithm that generates proofsoftermination
in some cases.
5. Section 7: We prove Program 3 terminates using Theorem 5.7 and hence using Ram
sey’s Theorem; however, we prove the premise of Theorem 5.7 using transition invari
ants. We then state Theorem 7.3 that encapsulates this kind of proof. It seems difficult
to obtain a proof that Program 3 terminates without using Ramsey’s Theorem.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Program 0
(x , y) = ( input (NAT) , input (NAT))
While
x
>
0
control = input (1 ,2)
i f
control = 1
(x , y)=(x+10,y

1)
else
i f
control = 2
(x , y)=(y+17,x

2)
6. Section 8: We prove Program 3 terminates using Theorem 6.5 and hence using Ram
sey’s Theorem and matrices. Program 3 has some properties that make this a good
illustration.
7. Section 9: We prove Program 4 terminates using Theorem 7.3 and hence Ramsey’s
Theorem and transition invariants. Program 4 has some properties that make this a
good illustration.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '11
 staff
 Halting problem, Mathematical proof, Ramsey's theorem

Click to edit the document details