Type-Based Useless-Variable Elimination

Useless-variable elimination is a transformation that eliminates variables whose values does not affect the result 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 has several attractive features. 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: for a simply-typed λ-calculus, it runs in time almost linear in the size of an input expression. 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.

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

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

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

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

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

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

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

[8]  Robin Milner,et al.  Definition of standard ML , 1990 .

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

[10]  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.

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

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

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

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

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

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

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

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

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

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

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

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

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

[24]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

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

[26]  Akinori Yonezawa,et al.  Garbage Collection via Dynamic Type Inference - A Fomal Treatment , 1998, Types in Compilation.

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