## Type inference for recursive definitions (1999)

### Cached

### Download Links

- [cs-people.bu.edu]
- [cs-people.bu.edu]
- [www.cs.bu.edu]
- [cs-people.bu.edu]
- [www.cs.bu.edu]
- [www.cs.bu.edu]
- DBLP

### Other Repositories/Bibliography

Venue: | In Proc. 14th Ann. IEEE Symp. Logic in Comput. Sci |

Citations: | 2 - 1 self |

### BibTeX

@INPROCEEDINGS{Kfoury99typeinference,

author = {Assaf J. Kfoury and Santiago M. Pericás-geertsen},

title = {Type inference for recursive definitions},

booktitle = {In Proc. 14th Ann. IEEE Symp. Logic in Comput. Sci},

year = {1999},

pages = {119--128}

}

### OpenURL

### Abstract

We consider type systems that combine universal types, recursive types, and object types. We study type inference in these systems under a rank restriction, following Leivant's notion of rank. To motivate our work, we present several examples showing how our systems can be used to type programs encountered in practice. We show that type inference in the rank-k system is decidable for k ≤ 2 and undecidable for k ≥ 3. (Similar results based on different techniques are known to hold for System F, without recursive types and object types.) Our undecidability result is obtained by a reduction from a particular adaptation (which we call “regular”) of the semi-unification problem and whose undecidability is, interestingly, obtained by methods totally different from those used in the case of standard (or finite) semiunification.

### Citations

1615 |
The Java Language Specification
- Team, Gosling, et al.
- 1996
(Show Context)
Citation Context ... possible, depending on the language and the typing rules. If it can be carried out, type inference turns untyped programs into strongly typed ones. Modern languages such as Haskell [PJHH + 93], Java =-=[GJS96]-=-, and ML [MTHM90] were all designed with strong typing in mind. Despite its many benefits, the Hindley/Milner type system has several limitations, preventing perfectly safe programs from being typed. ... |

936 | A theory of type polymorphism in progra.mming
- Milner
- 1978
(Show Context)
Citation Context ...formation from untyped or partially typed programs, plays an increasingly important role in the static analysis of computer programs. Originally devised by Hindley [Hin69] and independently by Milner =-=[Mil78]-=-, it has found its way into the design of several recent programming languages. 1 Type inference may or may not be possible, depending on the language and the typing rules. If it can be carried out, t... |

891 | A Theory of Objects
- Abadi, Cardelli
- 1996
(Show Context)
Citation Context ...of practical importance. Towards this goal, and without too much effort, our analysis can be extended to a language with objects, in the formulation proposed by Abadi and Cardelli in their #-calculus =-=[AC96]. Specific-=-ally, we also consider type inference when we combine universal types and recursive types together with object types. Our extension does not include other notions (such as "subtyping") that ... |

