Advertisement

Dead Code Elimination through Dependent Types

  • Hongwei Xi
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1551)

Abstract

Pattern matching is an important feature in various functional programming languages such as SML, Caml, Haskell, etc. In these languages, unreachable or redundant matching clauses, which can be regarded as a special form of dead code, are a rich source for program errors. Therefore, eliminating unreachable matching clauses at compiletime can significantly enhance program error detection. Furthermore, this can also lead to significantly more efficient code at run-time.

We present a novel approach to eliminating unreachable matching clauses through the use of the dependent type system of DML, a functional programming language that enriches ML with a restricted form of dependent types. We then prove the correctness of the approach, which consists of the major technical contribution of the paper. In addition, we demonstrate the applicability of our approach to dead code elimination through some realistic examples. This constitutes a practical application of dependent types to functional programming, and in return it provides us with further support for the methodology adopted in our research on dependent types in practical programming.

Keywords

Dependent Type Functional Programming Dead Computation Type Annotation Constraint Domain 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [1]
    Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers. Addison-Wesley, Reading, Massachusetts, 1986.Google Scholar
  2. [2]
    Rowan Davies. Practical refinement-type checking. Thesis Proposal, November 1997.Google Scholar
  3. [3]
    Manuel Fähndrich and Alexander Aiken. Program analysis using mixed term and set constraints. In Proceedings of the 4th International Static Analysis Symposium, September 1997.Google Scholar
  4. [4]
    Tim Freeman and Frank Pfenning. Refinement types for ML. In ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 268–277, Toronto, Ontario, 1991.Google Scholar
  5. [5]
    F. Gecseg and M Steinb. Tree automata. Akademiai Kiado, 1991.Google Scholar
  6. [6]
    Paul Hudak, S. L. Peyton Jones, and Philip Wadler. Report on the programming language Haskell, a non-strict purely-functional programming language, Version 1.2. SIGPLAN Notices, 27(5), May 1992.Google Scholar
  7. [7]
    John Hughes. Compile-time analysis of functional programs. In D. Turner, editor, Research Topics in Functional Programming, pages 117–153. Addison-Wesley, 1990.Google Scholar
  8. [8]
    N. Jones and S. Muchnick. Flow analysis and optimization of lisp-like structures. In Conference Record of 6th ACM SIGPLAN Symposium on Principles of Programming Languages, pages 244–256, January 1979.Google Scholar
  9. [9]
    Gilles Kahn. Natural semantics. In Proceedings of the Symposium on Theoretical Aspects of Computer Science, pages 22–39. Springer-Verlag LNCS 247, 1987.Google Scholar
  10. [10]
    J. Knoop, O. Rüthing, and B. Steffen. Partial dead code elimination. In Proceedings of the ACM SIGPLAN Conference on Programming Language Implementation and Design, pages 147–158, June 1994.Google Scholar
  11. [11]
    Y. Liu and D. Stoller. Dead code elimination using program-based regular tree grammars. Available at ftp://ftp.cs.indiana.edu/pub/liu/ElimDeadRec-TR97.ps.Z.
  12. [12]
    Robin Milner, Mads Tofte, Robert W. Harper, and D. MacQueen. The Definition of Standard ML. MIT Press, Cambridge,Massachusetts, 1997.Google Scholar
  13. [13]
    Heintze Nevin. Set-based Program Analysis of ML programs. Ph. D dissertation, Carnegie Mellon University, 1992.Google Scholar
  14. [14]
    F. Tip. A survey of program slicing. Journal of Programming Languages, 3(3):121–189, 1995.Google Scholar
  15. [15]
    P. Wadler and J. Hughes. Projections for strictness analysis. In Proceedings of the 3rd International Conference on Functional Programming and Computer Architecture, volume 274 of Lecture Notes in Computer Science, pages 385–407. Springer-Verlag, 1987.Google Scholar
  16. [16]
    Pierre Weis and Xavier Leroy. Le langage Caml. InterEditions, Paris, 1993.Google Scholar
  17. [17]
    H. Xi and F. Pfenning. Eliminating array bound checking through dependent types. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 249–257, June 1998.Google Scholar
  18. [18]
    H. Xi and F. Pfenning. Dependent types in practical programming. In Proceedings of ACM SIGPLAN Symposium on Principles of Programming Languages, January 1999.Google Scholar
  19. [19]
    Hongwei Xi. Some examples of DML programming. Available at http://www.cs.cmu.edu/~hwxi/DML/examples/, November 1997.
  20. [20]
    Hongwei Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1998. pp. viii+189. Forthcoming. The current version is available as http://www.cs.cmu.edu/~hwxi/DML/thesis.ps.
  21. [21]
    K. Yi and S. Ryu. Towards a cost-effective estimation of uncaught exceptions in standard ml programs. In Proceedings of the 4th International Static Analysis Symposium, September 1997.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1998

Authors and Affiliations

  • Hongwei Xi
    • 1
  1. 1.Department of Computer Science and EngineeringOregon Graduate InstitutePortland

Personalised recommendations