Skip to main content Accessibility help

Fair enumeration combinators



Enumerations represented as bijections between the natural numbers and elements of some given type have recently garnered interest in property-based testing because of their efficiency and flexibility. There are, however, many ways of defining these bijections, some of which are better than others. This paper offers a new property of enumeration combinators called fairness that identifies enumeration combinators that are better suited to property-based testing. Intuitively, the result of a fair combinator indexes into its argument enumerations equally when constructing its result. For example, extracting the nth element from our enumeration of three-tuples indexes about $\sqrt[3]{n}$ elements into each of its components instead of, say, indexing $\sqrt[2]{n}$ into one and $\sqrt[4]{n}$ into the other two, as you would if a three-tuple were built out of nested pairs. Similarly, extracting the nth element from our enumeration of a three-way union returns an element that is $\frac{n}{3}$ into one of the argument enumerators. The paper presents a semantics of enumeration combinators, a theory of fairness, proofs establishing fairness of our new combinators and that some combinations of fair combinators are not fair. We also report on an evaluation of fairness for the purpose of finding bugs in programming-language models. We show that fair enumeration combinators have complementary strengths to an existing, well-tuned ad hoc random generator (better on short time scales and worse on long time scales) and that using unfair combinators is worse across the board.



Hide All
Appel, A. W., Dockins, R. & Leroy, X. (2012) A list-machine benchmark for mechanized metatheory. J. Autom. Reson. 49 (3), 453491.
Bulwahn, L. (2012) The new quickcheck for Isabelle: Random, exhaustive and symbolic testing under one roof. In Proceedings of the International Conference on Certified Programs and Proofs.
Classen, K. & Hughes, J. (2000) QuickCheck: A lightweight tool for random testing of Haskell programs. In Proceedings of the International Conference on Functional Programming.
Duregård, J., Jansson, P. & Wang, M. (2012) Feat: Functional enumeration of algebraic types. In Proceedings of the Haskell Symposium.
Felleisen, M., Findler, R. B. & Flatt, M. (2009) Semantics Engineering with PLT Redex. MIT Press.
Flatt, M. & PLT (2010) Reference: Racket. Technical Report PLT-TR-2010-1. PLT Design Inc. Available at:
Kennedy, A. J. & Vytiniotis, D. (2010) Every bit counts: The binary representation of typed data and programs. J. Funct. Program. 22 (4–5).
Klein, C., Clements, J., Dimoulas, C., Eastlund, C., Felleisen, M., Flatt, M., McCarthy, J. A., Rafkind, J., Tobin-Hochstadt, S. & Findler, R. B. (2012) Run your research: On the effectiveness of lightweight mechanization. In Proceedings of the Symposium on Principles of Programming Languages.
Klein, C. & Findler, R. B. (2009) Randomized testing in PLT redex. In Proceedings of the Scheme and Functional Programming, pp. 26–36.
Klein, C., Findler, R. B. & Flatt, M. (2013) The racket virtual machine and randomized testing. Higher-Order Symbol. Comput.
Kuraj, I. & Kuncak, V. (2014) SciFe: Scala framework for efficient enumeration of data structures with invariants. In Proceedings of the Scala Workshop.
Kuraj, I., Kuncak, V. & Jackson, D. (2015) Programming with enumerable sets of structures. In Proceedings of the Object-Oriented Programming, Systems, Languages, and Applications.
Matthews, J., Findler, R. B., Flatt, M. & Felleisen, M. (2004) A visual environment for developing context-sensitive term rewriting systems. In Proceedings of the International Conference on Rewriting Techniques and Applications.
Miller, B. P., Fredriksen, L. & So, B. (1990) An empirical study of the reliability of UNIX utilities. Commun. ACM 33 (12).
Pałka, M. H. (2012) Testing an Optimising Compiler by Generating Random Lambda Terms. Licentiate of Philosophy Dissertation. Chalmers University of Technology and Göteborg University.
Pałka, M. H., Claessen, K., Russo, A. & Hughes, J. (2011) Testing an optimising compiler by generating random lambda terms. In Proceedings of the International Workshop on Automation of Software Test.
Runciman, C., Naylor, M. & Lindblad, F. (2008) SmallCheck and lazy SmallCheck: Automatic exhaustive testing for small values. In Proceedings of the Haskell Symposium.
Szudzik, M. (2006) An elegant pairing function. Available at:
Takikawa, A., Strickland, T. S. & Tobin-Hochstadt, S. (2013) Constraining delimited control with contracts. In Proceedings of the European Symposium on Programming, pp. 229–248.
Tarau, P. (2012) Deriving a fast inverse of the generalized cantor N-tupling bijection. In Proceedings of the International Conference on Logic Programming.
Tarau, P. (2013) Compact serialization of prolog terms (with Catalan Skeletons, Cantor Tupling and Gödel Numberings). Theory Pract. Log. Program. 13 (4–5).
Yang, X., Chen, Y., Eide, E. & Regehr, J. (2011) Finding and understanding bin C compilers. In Proceedings of the Programming Language Design and Implementation.

Related content

Powered by UNSILO
Type Description Title
Supplementary materials

New et al supplementary material
New et al supplementary material 1

 Unknown (46 KB)
46 KB

Fair enumeration combinators



Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed.

Fair enumeration combinators

Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *