Finiteness and rational sequences, constructively

Rational sequences are possibly infinite sequences with a finite number of distinct suffixes. In this paper, we present different implementations of rational sequences in Martin–Löf type theory. First, we literally translate the above definition of rational sequence into the language of type theory, i.e., we construct predicates on possibly infinite sequences expressing the finiteness of the set of suffixes. In type theory, there exist several inequivalent notions of finiteness. We consider two of them, listability and Noetherianness, and show that in the implementation of rational sequences the two notions are interchangeable. Then we introduce the type of lists with backpointers, which is an inductive implementation of rational sequences. Lists with backpointers can be unwound into rational sequences, and rational sequences can be truncated into lists with backpointers. As an example, we see how to convert the fractional representation of a rational number into its decimal representation and vice versa.

[1]  Régis Spadotti,et al.  A Mechanized Theory of Regular Trees in Dependent Type Theory , 2015, ITP.

[2]  Tarmo Uustalu,et al.  Variations on Noetherianness , 2016, MSFP.

[3]  Neil Ghani,et al.  Representing Cyclic Structures as Nested Datatypes , 2006 .

[4]  Alexandra Silva,et al.  Language Constructs for Non-Well-Founded Computation , 2013, ESOP.

[5]  Stephen L. Bloom,et al.  The Existence and Construction of Free Iterative Theories , 1976, J. Comput. Syst. Sci..

[6]  Bruno Courcelle,et al.  Fundamental Properties of Infinite Trees , 1983, Theor. Comput. Sci..

[7]  C. C. Elgot Monadic Computation And Iterative Algebraic Theories , 1982 .

[8]  Tarmo Uustalu,et al.  On streams that are finitely red , 2012, Log. Methods Comput. Sci..

[9]  Ulf Norell,et al.  Dependently typed programming in Agda , 2009, TLDI '09.

[10]  Davide Ancona,et al.  Regular corecursion in Prolog , 2012, SAC '12.

[11]  C. C. Elgot,et al.  On the algebraic structure of rooted trees , 1978 .

[12]  Joe B. Wells,et al.  Cycle therapy: a prescription for fold and unfold on regular trees , 2001, PPDP '01.

[13]  Erik Parmann Investigating Streamless Sets , 2014, TYPES.

[14]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

[15]  Tarmo Uustalu,et al.  Dependently typed programming with finite sets , 2015, WGP@ICFP.

[16]  Jirí Adámek,et al.  Free iterative theories: a coalgebraic view , 2003, Mathematical Structures in Computer Science.

[17]  Susanna Ginali,et al.  Regular Trees and the Free Iterative Theory , 1979, J. Comput. Syst. Sci..