Inferring Recursive Data Types

This paper contains ve results on the problem of inferring types. The rst is that type inference over recursive types with unions and data constructors can be done in cubic time using a ow analysis. The second is a general theorem characterizing the time complexity of bottom-up logic programs. The O(n 3) running time of the ow analysis is a corollary of this bottom-up run time theorem. The third is that for shallow case statements typability by the semantic types of Aiken, Wim-mers and Lakshman is equivalent to typability by recursive types and hence can be determined by ow analysis. The fourth is that, even for rst order programs of arity one, typability by recursive types is PSPACE hard for polymorphic programs. The nal result is that for any xed bound on order and arity Hindley-Milner typability can be determined in pseudo-linear time, i.e., O(nn(n)) where is the inverse Ackerman function. The last two results suggest that let-polymorphism over simple types is fundamentally more tractable than let-polymorphism over recursive types.

[1]  Samuel B. Williams,et al.  ASSOCIATION FOR COMPUTING MACHINERY , 2000 .

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

[3]  Gordon D. Plotkin,et al.  An ideal model for recursive polymorphic types , 1984, Inf. Control..

[4]  Prateek Mishra,et al.  Towards a Theory of Types in Prolog , 1984, SLP.

[5]  Prateek Mishra,et al.  Declaration-free type checking , 1985, POPL.

[6]  M. Gordon HOL: A Proof Generating System for Higher-Order Logic , 1988 .

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

[8]  Joxan Jaffar,et al.  A finite presentation theorem for approximating logic programs , 1989, POPL '90.

[9]  Olin Shivers,et al.  Data-flow analysis and type recovery in Scheme , 1990 .

[10]  Thom W. Frühwirth,et al.  Logic programs as types for logic programs , 1991, [1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science.

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

[12]  Jeffrey F. Naughton,et al.  Bottom-Up Evaluation of Logic Programs , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[13]  Harald Ganzinger,et al.  Set constraints are the monadic class , 1993, [1993] Proceedings Eighth Annual IEEE Symposium on Logic in Computer Science.

[14]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

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

[16]  Alexander Aiken,et al.  The Complexity of Set Constraints , 1993, CSL.

[17]  Nevin Heintze,et al.  Set-based analysis of ML programs , 1994, LFP '94.

[18]  Witold Charatonik,et al.  Negative set constraints with equality , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[19]  Alexander Aiken,et al.  Soft typing with conditional types , 1994, POPL '94.

[20]  Witold Charatonik,et al.  Set constraints with projections are in NEXPTIME , 1994, Proceedings 35th Annual Symposium on Foundations of Computer Science.

[21]  Pascal Van Hentenryck,et al.  Type analysis of Prolog using type graphs , 1994, PLDI '94.

[22]  Nevin Heintze Control-Flow Analysis and Type Systems , 1995, SAS.

[23]  Alexander Aiken,et al.  Decidability of Systems of Set Constraints with Negative Constraints , 1994, Inf. Comput..

[24]  Suresh Jagannathan,et al.  Effective Flow Analysis for Avoiding Run-Time Checks , 1995, SAS.

[25]  A type system equivalent to flow analysis , 1995, TOPL.