Skip to main content

A Type- and Control-Flow Analysis for System F

  • Conference paper
  • First Online:
Book cover Implementation and Application of Functional Languages (IFL 2012)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 8241))

Included in the following conference series:

Abstract

We present a monovariant flow analysis for System F (with recursion). The flow analysis yields both control-flow information, approximating the \(\lambda \)- and \(\varLambda \)-expressions that may be bound to variables, and type-flow information, approximating the type expressions that may instantiate type variables. Moreover, the two flows are mutually beneficial: the control flow determines which \(\varLambda \)-expressions may be applied to which type expressions (and, hence, which type expressions may instantiate which type variables), while the type flow filters the \(\lambda \)- and \(\varLambda \)-expressions that may be bound to variables (by rejecting expressions with static types that are incompatible with the static type of the variable under the type flow). As is typical for a monovariant control-flow analysis, control-flow information is expressed as an abstract environment mapping variables to sets of (syntactic) \(\lambda \)- and \(\varLambda \)-expressions that occur in the program under analysis. Similarly, type-flow information is expressed as an abstract environment mapping type variables to sets of (syntactic) types that occur in the program under analysis. Compatibility of static types (with free type variables) under a type flow is decided by interpreting the abstract environment as productions for a regular-tree grammar and querying if the languages generated by taking the types in question as starting terms have a non-empty intersection.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 72.00
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Although there are many type-based [27] control-flow analyses, where the analyses are expressed as a sophisticated type systems, the language under analysis is typically a simply-typed language.

  2. 2.

    These abstraction functions are “shallow” in the sense that they do not abstract and join the embedded run-time type and value environments.

  3. 3.

    Again, we draw a distinction between flow analyses expressed as sophisticated type systems and flow analyses of languages with sophisticated type systems.

