skip to main content
article

A trustworthy mechanized formalization of R

Published:06 April 2020Publication History
Skip Abstract Section

Abstract

The R programming language is very popular for developing statistical software and data analysis, thanks to rich libraries, concise and expressive syntax, and support for interactive programming. Yet, the semantics of R is fairly complex, contains many subtle corner cases, and is not formally specified. This makes it difficult to reason about R programs. In this work, we develop a big-step operational semantics for R in the form of an interpreter written in the Coq proof assistant. We ensure the trustworthiness of the formalization by introducing a monadic encoding that allows the Coq interpreter, CoqR, to be in direct visual correspondence with the reference R interpreter, GNU R. Additionally, we provide a testing framework that supports systematic comparison of CoqR and GNU R. In its current state, CoqR covers the nucleus of the R language as well as numerous additional features, making it pass a significant number of realistic test cases from the GNU R and FastR projects. To exercise the formal specification, we prove in Coq the preservation of memory invariants in selected parts of the interpreter. This work is an important first step towards a robust environment for formal verification of R programs.

References

  1. Karthikeyan Bhargavan, Antoine Delignat-Lavaud, and Sergio Maffeis. 2013. Language-Based Defenses Against Untrusted Browser Origins. In Usenix security symposium. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Martin Bodin, Arthur Charguéraud, Daniele Filaretti, Philippa Gardner, Sergio Maffeis, Daiva Naudinien, Alan Schmitt, and Gareth Smith. 2014. A Trusted Mechanised JavaScript Specification. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Patrick Burns. 2011. The R Inferno.Google ScholarGoogle Scholar
  4. Arthur Charguéraud, Alan Schmitt, and Thomas Wood. 2018. JSExplain: A Double Debugger for JavaScript. In The web conference. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. ECMA International. 2010. Test262. https://github.com/tc39/test262 .Google ScholarGoogle Scholar
  6. Philippa Gardner, Sergio Maffeis, and Gareth Smith. 2012. Towards a Program Logic for JavaScript. In POPL. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Filippo Ghibellini. 2017. Dynamic test generation for R packages. Bachelor’s Thesis.Google ScholarGoogle Scholar
  8. Google. {n. d.} R Style Guide. Retrieved 2018 from https://google. github.io/styleguide/Rguide.xml .Google ScholarGoogle Scholar
  9. Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. 2010. The Essence of JavaScript. In ECOOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Ross Ihaka and Robert Gentleman. 1996. R: a Language for Data Analysis and Graphics. Journal of computational and graphical statistics.Google ScholarGoogle Scholar
  11. Jacques-Henri Jourdan, François Pottier, and Xavier Leroy. 2012. Validating LR(1) Parsers. In ESOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Tomas Kalibera, Petr Maj, Floreal Morandat, and Jan Vitek. 2014. A Fast Abstract Syntax Tree Interpreter for R. In Virtual execution environments. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Robbert Krebbers and Freek Wiedijk. 2011. A Formalization of the C99 Standard in HOL, Isabelle and Coq. In Calculemus/mkm. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Xavier Leroy. 2009. Formal Verification of a Realistic Compiler. Communications of the acm. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Xavier Leroy. 2014. How much is a mechanized proof worth, certification-wise? In Principles in Practice.Google ScholarGoogle Scholar
  16. Sergio Maffeis, John C. Mitchell, and Ankur Taly. 2008. An Operational Semantics for JavaScript. In APLAS. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Sergio Maffeis, John C. Mitchell, and Ankur Taly. 2009. Isolating JavaScript with Filters, Rewriting, and Wrappers. In ESORICS. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Sergio Maffeis, John C. Mitchell, and Ankur Taly. 2010. Object Capabilities and Isolation of Untrusted Web Applications. In SP. IEEE. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Petr Maj, Tomas Kalibera, and Jan Vitek. 2013. TestR: R Language Test Driven Specification. In The R User Conference, UseR!Google ScholarGoogle Scholar
  20. Jonathan McPherson. 2014. Debugging in R. In The R User Conference, UseR!Google ScholarGoogle Scholar
  21. Floréal Morandat, Brandon Hill, Leo Osvald, and Jan Vitek. 2012. Evaluating the design of the R language. In ECOOP.Google ScholarGoogle Scholar
  22. Mozilla. 2013. Mozilla Automated JavaScript Tests. https://developer. mozilla . org / en - US / docs / SpiderMonkey / Running _ Automated _ JavaScript_Tests .Google ScholarGoogle Scholar
  23. Daejun Park, Andrei Stefnescu, and Grigore Rou. 2015. KJS: A Complete Formal Semantics of JavaScript. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Joe Gibbs Politz, Matthew J. Carroll, Benjamin S. Lerner, Justin Pombrio, and Shriram Krishnamurthi. 2012. A Tested Semantics for Getters, Setters, and eval in JavaScript. DLS.Google ScholarGoogle Scholar
  25. R Core Team. 2015. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing. https://www.R-project.org/ .Google ScholarGoogle Scholar
  26. R Core Team. 2000. R Language Definition. R foundation for statistical computing.Google ScholarGoogle Scholar
  27. R Core Team. {n. d.} The Comprehensive R Archive Network. Retrieved 2018 from https://cran.r-project.org/ .Google ScholarGoogle Scholar
  28. Gregor Richards, Christian Hammer, Brian Burg, and Jan Vitek. 2011. The eval that Men Do. A large-scale study of the use of eval in javascript applications. In ECOOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Ankur Taly, Úlfar Erlingsson, John C. Mitchell, Mark S. Miller, and Jasvir Nagra. 2011. Automated Analysis of Security-Critical JavaScript APIs. In SP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. The Coq development team. 1984. the Coq Proof Assistant. Retrieved 2018 from https://coq.inria.fr/ .Google ScholarGoogle Scholar
  31. Luke Tierney, Gabe Becker, and Tomas Kalibera. 2017. ALTREP and Other Things. In R-devel.Google ScholarGoogle Scholar
  32. Roman Tsegelskyi and Jan Vitek. 2014. TestR: Generating Unit Tests for R Internals. In The R User Conference, UseR!Google ScholarGoogle Scholar
  33. Philip Wadler. 1992. Comprehending Monads. Mathematical structures in computer science.Google ScholarGoogle Scholar
  34. Thomas Wuerthinger. 2012. Truffle: A Self-Optimizing Runtime System.Google ScholarGoogle Scholar
  35. Xuejun Yang, Yang Chen, Eric Eide, and John Regehr. 2011. Finding and Understanding Bugs in C Compilers. In PLDI. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A trustworthy mechanized formalization of R

      Recommendations

      Comments

      Login options

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

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 53, Issue 8
        DLS '18
        August 2018
        100 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3393673
        Issue’s Table of Contents
        • cover image ACM Conferences
          DLS 2018: Proceedings of the 14th ACM SIGPLAN International Symposium on Dynamic Languages
          October 2018
          100 pages
          ISBN:9781450360302
          DOI:10.1145/3276945

        Copyright © 2018 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 6 April 2020

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!