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 n th 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 n th 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.

[1]  Sam Tobin-Hochstadt,et al.  Constraining Delimited Control with Contracts , 2013, ESOP.

[2]  Paul Tarau Deriving a Fast Inverse of the Generalized Cantor N-tupling Bijection , 2012, ICLP.

[3]  Paul Tarau,et al.  Compact serialization of Prolog terms (with catalan skeletons, cantor tupling and Gödel numberings) , 2013, Theory and Practice of Logic Programming.

[4]  Koen Claessen,et al.  QuickCheck: a lightweight tool for random testing of Haskell programs , 2011, SIGP.

[5]  Colin Runciman,et al.  Smallcheck and lazy smallcheck: automatic exhaustive testing for small values , 2008, Haskell '08.

[6]  Lukas Bulwahn,et al.  The New Quickcheck for Isabelle - Random, Exhaustive and Symbolic Testing under One Roof , 2012, CPP.

[7]  Koen Claessen,et al.  Testing an optimising compiler by generating random lambda terms , 2011, AST '11.

[8]  Meng Wang,et al.  Feat: functional enumeration of algebraic types , 2012, Haskell.

[9]  Xuejun Yang,et al.  Finding and understanding bugs in C compilers , 2011, PLDI '11.

[10]  Sam Tobin-Hochstadt,et al.  Run your research: on the effectiveness of lightweight mechanization , 2012, POPL '12.

[11]  Dimitrios Vytiniotis,et al.  Under Consideration for Publication in J. Functional Programming Every Bit Counts: the Binary Representation of Typed Data and Programs , 2022 .

[12]  Andrew W. Appel,et al.  A List-Machine Benchmark for Mechanized Metatheory , 2011, Journal of Automated Reasoning.

[13]  Barton P. Miller,et al.  An empirical study of the reliability of UNIX utilities , 1990, Commun. ACM.

[14]  Robert Bruce Findler,et al.  The Racket virtual machine and randomized testing , 2012, High. Order Symb. Comput..

[15]  Viktor Kuncak,et al.  SciFe: Scala framework for efficient enumeration of data structures with invariants , 2014, SCALA@ECOOP.

[16]  Matthias Felleisen,et al.  A Visual Environment for Developing Context-Sensitive Term Rewriting Systems , 2004, RTA.

[17]  Casey Klein,et al.  Randomized Testing in PLT Redex , 2009 .

[18]  Viktor Kuncak,et al.  Programming with enumerable sets of structures , 2015, OOPSLA.

[19]  Matthias Felleisen,et al.  Semantics Engineering with PLT Redex , 2009 .