skip to main content
10.1145/3519939.3523707acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections

Computing correctly with inductive relations

Published:09 June 2022Publication History

ABSTRACT

Inductive relations are the predominant way of writing specifications in mechanized proof developments. Compared to purely functional specifications, they enjoy increased expressive power and facilitate more compositional reasoning. However, inductive relations also come with a significant drawback: they can’t be used for computation.

In this paper, we present a unifying framework for extracting three different kinds of computational content from inductively defined relations: semi-decision procedures, enumerators, and random generators. We show how three different instantiations of the same algorithm can be used to generate all three classes of computational definitions inside the logic of the Coq proof assistant. For each derived computation, we also derive mechanized proofs that it is sound and complete with respect to the original inductive relation, using Ltac2, Coq’s new metaprogramming facility.

We implement our framework on top of the QuickChick testing tool for Coq, and demonstrate that it covers most cases of interest by extracting computations for the inductive relations found in the Software Foundations series. Finally, we evaluate the practicality and the efficiency of our approach with small case studies in randomized property-based testing and proof by computational reflection.

References

  1. Thomas Arts, Laura M. Castro, and John Hughes. 2008. Testing Erlang Data Types with QuviQ QuickCheck. In 7th ACM SIGPLAN Workshop on Erlang. ACM, 1–8. isbn:978-1-60558-065-4 https://doi.org/10.1145/1411273.1411275 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Stefan Berghofer, Lukas Bulwahn, and Florian Haftmann. 2009. Turning Inductive into Equational Specifications. In 22nd International Conference on Theorem Proving in Higher Order Logics (Lecture Notes in Computer Science, Vol. 5674). Springer, 131–146. isbn:978-3-642-03358-2 http://www4.in.tum.de/~haftmann/pdf/turning_inductive_into_equational_specifications_berghofer_bulwahn_haftmann.pdfGoogle ScholarGoogle ScholarDigital LibraryDigital Library
  3. Stefan Berghofer and Tobias Nipkow. 2002. Executing Higher Order Logic. In International Workshop on Types for Proofs and Programs (TYPES) (Lecture Notes in Computer Science, Vol. 2277). Springer, 24–40. isbn:3-540-43287-6 http://www4.in.tum.de/publ/papers/TYPES2000.pdfGoogle ScholarGoogle Scholar
  4. Yves Bertot and Pierre Castéran. 2004. * Proof by Reflection. Springer Berlin Heidelberg, Berlin, Heidelberg. 433–448. isbn:978-3-662-07964-5 https://doi.org/10.1007/978-3-662-07964-5_16 Google ScholarGoogle ScholarCross RefCross Ref
  5. Lukas Bulwahn. 2012. The New Quickcheck for Isabelle - Random, Exhaustive and Symbolic Testing under One Roof. In 2nd International Conference on Certified Programs and Proofs (CPP) (Lecture Notes in Computer Science, Vol. 7679). Springer, 92–108. https://www.irisa.fr/celtique/genet/ACF/BiblioIsabelle/quickcheckNew.pdfGoogle ScholarGoogle Scholar
  6. Lukas Bulwahn. 2012. Smart Testing of Functional Programs in Isabelle. In 18th International Conference on Logic for Programming, Artificial Intelligence, and Reasoning (LPAR) (Lecture Notes in Computer Science, Vol. 7180). Springer, 153–167. isbn:978-3-642-28716-9 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.229.1307&rep=rep1&type=pdfGoogle ScholarGoogle Scholar
  7. Harsh Raju Chamarthi, Peter C. Dillinger, Matt Kaufmann, and Panagiotis Manolios. 2011. Integrating Testing and Interactive Theorem Proving. In 10th International Workshop on the ACL2 Theorem Prover and its Applications (EPTCS, Vol. 70). 4–19. arxiv:1105.4394Google ScholarGoogle Scholar
  8. Koen Claessen, Jonas Duregård, and Michał H. Pał ka. 2014. Generating Constrained Random Data with Uniform Distribution. In Functional and Logic Programming (Lecture Notes in Computer Science, Vol. 8475). Springer, 18–34. isbn:978-3-319-07150-3 https://doi.org/10.1007/978-3-319-07151-0_2 Google ScholarGoogle ScholarCross RefCross Ref
  9. Koen Claessen and John Hughes. 2000. QuickCheck: a lightweight tool for random testing of Haskell programs. In 5th ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, 268–279. http://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdfGoogle ScholarGoogle ScholarDigital LibraryDigital Library
  10. The Coq Development Team. 2021. The Coq Proof Assistant. https://doi.org/10.5281/zenodo.4501022 Google ScholarGoogle ScholarCross RefCross Ref
  11. David Delahaye, Catherine Dubois, and Jean-Frédéric Étienne. 2007. Extracting Purely Functional Contents from Logical Inductive Types. In 20th International Conference on Theorem Proving in Higher Order Logics (TPHOLs) (Lecture Notes in Computer Science, Vol. 4732). Springer, 70–85. isbn:978-3-540-74590-7 http://cedric.cnam.fr/~delahaye/papers/pred-exec%20(TPHOLs’07).pdfGoogle ScholarGoogle ScholarCross RefCross Ref
  12. Peter Dybjer, Qiao Haiyan, and Makoto Takeyama. 2004. Random Generators for Dependent Types. In First International Colloquium Theoretical Aspects of Computing (Lecture Notes in Computer Science, Vol. 3407). Springer, 341–355. isbn:3-540-25304-1 https://doi.org/10.1007/978-3-540-31862-0_25 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Burke Fetscher, Koen Claessen, Michal H. Palka, John Hughes, and Robert Bruce Findler. 2015. Making Random Judgments: Automatically Generating Well-Typed Terms from the Definition of a Type-System. In 24th European Symposium on Programming (Lecture Notes in Computer Science, Vol. 9032). Springer, 383–405. isbn:978-3-662-46668-1 http://users.eecs.northwestern.edu/~baf111/random-judgments/Google ScholarGoogle ScholarCross RefCross Ref
  14. Milos Gligoric, Tihomir Gvero, Vilas Jagannath, Sarfraz Khurshid, Viktor Kuncak, and Darko Marinov. 2010. Test generation through programming in UDITA. In 32nd ACM/IEEE International Conference on Software Engineering. ACM, 225–234. isbn:978-1-60558-719-6 https://doi.org/10.1145/1806799.1806835 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Harrison Goldstein, John Hughes, Leonidas Lampropoulos, and Benjamin C. Pierce. 2021. Do Judge a Test by its Cover - Combining Combinatorial and Property-Based Testing. In Programming Languages and Systems - 30th European Symposium on Programming, ESOP 2021, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2021, Luxembourg City, Luxembourg, March 27 - April 1, 2021, Proceedings, Nobuko Yoshida (Ed.) (Lecture Notes in Computer Science, Vol. 12648). Springer, 264–291. https://doi.org/10.1007/978-3-030-72019-3_10 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Florian Haftmann and Tobias Nipkow. 2010. Code Generation via Higher-Order Rewrite Systems. In Functional and Logic Programming, Matthias Blume, Naoki Kobayashi, and Germán Vidal (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 103–117. isbn:978-3-642-12251-4Google ScholarGoogle Scholar
  17. Ralf Hinze, Andres Löh, and Bruno C. d. S. Oliveira. 2006. "Scrap Your Boilerplate" Reloaded. In Functional and Logic Programming, 8th International Symposium, FLOPS 2006, Fuji-Susono, Japan, April 24-26, 2006, Proceedings, Masami Hagiya and Philip Wadler (Eds.) (Lecture Notes in Computer Science, Vol. 3945). Springer, 13–29. https://doi.org/10.1007/11737414_3 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Cătălin Hriţcu, John Hughes, Benjamin C. Pierce, Antal Spector-Zabusky, Dimitrios Vytiniotis, Arthur Azevedo de Amorim, and Leonidas Lampropoulos. 2013. Testing Noninterference, Quickly. In 18th ACM SIGPLAN International Conference on Functional Programming (ICFP). ACM, 455–468. http://prosecco.gforge.inria.fr/personal/hritcu/publications/testing-noninterference-icfp2013.pdfGoogle ScholarGoogle ScholarDigital LibraryDigital Library
  19. Cătălin Hriţcu, Leonidas Lampropoulos, Antal Spector-Zabusky, Arthur Azevedo de Amorim, Maxime Dénès, John Hughes, Benjamin C. Pierce, and Dimitrios Vytiniotis. 2016. Testing Noninterference, Quickly. Journal of Functional Programming (JFP); Special issue for ICFP 2013, 26 (2016), April, e4 (62 pages). issn:1469-7653 https://doi.org/10.1017/S0956796816000058 Technical Report available as arXiv:1409.0393. Google ScholarGoogle Scholar
  20. John Hughes. 2019. How to Specify It!. 20th International Symposium on Trends in Functional Programming.Google ScholarGoogle Scholar
  21. Casey Klein and Robert Bruce Findler. 2009. Randomized Testing in PLT Redex. In Workshop on Scheme and Functional Programming (SFP). http://www.eecs.northwestern.edu/~robby/pubs/papers/scheme2009-kf.pdfGoogle ScholarGoogle Scholar
  22. Ivan Kuraj and Viktor Kuncak. 2014. SciFe: Scala framework for efficient enumeration of data structures with invariants. In Proceedings of the Fifth Annual Scala Workshop. ACM, 45–49. isbn:978-1-4503-2868-5 https://doi.org/10.1145/2637647.2637655 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Leonidas Lampropoulos. 2018. Random Testing for Language Design. Ph.D. Dissertation. University of Pennsylvania.Google ScholarGoogle Scholar
  24. Leonidas Lampropoulos, Zoe Paraskevopoulou, and Benjamin C. Pierce. 2018. Generating good generators for inductive relations. PACMPL, 2, POPL (2018), 45:1–45:30. https://doi.org/10.1145/3158133 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Leonidas Lampropoulos and Benjamin C. Pierce. 2018. QuickCHick: Property-Based Testing In Coq. Electronic textbook. http://www.cis.upenn.edu/~bcpierce/sfGoogle ScholarGoogle Scholar
  26. Max S. New, Burke Fetscher, Robert Bruce Findler, and Jay A. McCarthy. 2017. Fair enumeration combinators. J. Funct. Program., 27 (2017), e19. https://doi.org/10.1017/S0956796817000107 Google ScholarGoogle ScholarCross RefCross Ref
  27. Ulf Norell. 2008. Dependently Typed Programming in Agda. In Proceedings of the 6th International Conference on Advanced Functional Programming (AFP’08). Springer-Verlag, Berlin, Heidelberg. 230–266. isbn:3642046517Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Manolis Papadakis and Konstantinos F. Sagonas. 2011. A PropEr integration of types and function specifications with property-based testing. In Proceedings of the 10th ACM SIGPLAN workshop on Erlang, Tokyo, Japan, September 23, 2011. 39–50. https://doi.org/10.1145/2034654.2034663 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Pierre-Marie Pédrot. 2019. Ltac2: Tactical Warfare. The Fifth International Workshop on Coq for Programming LanguagesCoqPL. https://www.pédrot.fr/articles/coqpl2019.pdfpdfGoogle ScholarGoogle Scholar
  30. Benjamin C. Pierce, Arthur Azevedo de Amorim, Chris Casinghino, Marco Gaboardi, Michael Greenberg, Cǎtǎlin Hriţcu, Vilhelm Sjöberg, Andrew Tolmach, and Brent Yorgey. 2018. Programming Language Foundations. Electronic textbook, Version 5.5.. http://www.cis.upenn.edu/~bcpierce/sfGoogle ScholarGoogle Scholar
  31. Benjamin C. Pierce, Arthur Azevedo de Amorim, Chris Casinghino, Marco Gaboardi, Michael Greenberg, Cǎtǎlin Hriţcu, Vilhelm Sjöberg, and Brent Yorgey. 2018. Logical Foundations. Electronic textbook, Version 5.5. http://www.cis.upenn.edu/~bcpierce/sfGoogle ScholarGoogle Scholar
  32. Amir Pnueli, Michael Siegel, and Eli Singerman. 1998. Translation Validation. In Tools and Algorithms for Construction and Analysis of Systems, 4th International Conference, TACAS ’98, Held as Part of the European Joint Conferences on the Theory and Practice of Software, ETAPS’98, Lisbon, Portugal, March 28 - April 4, 1998, Proceedings, Bernhard Steffen (Ed.) (Lecture Notes in Computer Science, Vol. 1384). Springer, 151–166. isbn:3-540-64356-7 https://doi.org/10.1007/BFb0054170 Google ScholarGoogle ScholarCross RefCross Ref
  33. Matthieu Sozeau and Nicolas Oury. 2008. First-Class Type Classes. In Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics (TPHOLs ’08). Springer-Verlag, Berlin, Heidelberg. 278–293. isbn:978-3-540-71065-3 https://doi.org/10.1007/978-3-540-71067-7_23 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Pierre-Nicolas Tollitte, David Delahaye, and Catherine Dubois. 2012. Producing Certified Functional Code from Inductive Specifications. In Second International Conference on Certified Programs and Proofs (CPP) (Lecture Notes in Computer Science, Vol. 7679). Springer. isbn:978-3-642-35307-9 http://cedric.cnam.fr/~delahaye/papers/relext-coq%20%28CPP%2712%29.pdfGoogle ScholarGoogle ScholarDigital LibraryDigital Library
  35. Niki Vazou. 2016. Liquid Haskell: Haskell as a Theorem Prover. Ph.D. Dissertation. University of California, San Diego, USA. http://www.escholarship.org/uc/item/8dm057wsGoogle ScholarGoogle Scholar
  36. Alexey Rodriguez Yakushev and Johan Jeuring. 2010. Enumerating Well-Typed Terms Generically. In Approaches and Applications of Inductive Programming, Ute Schmid, Emanuel Kitzelmann, and Rinus Plasmeijer (Eds.) (Lecture Notes in Computer Science, Vol. 5812). Springer Berlin Heidelberg, 93–116. isbn:978-3-642-11930-9 https://doi.org/10.1007/978-3-642-11931-6_5 Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Computing correctly with inductive relations

        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
        • Published in

          cover image ACM Conferences
          PLDI 2022: Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation
          June 2022
          1038 pages
          ISBN:9781450392655
          DOI:10.1145/3519939
          • General Chair:
          • Ranjit Jhala,
          • Program Chair:
          • Işil Dillig

          Copyright © 2022 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 the author(s) 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: 9 June 2022

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          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