Skip to main content
    • Aa
    • Aa

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
AppelA. W., DockinsR. & LeroyX. (2012) A list-machine benchmark for mechanized metatheory. J. Autom. Reson. 49 (3), 453491.
BulwahnL. (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.
ClassenK. & HughesJ. (2000) QuickCheck: A lightweight tool for random testing of Haskell programs. In Proceedings of the International Conference on Functional Programming.
DuregårdJ., JanssonP. & WangM. (2012) Feat: Functional enumeration of algebraic types. In Proceedings of the Haskell Symposium.
FelleisenM., FindlerR. B. & FlattM. (2009) Semantics Engineering with PLT Redex. MIT Press.
FlattM. & PLT (2010) Reference: Racket. Technical Report PLT-TR-2010-1. PLT Design Inc. Available at:
KennedyA. J. & VytiniotisD. (2010) Every bit counts: The binary representation of typed data and programs. J. Funct. Program. 22 (4–5).
KleinC., ClementsJ., DimoulasC., EastlundC., FelleisenM., FlattM., McCarthyJ. A., RafkindJ., Tobin-HochstadtS. & FindlerR. B. (2012) Run your research: On the effectiveness of lightweight mechanization. In Proceedings of the Symposium on Principles of Programming Languages.
KleinC. & FindlerR. B. (2009) Randomized testing in PLT redex. In Proceedings of the Scheme and Functional Programming, pp. 26–36.
KleinC., FindlerR. B. & FlattM. (2013) The racket virtual machine and randomized testing. Higher-Order Symbol. Comput.
KurajI. & KuncakV. (2014) SciFe: Scala framework for efficient enumeration of data structures with invariants. In Proceedings of the Scala Workshop.
KurajI., KuncakV. & JacksonD. (2015) Programming with enumerable sets of structures. In Proceedings of the Object-Oriented Programming, Systems, Languages, and Applications.
MatthewsJ., FindlerR. B., FlattM. & FelleisenM. (2004) A visual environment for developing context-sensitive term rewriting systems. In Proceedings of the International Conference on Rewriting Techniques and Applications.
MillerB. P., FredriksenL. & SoB. (1990) An empirical study of the reliability of UNIX utilities. Commun. ACM 33 (12).
PałkaM. H. (2012) Testing an Optimising Compiler by Generating Random Lambda Terms. Licentiate of Philosophy Dissertation. Chalmers University of Technology and Göteborg University.
PałkaM. H., ClaessenK., RussoA. & HughesJ. (2011) Testing an optimising compiler by generating random lambda terms. In Proceedings of the International Workshop on Automation of Software Test.
RuncimanC., NaylorM. & LindbladF. (2008) SmallCheck and lazy SmallCheck: Automatic exhaustive testing for small values. In Proceedings of the Haskell Symposium.
SzudzikM. (2006) An elegant pairing function. Available at:
TakikawaA., StricklandT. S. & Tobin-HochstadtS. (2013) Constraining delimited control with contracts. In Proceedings of the European Symposium on Programming, pp. 229–248.
TarauP. (2012) Deriving a fast inverse of the generalized cantor N-tupling bijection. In Proceedings of the International Conference on Logic Programming.
TarauP. (2013) Compact serialization of prolog terms (with Catalan Skeletons, Cantor Tupling and Gödel Numberings). Theory Pract. Log. Program. 13 (4–5).
YangX., ChenY., EideE. & RegehrJ. (2011) Finding and understanding bin C compilers. In Proceedings of the Programming Language Design and Implementation.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
Type Description Title
Supplementary Materials

New et al supplementary material
New et al supplementary material 1

 Unknown (46 KB)
46 KB


Full text views

Total number of HTML views: 4
Total number of PDF views: 44 *
Loading metrics...

Abstract views

Total abstract views: 110 *
Loading metrics...

* Views captured on Cambridge Core between 30th August 2017 - 22nd October 2017. This data will be updated every 24 hours.