Safety Analysis versus Type Inference

Safety analysis is an algorithm for determining if a term in an untyped lambda calculus with constants is safe, i.e., if it does not cause an error during evaluation. This ambition is also shared by algorithms for type inference. Safety analysis and type inference are based on rather different perspectives, however. Safety analysis is global in that it can only analyze a complete program. In contrast, type inference is local in that it can analyze pieces of a program in isolation. In this paper we prove that safety analysis is sound, relative to both a strict and a lazy operational semantics. We also prove that safety analysis accepts strictly more safe lambda terms than does type inference for simple types. The latter result demonstrates that global program analyses can be more precise than local ones.

[1]  Anders Bondorf Similix 5.0 Manual , 1993 .

[2]  Satish R. Thatte,et al.  Type Inference with Partial Types , 1988, Theor. Comput. Sci..

[3]  Neil D. Jones,et al.  Flow Analysis of Lambda Expressions (Preliminary Version) , 1981, ICALP.

[4]  D. Kozen,et al.  Ecien t Inference of Partial Types , 1994 .

[5]  Anders Bondorf,et al.  Automatic Autoprojection of Higher Order Recursive Equations , 1990, Sci. Comput. Program..

[6]  Peter Sestoft,et al.  Replacing function parameters by global variables , 1989, FPCA.

[7]  Mitchell Wand,et al.  Type Inference for Partial Types is Decidable , 1992, ESOP.

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

[9]  H. Barendregt,et al.  Types in lambda calculi and programming languages (invited lecture) , 1990 .

[10]  Jens Palsberg,et al.  Object-oriented type inference , 1991, OOPSLA '91.

[11]  Paola Giannini,et al.  A Complete Type Inference Algorithm for Simple Intersection Types , 1992, CAAP.

[12]  N. Jones Flow Analysis of Lambda Expressions , 1981 .

[13]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[14]  Henk Barendregt,et al.  Types in Lambda Calculi and Programming Languages , 1990, ESOP.

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

[16]  A. E. Ayers Efficient Closure Analysis with Reachability , 1992, WSA.

[17]  Jens Palsberg,et al.  Polyvariant Analysis of the Untyped Lambda Calculus , 1992 .

[18]  Joëlle Despeyroux,et al.  Proof of Translation in Natural Semantics , 1986, LICS.

[19]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

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

[21]  Neil D. Jones,et al.  A partial evaluator for the untyped lambda-calculus , 1991, Journal of Functional Programming.

[22]  Olin Shivers,et al.  Control-flow analysis of higher-order languages of taming lambda , 1991 .

[23]  D. Kozen,et al.  Efficient Inference of Partial Types , 1992 .

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

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

[26]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.