## Stop when you are Almost-Full Adventures in constructive termination

### BibTeX

@MISC{Vytiniotis_stopwhen,

author = {Dimitrios Vytiniotis and Thierry Coquand},

title = {Stop when you are Almost-Full Adventures in constructive termination},

year = {}

}

### OpenURL

### Abstract

Disjunctive well-foundedness (used in Terminator), size-change termination, and well-quasi-orders (used in supercompilation and term-rewrite systems) are examples of techniques that have been successfully applied to automatic proofs of program termination and online termination testing, respectively. Although these works originate in different communities, there is an intimate connection between them – they rely on closely related principles and both employ similar arguments from Ramsey theory. At the same time there is a notable absence of these techniques in programming systems based on constructive type theory. In this paper we’d like to highlight the aforementioned connection and make the core ideas widely accessible to theoreticians and Coq programmers, by offering a Coq development which culminates in some novel tools for performing induction. The benefit is nice composability properties of termination arguments at the cost of intuitive and lightweight user obligations. Inevitably, we have to present some Ramsey-like arguments: Though similar proofs are typically classical, we offer an entirely constructive development standing on the shoulders of Veldman and Bezem, and Richman and Stolzenberg. 1.

### Citations

470 |
P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions
- Bertot, Castéran
- 2004
(Show Context)
Citation Context ...te pleasant to use due to the composability of almost-full relations and the nature of the userobligations that arise. Apart from contributing to Coq’s large arsenal of recursion-encoding techniques =-=[4, 5, 17, 27, 6]-=-, the other significant contribution of this article is to bring together ideas from different research communities in a type-theoretic framework. 2. Well-quasi-orders and almost-full relations The st... |

316 |
On a Problem of Formal Logic
- Ramsey
(Show Context)
Citation Context ...F because it relates no elements whatsoever! Although we have focused on binary relations, a generalization of our development to n-ary relations (corresponding to the original version of the theorem =-=[21]-=-) is entirely possible. As a final remark, the intersection theorem for the case of WQOs is folklore – in the context of WQOs the transitivity assumption seems to significantly simplify the proof. For... |

175 | The size-change principle for program termination
- Lee, Jones, et al.
- 2001
(Show Context)
Citation Context ...ion invariants [20] method has been an extremely successful approach for automatic proofs of program termination, leading to industrial-strength tools, such as Terminator [7]. Size-change termination =-=[15, 12, 24]-=- is another very successful methodology for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory [11]. Furthermore, research on online terminati... |

169 | Towards a practical programming language based on dependent type theory - Norell - 2007 |

134 | Termination Proofs for Systems Code
- Cook, Podelski, et al.
- 2006
(Show Context)
Citation Context ... years, the so-called transition invariants [20] method has been an extremely successful approach for automatic proofs of program termination, leading to industrial-strength tools, such as Terminator =-=[7]-=-. Size-change termination [15, 12, 24] is another very successful methodology for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory [11]. Fur... |

119 |
the tree theorem, and Vazsonyi's conjecture
- Well-quasi-ordering
- 1960
(Show Context)
Citation Context ... recursive types is of particular interest as it is a well-studied topic in the context of WQOs, where the canonical WQO for lists and more general recursive types is based on homeomorphic embeddings =-=[18, 14]-=-. There have been attempts to port some of these theorems for WQOs in a constructive setting (e.g. homeomorphic embeddings for lists on finite alphabets [3, 23]) so we believe this is a quite plausibl... |

89 | Transition Invariants
- Podelski, Rybalchenko
- 2004
(Show Context)
Citation Context ...rograms. Despite the difficulties, however, several research communities have managed to make good progress in termination-related problems. Over the recent years, the so-called transition invariants =-=[20]-=- method has been an extremely successful approach for automatic proofs of program termination, leading to industrial-strength tools, such as Terminator [7]. Size-change termination [15, 12, 24] is ano... |

73 | An algorithm of generalization in positive supercompilation
- Sørensen, Glück
- 1995
(Show Context)
Citation Context ...gy for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory [11]. Furthermore, research on online termination testing [16] and supercompilation =-=[25]-=- has for a while been using termination testing criteria for function reductions and inlining based on well-quasiorders, often employing Ramsey-like arguments to form more complex termination testing ... |

65 |
On well-quasi-ordering finite trees
- Nash-Williams
- 1963
(Show Context)
Citation Context ... also that we’ve stopped worrying about the transitivity condition – indeed we are not going to need it! Some of the proofs in later parts of the paper would be simpler (and they are, in related work =-=[18]-=-) but essentially all interesting properties of WQOs can be proved on AFs without requiring transitivity. 3. Well-founded vs. almost-full relations To build up some more intuitions about AF relations,... |

38 | Subset Coercions in Coq
- Sozeau
(Show Context)
Citation Context ...ques in type theory and Coq, some of which include good support for automation. The most straightforward way to program recursion in Coq [4] is either by structural recursion or by using subset types =-=[26]-=- and measure arguments. An extension of “guarded” recursion (and co-recursion) implemented in a variant of Agda is sized-types [1] (not to be confused with size-change termination). The Bove and Capre... |