605 |
The Definition of Standard ML (Revised
- Milner, Tofte, et al.
- 1997
(Show Context)
Citation Context ...ding on the language and the typing rules. If it can be carried out, type inference turns untyped programs into strongly typed ones. Modern languages such as Haskell [PJHH + 93], Java [GJS96], and ML =-=[MTHM90]-=- were all designed with strong typing in mind. Despite its many benefits, the Hindley/Milner type system has several limitations, preventing perfectly safe programs from being typed. One such limitati... |

305 | Subtyping recursive types
- Amadio, Cardelli
- 1993
(Show Context)
Citation Context ...he type S(#) where S = {(t, #)}. A type # is contractive in the type variable t, written # # t, if either t is not free in # or # can be unfolded as a type having # or [ ] as its top type constructor =-=[AC93]-=-. A type environment is a finite mapping from the set of term variables Var to the set of types. Let E, E # , ... range over the set of type environments and define dom(E) = {x | ##.(x : #) # E} and r... |

147 |
Linear Unification
- Paterson, Wegman
- 1978
(Show Context)
Citation Context ...Monorec), but without polymorphic (Let), has the same complexity as type inference for the simply-typed λ-calculus, which can be made to run in linear time and is therefore very efficient in practice =-=[23, 8]-=-. Just like first-order unification, it is PTIME-complete [3]. Type inference in ML may require exponential time only in the presence of polymorphic (Let) [11, 14] and this happens only in the case of... |

142 |
The principal type-scheme of an object in combinatory logic
- Hindley
- 1969
(Show Context)
Citation Context ...s of automatically inferring type information from untyped or partially typed programs, plays an increasingly important role in the static analysis of computer programs. Originally devised by Hindley =-=[Hin69]-=- and independently by Milner [Mil78], it has found its way into the design of several recent programming languages. 1 Type inference may or may not be possible, depending on the language and the typin... |

135 | Type inference with polymorphic recursion
- Henglein
- 1993
(Show Context)
Citation Context ...with appropriate rules (Inst) and (Gen) to instantiate and generalize type schemes. The difference between (Monorec) and (Polyrec) was recognized early on [20] and examined in depth in several papers =-=[6, 12]-=-. There are recursive definitions which, after appropriate recoding, can be typed by (Monorec) together with a rule (Let) for the usual polymorphic let of ML. This is the case of many simultaneous rec... |

120 | The Glasgow Haskell compiler: A technical overview
- Jones, Hall, et al.
- 1993
(Show Context)
Citation Context ... may or may not be possible, depending on the language and the typing rules. If it can be carried out, type inference turns untyped programs into strongly typed ones. Modern languages such as Haskell =-=[24]-=-, Java [5], and ML [19] were all designed with strong typing in mind. Despite its many benefits, the Hindley/Milner type system has several limitations, preventing perfectly safe programs from being t... |

93 | What are principal typings and what are they good for
- Jim
- 1996
(Show Context)
Citation Context ... our systems: It is common to all type systems (most notably, System F) involving universal types at ranks # 1. The importance of a substitutionbased principality property in practice is discussed in =-=[Jim96]-=-. . Investigate the relationship between our systems, based on universal types and recursive types, to derive types for recursive definitions and the systems proposed by Jim, based on intersection typ... |

93 |
Polymorphic type schemes and recursive definitions
- Mycroft
- 1984
(Show Context)
Citation Context ...undecidable when (Polyrec) is added together with appropriate rules (Inst) and (Gen) to instantiate and generalize type schemes. The difference between (Monorec) and (Polyrec) was recognized early on =-=[Myc84]-=- and examined in depth in several papers [Hen93, KTU93a]. There are recursive definitions which, after appropriate recoding, can be typed by (Monorec) together with a rule (Let) for the usual polymorp... |

85 |
Polymorphic Type Inference
- Leivant
- 1983
(Show Context)
Citation Context ...s. In other words, if there exists a path from the root to a quantifier that passes to the left of k arrows then the type is at least rank-(k + 1). This notion is similar to that defined for System F =-=[Lei83]-=-. We extend it to include recursive types and object types. For every k # 0, define the hierarchy T Ob k as follows, T Ob 0 = TVar # Q # {(# # #) | #, # # T Ob 0 } # {(t.#) | # # T Ob 0 } # {[# i : # ... |

83 | Type inference for recursively constrained types and its application to OOP
- Eifrig, Smith, et al.
- 1995
(Show Context)
Citation Context ...is is not what is novel in our approach. Rather, what is new is the way constraints are collected and combined so that types can be inferred using a unification-based mechanism. Our work differs from =-=[EST95]-=- in that constraints sets are solved as early as possible and types (as opposed to constraint types) are inferred. The lack of subsumption reduces the typing power of our system but simplifies the typ... |

78 | A direct algorithm for type inference in the rank-2 fragment of the second-order λ-calculus - Kfoury, Wells - 1994 |

76 |
Basic simple type theory
- Hindley
- 1997
(Show Context)
Citation Context ...Monorec), but without polymorphic (Let), has the same complexity as type inference for the simply-typed λ-calculus, which can be made to run in linear time and is therefore very efficient in practice =-=[23, 8]-=-. Just like first-order unification, it is PTIME-complete [3]. Type inference in ML may require exponential time only in the presence of polymorphic (Let) [11, 14] and this happens only in the case of... |

75 | Recursive unsolvability of a problem of Thue - Post |

61 |
On the sequential nature of unification
- Dwork, Kanellakis, et al.
- 1984
(Show Context)
Citation Context ...e inference for the simply-typed #-calculus, which can be made to run in linear time and is therefore very efficient in practice [PW78, Hin97]. Just like first-order unification, it is PTIME-complete =-=[DKM84]-=-. Type inference in ML may require exponential time only in the presence of polymorphic (Let) [KMM91, KTU94] and this happens only in the case of programs that are arguably pathological [McA96]. Towar... |

55 |
Type reconstruction in the presence of polymorphic recursion
- Kfoury, Tiuryn, et al.
- 1993
(Show Context)
Citation Context ...with appropriate rules (Inst) and (Gen) to instantiate and generalize type schemes. The difference between (Monorec) and (Polyrec) was recognized early on [20] and examined in depth in several papers =-=[6, 12]-=-. There are recursive definitions which, after appropriate recoding, can be typed by (Monorec) together with a rule (Let) for the usual polymorphic let of ML. This is the case of many simultaneous rec... |