References

  1. Aiken, A.: Introduction to set constraint-based program analysis. Sci. Comput. Program. 35(2–3), 79–111 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  2. Aiken, A., Murphy, B.R.: Implementing regular tree expressions. In: Conference on Functional Programming Languages and Computer Architecture (FPCA). LNCS, vol. 523, pp. 427–447, August 1991

    Google Scholar 

  3. Aiken, A., Murphy, B.R.: Static type inference in a dynamically typed language. In: Symposium on Principles of Programming Languages (POPL), pp. 279–290, January 1991

    Google Scholar 

  4. Cejtin, H., Jagannathan, S., Weeks, S.: Flow-directed closure conversion for typed languages. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 56–71. Springer, Heidelberg (2000)

    Google Scholar 

  5. Cousot, P., Cousot, R.: Compositional and inductive semantic definitions in fixpoint, equational, constraint, closure-condition, rule-based and game-theoretic form, invited paper. In: Conference on Computer Aided Verification (CAV). LNCS, vol. 939, pp. 293–308, July 1995

    Google Scholar 

  6. Cousot, P., Cousot, R.: Formal language, grammar and set-constraint-based program analysis by abstract interpretation. In: Conference on Functional Programming Languages and Computer Architecture (FPCA), pp. 170–181, June 1995

    Google Scholar 

  7. Flanagan, C., Sabry, A., Duba, B.F., Felleisen, M.: The essence of compiling with continuations. In: Conference on Programming Language Design and Implementation (PLDI), pp. 237–247, June 1993

    Google Scholar 

  8. Fluet, M.: A type- and control-flow analysis for System F. Tech. rep., Rochester Institute of Technology. https://ritdml.rit.edu/handle/1850/15920, February 2013

  9. Gecseg, F., Steinby, M.: Tree Automata. Akademiai Kiado, Budapest (1984)

    MATH  Google Scholar 

  10. Girard, J.Y.: Une extension de l’interpretation de Gödel à l’analyse, et son application à l’élimination des coupures dans l’analyse et la théorie des types. In: Scandinavian Logic Symposium. Stud. Logic Found. Math. 63, 63–92 (1971)

    Article  MathSciNet  Google Scholar 

  11. Harper, R., Morrisett, G.: Compiling polymorphism using intensional type analysis. In: Symposium on Principles of Programming Languages (POPL), pp. 130–141, Januay 1995

    Google Scholar 

  12. Heintze, N.: Set-based program analysis of ML programs. In: Conference on Lisp and Functional Programming (LFP), pp. 306–317, June 1994

    Google Scholar 

  13. Heintze, N., Jaffar, J.: A finite presentation theorem for approximating logic programs. In: Symposium on Principles of Programming Languages (POPL), pp. 197–209, January 1990

    Google Scholar 

  14. Henglein, F.: Type inference with polymorphic recursion. ACM Trans. Program. Lang. Syst. 15(2), 253–289 (1993)

    Article  Google Scholar 

  15. Jagannathan, S., Weeks, S., Wright, A.K.: Type-directed flow analysis for typed intermediate languages. In: International Symposium on Static Analysis (SAS). LNCS, vol. 1302, pp. 232–249, September 1997

    Google Scholar 

  16. Jones, N.D.: Flow analysis of lambda expressions (preliminary version). In: International Colloquium on Automata, Languages and Programming (ICALP). LNCS, vol. 115, pp. 114–128, July 1981

    Google Scholar 

  17. Jones, N.D.: Flow analysis of lazy higher-order functional programs. In: Abramsky, S., Hankin, C. (eds.) Abstract Interpretation of Declarative Languages, Chap. 4, pp. 103–122. Ellis Horwood, Chicheste (1987)

    Google Scholar 

  18. Jones, N.D., Muchnick, S.S.: Flow analysis and optimization of LISP-like structures. In: Symposium on Principles of Programming Languages (POPL), pp. 244–256, January 1979

    Google Scholar 

  19. Kfoury, A., Tiuryn, J., Urzyczyn, P.: Type reconstruction in the presence of polymorphic recursion. ACM Trans. Program. Lang. Syst. 15(2), 290–311 (1993)

    Article  Google Scholar 

  20. Launchbury, J., Peyton Jones, S.: Lazy functional state threads. In: Conference on Programming Language Design and Implementation (PLDI), pp. 24–35, June 1994

    Google Scholar 

  21. Launchbury, J., Peyton Jones, S.: State in Haskell. Lisp Symbolic Comput. 8(4), 293–341 (1995)

    Article  Google Scholar 

  22. Midtgaard, J.: Control-flow analysis of functional programs. ACM Comput. Surv. 44(3), 10:1–10:33 (2012)

    Article  Google Scholar 

  23. Midtgaard, J., Adams, M., Might, M.: A structural soundness proof for Shivers’s escape technique. In: International Symposium on Static Analysis (SAS). LNCS, vol. 7460, pp. 352–369, September 2012

    Google Scholar 

  24. Mishra, P., Reddy, U.S.: Declaration-free type checking. In: Symposium on Principles of Programming Languages (POPL), pp. 7–21. ACM, January 1985

    Google Scholar 

  25. Mycroft, A.: Polymorphic type schemes and recursive definitions. In: International Symposium on Programming. LNCS, vol. 167, pp. 217–228, April 1984

    Google Scholar 

  26. Nielson, F., Nielson, H.R., Hankin, C.: Principles of Program Analysis. Springer, Heidelberg (1999)

    Book  MATH  Google Scholar 

  27. Palsberg, J.: Type-based analysis and applications. In: Workshop on Programming Analysis for Software Tools and Engineering (PASTE), pp. 20–27 (2001)

    Google Scholar 

  28. Peyton Jones, S.: Compiling Haskell by program transformation: A report from the trenches. In: European Symposium on Programming (ESOP). LNCS, vol. 1058, pp. 18–44, April 1996

    Google Scholar 

  29. Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization and concretization. Higher-Order Symbolic Comput. 19(1), 125–162 (2006)

    Article  MATH  Google Scholar 

  30. Reppy, J.: Type-sensitive control-flow analysis. In: Workshop on ML (ML). pp. 74–83, September 2006

    Google Scholar 

  31. Reynolds, J.: Towards a theory of type structure. In: International Symposium on Programming. LNCS, vol. 19, pp. 408–425, April 1974

    Google Scholar 

  32. Rossberg, A., Russo, C., Dreyer, D.: F-ing modules. In: Workshop on Types in Language Design and Implementation (TLDI), pp. 89–102, January 2010

    Google Scholar 

  33. Serrano, M.: Control flow analysis: a functional languages compilation paradigm. In: Symposium on Applied Computing (SAC), pp. 118–122, Feburary 1995

    Google Scholar 

  34. Sestoft, P.: Replacing function parameters by global variables. In: Conference on Functional Programming Languages and Computer, Architecture (FPCA), pp. 39–53, September 1989

    Google Scholar 

  35. Shivers, O.: Control-flow analysis in Scheme. In: Conference on Programming Language Design and Implementation (PLDI), pp. 164–174, June 1988

    Google Scholar 

  36. Shivers, O.: Control-Flow Analysis of Higher-Order Languages or Taming Lambda. Ph.D. thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania, Technical Report CMU-CS-91-145, May 1991

    Google Scholar 

  37. Sulzmann, M., Chakravarty, M.M.T., Peyton Jones, S., Donnelly, K.: System F with type equality coercions. In: Workshop on Types in Language Design and Implementation (TLDI), pp. 53–66, January 2007

    Google Scholar 

  38. Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., Lee, P.: TIL: a type-directed optimizing compiler for ML. In: Conference on Programming Language Design and Implementation (PLDI), pp. 181–192, May 1996

    Google Scholar 

  39. Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Inf. Comput. 115(1), 38–94 (1994)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgments

Many thanks to Jan Midtgaard for the excellent survey “Control-flow analysis of functional programs” [22] and companion bibliography and for valuable feedback on an earlier draft. Thanks to Jurriaan Hage, Fritz Henglein, and Peter Thiemann for thoughtful conversation at IFL’12. This material is based upon work supported by the National Science Foundation under Grant No. 1065099.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Matthew Fluet .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Fluet, M. (2013). A Type- and Control-Flow Analysis for System F. In: Hinze, R. (eds) Implementation and Application of Functional Languages. IFL 2012. Lecture Notes in Computer Science(), vol 8241. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-41582-1_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-41582-1_8

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-41581-4

  • Online ISBN: 978-3-642-41582-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics