skip to main content
research-article
Open Access

A completely unique account of enumeration

Published:31 August 2022Publication History
Skip Abstract Section

Abstract

How can we enumerate the inhabitants of an algebraic datatype? This paper explores a datatype generic solution that works for all regular types and indexed families. The enumerators presented here are provably both complete and unique—they will eventually produce every value exactly once—and fair—they avoid bias when composing enumerators. Finally, these enumerators memoise previously enumerated values whenever possible, thereby avoiding repeatedly recomputing recursive results.

References

  1. Marcin Benke, Peter Dybjer, and Patrik Jansson. 2003. Universes for Generic Programs and Proofs in Dependent Type Theory. Nord. J. Comput., 10, 4 (2003), 265–289. https://dl.acm.org/doi/10.5555/985799.985801 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Edwin C. Brady. 2013. Idris: general purpose programming with dependent types. In Proceedings of the 7th Workshop on Programming languages meets program verification, PLPV 2013, Rome, Italy, January 22, 2013, Matthew Might, David Van Horn, Andreas Abel, and Tim Sheard (Eds.). ACM, 1–2. https://doi.org/10.1145/2428116.2428118 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Rudy Matela Braquehais. 2017. Tools for discovery, refinement and generalization of functional properties by enumerative testing. Ph.D. Dissertation. University of York, UK. http://ethos.bl.uk/OrderDetails.do?uin=uk.bl.ethos.731590 Google ScholarGoogle Scholar
  4. Lukas Bulwahn. 2012. The New Quickcheck for Isabelle - Random, Exhaustive and Symbolic Testing under One Roof. In Certified Programs and Proofs - Second International Conference, CPP 2012, Kyoto, Japan, December 13-15, 2012. Proceedings, Chris Hawblitzel and Dale Miller (Eds.) (Lecture Notes in Computer Science, Vol. 7679). Springer, 92–108. https://doi.org/10.1007/978-3-642-35308-6_10 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Lukas Bulwahn. 2012. Smart Testing of Functional Programs in Isabelle. In Logic for Programming, Artificial Intelligence, and Reasoning - 18th International Conference, LPAR-18, Mérida, Venezuela, March 11-15, 2012. Proceedings, Nikolaj S. Bjørner and Andrei Voronkov (Eds.) (Lecture Notes in Computer Science, Vol. 7180). Springer, 153–167. https://doi.org/10.1007/978-3-642-28717-6_14 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. James Chapman, Pierre-Évariste Dagand, Conor McBride, and Peter Morris. 2010. The gentle art of levitation. In Proceeding of the 15th ACM SIGPLAN international conference on Functional programming, ICFP 2010, Baltimore, Maryland, USA, September 27-29, 2010, Paul Hudak and Stephanie Weirich (Eds.). ACM, 3–14. https://doi.org/10.1145/1863543.1863547 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Koen Claessen, Jonas Duregård, and Michal H. Palka. 2015. Generating constrained random data with uniform distribution. J. Funct. Program., 25 (2015), https://doi.org/10.1017/S0956796815000143 Google ScholarGoogle ScholarCross RefCross Ref
  8. Koen Claessen and John Hughes. 2000. QuickCheck: a lightweight tool for random testing of Haskell programs. In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP ’00), Montreal, Canada, September 18-21, 2000, Martin Odersky and Philip Wadler (Eds.). ACM, 268–279. https://doi.org/10.1145/351240.351266 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Koen Claessen, Moa Johansson, Dan Rosén, and Nicholas Smallbone. 2012. HipSpec: Automating Inductive Proofs of Program Properties. In ATx’12/WInG’12: Joint Proceedings of the Workshops on Automated Theory eXploration and on Invariant Generation, Manchester, UK, June 2012, Jacques D. Fleuriot, Peter Höfner, Annabelle McIver, and Alan Smaill (Eds.) (EPiC Series in Computing, Vol. 17). EasyChair, 16–25. https://doi.org/10.29007/3qwr Google ScholarGoogle Scholar
  10. Koen Claessen, Nicholas Smallbone, and John Hughes. 2010. QuickSpec: Guessing Formal Specifications Using Testing. In Tests and Proofs - 4th International Conference, [email protected] 2010, Málaga, Spain, July 1-2, 2010. Proceedings, Gordon Fraser and Angelo Gargantini (Eds.) (Lecture Notes in Computer Science, Vol. 6143). Springer, 6–21. https://doi.org/10.1007/978-3-642-13977-2_3 Google ScholarGoogle ScholarCross RefCross Ref
  11. Coq Development Team. 2020. The Coq Proof Assistant Reference Manual. Available at https://coq.inria.fr/doc/ Google ScholarGoogle Scholar
  12. Pierre-Évariste Dagand. 2013. A cosmology of datatypes : reusability and dependent types. Ph.D. Dissertation. University of Strathclyde, Glasgow, UK. http://oleg.lib.strath.ac.uk/R/?func=dbin-jump-full&object_id=22713 Google ScholarGoogle Scholar
  13. Pierre-Évariste Dagand and Conor McBride. 2012. Transporting functions across ornaments. In ACM SIGPLAN International Conference on Functional Programming, ICFP’12, Copenhagen, Denmark, September 9-15, 2012, Peter Thiemann and Robby Bruce Findler (Eds.). ACM, 103–114. https://doi.org/10.1145/2364527.2364544 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Leonardo Mendonça de Moura, Soonho Kong, Jeremy Avigad, Floris van Doorn, and Jakob von Raumer. 2015. The Lean Theorem Prover (System Description). In Automated Deduction - CADE-25 - 25th International Conference on Automated Deduction, Berlin, Germany, August 1-7, 2015, Proceedings, Amy P. Felty and Aart Middeldorp (Eds.) (Lecture Notes in Computer Science, Vol. 9195). Springer, 378–388. https://doi.org/10.1007/978-3-319-21401-6_26 Google ScholarGoogle Scholar
  15. Edsko de Vries and Andres Löh. 2014. True sums of products. In Proceedings of the 10th ACM SIGPLAN workshop on Generic programming, WGP 2014, Gothenburg, Sweden, August 31, 2014, José Pedro Magalhães and Tiark Rompf (Eds.). ACM, 83–94. https://doi.org/10.1145/2633628.2633634 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Maxime Dénès, Cătălin Hriţcu, Leonidas Lampropoulos, Zoe Paraskevopoulou, and Benjamin C Pierce. 2014. QuickChick: Property-based testing for Coq. In The Coq Workshop. Google ScholarGoogle Scholar
  17. Dominique Devriese and Frank Piessens. 2011. On the bright side of type classes: instance arguments in Agda. In Proceeding of the 16th ACM SIGPLAN international conference on Functional Programming, ICFP 2011, Tokyo, Japan, September 19-21, 2011, Manuel M. T. Chakravarty, Zhenjiang Hu, and Olivier Danvy (Eds.). ACM, 143–155. https://doi.org/10.1145/2034773.2034796 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Jonas Duregård, Patrik Jansson, and Meng Wang. 2012. Feat: functional enumeration of algebraic types. In Proceedings of the 5th ACM SIGPLAN Symposium on Haskell, Haskell 2012, Copenhagen, Denmark, 13 September 2012, Janis Voigtländer (Ed.). ACM, 61–72. https://doi.org/10.1145/2364506.2364515 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Peter Dybjer, Qiao Haiyan, and Makoto Takeyama. 2004. Random Generators for Dependent Types. In Theoretical Aspects of Computing - ICTAC 2004, First International Colloquium, Guiyang, China, September 20-24, 2004, Revised Selected Papers, Zhiming Liu and Keijiro Araki (Eds.) (Lecture Notes in Computer Science, Vol. 3407). Springer, 341–355. https://doi.org/10.1007/978-3-540-31862-0_25 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Qiao Haiyan. 2007. Testing and Proving Distributed Algorithms in Constructive Type Theory. In Tests and Proofs - 1st International Conference, TAP 2007, Zurich, Switzerland, February 12-13, 2007. Revised Papers, Yuri Gurevich and Bertrand Meyer (Eds.) (Lecture Notes in Computer Science, Vol. 4454). Springer, 79–94. https://doi.org/10.1007/978-3-540-73770-4_5 Google ScholarGoogle ScholarCross RefCross Ref
  21. Ralf Hinze. 2000. Generalizing generalized tries. J. Funct. Program., 10, 4 (2000), 327–351. https://doi.org/10.1017/s0956796800003713 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Ralf Hinze, Johan Jeuring, and Andres Löh. 2004. Type-indexed data types. Sci. Comput. Program., 51, 1-2 (2004), 117–151. https://doi.org/10.1016/j.scico.2003.07.001 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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
  24. Leonidas Lampropoulos, Zoe Paraskevopoulou, and Benjamin C. Pierce. 2018. Generating good generators for inductive relations. Proc. ACM Program. Lang., 2, POPL (2018), 45:1–45:30. https://doi.org/10.1145/3158133 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. M. Douglas McIlroy. 1999. Power Series, Power Serious. J. Funct. Program., 9, 3 (1999), 325–337. https://doi.org/10.1017/s0956796899003299 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. 2009. Dependently typed programming in Agda. In Proceedings of TLDI’09: 2009 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Savannah, GA, USA, January 24, 2009, Andrew Kennedy and Amal Ahmed (Eds.). ACM, 1–2. https://doi.org/10.1145/1481861.1481862 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Zoe Paraskevopoulou, Catalin Hritcu, Maxime Dénès, Leonidas Lampropoulos, and Benjamin C. Pierce. 2015. Foundational Property-Based Testing. In Interactive Theorem Proving - 6th International Conference, ITP 2015, Nanjing, China, August 24-27, 2015, Proceedings, Christian Urban and Xingyuan Zhang (Eds.) (Lecture Notes in Computer Science, Vol. 9236). Springer, 325–343. https://doi.org/10.1007/978-3-319-22102-1_22 Google ScholarGoogle ScholarCross RefCross Ref
  29. Colin Runciman, Matthew Naylor, and Fredrik Lindblad. 2008. Smallcheck and lazy smallcheck: automatic exhaustive testing for small values. In Proceedings of the 1st ACM SIGPLAN Symposium on Haskell, Haskell 2008, Victoria, BC, Canada, 25 September 2008, Andy Gill (Ed.). ACM, 37–48. https://doi.org/10.1145/1411286.1411292 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Nikhil Swamy, Cătălin Hriţcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean Karim Zinzindohoue, and Santiago Zanella Béguelin. 2016. Dependent types and multi-monadic effects in F. 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, Rastislav Bodík and Rupak Majumdar (Eds.). ACM, 256–270. https://doi.org/10.1145/2837614.2837655 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Paul van der Walt and Wouter Swierstra. 2012. Engineering Proof by Reflection in Agda. In Implementation and Application of Functional Languages - 24th International Symposium, IFL 2012, Oxford, UK, August 30 - September 1, 2012, Revised Selected Papers, Ralf Hinze (Ed.) (Lecture Notes in Computer Science, Vol. 8241). Springer, 157–173. https://doi.org/10.1007/978-3-642-41582-1_10 Google ScholarGoogle ScholarCross RefCross Ref
  32. Alexey Rodriguez Yakushev and Johan Jeuring. 2009. Enumerating Well-Typed Terms Generically. In Approaches and Applications of Inductive Programming, Third International Workshop, AAIP 2009, Edinburgh, UK, September 4, 2009. Revised Papers, Ute Schmid, Emanuel Kitzelmann, and Rinus Plasmeijer (Eds.) (Lecture Notes in Computer Science, Vol. 5812). Springer, 93–116. https://doi.org/10.1007/978-3-642-11931-6_5 Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. A completely unique account of enumeration

        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

        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!