A tutorial on type-based termination1 2 2Gilles Barthe Benjamin Gr´egoire Colin Riba1IMDEA Software, Madrid, Spain2INRIA Sophia-Antipolis, FranceAbstract. Type-based termination is a method to enforce terminationof recursive definitions through a non-standard type system that intro-duces a notion of size for inhabitants of inductively defined types. Thepurpose of this tutorial is to provide a gentle introduction to a polymor-phically typed λ-calculus with type-based termination, and to the sizeinference algorithm which is used to guarantee automatically terminationof recursive definitions.1 IntroductionFunctional programming languages advocate the use of mathematically intuitiveconstructions to develop programs. In particular, functional programming lan-guages feature mechanisms to introduce and manipulate finite datatypes such aslists and trees, and infinite datatypes such as streams and infinite trees. Thereare two basic ingredients to manipulate elements of a datatype: case analysis,that enables to reason by analysis on the top constructor, and fixpoints, that en-able to define functions by recursion and co-recursion. Traditionally, functionalprogramming languages allow for unrestricted fixpoints, which are subsumed bythe constructionΓ,f : τ ‘ e : τΓ ‘ (letrec f = e) : ττwhose computational behavior is given by the reduction rule(letrec f = e) → e[f := (letrec f = e)]τ τUnrestricted use of fixpoints leads to typable expressions that diverge, i.e. ...
Voir