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.
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarCross Ref
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- The Coq Development Team. 2021. The Coq Proof Assistant. https://doi.org/10.5281/zenodo.4501022 Google ScholarCross Ref
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- John Hughes. 2019. How to Specify It!. 20th International Symposium on Trends in Functional Programming.Google Scholar
- 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 Scholar
- 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 ScholarDigital Library
- Leonidas Lampropoulos. 2018. Random Testing for Language Design. Ph.D. Dissertation. University of Pennsylvania.Google Scholar
- 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 ScholarDigital Library
- Leonidas Lampropoulos and Benjamin C. Pierce. 2018. QuickCHick: Property-Based Testing In Coq. Electronic textbook. http://www.cis.upenn.edu/~bcpierce/sfGoogle Scholar
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarCross Ref
Index Terms
- Computing correctly with inductive relations
Recommendations
Merging Inductive Relations
Inductive relations offer a powerful and expressive way of writing program specifications while facilitating compositional reasoning. Their widespread use by proof assistant users has made them a particularly attractive target for proof ...
POPLMark reloaded: mechanizing logical relations proofs (invited talk)
CPP 2018: Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and ProofsMechanizing formal systems, given via axioms and inference rules, together with proofs about them plays an important role in establishing trust in formal developments. Over the past decade, the POPLMark challenge popularized the use of proof assistants ...
Producing Certified Functional Code from Inductive Specifications
Certified Programs and ProofsAbstractProof assistants based on type theory allow the user to adopt either a functional style, or a relational style (e.g., by using inductive types). Both styles have pros and cons. Relational style may be preferred because it allows the user to ...
Comments