## Numbering matters: First-order canonical forms for second-order recursive types (2004)

### Cached

### Download Links

- [cristal.inria.fr]
- [pauillac.inria.fr]
- [cristal.inria.fr]
- [gallium.inria.fr]
- [cristal.inria.fr]
- DBLP

### Other Repositories/Bibliography

Venue: | In Proceedings of the 2004 ACM SIGPLAN International Conference on Functional Programming (ICFP’04 |

Citations: | 12 - 1 self |

### BibTeX

@INPROCEEDINGS{Gauthier04numberingmatters:,

author = {Nadji Gauthier},

title = {Numbering matters: First-order canonical forms for second-order recursive types},

booktitle = {In Proceedings of the 2004 ACM SIGPLAN International Conference on Functional Programming (ICFP’04},

year = {2004},

pages = {150--161}

}

### OpenURL

### Abstract

We study a type system equipped with universal types and equirecursive types, which we refer to as Fµ. We show that type equality may be decided in time O(n log n), an improvement over the previous known bound of O(n 2). In fact, we show that two more general problems, namely entailment of type equations and type unification, may be decided in time O(n log n), a new result. To achieve this bound, we associate, with every Fµ type, a first-order canonical form, which may be computed in time O(n log n). By exploiting this notion, we reduce all three problems to equality and unification of first-order recursive terms, for which efficient algorithms are known. 1

### Citations

707 | Types and Programming Languages - Pierce - 2002 |

303 | N.: Lambda Calculus Notation with Nameless Dummies, a Tool for Automatic Formula Manipulation.; Indag
- Bruijn
- 1972
(Show Context)
Citation Context ... complexity O(n 2 ). It is worth recalling that, in system F (that is, in the absence of recursive types), types can be compared in time O(n), provided they are represented using a De Bruijn encoding =-=[6]-=-. The cost of converting a nameful representation into a De Bruijn encoding is O(n log n), assuming some flavor of balanced trees is used to map atoms to integer indices. (The expected cost can be bro... |

208 | A new approach to abstract syntax with variable binding - Gabbay, Pitts - 2002 |

130 | Guarded recursive datatype constructors
- Xi, Chen, et al.
- 2003
(Show Context)
Citation Context ...ion algorithm whose complexity is O(n log n). We are in fact able to settle a more general question: does an extension of equirecursive Fµ with guarded algebraic data types, in the style of Xi et al. =-=[19]-=-, have decidable typechecking? Such a type system is not of purely theoretical interest: for instance, it could be a component of a type-preserving compiler whose front-end implements a typical object... |

119 | Comparing Object Encodings
- Bruce, Cardelli, et al.
- 1999
(Show Context)
Citation Context ...gorithms are known. 1 Introduction During the last decade, the programming language community spent a great deal of effort studying object-oriented programming languages and devising object encodings =-=[2, 5, 12]-=-. A typical object encoding is a type-preserving translation of a surface object-oriented language into a typed λ-calculus. Such an encoding may serve two purposes. First, it explains object-oriented ... |

75 | Type inference for records in a natural extension of ML
- Rémy
- 1993
(Show Context)
Citation Context ... that equirecursive types are more powerful and more elegant, and should be preferred, provided appropriate decision algorithms are available. It is worth noting that our results still hold when rows =-=[15, 16]-=- are added to the syntax of types. The definition of the encoding N requires no change. The key point is that the equational theory of rows is compatible with the notion of free atoms, on which the en... |

65 | Coinductive axiomatization of recursive type equality and subtyping
- Brandt, Henglein
- 1997
(Show Context)
Citation Context ..., which we write =µa, is coinductively defined by the rules in Figure 2. The definition of =µa is entirely standard. (For background reading on recursive types and coinduction, we refer the reader to =-=[1, 9]-=-.) Relations are extended to vectors in a pointwise manner, so that �τ =µa �τ ′ means that, for every index i, the i-th components of the vectors �τ and �τ ′ are in the relation =µa. The effect of the... |

53 | Nominal unification
- Urban, Pitts, et al.
- 2004
(Show Context)
Citation Context ...es an algorithm whose time complexity is quadratic. The problem of determining whether two Fµ types are unifiable may be turned, in a rather straightforward manner, into a nominal unification problem =-=[18]-=-, provided nominal unification is extended with support for recursive terms, which appears straightforward. However, neither we nor Urban [17] are currently able to formulate a nominal unification alg... |

37 | Recursive subtyping revealed
- Gapeyev, Levin, et al.
(Show Context)
Citation Context ...t state it more precisely, because Fµ comes in two flavors, whose typechecking problems are quite different: one extends F with isorecursive types, while the other extends it with equirecursive types =-=[9]-=-. In an extension of F with isorecursive types, two new typing rules are added to the type system, which direct the typechecker to fold or unfold a recursive type. The definition François Pottier INRI... |

34 | Type-preserving compilation of Featherweight Java
- League, Shao, et al.
- 2002
(Show Context)
Citation Context ...gorithms are known. 1 Introduction During the last decade, the programming language community spent a great deal of effort studying object-oriented programming languages and devising object encodings =-=[3, 7, 15, 12, 16]-=-. A typical object encoding is a type-preserving translation of a surface object-oriented language into a typed λcalculus. Such an encoding may serve two purposes. First, it explains object-oriented p... |

33 |
Higher-order Unification and Matching
- Dowek
(Show Context)
Citation Context ...fication problem for Fµ types, which we refer to as second-order recursive types and which Glew refers to as second-order trees. Yet, the present paper has nothing to do with second-order unification =-=[7]-=-. Here, we are interested in unification modulo =µa, that is, modulo αequivalence of atoms and folding and unfolding of recursive types. Second-order (or higher-order) unification consists in unifying... |

32 | Representing java classes in a typed intermediate language
- League, Shao, et al.
- 1999
(Show Context)
Citation Context ...gorithms are known. 1 Introduction During the last decade, the programming language community spent a great deal of effort studying object-oriented programming languages and devising object encodings =-=[2, 5, 12]-=-. A typical object encoding is a type-preserving translation of a surface object-oriented language into a typed λ-calculus. Such an encoding may serve two purposes. First, it explains object-oriented ... |

32 | Syntactic considerations on recursive types
- Abadi, Fiore
- 1996
(Show Context)
Citation Context ...t state it more precisely, because Fµ comes in two flavors, whose typechecking problems are quite different: one extends F with isorecursive types, while the other extends it with equirecursive types =-=[1, 10]-=-. In an extension of F with isorecursive types, two new typing rules are added to the type system, which direct the typechecker to fold or unfold a recursive type. (These rules François Pottier INRIA ... |

20 | An efficient class and object encoding
- Glew
(Show Context)
Citation Context ...gorithms are known. 1 Introduction During the last decade, the programming language community spent a great deal of effort studying object-oriented programming languages and devising object encodings =-=[3, 7, 15, 12, 16]-=-. A typical object encoding is a type-preserving translation of a surface object-oriented language into a typed λcalculus. Such an encoding may serve two purposes. First, it explains object-oriented p... |

18 |
efficient object encoding using intersection types
- Simple
- 1998
(Show Context)
Citation Context ...gorithms are known. 1 Introduction During the last decade, the programming language community spent a great deal of effort studying object-oriented programming languages and devising object encodings =-=[2, 5, 12]-=-. A typical object encoding is a type-preserving translation of a surface object-oriented language into a typed λ-calculus. Such an encoding may serve two purposes. First, it explains object-oriented ... |

17 | Polymorphic typed defunctionalization
- Pottier, Gauthier
- 2004
(Show Context)
Citation Context ...nent of a type-preserving compiler whose front-end implements a typical object encoding, requiring universal types and recursive types, and whose back-end performs defunctionalization in the style of =-=[14]-=-, requiring guarded algebraic data types. The key issue is then to decide whether two Fµ types are equal under a number of equality hypotheses, that is, to decide whether a conjunction of type equatio... |

16 | Projective ML
- R'emy
- 1992
(Show Context)
Citation Context ... that equirecursive types are more powerful and more elegant, and should be preferred, provided appropriate decision algorithms are available. It is worth noting that our results still hold when rows =-=[15, 16]-=- are added to the syntax of types. The definition of the encoding N requires no change. The key point is that the equational theory of rows is compatible with the notion of free atoms, on which the en... |

15 |
Résolution d’équations dans des langages d’ordre
- Huet
- 1976
(Show Context)
Citation Context ...scheme. We prove that, by using appropriate data structures, the time complexity of computing a type’s encoding is O(n log n). Furthermore, a standard first-order unification algorithm such as Huet’s =-=[11]-=- allows testing two recursive first-order terms for equality in time O(nα(n)). There follows that type equality in Fµ has time complexity O(n log n). The problem of determining whether two Fµ types ar... |

6 | Subtyping recursive types in kernel Fun
- Colazzo, Ghelli
- 1999
(Show Context)
Citation Context ...(a) T �σ =µ µα ′ .(a) T �σ ′ {α ↦→ µα.(a)��� σ}σ =µ {α ′ ↦→ µα ′ .(a)��� σ ′ }σ ′ µα.(a)��� σ =µ µα ′ .(a)��� σ ′ Figure 5: Equality of first-order recursive terms 2.5 Related work Colazzo and Ghelli =-=[3]-=- study the decision problem for the subtyping relationship in an extension of Kernel Fun with equirecursive types, and find it to be decidable. This implies that type equality in Fµ is decidable as we... |

5 | Intensional analysis of higher-kinded recursive types
- Collins, Shao
- 2002
(Show Context)
Citation Context ...enerate no code—to the programming language, as proposed by Abadi and Fiore [1], or defining more complex typing rules for folding and unfolding, perhaps along the lines suggested by Collins and Shao =-=[5]-=-.) The definition of type equality is the same as in F : that is, no new axioms are added to deal with recursive types. Thus, typechecking isorecursive Fµ is no more difficult than typechecking F . In... |

4 | A theory of second-order trees
- Glew
- 2002
(Show Context)
Citation Context ... received little attention in the literature. As suggested above, the key issue is to decide whether two types are equal. It appears to have been only recently studied by Glew, who found it decidable =-=[10]-=-. Glew’s algorithm has time complexity O(n 2 ), where n is the size of the types at hand. In the present paper, we improve upon Glew’s result by giving a decision algorithm whose complexity is O(n log... |

3 | Efficient hash-consing of recursive types
- Considine
- 2000
(Show Context)
Citation Context ...he area of (partial) type inference for Fµ. It may also be used to implement hashconsing of second-order recursive types, a technique that so far has been studied for first-order recursive types only =-=[4]-=-. 2 Types and type equality in Fµ In this section, we define the problem and highlight some of its subtleties. We explain how the decision problems for typesτ := α (variable) | a (atom) | µα.T �τ (typ... |

1 |
Implementation of N . http://caml. inria.fr/~gauthier/naming.tar.gz
- Gauthier
- 2004
(Show Context)
Citation Context ...ulting trie, again in time O(log n). Thus, we have proved: Theorem 7.2 If # has size n, then N alg (#) may be computed in space O(n) and time O(n log n). # An OCaml implementation is available online =-=[10]-=-. 8 Conclusion Our results are intended as a first step towards promoting the use of equirecursive types in type-preserving compilers. So far, most type-preserving compilers for object-oriented langua... |