skip to main content
10.1145/62678.62701acmconferencesArticle/Chapter ViewAbstractPublication PageslfpConference Proceedingsconference-collections
Article
Free access

Type inference and semi-unification

Published: 01 January 1988 Publication History

Abstract

The Milner Calculus is the typed λ-calculus underlying the type system for the programming language ML [Har86] and several other strongly typed polymorphic functional languages such as Miranda [Tur86] and SPS [Wan84]. Mycroft [Myc84] extended the problematical typing rule for recursive definitions and proved that the resulting calculus, termed Milner-Mycroft Calculus here, is sound with respect to Milner's [Mil78] semantics and that it preserves the principal typing property [DM82] of the Milner Calculus. The extension is of practical significance in typed logic programming languages [MO84] and, more generally, in any language with (mutually) recursive definitions.
Mycroft didn't solve the decidability problem for typings in this calculus, though. This was an open problem independently raised also by Meertens [Mee83]. The decidability question was answered in the affirmative just recently by Kfoury et al. in [KTU88]. We show that the type inference problems in the Milner and the Milner-Mycroft Calculi can be reduced to solving equations and inequations between first-order terms, a problem we have termed semi-unification. We show that semi-unification problems have most general solutions in analogy to unification problems — which translates into principal typing properties for the underlying calculi. In contrast to the (essentially) nonconstructive methods of [KTU88] we present functional specifications, which we prove partially correct, for computing the most general solution of semi-unification problems, and we devise a concrete nondeterministic algorithm on a graph-theoretic representation for computing these most general solutions. Finally, we point out some erroneous statements about the efficiency of polymorphic type checking that have persisted throughout the literature including an incorrect claim, submitted by ourselves, of polynomial time type checking in the Milner-Mycroft Calculus.

References

[1]
L. Cardelli. A semantics of multiple inheritance. In Int.,_qymp. on Semantics of Data Types, pages 51-68, Springer-Verlag, 1984.
[2]
L. Cardelli. Basic Polymorphic Typechecking. Polymorphism, 2(1), Jan. 1985.
[3]
D. Clement, J. Despeyroux, T. Despeyroux, and G. Kahn. A simple applicative language: mini-ml. INRIA Centre Sophia Antipolis, RR No. 529, May 1986.
[4]
H. Curry and R. Feys. Combinatory Logic. Volume I of Studies in Logic and the Foundations of Mathematics, North- Holland, 1958.
[5]
L. Cardelli and P. Wegner. On Understanding Types, Data Abstraction, and Polymorphism. Technical Report CS-85- 14, Dept. of Computer Science, Brown University, August 1985.
[6]
L. Damas and R. Milner. Principal Type Schemes for Functional Programs. In Proc. 9th Annual ACM $ymp. on Principles of Programming Languages, pages 207-212, Jan. 1982.
[7]
E. Eder. Properties of substitutions and unifications. J. Symbolic Computation, 1:31-46, 1985.
[8]
R. Harper. Introduction to Standard ML (Preliminary Draft). Technical Report, University of Edinburgh, February 1986.
[9]
F. Henglein. A Polymorphic Type Model for SETL. Technical Report (SETL Newsletter) 221, New York University, July 1987.
[10]
F. Henglein. Semi-Unification. Technical Report (SETL Newsletter) 223, New York University, April 1988.
[11]
F. Henglein. The Milner-Mycroft Calculus is Tractable. In Proc. A CM Conf on LISP and Functional Programming, ACM, ACM Press, June 1988.
[12]
R. Hindley. The Principal Type-Scheme of an Object in Combinatory Logic. Tra'ns. Amer. Math. Soc., 146:29-60, Dec. 1969.
[13]
J. Hopcroft and R. Karp. An algorithm for testing the equivalence of finite automata. Technical Report TR-71-114, Dept. of Computer Science, Corne}l U., 1971.
[14]
A. Kfoury. Personal communication. April 1988.
[15]
A. Kfoury, J. Tiuryn, and P. Urzyczyn. A Proper Extension of ML with an Effective Type-Assignment. In Proc. 15ih Annual ACM Syrup. on Principles of Programming Languages, pages 58--69, ACM, ACM Press, Jan. 1988.
[16]
D. Leivant. Polymorphic type inference. In Proc. l Oth A CM Syrup. on Principles of Programming Languages, pages 88-98, ACM, Jan. 1983.
[17]
J. Lassez, M. Maher, and K. Marriott. Unification Revisited. Technical Report, IBM Yorktown Heights, 1986.
[18]
Z. Manna. Mathematical Theory of Comutation. McGraw-Hill, 1974.
[19]
L. Meertens. Incremental Polymorphic Type Checking in B. In Proc. l Oth AUM POPL, pages 265-275, 1983.
[20]
J. Mitchell and R. Harper. The essence of ml. In Proc. Syrup. on Principles of Programming Languages, ACM, Jan. 1988.
[21]
R. Milner. A Theory of Type Polymorphism in Programming. J. Computer and System Sciences, 17:348-375, 1978.
[22]
j. Mitchell. Type inference and type containment. In Proc. Int'l Syrup. on Semantics of Data Types, LNU$173, pages 257- 277, June 1984.
[23]
A. Martelli and U. Montanari. An Efficient Unification Algorithm. ACM TOPLAS, 4(2):258-282, Apr. 1982.
[24]
A. Mycroft and R. O'Keefe. A polymorphic type system for prolog. Artificial Intelligence, 23:295-307, 1984.
[25]
L. Meertens and S. Pemberton. Description of B. SIGPLAN Notices, 20(2):58- 76, Feb. 1985.
[26]
D. MacQueen, G. Plotkin, and R. Sethi. An Ideal Model for Recursive Polymorphic Types. Informalion and Control, 71, 1986.
[27]
P. Mishra and U. Reddy. Declaration- Free Type Checking. In Proc. 12th A UM Symp. on Principles o f ProgrammiT~g Languages, pages 7-21, ACM, Jan. 1985.
[28]
A. Mycroft. Polymorphic Type Schemes and Recursive Definitions. In Proc. 6th Int. Conf. on Programming, LNCS 167, 1984.
[29]
M. Paterson and M. Wegman. Linear Unification. J. of Computer and System Sciences, 16:158-167, 1978.
[30]
J. Schwartz, R. Dewar, E. Dubinsky, and E. Schonberg. Programming with Sets: An Introduction to SETL. Springer- Verlag, 1986.
[31]
D. Turner. An Overview of Miranda. SIGPLAN Notices, 21(12):158-166, Dec. 1986.
[32]
M. ~Vand. A Semantic Prototyping System. Proc. ACM SIGPLAN 'Sd Syrup. on Compiler Consiruclion, SIGPLAN ! Notices, 19(6):213-221, June 1984.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
LFP '88: Proceedings of the 1988 ACM conference on LISP and functional programming
January 1988
351 pages
ISBN:089791273X
DOI:10.1145/62678
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 January 1988

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Article

Conference

LISP88
LISP88: Lisp & Functional Programming 88
July 25 - 27, 1988
Utah, Snowbird, USA

Acceptance Rates

Overall Acceptance Rate 30 of 109 submissions, 28%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)49
  • Downloads (Last 6 weeks)11
Reflects downloads up to 29 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media