skip to main content
10.1145/2491956.2491979acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Monadic abstract interpreters

Published:16 June 2013Publication History

ABSTRACT

Recent developments in the systematic construction of abstract interpreters hinted at the possibility of a broad unification of concepts in static analysis. We deliver that unification by showing context-sensitivity, polyvariance, flow-sensitivity, reachability-pruning, heap-cloning and cardinality-bounding to be independent of any particular semantics. Monads become the unifying agent between these concepts and between semantics. For instance, by plugging the same "context-insensitivity monad" into a monadically-parameterized semantics for Java or for the lambda calculus, it yields the expected context-insensitive analysis.

To achieve this unification, we develop a systematic method for transforming a concrete semantics into a monadically-parameterized abstract machine. Changing the monad changes the behavior of the machine. By changing the monad, we recover a spectrum of machines---from the original concrete semantics to a monovariant, flow- and context-insensitive static analysis with a singly-threaded heap and weak updates.

The monadic parameterization also suggests an abstraction over the ubiquitous monotone fixed-point computation found in static analysis. This abstraction makes it straightforward to instrument an analysis with high-level strategies for improving precision and performance, such as abstract garbage collection and widening.

While the paper itself runs the development for continuation-passing style, our generic implementation replays it for direct-style lambda-calculus and Featherweight Java to support generality.

References

  1. M. S. Ager, O. Danvy, and J.Midtgaard. A functional correspondence between monadic evaluators and abstract machines for languages with computational effects. Theor. Comput. Sci., 342(1):149--172, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. M. Biernacka and O. Danvy. A syntactic correspondence between context-sensitive calculi and abstract machines. Theor. Comput. Sci., 375(1--3):76--108, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. M. T. Chakravarty, G. Keller, S. L. P. Jones, and S. Marlow. Associated types with class. In POPL, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In POPL, 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. P. Cousot and R. Cousot. Systematic design of program analysis frameworks. In POPL, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. O. Danvy. A new one-pass transformation into monadic normal form. In CC, volume 2622 of LNCS, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. O. Danvy. Defunctionalized interpreters for programming languages. In ICFP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Filinski. Monads in action. In POPL, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In PLDI, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. P. Hudak and J. Young. Collecting interpretations of expressions. ACM Trans. Prog. Lang. Syst., 13(2):269--290, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. P. Jones. Type Classes with Functional Dependencies. In ESOP, volume 1782 of LNCS, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. A. Lakhotia, D. R. Boccardo, A. Singh, and A.Manacero, Jr. Contextsensitive analysis of obfuscated x86 executables. In PEPM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In POPL, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. M. Might. Environment analysis of higher-order languages. PhD thesis, Georgia Institute of Technology, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. M. Might. Abstract interpreters for free. In SAS, volume 6337 of LNCS, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Might. Shape analysis in the absence of pointers and structure. In VMCAI, volume 5944 of LNCS, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. M. Might and P. Manolios. A posteriori soundness for nondeterministic abstract interpretations. In VMCAI, volume 5944 of LNCS, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M.Might and O. Shivers. Improving flow analyses via CFA: abstract garbage collection and counting. In ICFP, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. M. Might, Y. Smaragdakis, and D. Van Horn. Resolving and exploiting the k-CFA paradox: illuminating functional vs. objectoriented program analysis. In PLDI, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. F. Nielson. Two-level semantics and abstract interpretation. Theor. Comput. Sci., 69(2):117--242, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. T. Schrijvers and B. C. Oliveira. Monads, zippers and views: virtualizing the monad stack. In ICFP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. O. G. Shivers. Control-flow analysis of higher-order languages or taming lambda. PhD thesis, Carnegie Mellon University, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Van Horn and M. Might. Abstracting abstract machines. In ICFP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. D. Van Horn and M. Might. Abstracting abstract machines: a systematic approach to higher-order program analysis. Commun. ACM, 54(9):101--109, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In POPL, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Monadic abstract interpreters

      Recommendations

      Reviews

      Jacques Carette

      Abstract interpretation is an important conceptual framework that unifies many different concepts in static analysis. However, writing a general, modular, abstract interpreter has not been as straightforward. There are two difficulties: a software engineering challenge, and an encoding issue. The software engineering challenge is to find the right abstractions that capture the kind of polymorphism inherent in abstract interpretation. The encoding issue involves finding a way to phrase the operational semantics of languages using a suitable abstract machine that lends itself well to abstract interpretation. This is exactly what the authors solve in this gem of a paper. Aimed directly at experts, the paper walks readers through the process of taking a lambda calculus and rewriting it (using continuation passing style, an explicit store, and explicit contexts) so that it is better suited for abstract interpretation. Next, using an explicit implementation in Haskell, various aspects (nondeterminism, store, time, and addresses) are systematically abstracted away from the interpreter into a monad. Then, to prove that this beautiful series of abstractions is more than mere theory, the authors show how to concretely implement a variety of analyses using this framework. While this section might seem a little ad hoc, they then show how it all fits together in an elegant conceptual framework. This paper is a real tour de force. Not only is it very well written, it presents an extremely elegant solution to an important, thorny problem. The only unfortunate aspect is that the authors chose an initial algebra encoding of their base language, rather than the much more flexible "finally tagless" encoding. Online Computing Reviews Service

      Access critical reviews of Computing literature here

      Become a reviewer for Computing Reviews.

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        PLDI '13: Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation
        June 2013
        546 pages
        ISBN:9781450320146
        DOI:10.1145/2491956
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 48, Issue 6
          PLDI '13
          June 2013
          515 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2499370
          Issue’s Table of Contents

        Copyright © 2013 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 16 June 2013

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        PLDI '13 Paper Acceptance Rate46of267submissions,17%Overall Acceptance Rate406of2,067submissions,20%

        Upcoming Conference

        PLDI '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader