## Beating the Productivity Checker Using Embedded Languages

### Cached

### Download Links

Citations: | 6 - 3 self |

### BibTeX

@MISC{Danielsson_beatingthe,

author = {Nils Anders Danielsson},

title = {Beating the Productivity Checker Using Embedded Languages},

year = {}

}

### OpenURL

### Abstract

Abstract. Some total languages, like Agda and Coq, allow the use of guarded corecursion to construct infinite values and proofs. Guarded corecursion is a form of recursion in which arbitrary recursive calls are allowed, as long as they are guarded by a coinductive constructor. Guardedness ensures that programs are productive, i.e. that every finite prefix of an infinite value can be computed in finite time. However, many productive programs are not guarded, and it can be nontrivial to put them in guarded form. This paper gives a method for turning a productive program into a guarded program. The method amounts to defining a problem-specific language as a data type, writing the program in the problem-specific language, and writing a guarded interpreter for this language. 1

### Citations

308 | Definitional interpreters for higher-order programming languages - Reynolds - 1972 |

183 | Towards a Practical Programming Language based on Dependent Type Theory
- Norell
- 2007
(Show Context)
Citation Context ...pes defined using mixed induction and coinduction (see Section 2), so it requires a programming language with support for such definitions. The examples in the paper have been implemented using Agda (=-=Norell 2007-=-; Agda Team 2010), a dependently typed, total1 functional programming language with good support for mixed induction and coinduction. The supporting source code is at the time of writing available to ... |

128 | Proving the correctness of reactive systems using sized types
- Hughes, Pareto, et al.
- 1996
(Show Context)
Citation Context ...ng it. Instead of working around the limitations of guarded corecursion one can include language features which make it easier to explain why programs are productive. One such feature is sized types (=-=Hughes et al. 1996-=-; Barthe et al. 2004; Abel 2009), and the λ-calculi of Buchholz (2005) provide other examples. Another approach is to use cleverer algorithms for establishing productivity. Endrullis et al. (2010, 200... |

125 |
Bisimilarity as a theory of functional programming
- Gordon
- 1995
(Show Context)
Citation Context ... potentially infinite, including streams and other (potentially) infinite data types (Coquand 1994; Giménez 1996; Turner 2004), process congruences (Milner 1990), congruences for functional programs (=-=Gordon 1999-=-), and semantics for divergence of programs (Cousot and Cousot 1992; Hughes and Moran 1995; Leroy and Grall 2009; Nakata and Uustalu 2009). When working with infinite values in a total setting it is c... |

86 | Infinite objects in type theory
- Coquand
(Show Context)
Citation Context ...1 Introduction Coinduction and corecursion are useful techniques for defining and reasoning about things which are potentially infinite, including streams and other (potentially) infinite data types (=-=Coquand 1994-=-; Giménez 1996; Turner 2004), process congruences (Milner 1990), congruences for functional programs (Gordon 1999), and semantics for divergence of programs (Cousot and Cousot 1992; Hughes and Moran 1... |

69 | A categorical programming language - Hagino - 1987 |

68 | Inductive Definition in Type Theory - Mendler - 1987 |

66 | Coinductive axiomatization of recursive type equality and subtyping - Brandt, Henglein - 1998 |

52 | Behavioural differential equations: a coinductive calculus of streams, automata, and power series. TCS - Rutten - 2003 |

45 | T.: Type-based termination of recursive definitions - Barthe, Frade, et al. - 2004 |

36 | Interactive programs in dependent type theory - Hancock, Setzer - 2000 |

35 | Coinductive Big-step Operational Semantics - Leroy, Grall |

31 | Total functional programming - Turner |

30 | General recursion via coinductive types - Capretta - 2005 |

26 |
On the productivity of recursive list definitions
- Sijtsma
- 1989
(Show Context)
Citation Context ...blemspecific language, and writing a guarded interpreter for this language. 1 Introduction When working with infinite values in a total setting it is common to require that every value is productive (=-=Sijtsma 1989-=-): even though a value is conceptually infinite, it should always be possible to compute the next unit of information in finite time. The primitive methods for defining infinite values in the proof as... |

23 | Proof methods for corecursive programs
- Gibbons, Hutton
- 2005
(Show Context)
Citation Context ...e termination checker ensures that these proofs are productive. Elements of coinductively defined relations can be constructed using corecursion. As an example, let us prove the map-iterate property (=-=Gibbons and Hutton 2005-=-): map f (iterate f x) ≈ iterate f (f x). The function iterate is defined corecursively: iterate : {A : Set} → (A → A) → A → Stream A iterate f x = x :: ♯ iterate f (f x) This function repeatedly appl... |

21 | Filters on coinductive streams, an application to Eratosthenes’ sieve
- Bertot
- 2005
(Show Context)
Citation Context ...addressed by the paper: • The paper’s focus is on establishing productivity, not on representing non-productive definitions, nor on making non-productive definitions total by restricting their types (=-=Bertot 2005-=-). • No attempt is made to automate the technique: as it stands it provides a manual, somewhat ad hoc method for getting productive definitions accepted by a system based on guarded corecursion. The r... |

18 | Exploring the regular tree types - Morris, Altenkirch, et al. - 2006 |

17 | Generalised coinduction - Bartels |

17 | Ensuring streams flow - Telford, Turner - 1997 |

16 | Representations of stream processors using nested fixed points - Hancock, Pattinson, et al. |

14 | A term calculus for (co-)recursive definitions on streamlike data structures - Buchholz - 2005 |

14 | Data-oblivious stream productivity - Endrullis, Grabmayer, et al. - 2008 |

10 | Functional pearl: Streams and unique fixed points - Hinze - 2008 |

10 | A universe of strictly positive families - Morris, Altenkirch, et al. - 2007 |

9 | A unifying approach to recursive and co-recursive definitions - Gianantonio, Miculan - 2003 |

9 | Making Choices Lazily
- Hughes, Moran
- 1995
(Show Context)
Citation Context ...ypes (Coquand 1994; Giménez 1996; Turner 2004), process congruences (Milner 1990), congruences for functional programs (Gordon 1999), and semantics for divergence of programs (Cousot and Cousot 1992; =-=Hughes and Moran 1995-=-; Leroy and Grall 2009; Nakata and Uustalu 2009). When working with infinite values in a total setting it is common to require productivity: even though a value is conceptually infinite, it should alw... |

9 | Total parser combinators - Danielsson - 2010 |

8 | Calcul de Constructions Infinies et son Application la Vrification des Systmes Communicants - Un - 1996 |

8 | Mixed inductive/coinductive types and strong normalization
- Abel
- 2007
(Show Context)
Citation Context ...itations of guarded corecursion one can include language features which make it easier to explain why programs are productive. One such feature is sized types (Hughes et al. 1996; Barthe et al. 2004; =-=Abel 2009-=-), and the λ-calculi of Buchholz (2005) provide other examples. Another approach is to use cleverer algorithms for establishing productivity. Endrullis et al. (2010, 2008) present algorithms which han... |

8 | Recursive function definition over coinductive types
- Matthews
- 1999
(Show Context)
Citation Context ...ods seem to be quite general, and have been implemented (in Isabelle and Coq, respectively; note that guarded corecursion is not a primitive feature of Isabelle). The implementations mentioned above (=-=Matthews 1999-=-; Di Gianantonio and Miculan 2003; Niqui 2009, 2010) provide you with unique solutions to equations, whereas when using the method described in this paper you need to prove correctness and uniqueness ... |

7 | Linear-time breadth-first tree algorithms: An exercise in the arithmetic of folds and zips - Jones, Gibbons - 1993 |

7 | Termination checking in the presence of nested inductive and coinductive types. Short note supporting a talk given at PAR 2010, 2010. Available from http://www.cse.chalmers.se/~nad/publications
- Altenkirch, Danielsson
(Show Context)
Citation Context ... of a stream processor: 3 The prefix operator ♯ is the most tightly binding operator in this paper; ordinary function application binds tighter, though. 4 Currently this is not quite correct in Agda (=-=Altenkirch and Danielsson 2010-=-), but for the purposes of this paper the differences are irrelevant.32 Beating the Productivity Checker Using Embedded Languages � � : {A B : Set} → SP A B → Stream A → Stream B � put b sp � as = b ... |

6 | A coinductive monad for prop-bounded recursion - Megacz - 2007 |

6 | Trace-based coinductive operational semantics for while
- Nakata, Uustalu
- 2009
(Show Context)
Citation Context ...), process congruences (Milner 1990), congruences for functional programs (Gordon 1999), and semantics for divergence of programs (Cousot and Cousot 1992; Hughes and Moran 1995; Leroy and Grall 2009; =-=Nakata and Uustalu 2009-=-). When working with infinite values in a total setting it is common to require productivity: even though a value is conceptually infinite, it should always be possible to compute the next unit of inf... |

5 | Danielsson, Thorsten Altenkirch, Mixing induction and coinduction - Anders - 2009 |

4 | Danielsson and Thorsten Altenkirch. Subtyping, declaratively; an exercise in mixed induction and coinduction - Anders - 2010 |

4 | Using structural recursion for corecursion - Bertot, Komendantskaya - 2008 |

3 | declaratively: An exercise in mixed induction and coinduction - Subtyping - 2010 |

3 | Ariya Isihara, and Jan Willem Klop. Productivity of stream definitions - Endrullis, Grabmayer, et al. |

2 |
Code accompanying the paper. Currently available from http://www.cs.nott.ac.uk/~nad
- Danielsson
(Show Context)
Citation Context ... 2010), a dependently typed, total 1 functional programming language with good support for mixed induction and coinduction. The supporting source code is at the time of writing available to download (=-=Danielsson 2010-=-). The rest of the paper is structured as follows: Section 2 discusses induction and coinduction in the context of Agda, Sects. 3–7 introduce the language-based approach to productivity through a numb... |

