Efficient Inference of Object Types

Abadi and Cardelli have recently investigated a calculus of objects [2]. The calculus supports a key feature of object-oriented languages: an object can be emulated by another object that has more refined methods. Abadi and Cardelli presented four first-order type systems for the calculus. The simplest one is based on finite types and no subtyping, and the most powerful one has both recursive types and subtyping. Open until now is the question of type inference, and in the presence of subtyping “the absence of minimum typings poses practical problems for type inference” [2]. In this paper we give an O(n3) algorithm for each of the four type inference problems and we prove that all the problems are P-complete. We also indicate how to modify the algorithms to handle functions and records.

[1]  Prateek Mishra,et al.  Polymorphic Subtype Inference: Closing the Theory-Practice Gap , 1989, TAPSOFT, Vol.2.

[2]  Jens Palsberg,et al.  Efficient inference of partial types , 1992, Proceedings., 33rd Annual Symposium on Foundations of Computer Science.

[3]  John C. Mitchell,et al.  Lower bounds on type inference with subtypes , 1995, POPL '95.

[4]  Richard M. Karp,et al.  Parallel Algorithms for Shared-Memory Machines , 1991, Handbook of Theoretical Computer Science, Volume A: Algorithms and Complexity.

[5]  John C. Mitchell,et al.  A lambda calculus of objects and method specialization , 1993, [1993] Proceedings Eighth Annual IEEE Symposium on Logic in Computer Science.

[6]  Ravi B. Boppana,et al.  The Complexity of Finite Functions , 1991, Handbook of Theoretical Computer Science, Volume A: Algorithms and Complexity.

[7]  Martín Abadi,et al.  A Theory of Primitive Objects: Second-Order Systems , 1995, Sci. Comput. Program..

[8]  Martín Abadi,et al.  A semantics of object types , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[9]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[10]  Jerzy Tiuryn Subtype inequalities , 1992, [1992] Proceedings of the Seventh Annual IEEE Symposium on Logic in Computer Science.

[11]  Alexander Aiken,et al.  Type inclusion constraints and type inference , 1993, FPCA '93.

[12]  Marcin Benke Efficient Type Reconstruction in the Presence of Inheritance , 1993, MFCS.

[13]  Prateek Mishra,et al.  Type Inference with Subtypes , 1990, Theor. Comput. Sci..

[14]  Mitchell Wand,et al.  Type inference for record concatenation and multiple inheritance , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[15]  Giuseppe F. Italiano,et al.  Amortized Efficiency of a Path Retrieval Data Structure , 1986, Theor. Comput. Sci..

[16]  John C. Mitchell,et al.  On the Sequential Nature of Unification , 1984, J. Log. Program..

[17]  Bent Bruun Kristensen,et al.  The BETA Programming Language , 1987, Research Directions in Object-Oriented Programming.

[18]  Fritz Henglein,et al.  Fast Left-Linear Semi-Unification , 1991, ICCI.

[19]  Scott F. Smith,et al.  Type inference for recursively constrained types and its application to OOP , 1995, MFPS.

[20]  Martín Abadi,et al.  A Theory of Primitive Objects , 1996 .

[21]  John C. Mitchell,et al.  Coercion and type inference , 1984, POPL.

[22]  Fritz Henglein,et al.  Type inference and semi-unification , 1988, LISP and Functional Programming.