Type-based useless variable elimination

Useless variable elimination [25] is a transformation that eliminates variables whose values contribute nothing to the final outcome of a computation. We present a type-based method for useless variable elimination and prove its correctness. The algorithm is a surprisingly simple extension of the usual type reconstruction algorithm. Our method seems more attractive than other methods for useless variable elimination in several respects. First, it is simple, so that the proof of the correctness is clear and the method can be easily extended to deal with a polymorphic language. Second, it is efficient: it runs in time almost linear in the size of an input expression for a simply-typed λ-calculus, while Wand and Siveroni's 0CFA-based method may require a cubic time. Moreover, our transformation is optimal in a certain sense among those that preserve well-typedness, both for the simply-typed language and for an ML-style polymorphically-typed language. On the other hand, Wand and Siveroni's method is not optimal for the polymophically-typed language.

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

[2]  Torben Æ. Mogensen Types for 0, 1 or Many Uses , 1997, Implementation of Functional Languages.

[3]  Robert E. Tarjan,et al.  Efficiency of a Good But Not Linear Set Union Algorithm , 1972, JACM.

[4]  John C. Mitchell,et al.  Foundations for programming languages , 1996, Foundation of computing series.

[5]  Alan Robinson,et al.  Computational Logic - Essays in Honor of Alan Robinson , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[6]  Jens Palsberg Equality-based flow analysis versus recursive types , 1998, TOPL.

[7]  Naoki Kobayashi Type-based useless variable elimination , 1999 .

[8]  David A. McAllester,et al.  On the cubic bottleneck in subtyping and flow analysis , 1997, Proceedings of Twelfth Annual IEEE Symposium on Logic in Computer Science.

[9]  Mike Paterson,et al.  Linear unification , 1976, STOC '76.

[10]  S. Jones,et al.  A Transformation-Based Optimiser for Haskell , 1998, Sci. Comput. Program..

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

[12]  Greg Morrisett,et al.  Compiling with Types , 1995 .

[13]  Suresh Jagannathan,et al.  Polymorphic splitting: an effective polyvariant flow analysis , 1998, TOPL.

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

[15]  Nevin Heintze,et al.  Control-Flow Analysis and Type Systems , 1995, SAS.

[16]  Jens Palsberg,et al.  A type system equivalent to flow analysis , 1995, TOPL.

[17]  Jens Palsberg,et al.  From polyvariant flow information to intersection and union types , 1998, POPL '98.

[18]  Paliath Narendran,et al.  Semi-Unification , 1991, Theor. Comput. Sci..

[19]  David A. McAllester,et al.  Linear-time subtransitive control flow analysis , 1997, PLDI '97.

[20]  Paola Giannini,et al.  Refinement Types for Program Analysis , 1996, SAS.

[21]  Michael Leuschel,et al.  Redundant Argument Filtering of Logic Programs , 1996, LOPSTR.

[22]  Pascal Fradet,et al.  Collecting more garbage , 1994, LFP '94.

[23]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

[24]  Stefano Berardi,et al.  Pruning Simply Typed Lambda-Terms , 1996, J. Log. Comput..

[25]  Jens Palsberg,et al.  From Polyvariant flow information to intersection and union types , 2001, J. Funct. Program..

[26]  Mitchell Wand,et al.  Constraint systems for useless variable elimination , 1999, POPL '99.

[27]  Olivier Danvy,et al.  Lambda-dropping: transforming recursive equations into programs with block structure , 1997, Theor. Comput. Sci..

[28]  Thomas W. Reps,et al.  Program Specialization via Program Slicing , 1996, Dagstuhl Seminar on Partial Evaluation.

[29]  Kwangkeun Yi,et al.  Proofs about a folklore let-polymorphic type inference algorithm , 1998, TOPL.

[30]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.