2 |
Hamming’s exercise in SASL. EWD792 (privately circulated note
- Dijkstra
- 1981
(Show Context)
Citation Context ...is type can be defined recursively. The authors state that the method is still very limited and that, as presented, it cannot handle van de Snepscheut’s corecursive definition of the Hamming numbers (=-=Dijkstra 1981-=-), which can easily be handled using the method described in this paper. Niqui (2009) implements a corecursion scheme called λ-coiteration (Bartels 2003) in Coq. He states that this scheme cannot hand... |

2 | Coiterative morphisms: Interactive equational reasoning for bisimulation, using coalgebras - Niqui - 2010 |

1 | Time flies like an applicative functor. Available at http://www.e-pig.org/ epilogue/?p=186 - McBride - 2009 |

1 | Code accompanying the paper. Available from the paper’s official download - Danielsson |

1 |
Coalgebraic reasoning in Coq: Bisimulation and the λ-coiteration scheme
- Niqui
- 2009
(Show Context)
Citation Context ...emented (in Isabelle and Coq, respectively; note that guarded corecursion is not a primitive feature of Isabelle). The implementations mentioned above (Matthews 1999; Di Gianantonio and Miculan 2003; =-=Niqui 2009-=-, 2010) provide you with unique solutions to equations, whereas when using the method described in this paper you need to prove correctness and uniqueness manually if you are interested in these prope... |

1 | Code accompanying the paper. Available from http://www.cs.nott. ac.uk/~nad - Danielsson |