## Programming with inductive and co-inductive types (1992)

Citations: | 7 - 0 self |

### BibTeX

@TECHREPORT{Greiner92programmingwith,

author = {John Greiner},

title = {Programming with inductive and co-inductive types},

institution = {},

year = {1992}

}

### OpenURL

### Abstract

Abstract We look at programming with inductive and co-inductive datatypes, which are inspired theoretically by initial algebras and final co-algebras, respectively. A predicative calculus which incorporates these datatypes as primitive constructs is presented. This calculus allows reduction sequences which are significantly more efficient for two dual classes of common programs than do previous calculi using similar primitives. Several techniques for programming in this calculus are illustrated with numerous examples. A short survey of related work is also included.

### Citations

1332 | Monads for functional programming
- Wadler
- 1993
(Show Context)
Citation Context ...isomorphic to 1. Adapting examples from the isomorphic type InfStream 1 , unit j G[1]Id 1 \LambdasId Unit , = out \Gamma 1 , = G[Unit]out , = out Many more inductive type examples can be adapted from =-=[3]-=-. B Translation to F 2 Since F 2 has figured prominently in the work on (co-)inductive types, we give a translation \Deltasfrom * MM _* to F 2 . Type and term variables occurring only on the right-han... |

752 |
Structure and Interpretation of Computer Programs
- Abelson, Sussman
- 1985
(Show Context)
Citation Context ... j *x : 1 + A \Thetas(1 + A): case(x; *u : 1:inl u; *y : A \Thetas(1 + A):inr(ss 1 y)) car j \Lambda A:RfL; 1 + A \ThetasLg[1 + A]f A typical evaluation sequence of an application of car is car [Nat] =-=[1; 2]-=- \Lambdas\Gamma ! f (\Phis(R[1 + Nat]f) (inrh1; [2]i)) j f (case(inrh1; [2]i; *u : 1:inl \Lambda ; *al : A \ThetasList A :inrhss 1 al; R[1 + Nat]f (ss 2 al)i)) \Lambdas\Gamma ! f (inrh1; R[1 + Nat]f [... |

163 | A final coalgebra theorem - Aczel, Mendler - 1989 |

138 | Higher-order modules and the phase distinction
- Harper, Mitchell, et al.
- 1990
(Show Context)
Citation Context ...[zero; succ]. Its inverse, in \Gamma 1 fF g, is related to the mappings zero? and pred. Details are found in Example 11. 3 The Calculus * MM _* The calculus is based upon a restricted version of * ML =-=[11]-=-. The higher kinds of that calculus are omitted to avoid complications that arise between type constructor application and the positivity requirement of _ and * 2 . The explicit set injection is also ... |

112 |
Inductively defined types
- Coquand, Paulin-Mohring
- 1990
(Show Context)
Citation Context ...d \Theta . Instead, all types are defined with a _ or * constructor and a possibly empty list of functors corresponding to the o/ i 's in _(*X:o/ 1 + \Deltas\Deltas\Deltas+ o/ n ). Coquand and Paulin =-=[5]-=-, and Pfenning and Paulin-Mohring [25] are similar in that they also do not assume any base types or the constructors + and \Theta . However, they do not work in a category theoretic framework and the... |

98 | Inductive types and type constraints in the second-order lambda-calculus - Mendler - 1991 |

69 | A categorical programming language
- Hagino
- 1987
(Show Context)
Citation Context ...for practical programming. This is the motivation for our extensive look at examples within the calculus. These (co-)inductive type constructors are inspired by initial algebras and final co-algebras =-=[8, 9, 19]-=- of category theory. Some examples of this paper use simple commuting diagrams to help explain the definition of some functions in the calculus. A basic knowledge of category theory will be helpful, b... |

66 | Recursive definitions in type theory - Constable, Mendler - 1985 |

48 | A typed lambda calculus with categorical type constructors
- Hagino
- 1987
(Show Context)
Citation Context ...for practical programming. This is the motivation for our extensive look at examples within the calculus. These (co-)inductive type constructors are inspired by initial algebras and final co-algebras =-=[8, 9, 19]-=- of category theory. Some examples of this paper use simple commuting diagrams to help explain the definition of some functions in the calculus. A basic knowledge of category theory will be helpful, b... |

43 | Inductively Defined Types in the Calculus of Constructions
- Pfenning, Paulin-Mohring
- 1990
(Show Context)
Citation Context ...ined with a _ or * constructor and a possibly empty list of functors corresponding to the o/ i 's in _(*X:o/ 1 + \Deltas\Deltas\Deltas+ o/ n ). Coquand and Paulin [5], and Pfenning and Paulin-Mohring =-=[25]-=- are similar in that they also do not assume any base types or the constructors + and \Theta . However, they do not work in a category theoretic framework and they use inductive, but not co-inductive ... |

36 |
Contracting proofs to programs
- Leivant
- 1990
(Show Context)
Citation Context ...y theory. The definition of \Phi fug[o/ 1 ][o/ 2 ] f t is 6 This definition is adapted in conjunction with Daniel Leivant and is a correction of the analogous definitions in Hagino [8, 9] and Leivant =-=[12]-=-. 7sif u j *X:X, f t if u j *X:Y; X 6= Y , t if u j *X:1, \Lambdasif u j *X:o/ 0 1 \Thetaso/ 0 2 , h\Phi f*X:o/ 0 1 g[o/ 1 ][o/ 2 ] f (ss 1 t); \Phi f*X:o/ 0 2 g[o/ 1 ][o/ 2 ] f (ss 2 t)i if u j *X:o/... |

30 | Programming in higher-order typed lambdacalculi
- Pierce, Dietzen, et al.
- 1989
(Show Context)
Citation Context ...o Void is isomorphic to some type given in the conventional form. Observe that if X does not occur in o/, then _(*X:o/) is isomorphic to o/ . A number of the examples in this section are adapted from =-=[26]-=-. 4.1 Maps to inductive types (and constants) It is helpful to first examine the structure of inductive constants and constructors. Recall that from a categorial perspective, constants are isomorphic ... |

28 |
Programming with proofs: A second order type theory
- Parigot
- 1988
(Show Context)
Citation Context ... our inverses. Pierce, Dietzen, and Michaylov [26] present an example-based tutorial on programming in the F i hierarchy of calculi, using iterators for inductive types. Both Leivant [12] and Parigot =-=[22, 23, 24]-=- view programs with inductive data types as being derived from proofs. Leivant formalizes the extraction of programs from several families of calculi, giving numerous examples. Instead of extending a ... |

21 |
Inductively Defined Functions in Functional Programming Languagesâ€ť, LFCS
- Burstall
- 1987
(Show Context)
Citation Context ... than _(*X:o/ ) is a type and not a type scheme. He also proves that the addition of inductive types "does not result in new functions being representable, but it does allow new algorithms". Burstall =-=[4]-=- extends ML with an inductive case statement, and relates programming with inductive types to specification with abstract data types, another area which uses initial algebras and sometimes final co-al... |

19 | Program Calculation Properties of Continuous Algebras
- Fokkinga, Meijer
- 1991
(Show Context)
Citation Context ...so/ n ), which makes use of types such as Stream A inconvenient. Crole [6] gives a model for an inductive calculus. With the assumption that C is the category of CPO's, Meijer, Fokkinga, and Paterson =-=[15, 7]-=- eliminate the distinction between least and greatest fixed points. Thus, in \Gamma 1 fug = outfug. This allows additional elegant recursion schemes, but introduces non-strictness. 7 Conclusions Algeb... |

19 |
Finitely stratified polymorphism
- Leivant
- 1991
(Show Context)
Citation Context ... Example 6 to a constant-time function using recursors. A more systematic approach to defining 27sthe extensions in their target calculus could be obtained from our _ types and related terms. Leivant =-=[13]-=- looks at Church numerals in a predicative version of F 2 , describing precisely what computations can be defined on that type. When adding inductive types to this stratified calculus, he shows that t... |

19 |
On representation of data in lambda calculus
- Parigot
- 1989
(Show Context)
Citation Context ...hem from being as useful in practice as desired. The typical example is that of the predecessor function on the common Church numeral encoding in F 2 , which requires linear-time, as shown by Parigot =-=[24]-=-. Most encodings in other calculi are closely related and suffer the same problem. Our calculus allows similar encodings of data types, but the calculus offers extensions admitting definitions of cons... |

19 |
A note on categorical datatypes
- Wraith
- 1989
(Show Context)
Citation Context ...act data types, another area which uses initial algebras and sometimes final co-algebras. Hagino [10] extends ML with a "codatatype" declaration and a "merge" statement which corresponds to G. Wraith =-=[27]-=- uses a rougher equivalent system. Both notations, however, assume definitions of co-inductive types are of the form *(*X:o/ 1 \Thetas\Deltas\Deltas\Deltas\Thetaso/ n ), which makes use of types such ... |

16 |
Predicative type universes and primitive recursion
- Mendler
- 1991
(Show Context)
Citation Context ...a; li) , = f 2 ha; hl; g lii BT A : g(leaf [A] a) , = f 1 a g(makeBT [A]ht 1 ; t 2 i) , = f 2 hht 1 ; g t 1 i; ht 2 ; g t 2 ii It is well-known that induction can implement primitive recursion, e.g., =-=[20, 26]-=-. However, such simulation is, an intuitive sense, frequently too inefficient. This intuition has been formalized for (the Church numeral encoding of) natural numbers by Parigot in [24]. This section ... |