16 | Ramsey's theorem and the pigeonhole principle in intuitionistic mathematics
- Veldman, Bezem
- 1992
(Show Context)
Citation Context ...duction principles. Inevitably, we have to present some Ramsey-like arguments: Though similar proofs are typically classical, we offer a constructive development in the footsteps of Veldman and Bezem =-=[28, 9]-=-, and Richman and Stolzenberg [22]. Specifically, our contributions with this paper are: • We introduce a novel mechanism for type-based termination, that of almost-full relations (Section 2), which i... |

14 | Certified size-change termination
- Krauss
- 2007
(Show Context)
Citation Context ...lar techniques to help programmers prove the totality of their definitions inprogramming systems based on constructive type theory. To quote some related work on size-change termination for Isabelle =-=[14]-=-: “Our proof uses classical logic, including the (infinite, but countable) axiom of choice. It would be interesting to investigate if the proof can be modified to work in a weaker framework” We show t... |

9 |
and Venanzio Capretta. Modelling general recursion in type theory
- Bove
(Show Context)
Citation Context ...te pleasant to use due to the composability of almost-full relations and the nature of the userobligations that arise. Apart from contributing to Coq’s large arsenal of recursion-encoding techniques =-=[4, 5, 17, 27, 6]-=-, the other significant contribution of this article is to bring together ideas from different research communities in a type-theoretic framework. 2. Well-quasi-orders and almost-full relations The st... |

8 |
An analysis of Ramsey’s Theorem
- Coquand
- 1994
(Show Context)
Citation Context ... Veldman’s original ideas [28, 9]. This is not to say that our development is the only possible way to develop constructive Ramsey-like arguments, for instance there exists an alternative formulation =-=[8]-=- but does not seem as suitable for termination purposes as the one we present in this paper. Similarly, constructive proofs of various homeomorphic embedding lemmas (such as Higman’s Lemma [3, 23, 10]... |

8 |
A new look at generalized rewriting in type theory
- Sozeau
- 2009
(Show Context)
Citation Context ... benign functional extensionality). It builds under Coq 8.3pl2. The new induction principles proposed in this paper are notnecessarily more expressive or easier to use than other (particularly recent =-=[6, 13, 27]-=-) related work – this is a topic that deserves further investigation, engineering, and potentially automation support. On the other hand, the induction principles that we propose here are quite amenab... |

8 | CoLoR: a Coq library on well-founded rewrite relations and its application on the automated verification of termination certificates
- Blanqui, Koprowski
(Show Context)
Citation Context ... good support for automation. The most straightforward way to program recursion in Coq [4] is either by structural recursion or by using subset types [26] and measure arguments. The Coq CoLoR library =-=[5]-=- can be used to manipulate well-founded relations and measures. An extension of “guarded” recursion (and co-recursion) implemented in a variant of Agda is sized-types [1] (not to be confused with size... |

8 |
Partial and nested recursive function definitions in higher-order logic
- Krauss
(Show Context)
Citation Context ...r each definition the user introduces an indexed type family with constructors corresponding to the recursive calls. Afterthe-fact, she can provide such an inductive witness at the call-sites. Krauss =-=[15]-=- proposes a related technique for showing automatically the termination of Isabelle functions by extracting their inductive graph and using an induction principle on that graph. In folowup work, Kraus... |

7 | Termination and guardedness checking with continuous types
- Abel
- 2003
(Show Context)
Citation Context ...n Coq [4] is either by structural recursion or by using subset types [26] and measure arguments. An extension of “guarded” recursion (and co-recursion) implemented in a variant of Agda is sized-types =-=[1]-=- (not to be confused with size-change termination). The Bove and Capretta method [5] is traditionally the de-facto way to define recursive programs that include complex argument relations in Type Theo... |

7 |
A constructive proof of Higman’s lemma in Isabelle
- Berghofer
- 2004
(Show Context)
Citation Context ...es is based on homeomorphic embeddings [18, 14]. There have been attempts to port some of these theorems for WQOs in a constructive setting (e.g. homeomorphic embeddings for lists on finite alphabets =-=[3, 23]-=-) so we believe this is a quite plausible direction for future work. 5. Size-change termination and AF induction We have examined combinators on AF relations, and simple examples such as lexicographic... |

7 |
Termination analysis and call graph construction for higherorder functional programs
- Sereni
- 2007
(Show Context)
Citation Context ...ion invariants [20] method has been an extremely successful approach for automatic proofs of program termination, leading to industrial-strength tools, such as Terminator [7]. Size-change termination =-=[15, 12, 24]-=- is another very successful methodology for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory [11]. Furthermore, research on online terminati... |

6 | General size-change termination and lexicographic descent. In The Essence of Computation: Complexity, Analysis, Transformation. Essays Dedicated to Neil D
- Ben-Amram
- 2002
(Show Context)
Citation Context ...(O,_) ⇒ fun frec ⇒ 1 | (_,O) ⇒ fun frec ⇒ 1 | (S x, S y) ⇒ fun frec ⇒ frec (S y, y) _ + frec (S y, x) _ end). unfold T in *. left. simpl; omega. unfold T in *. right. simpl; omega. Defined. Ben-Amram =-=[2]-=- notices that examples like gnlex belong in a syntactic class of programs that can be shown terminating by sizechange termination (SCT) [15, 12, 2] but not by a direct lexicographic descent argument, ... |

