Type Inference for First-Class Messages with Feature Constraints

We present a constraint system OF of feature trees that is appropriate to specify and implement type inference for first-class messages. OF extends traditional systems of feature constraints by a selection constraint x[y]z “by first-class feature tree” y, in contrast to the standard selection constraint x[f]y “by fixed feature” f. We investigate the satisfiability problem of OF and show that it can be solved in polynomial time, and even in quadratic time in an important special case. We compare OF with Treinen’s constraint system EF of feature constraints with first-class features, which has an NP-complete satisfiability problem. This comparison yields that the satisfiability problem for OF with negation is NP-hard. Based on OF we give a simple account of type inference for first-class messages in the spirit of Nishimura’s recent proposal, and we show that it has polynomial time complexity: We also highlight an immediate extension that is desirable but makes type inference NP-hard.

[1]  Luca Cardelli,et al.  Subtyping recursive types , 1991, POPL '91.

[2]  Rolf Backofen A Complete Axiomatization of a Theory with Feature and Arity Constraints , 1995, J. Log. Program..

[3]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

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

[5]  Harry G. Mairson,et al.  Unification and ML-Type Reconstruction , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[6]  Didier Rémy,et al.  Objective ML: An Effective Object-Oriented Extension to ML , 1998, Theory Pract. Object Syst..

[7]  Harry G. Mairson Deciding ML typability is complete for deterministic exponential time , 1989, POPL '90.

[8]  J. Van Leeuwen,et al.  Handbook of theoretical computer science - Part A: Algorithms and complexity; Part B: Formal models and semantics , 1990 .

[9]  Joachim Niehren,et al.  Ordering Constraints over Feature Trees , 1997, Constraints.

[10]  Susumu Nishimura,et al.  Static typing for dynamic messages , 1998, POPL '98.

[11]  Jens Palsberg Efficient Inference of Object Types , 1995, Inf. Comput..

[12]  Jerzy Tiuryn,et al.  An analysis of ML typability , 1994, JACM.

[13]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[14]  Stephan Merz,et al.  Type checking higher-order polymorphic multi-methods , 1997, POPL '97.

[15]  Jan van Leeuwen,et al.  Handbook of Theoretical Computer Science, Vol. A: Algorithms and Complexity , 1994 .

[16]  Didier Rémy,et al.  Objective ML: a simple object-oriented extension of ML , 1997, POPL '97.

[17]  Martin Odersky,et al.  A second look at overloading , 1995, FPCA '95.

[18]  François Pottier,et al.  A framework for type inference with subtyping , 1998, ICFP '98.

[19]  Martin Müller,et al.  Type Inference for First-Class Messages with Feature Constraints , 2000, Int. J. Found. Comput. Sci..

[20]  Joachim Niehren,et al.  Ordering Constraints over Feature Trees Expressed in Second-Order Monadic Logic , 2000, Inf. Comput..

[21]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[22]  William C. Rounds,et al.  Feature Logics , 1997, Handbook of Logic and Language.

[23]  Rolf Backofen Expressivity and decidability of first-order languages over feature trees , 1994 .

[24]  Gert Smolka,et al.  A Feature Constraint System for Logic Programming with Entailment , 1994, Theor. Comput. Sci..

[25]  Gert Smolka The Oz Programming Model , 1996 .

[26]  David S. Johnson,et al.  Computers and Intractability: A Guide to the Theory of NP-Completeness , 1978 .

[27]  Atsushi Ohori,et al.  A polymorphic record calculus and its compilation , 1995, TOPL.

[28]  Friedhelm Meyer auf der Heide,et al.  Dynamic Perfect Hashing: Upper and Lower Bounds , 1994, SIAM J. Comput..

[29]  R. Hindley The Principal Type-Scheme of an Object in Combinatory Logic , 1969 .

[30]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[31]  Andreas Podelski,et al.  Towards a Meaning of LIFE , 1991, J. Log. Program..

[32]  Ralf Treinen Feature Constraints with First-Class Features , 1993, MFCS.

[33]  Joachim Niehren,et al.  Inclusion Constraints over Non-empty Sets of Trees , 1997, TAPSOFT.

[34]  Martin Sulzmann Proofs of Properties about HM(X) , 1998 .

[35]  Friedhelm Meyer auf der Heide,et al.  Dynamic perfect hashing: upper and lower bounds , 1988, [Proceedings 1988] 29th Annual Symposium on Foundations of Computer Science.

[36]  Gert Smolka,et al.  A Feature-Based Constraint System for Logic Programming with Entailment , 1992, FGCS.

[37]  Mitchell Wand,et al.  Complete Type Inference for Simple Objects , 1987, LICS.

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

[39]  Ivan A. Sag,et al.  Book Reviews: Head-driven Phrase Structure Grammar and German in Head-driven Phrase-structure Grammar , 1996, CL.

[40]  Gert Smolka,et al.  Records for Logic Programming , 1994, J. Log. Program..

[41]  Herbert S. Wilf,et al.  Algorithms and Complexity , 1994, Lecture Notes in Computer Science.

[42]  Gert Smolka,et al.  A Complete and Recursive Feature Theory , 1994, ACL.

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

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