7 |
Metacircularity in the polymorphic -calculus
- Pfenning, Lee
- 1991
(Show Context)
Citation Context ...Instead of extending a calculus to improve efficiency, Parigot examines alternate encodings of Nat in F 2 (optionally extended with fix ) which allow constant-time destructors. Michaylov and Pfenning =-=[21]-=- describe a process to compile F 2 terms to F 2 extended with constants for inductive constructors and recursors. It translates, for example, the common pair-based pred function similar to Example 6 t... |

5 |
Codatatypes in ML
- Hagino
- 1989
(Show Context)
Citation Context ...h an inductive case statement, and relates programming with inductive types to specification with abstract data types, another area which uses initial algebras and sometimes final co-algebras. Hagino =-=[10]-=- extends ML with a "codatatype" declaration and a "merge" statement which corresponds to G. Wraith [27] uses a rougher equivalent system. Both notations, however, assume definitions of co-inductive ty... |

3 | second-order lambda calculi with recursive types - First- - 1986 |

2 |
Quotient types via coequalizers in Martin-Lof type theory
- Mendler
- 1990
(Show Context)
Citation Context ...for practical programming. This is the motivation for our extensive look at examples within the calculus. These (co-)inductive type constructors are inspired by initial algebras and final co-algebras =-=[8, 9, 19]-=- of category theory. Some examples of this paper use simple commuting diagrams to help explain the definition of some functions in the calculus. A basic knowledge of category theory will be helpful, b... |