6 |
A coinductive monad for prop-bounded recursion
- Megacz
- 2007
(Show Context)
Citation Context ...te pleasant to use due to the composability of almost-full relations and the nature of the userobligations that arise. Apart from contributing to Coq’s large arsenal of recursion-encoding techniques =-=[4, 5, 17, 27, 6]-=-, the other significant contribution of this article is to bring together ideas from different research communities in a type-theoretic framework. 2. Well-quasi-orders and almost-full relations The st... |

6 |
Well quasi-ordered sets
- Richman, Stolzenberg
- 1990
(Show Context)
Citation Context ...ve to present some Ramsey-like arguments: Though similar proofs are typically classical, we offer a constructive development in the footsteps of Veldman and Bezem [28, 9], and Richman and Stolzenberg =-=[22]-=-. Specifically, our contributions with this paper are: • We introduce a novel mechanism for type-based termination, that of almost-full relations (Section 2), which is a weaker version of the more tra... |

5 | Higman’s lemma in type theory
- Fridlender
- 1998
(Show Context)
Citation Context ...ulation [8] but does not seem as suitable for termination purposes as the one we present in this paper. Similarly, constructive proofs of various homeomorphic embedding lemmas (such as Higman’s Lemma =-=[3, 23, 10]-=-) have appeared in the literature. Our development seems to be the first that connects constructive Ramsey theory and termination proving. Nowadays there exists a large set of recursion-encoding techn... |

4 | Size-change termination and transition invariants
- Heizmann, Jones, et al.
- 2010
(Show Context)
Citation Context ...nator [7]. Size-change termination [15, 12, 24] is another very successful methodology for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory =-=[11]-=-. Furthermore, research on online termination testing [16] and supercompilation [25] has for a while been using termination testing criteria for function reductions and inlining based on well-quasiord... |

3 |
Call-by-value termination in the untyped lambda-calculus
- Jones, Bohr
(Show Context)
Citation Context ...ion invariants [20] method has been an extremely successful approach for automatic proofs of program termination, leading to industrial-strength tools, such as Terminator [7]. Size-change termination =-=[15, 12, 24]-=- is another very successful methodology for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory [11]. Furthermore, research on online terminati... |

3 | An inductive version of Nash-Williams’ minimal-badsequence argument for Higman’s Lemma
- Seisenberger
- 2002
(Show Context)
Citation Context ...es is based on homeomorphic embeddings [18, 14]. There have been attempts to port some of these theorems for WQOs in a constructive setting (e.g. homeomorphic embeddings for lists on finite alphabets =-=[3, 23]-=-) so we believe this is a quite plausible direction for future work. 5. Size-change termination and AF induction We have examined combinators on AF relations, and simple examples such as lexicographic... |

2 |
The optimal fixed point combinator
- Charguéraud
- 2010
(Show Context)
Citation Context ... benign functional extensionality). It builds under Coq 8.3pl2. The new induction principles proposed in this paper are notnecessarily more expressive or easier to use than other (particularly recent =-=[6, 13, 27]-=-) related work – this is a topic that deserves further investigation, engineering, and potentially automation support. On the other hand, the induction principles that we propose here are quite amenab... |

2 | Termination of Isabelle functions via termination of rewriting
- Krauss, Sternagel, et al.
- 2011
(Show Context)
Citation Context ... benign functional extensionality). It builds under Coq 8.3pl2. The new induction principles proposed in this paper are notnecessarily more expressive or easier to use than other (particularly recent =-=[6, 13, 27]-=-) related work – this is a topic that deserves further investigation, engineering, and potentially automation support. On the other hand, the induction principles that we propose here are quite amenab... |

1 |
A direct proof of Ramsey’s Theorem. Unpublished note, available from http://www.chalmers.se/ ∼ coquand/ intuitionism.html
- Coquand
- 2010
(Show Context)
Citation Context ...duction principles. Inevitably, we have to present some Ramsey-like arguments: Though similar proofs are typically classical, we offer a constructive development in the footsteps of Veldman and Bezem =-=[28, 9]-=-, and Richman and Stolzenberg [22]. Specifically, our contributions with this paper are: • We introduce a novel mechanism for type-based termination, that of almost-full relations (Section 2), which i... |

1 |
The essence of computation. chapter Homeomorphic embedding for online termination of symbolic methods
- Leuschel
- 2002
(Show Context)
Citation Context ... very successful methodology for automatic proofs of program termination. In the core of both works lies a formal argument from Ramsey theory [11]. Furthermore, research on online termination testing =-=[16]-=- and supercompilation [25] has for a while been using termination testing criteria for function reductions and inlining based on well-quasiorders, often employing Ramsey-like arguments to form more co... |