<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Proving termination of programs having transition invariants of height ω</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Stefano Berardi</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Paulo Oliva</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Silvia Steila</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Queen Mary University of London</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Universita` degli studi di Torino</institution>
        </aff>
      </contrib-group>
      <fpage>237</fpage>
      <lpage>240</lpage>
      <abstract>
        <p>We study the proof of a recent and relevant result about termination of programs, the Termination Theorem by Podelski and Rybalchenko [9]. We prove that in a special case, the only case which is used in applications, all programs proved to be terminating may be described by some primitive recursive map. Fix any transition relation R over the set S of possible states of a program P . Assume In ⊆ S is the set of possible initial states of P , and that Acc is the set of accessible states of P , if we start from some state in In and we use the relation R finitely many times. The Termination Theorem by Podelski and Rybalchenko [9] may be stated as follows. The transition relation R is terminating from any initial state if and only if the transitive closure R+ of R, restricted to the set Acc of accessible states, is included in some finite union of well-founded relations. The authors formulate the Termination Theorem by introducing the concept of “disjunctively well-founded transition invariant”. A disjunctively wellfounded transition invariant is any binary relation T which is the union of a family T1, . . . , Tn of well-founded relations, and which includes the restriction to Acc of R+. The original statement of the Termination Theorem is: “R is terminating from any initial state if and only if R has some disjunctively well-founded transition invariant T ”. By building over this result the same authors and Byron Cook designed an algorithm they called Terminator [5], checking a sufficient condition for termination for a while-if program P in a simplified programming language. The Terminator algorithm takes P and looks for a disjunctively well-founded transition invariant T = T1 ∪ . . . ∪ Tn for P , with T1, . . . , Tn well-founded relations of height ω. The extra feature “of height ω” is found in the algorithm but not in the Theorem. If the Terminator algorithm finds T1, . . . , Tn as above, it deduces the termination for the program P using the Termination Theorem. This particular application of the Termination Theorem raises an interesting question: what is the status of a transition relation R having a disjunctively well-founded transition invariant T = T1 ∪ . . . ∪ Tnwhere each Ti has height ω? An answer to this question can lead to a characterization of the set of while-if programs which the termination algorithm can prove to be terminating.</p>
      </abstract>
      <kwd-group>
        <kwd>Introducing the Termination Theorem</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>2</p>
      <p>A characterization of the Termination Theorem in the
case of invariants of height ω
Our first result is the following. The Termination Theorem may derive that a
transition relation R is terminating using n relations T1, . . . , Tn of height ω if and
only if R has height ≤ ωn. Besides, in the case T1, . . . , Tn are primitive recursive
and R itself is (the graph of) the restriction of some primitive recursive map to
some primitive recursive subset, we may say more. In this case, indeed, the final
state of the program P is computable by some primitive recursive map in the
initial state.</p>
      <p>
        As a corollary we derive that the set of functions, having at least one
implementation in Podelski-Rybalchenko while-if language with a well-founded
disjunctively transition invariant where each relation has height ω, is exactly the
set of primitive recursive functions. This is an ongoing work: a preliminary draft
may be found in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. An independent proof of the same result, again in the form
of preliminary draft, may be found in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. The authors follow a completely
different approach, they use a miniaturization of the Dickson Lemma to prove the
Termination Theorem.
3
      </p>
    </sec>
    <sec id="sec-2">
      <title>A sketch of our proof</title>
      <p>
        Our approach is based over the analysis a new intuitionistic proof of the
Termination Theorem [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] (another intuitionistic proof already existed, by Thierry
Coquand [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]). The original proof of the Termination Theorem requires classical
logic and Ramsey’s Theorem. In order to intuitionistically prove the
Termination Theorem we introduced a kind of contrapositive of Ramsey Theorem, the
H-closure Theorem [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], which we are going to explain.
      </p>
      <p>First of all, we introduce the notion of H-well-foundation. Let T be any
binary relation on some set I. We say that a sequence s is T -homogeneous if
s ∈ H(T ), where H(T ) is defined as follows.</p>
      <p>Let T be a binary relation on some set I. H(T ) is the set of the T -decreasing
transitive finite sequences on I:
hx1, . . . , xni ∈ H(T ) ⇐⇒ ∀i, j ∈ [1, n].i &lt; j =⇒ xj T xi.</p>
      <p>T is H-well-founded if H(T ) is well-founded by one-step extension. If T is
well-founded that T is H-well-founded, but H-well-foundation is much weaker
than well-foundation. The notion of H-closure is new, therefore we provide some
examples. The relation T ≡ (6=) over {0, 1} is not well-founded because we have
the infinite chain 0 6= 1 6= 0 6= 1 . . .. Any sequence s ∈ H(T ), by definition
unfolding, has any two elements in relation 6=, therefore has pairwise distinct
elements, hence has length ≤ 2. Thus, H(T ) has height 2 w.r.t. the one-step
extension relation, therefore H(T ) is well-founded, and T is H-well-founded.
Another example (for which we skip the proof): a relation T over a finite set is
well-founded if and only if there are no T -cycles, that is, there are no x0, . . . , xn ∈
I such that x0T x1T . . . T xn = x0. A relation T over a finite set is H-well-founded
if and only if there are no T -loops, that is, there is no x ∈ I such that xT x. This
second condition is much weaker that the first one, a loop is a cycle but a cycle
in general is not a loop.</p>
      <p>
        The H-closure Theorem says that if R1, . . . , Rk are H-well-founded then
(R1 ∪ · · · ∪ Rk) is also H-well-founded. H-closure has an intuitionistic proof,
and, as we said, intuitionistically derives the Termination Theorem. In order to
characterize the Termination Theorem in the case of height ω relations, we first
strengthen H-closure as follows. If each Ri has ordinal height less or equal than
αi, then H(R1 ∪ · · · ∪ Rk) has ordinal height less or equal than 2α1⊕···⊕αk , where
⊕ is the natural sum of ordinals, defined as the smallest binary function which is
increasing in both arguments w.r.t. the pointwise ordering [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The proof uses a
simulation of the ordering of H(R1 ∪ · · · ∪ Rk) in the inclusion ordering over the
set of k-branching trees, whose branches are decreasing sequences in R1 ⊕· · ·⊕Rk
[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>Eventually, we embed the ordering of H(R1 ∪ · · · ∪ Rk) into the ordering over
[0, ωk], and we use the characterization for the decreasing sequences over [0, ωk]
in order to characterize the sequences of transitions for a given program P .</p>
      <p>
        After this proof was done, we were informed that Delhomm´e [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and Blass
and Gurevich [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] have already observed that the computation of the ordinal
height of a relation proven to be well-founded by the Termination Theorem is
the natural product of the individual heights.
4
      </p>
    </sec>
    <sec id="sec-3">
      <title>Conclusion and future work</title>
      <p>We proved the following characterization of the Termination Theorem. Assume
we have a program P whose transition relation R is the graph of a partial
recursive map restricted to a primitive recursive domain. Assume we have a
disjunctively well-founded transition invariant T = T1 ∪ . . . . . . Tn for R, with
T1, . . . , Tn primitive recursive and of height ω. Then we may compute the number
of steps of R and the final state by some primitive recursive function in the initial
state.</p>
      <p>We conjecture that the same result holds for the Terminator Algorithm based
on the Termination Theorem: a function has at least one implementation in
Podelski-Rybalchenko language which the Terminator Algorithm may catch
terminating if and only if the function is primitive recursive. One of the authors
is working on a proof of it. The result is not self-evident because there is much
more in the Terminator algorithm than just the Termination Theorem.</p>
      <p>If compared to the characterization of Termination Theorem based on
Dickson Lemma, our characterization has the advantage of being based over the
original proof of the Theorem. For this reason, we hope in a future work to be
able characterize the Termination Theorem in general, in the case of well-founded
relations of any ordinal height.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>S.</given-names>
            <surname>Berardi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Oliva</surname>
          </string-name>
          , and
          <string-name>
            <given-names>S.</given-names>
            <surname>Steila</surname>
          </string-name>
          .
          <article-title>Proving termination with transition invariants of height omega</article-title>
          .
          <source>Preliminary Draft</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>S.</given-names>
            <surname>Berardi</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Steila</surname>
          </string-name>
          .
          <article-title>Ramsey theorem as an intuitionistic property of well founded relations</article-title>
          . pages
          <fpage>93</fpage>
          -
          <lpage>107</lpage>
          ,
          <year>2014</year>
          . RTA-TLCA.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>A.</given-names>
            <surname>Blass</surname>
          </string-name>
          and
          <string-name>
            <given-names>Y.</given-names>
            <surname>Gurevich</surname>
          </string-name>
          .
          <article-title>Program termination and well partial orderings</article-title>
          .
          <source>ACM Trans. Comput. Logic</source>
          ,
          <volume>9</volume>
          (
          <issue>3</issue>
          ):
          <volume>18</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>18</lpage>
          :
          <fpage>26</fpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>P.</given-names>
            <surname>Carruth</surname>
          </string-name>
          .
          <article-title>Arithmetic of ordinals with applications to the theory of ordered abelian groups</article-title>
          .
          <source>Bull. Amer. Math. Soc.</source>
          ,
          <volume>48</volume>
          (
          <issue>4</issue>
          ):
          <fpage>223</fpage>
          -
          <lpage>334</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>B.</given-names>
            <surname>Cook</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Podelski</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Rybalchenko</surname>
          </string-name>
          .
          <article-title>Abstraction refinement for termination</article-title>
          .
          <source>In SAS</source>
          , pages
          <fpage>87</fpage>
          -
          <lpage>101</lpage>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>T.</given-names>
            <surname>Coquand</surname>
          </string-name>
          .
          <article-title>An analysis of ramsey's theorem</article-title>
          .
          <source>Inf. Comput.</source>
          ,
          <volume>110</volume>
          (
          <issue>2</issue>
          ):
          <fpage>297</fpage>
          -
          <lpage>304</lpage>
          ,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. C. Delhomm´e.
          <source>Height of a Superposition. Order</source>
          ,
          <volume>23</volume>
          (
          <issue>2-3</issue>
          ):
          <fpage>221</fpage>
          -
          <lpage>233</lpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>D.</given-names>
            <surname>Figueira</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Figueira</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Schmitz</surname>
          </string-name>
          , and
          <string-name>
            <surname>Ph</surname>
          </string-name>
          . Schnoebelen.
          <article-title>Ackermannian and primitive-recursive bounds with Dickson's Lemma</article-title>
          .
          <source>In LICS 2011: Proceedings of the 26th Annual IEEE Symposium on Logic in Computer Science</source>
          , pages
          <fpage>269</fpage>
          -
          <lpage>278</lpage>
          . IEEE Press,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>A.</given-names>
            <surname>Podelski</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Rybalchenko</surname>
          </string-name>
          .
          <article-title>Transition invariants</article-title>
          .
          <source>In LICS</source>
          , pages
          <fpage>32</fpage>
          -
          <lpage>41</lpage>
          . IEEE Computer Society,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>