1 |
Recursive Types via Fixpoint Objects. Unpublished manuscript
- Crole
- 1992
(Show Context)
Citation Context ...le commuting diagrams lead to methods for programming in the calculus. Assume that there exists an appropriate category C of types 1 , where arrows 1 Some features of such a category are discussed in =-=[2, 6]-=-. 1srepresent functions from one type to another and composition is function composition. We then look at F -algebras, for functors F : C ! C. An F -algebra is a pair ho/; gi consisting of an object o... |

1 |
15] Erik Meijer, Maarten Fokkinga, Ross Paterson. Functional Programming with Banana, Lenses, Envelopes and Barbed Wire
- communication
- 1991
(Show Context)
Citation Context ...Phisis well-defined. Alternatively, dropping the positivity constraint altogether introduces non-termination and requires redefinition of the evaluation of R and G, since \Phisis not always definable.=-=[14]-=- The syntax of the calculus creates one unfortunate semantic problem. It is not Church-Rosser when using the standard j rule and an inductive j-like rule corresponding to Theorem 2, Rfug[_(u)]infug t ... |

1 |
Recursive Programming With Proofs. Unpublished manuscript
- Parigot
- 1988
(Show Context)
Citation Context ... our inverses. Pierce, Dietzen, and Michaylov [26] present an example-based tutorial on programming in the F i hierarchy of calculi, using iterators for inductive types. Both Leivant [12] and Parigot =-=[22, 23, 24]-=- view programs with inductive data types as being derived from proofs. Leivant formalizes the extraction of programs from several families of calculi, giving numerous examples. Instead of extending a ... |