Abstract
We develop the first theory of control-flow graphs from first principles, and use it to create an algorithm for automatically synthesizing many variants of control-flow graph generators from a language’s operational semantics. Our approach first introduces a new algorithm for converting a large class of small-step operational semantics to an abstract machine. It next uses a technique called ”abstract rewriting” to automatically abstract the semantics of a language, which is used both to directly generate a CFG from a program (”interpreted mode”) and to generate standalone code, similar to a human-written CFG generator, for any program in a language. We show how the choice of two abstraction and projection parameters allow our approach to synthesize several families of CFG-generators useful for different kinds of tools. We prove the correspondence between the generated graphs and the original semantics. We provide and prove an algorithm for automatically proving the termination of interpreted-mode generators. In addition to our theoretical results, we have implemented this algorithm in a tool called Mandate, and show that it produces human-readable code on two medium-size languages with 60−80 rules, featuring nearly all intraprocedural control constructs common in modern languages. We then show these CFG-generators were sufficient to build two static analyses atop them. Our work is a promising step towards the grand vision of being able to synthesize all desired tools from the semantics of a programming language.
- Mads Sig Ager. 2004. From Natural Semantics to Abstract Machines. In International Symposium on Logic-Based Program Synthesis and Transformation. 245–261.
Google Scholar
Cross Ref
- Mads Sig Ager, Dariusz Biernacki, Olivier Danvy, and Jan Midtgaard. 2003. A Functional Correspondence between Evaluators and Abstract Machines. In Proceedings of the 5th ACM SIGPLAN international conference on Principles and Practice of Declarative Programming. 8–19.
Google Scholar
Digital Library
- Andrew W. Appel. 1998. Modern Compiler Implementation in ML. Cambridge University Press. isbn:0-521-58274-1
Google Scholar
- Franz Baader and Tobias Nipkow. 1999. Term Rewriting and All That. Cambridge University Press.
Google Scholar
Digital Library
- Didier Bert and Rachid Echahed. 1995. Abstraction of Conditional Term Rewriting Systems. In Logic Programming, Proceedings of the 1995 International Symposium, Portland, Oregon, USA, December 4-7, 1995. 162–176. http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6300583
Google Scholar
- Didier Bert, Rachid Echahed, and Bjarte M Ø stvold. 1993. Abstract Rewriting. In International Workshop on Static Analysis. 178–192.
Google Scholar
- Małgorzata Biernacka. 2006. A Derivational Approach to the Operational Semantics of Functional Languages. Ph.D. Dissertation. PhD thesis, BRICS PhD School, Department of Computer Science, Aarhus University, Aarhus, Denmark.
Google Scholar
- Martin Bodin, Philippa Gardner, Thomas Jensen, and Alan Schmitt. 2019. Skeletal semantics and their interpretations. PACMPL, 3, POPL (2019), 44:1–44:31. https://doi.org/10.1145/3290357
Google Scholar
Digital Library
- Denis Bogdanas and Grigore Roşu. 2015. K-Java: A Complete Semantics of Java. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015. 445–456.
Google Scholar
Digital Library
- Michael Carbin and Armando Solar-Lezama. 2018. MITScript Language Specification. http://6.s081.scripts.mit.edu/sp18/handout-pdfs/specification.pdf
Google Scholar
- Matteo Cimini and Jeremy G. Siek. 2016. The Gradualizer: A Methodology and Algorithm for Generating Gradual Type Systems. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, January 20 - 22, 2016. 443–455. https://doi.org/10.1145/2837614.2837632
Google Scholar
Digital Library
- Matteo Cimini and Jeremy G. Siek. 2017. Automatically Generating the Dynamic Semantics of Gradually Typed Languages. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. 789–803. http://dl.acm.org/citation.cfm?id=3009863
Google Scholar
- Clifford Noel Click. 1995. Combining Analyses, Combining Optimizations. Ph.D. Dissertation. Rice University.
Google Scholar
- Michael Codish, Saumya K. Debray, and Roberto Giacobazzi. 1993. Compositional Analysis of Modular Logic Programs. In Conference Record of the Twentieth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Charleston, South Carolina, USA, January 1993. 451–464. https://doi.org/10.1145/158511.158703
Google Scholar
Digital Library
- Michael Codish, Moreno Falaschi, and Kim Marriott. 1991. Suspension Analysis for Concurrent Logic Programs. In Logic Programming, Proceedings of the Eigth International Conference, Paris, France, June 24-28, 1991. 331–345.
Google Scholar
- Patrick Cousot and Radhia Cousot. 1992. Abstract Interpretation and Application to Logic Programs. The Journal of Logic Programming, 13, 2-3 (1992), 103–179.
Google Scholar
Digital Library
- Olivier Danvy. 2008. Defunctionalized Interpreters for Programming Languages. In Proceeding of the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP 2008, Victoria, BC, Canada, September 20-28, 2008. 131–142. https://doi.org/10.1145/1411204.1411206
Google Scholar
Digital Library
- Olivier Danvy and Jacob Johannsen. 2010. Inter-Deriving Semantic Artifacts for Object-Oriented Programming. J. Comput. System Sci., 76, 5 (2010), 302–323.
Google Scholar
Digital Library
- Olivier Danvy, Kevin Millikin, Johan Munk, and Ian Zerny. 2012. On Inter-Deriving Small-Step and Big-Step Semantics: A Case Study for Storeless Call-by-Need Evaluation. Theoretical Computer Science, 435 (2012), 21–42.
Google Scholar
Digital Library
- Olivier Danvy and Lasse R Nielsen. 2004. Refocusing in Reduction Semantics. BRICS Report Series, 11, 26 (2004).
Google Scholar
- David Darais, Nicholas Labich, Phúc C Nguyen, and David Van Horn. 2017. Abstracting Definitional Interpreters (Functional Pearl). Proceedings of the ACM on Programming Languages, 1, ICFP (2017), 12.
Google Scholar
Digital Library
- David Darais, Matthew Might, and David Van Horn. 2015. Galois Transformers and Modular Abstract Interpreters: Reusable Metatheory for Program Analysis. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, part of SPLASH 2015, Pittsburgh, PA, USA, October 25-30, 2015. 552–571. https://doi.org/10.1145/2814270.2814308
Google Scholar
Digital Library
- Nachum Dershowitz. 1987. Termination of Rewriting. Journal of Symbolic Computation, 3, 1-2 (1987), 69–115.
Google Scholar
Digital Library
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. Mit Press.
Google Scholar
Digital Library
- Jeanne Ferrante and Joe D Warren. 1987. The Program Dependence Graph and Its Use in Optimization. ACM Transactions on Programming Languages and Systems, 9, 3 (1987), 319–349.
Google Scholar
Digital Library
- Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In Proceedings of the ACM SIGPLAN’93 Conference on Programming Language Design and Implementation (PLDI), Albuquerque, New Mexico, USA, June 23-25, 1993. 237–247. https://doi.org/10.1145/155090.155113
Google Scholar
Digital Library
- Dionna Amalie Glaze and David Van Horn. 2014. Abstracting Abstract Control. In DLS’14, Proceedings of the 10th ACM Symposium on Dynamic Languages, part of SPLASH 2014, Portland, OR, USA, October 20-24, 2014. 11–22. https://doi.org/10.1145/2661088.2661098
Google Scholar
Digital Library
- Dionna Amalie Glaze, Nicholas Labich, Matthew Might, and David Van Horn. 2013. Optimizing Abstract Abstract Machines. In ACM SIGPLAN International Conference on Functional Programming, ICFP’13, Boston, MA, USA - September 25 - 27, 2013. 443–454. https://doi.org/10.1145/2500365.2500604
Google Scholar
Digital Library
- John Hannan and Dale Miller. 1992. From Operational Semantics to Abstract Machines. Mathematical Structures in Computer Science, 2, 4 (1992), 415–459.
Google Scholar
Cross Ref
- Chris Hathhorn, Chucky Ellison, and Grigore Roşu. 2015. Defining the Undefinedness of C. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, Portland, OR, USA, June 15-17, 2015. 336–345. https://doi.org/10.1145/2737924.2737979
Google Scholar
Digital Library
- Cornelis Huizing, Ron Koymans, and Ruurd Kuiper. 2010. A Small Step for Mankind. In Concurrency, Compositionality, and Correctness. Springer, 66–73.
Google Scholar
- Jean-Marie Hullot. 1980. Canonical Forms and Unification. In International Conference on Automated Deduction. 318–334.
Google Scholar
Cross Ref
- Husain Ibraheem and David A Schmidt. 1997. Adapting Big-Step Semantics to Small-Step Style: Coinductive Interpretations and "Higher-Order" Derivations. Electronic Notes in Theoretical Computer Science, 10 (1997), 121.
Google Scholar
Digital Library
- Suresh Jagannathan and Stephen Weeks. 1995. A Unified Treatment of Flow Analysis in Higher-Order Languages. In Conference Record of POPL’95: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Francisco, California, USA, January 23-25, 1995. 393–407. https://doi.org/10.1145/199448.199536
Google Scholar
Digital Library
- Neil D Jones. 1981. Flow Analysis of Lambda Expressions. In International Colloquium on Automata, Languages, and Programming. 114–128.
Google Scholar
- Jasper FT Kamperman and Humphrey Robert Walters. 1993. ARM Abstract Rewriting Machine.
Google Scholar
- Andy King and Mark Longley. 1995. Abstract Matching Can Improve on Abstract Unification.
Google Scholar
- Casey Klein, John Clements, Christos Dimoulas, Carl Eastlund, Matthias Felleisen, Matthew Flatt, Jay A McCarthy, Jon Rafkind, Sam Tobin-Hochstadt, and Robert Bruce Findler. 2012. Run Your Research: On the Effectiveness of Lightweight Mechanization. ACM SIGPLAN Notices, 47, 1 (2012), 285–296.
Google Scholar
Digital Library
- James Koppel, Varot Premtoon, and Armando Solar-Lezama. 2018. One Tool, Many Languages: Language-Parametric Transformation with Incremental Parametric Syntax. Proceedings of the ACM on Programming Languages, 2, OOPSLA (2018), 122.
Google Scholar
Digital Library
- Matthew R Lakin and Andrew M Pitts. 2007. A Metalanguage for Structural Operational Semantics. In Symposium on Trends in Functional Programming.
Google Scholar
- Dallas S Lankford. 1975. Canonical Inference. University of Texas, Department of Mathematics and Computer Sciences.
Google Scholar
- Derrick Lin, James Koppel, Angela Chen, and Armando Solar-Lezama. 2017. QuixBugs: A Multi-Lingual Program Repair Benchmark Set Based on the Quixey Challenge. In Proceedings Companion of the 2017 ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity. 55–56.
Google Scholar
Digital Library
- Panagiotis Manolios. 2001. Mechanical Verification of Reactive Systems.
Google Scholar
- Jan Midtgaard. 2012. Control-flow Analysis of Functional Programs. ACM Comput. Surv., 44, 3 (2012), Article 10, June, 33 pages. issn:0360-0300 https://doi.org/10.1145/2187671.2187672
Google Scholar
Digital Library
- Jan Midtgaard and Thomas P. Jensen. 2008. A Calculational Approach to Control-Flow Analysis by Abstract Interpretation. In Static Analysis, 15th International Symposium, SAS 2008, Valencia, Spain, July 16-18, 2008. Proceedings. 347–362. https://doi.org/10.1007/978-3-540-69166-2_23
Google Scholar
Digital Library
- Jan Midtgaard and Thomas P. Jensen. 2009. Control-flow Analysis of Function Calls and Returns by Abstract Interpretation. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP ’09). ACM, New York, NY, USA. 287–298. isbn:978-1-60558-332-7 https://doi.org/10.1145/1596550.1596592
Google Scholar
Digital Library
- Dominic P Mulligan, Scott Owens, Kathryn E Gray, Tom Ridge, and Peter Sewell. 2014. Lem: Reusable Engineering of Real-World Semantics. ACM SIGPLAN Notices, 49, 9 (2014), 175–188.
Google Scholar
Digital Library
- Flemming Nielson, Hanne R Nielson, and Chris Hankin. 2015. Principles of Program Analysis. Springer.
Google Scholar
Digital Library
- Nathaniel Nystrom, Michael R Clarkson, and Andrew C Myers. 2003. Polyglot: An Extensible Compiler Framework for Java. In International Conference on Compiler Construction. 138–152.
Google Scholar
- Daejun Park, Andrei Stefănescu, and Grigore Roşu. 2015. KJS: A Complete Formal Semantics of JavaScript. In ACM SIGPLAN Notices. 50, 346–356.
Google Scholar
Digital Library
- Corina S Păsăreanu, Radek Pelánek, and Willem Visser. 2005. Concrete Model Checking with Abstract Matching and Refinement. In International Conference on Computer Aided Verification. 52–66.
Google Scholar
- Justin Pombrio and Shriram Krishnamurthi. 2018. Inferring Type Rules for Syntactic Sugar. In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation. 812–825.
Google Scholar
Digital Library
- Justin Pombrio, Shriram Krishnamurthi, and Mitchell Wand. 2017. Inferring Scope through Syntactic Sugar. Proceedings of the ACM on Programming Languages, 1, ICFP (2017), 44.
Google Scholar
Digital Library
- Casper Bach Poulsen and Peter D Mosses. 2014. Deriving Pretty-Big-Step Semantics from Small-Step Semantics. In European Symposium on Programming Languages and Systems. 270–289.
Google Scholar
Digital Library
- Camilo Rocha, José Meseguer, and César Muñoz. 2017. Rewriting Modulo SMT and Open System Analysis. Journal of Logical and Algebraic Methods in Programming, 86, 1 (2017), 269–297.
Google Scholar
Cross Ref
- Grigore Roşu and Traian Florin Şerbănută. 2010. An Overview of the K Semantic Framework. The Journal of Logic and Algebraic Programming, 79, 6 (2010), 397–434.
Google Scholar
Cross Ref
- David A Schmidt. 1996. Abstract Interpretation of Small-Step Semantics. In LOMAPS Workshop on Analysis and Verification of Multiple-Agent Languages. 76–99.
Google Scholar
- Ilya Sergey and Dave Clarke. 2011. From Type Checking by Recursive Descent to Type Checking with an Abstract Machine. In Proceedings of the Eleventh Workshop on Language Descriptions, Tools and Applications. 2.
Google Scholar
Digital Library
- Ilya Sergey, Dominique Devriese, Matthew Might, Jan Midtgaard, David Darais, Dave Clarke, and Frank Piessens. 2013. Monadic Abstract Interpreters. In ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’13, Seattle, WA, USA, June 16-19, 2013. 399–410. https://doi.org/10.1145/2491956.2491979
Google Scholar
Digital Library
- Olin Shivers. 1991. Control-Flow Analysis of Higher-Order Languages. Ph.D. Dissertation. PhD thesis, Carnegie Mellon University.
Google Scholar
Digital Library
- Tamás Szabó, Sebastian Erdweg, and Markus Voelter. 2016. IncA: A DSL for the Definition of Incremental Program Analyses. In Automated Software Engineering (ASE), 2016 31st IEEE/ACM International Conference on. 320–331.
Google Scholar
Digital Library
- David Van Horn and Matthew Might. 2010. Abstracting Abstract Machines. In 15th ACM SIGPLAN International Conference on Functional Programming, ICFP’10.
Google Scholar
- Ferdinand Vesely and Kathleen Fisher. 2019. One Step at a Time. In European Symposium on Programming. 205–231.
Google Scholar
Cross Ref
- Guannan Wei, James Decker, and Tiark Rompf. 2018. Refunctionalization of Abstract Abstract Machines: Bridging the Gap Between Abstract Abstract Machines and Abstract Definitional Interpreters (Functional Pearl). Proceedings of the ACM on Programming Languages, 2, ICFP (2018), 105.
Google Scholar
Digital Library
- Yong Xiao, Amr Sabry, and Zena M. Ariola. 2001. From Syntactic Theories to Interpreters: Automating the Proof of Unique Decomposition. Higher-Order and Symbolic Computation, 14, 4 (2001), 387–409. https://doi.org/10.1023/A:1014408032446
Google Scholar
Digital Library
Index Terms
Automatically deriving control-flow graph generators from operational semantics
Recommendations
Formal Semantics and Analysis of Component Connectors in Reo
We present an operational semantics for a component composition language called Reo. Reo connectors exogenously compose and coordinate the interactions among individual components that comprise a complex system, into a coherent collaboration. The formal ...
Animating the Approach of Deriving Operational Semantics from Algebraic Semantics for Web Services
HASE '11: Proceedings of the 2011 IEEE 13th International Symposium on High-Assurance Systems EngineeringWeb services have became more and more important in these years, and BPEL4WS (BPEL) is a de facto standard for the web service composition and orchestration. It contains several distinct features, including the scope-based compensation and fault ...
A Formal Operational Semantics for SOFL
APSEC '97: Proceedings of the Fourth Asia-Pacific Software Engineering and International Computer Science ConferenceSOFL (Structured-Object-Based-Formal Language) is a formal language and method for practical systems development. As a language, it integrates data flow diagrams, VDM-SL, and Petri nets to provide a graphical and textural formal notation for ...






Comments