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.
Keywords
- Control Flow Analysis
- Information flow Type
- Abstract Environment
- Free Type Variables
- Sophisticated Type System
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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 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.
These abstraction functions are “shallow” in the sense that they do not abstract and join the embedded run-time type and value environments.
- 3.
Again, we draw a distinction between flow analyses expressed as sophisticated type systems and flow analyses of languages with sophisticated type systems.
References
Aiken, A.: Introduction to set constraint-based program analysis. Sci. Comput. Program. 35(2–3), 79–111 (1999)
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
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
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)
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
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
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
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
Gecseg, F., Steinby, M.: Tree Automata. Akademiai Kiado, Budapest (1984)
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)
Harper, R., Morrisett, G.: Compiling polymorphism using intensional type analysis. In: Symposium on Principles of Programming Languages (POPL), pp. 130–141, Januay 1995
Heintze, N.: Set-based program analysis of ML programs. In: Conference on Lisp and Functional Programming (LFP), pp. 306–317, June 1994
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
Henglein, F.: Type inference with polymorphic recursion. ACM Trans. Program. Lang. Syst. 15(2), 253–289 (1993)
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
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
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)
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
Kfoury, A., Tiuryn, J., Urzyczyn, P.: Type reconstruction in the presence of polymorphic recursion. ACM Trans. Program. Lang. Syst. 15(2), 290–311 (1993)
Launchbury, J., Peyton Jones, S.: Lazy functional state threads. In: Conference on Programming Language Design and Implementation (PLDI), pp. 24–35, June 1994
Launchbury, J., Peyton Jones, S.: State in Haskell. Lisp Symbolic Comput. 8(4), 293–341 (1995)
Midtgaard, J.: Control-flow analysis of functional programs. ACM Comput. Surv. 44(3), 10:1–10:33 (2012)
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
Mishra, P., Reddy, U.S.: Declaration-free type checking. In: Symposium on Principles of Programming Languages (POPL), pp. 7–21. ACM, January 1985
Mycroft, A.: Polymorphic type schemes and recursive definitions. In: International Symposium on Programming. LNCS, vol. 167, pp. 217–228, April 1984
Nielson, F., Nielson, H.R., Hankin, C.: Principles of Program Analysis. Springer, Heidelberg (1999)
Palsberg, J.: Type-based analysis and applications. In: Workshop on Programming Analysis for Software Tools and Engineering (PASTE), pp. 20–27 (2001)
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
Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization and concretization. Higher-Order Symbolic Comput. 19(1), 125–162 (2006)
Reppy, J.: Type-sensitive control-flow analysis. In: Workshop on ML (ML). pp. 74–83, September 2006
Reynolds, J.: Towards a theory of type structure. In: International Symposium on Programming. LNCS, vol. 19, pp. 408–425, April 1974
Rossberg, A., Russo, C., Dreyer, D.: F-ing modules. In: Workshop on Types in Language Design and Implementation (TLDI), pp. 89–102, January 2010
Serrano, M.: Control flow analysis: a functional languages compilation paradigm. In: Symposium on Applied Computing (SAC), pp. 118–122, Feburary 1995
Sestoft, P.: Replacing function parameters by global variables. In: Conference on Functional Programming Languages and Computer, Architecture (FPCA), pp. 39–53, September 1989
Shivers, O.: Control-flow analysis in Scheme. In: Conference on Programming Language Design and Implementation (PLDI), pp. 164–174, June 1988
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
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
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
Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Inf. Comput. 115(1), 38–94 (1994)
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
Corresponding author
Editor information
Editors and Affiliations
Rights 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)