54 |
The undecidability of the semi-unification problem
- Kfoury, Tiuryn, et al.
- 1990
(Show Context)
Citation Context ... recursive types, for every k # 4. Interestingly, the undecidability of regular semi-unification calls for methods entirely different from those used for the undecidability of finite semi-unification =-=[KTU93b]. For the -=-result in this paper, we use a reduction from the word problem for finitely generated monoids, which we have adapted from a similar encoding of the same word problem into "feature algebras" ... |

54 | Efficient inference of object types
- Palsberg
- 1995
(Show Context)
Citation Context ...stack": stack : #t 1 .t 2 .[isempty : bool, top : t 1 , pop : t 2 , push : t 1 # t 2 ] Recursive types must be used in order to type terms like stackpush(1)push(2)top. The type inference method i=-=n [Pal95]-=- can type this example but with a less informative type, while the method in [PJ97] cannot type this example at all, because of restrictions introduced by subtyping. Examples requiring rank-2 (or high... |

52 | Objective ml: An effective object-oriented extension to ml. Theory and Practice of Object Systems - Rémy, Vouillon - 1998 |

42 | Unification and ML type reconstruction
- KANELLAKIS, MAIRSON, et al.
- 1991
(Show Context)
Citation Context ... therefore very efficient in practice [23, 8]. Just like first-order unification, it is PTIME-complete [3]. Type inference in ML may require exponential time only in the presence of polymorphic (Let) =-=[11, 14]-=- and this happens only in the case of programs that are arguably pathological [17]. Towards filling the huge gap between efficient typeinference with (Monorec) and undecidable type-inference with (Pol... |

41 |
P.Urcyczyn: An Analysis of ML-Typability
- Kfoury
- 1990
(Show Context)
Citation Context ...ng regular solutions for instances of acyclic semi-unification, for which we have an always-terminating algorithm. Many of the ideas already used to handle the finite case of acyclic semi-unification =-=[KTU94]-=- are used again in the regular case of the same problem. As a result, whether an instance of acyclic semi-unification has a regular solution (and, therefore, whether a program is typable with rank-2 r... |

35 |
On subsumption and semi-unification in feature algebras
- Dörre, Rounds
- 1989
(Show Context)
Citation Context ...r, we use a reduction from the word problem for finitely generated monoids, which we have adapted from a similar encoding of the same word problem into "feature algebras" in computational li=-=nguistics [DR92]-=-. 1.3 Future Work . Investigate the lack of a substitution-based principality property and how to deal with it in practical implementations. Our various type systems do not have a substitution-based p... |

26 | Rank 2 type systems and recursive definitions
- Jim
- 1993
(Show Context)
Citation Context ... types in order to define such typing rules, and we seek precise conditions under which type inference remains feasible or at least decidable. An earlier attempt towards the same goal was made by Jim =-=[Jim95]-=-, who also proposed typing rules that are strictly more powerful than (Monorec). Jim's approach is based on the rank-2 intersection types, with which type inference remains decidable and is DEXPTIME-c... |

19 | Type reconstruction in finite rank fragments of secondorder lambda calculus - Kfoury, Tiuryn - 1992 |

10 | Type inference with simple selftypes is np-complete
- Palsberg, Jim
- 1997
(Show Context)
Citation Context ... ] Recursive types must be used in order to type terms like stackpush(1)push(2)top. The type inference method in [Pal95] can type this example but with a less informative type, while the method in [PJ=-=97]-=- cannot type this example at all, because of restrictions introduced by subtyping. Examples requiring rank-2 (or higher) types involving object types can be constructed by passing stack (with the rank... |

9 |
The word problem for certain classes of semigroups, Algebra and Logic 5
- GUREVICH
- 1966
(Show Context)
Citation Context ...cture is a monoid instead of a semigroup. In fact, the word problem remains undecidable in this case too. Lemma 4.4 (Word problem for monoids). The word problem for monoids is undecidable. Proof. See =-=[Gur66]-=-. 4.2 Undecidability of # fix 1 The terms we use in this section are defined over the signature # = {F} # Q containing a single ternary function symbol F and a set of constants Q. We write T # for the... |

5 | Inferring recursive data types
- McAllester
- 1996
(Show Context)
Citation Context ...mplete [DKM84]. Type inference in ML may require exponential time only in the presence of polymorphic (Let) [KMM91, KTU94] and this happens only in the case of programs that are arguably pathological =-=[McA96]-=-. Towards filling the huge gap between efficient type-inference with (Monorec) and undecidable type-inference with (Polyrec), one of our research goals is to formulate typing rules strictly more power... |

5 | Type inference with rank 1 polymorphism for typedirected compilation of ML - Ohori, Yoshida - 1999 |