Definition
Exhaustive enumeration is checking a property on every case in a finite, explicitly defined set of cases, instead of on a sample of them. The set is defined by its dimensions (the inputs, initial states and operation sequences that vary) and by a bound on each, such as the bit width of a value or the length of a sequence. If every case ran and the oracle that judges each case is correct, a pass shows that the property holds on the whole set, and nothing about cases outside it.
The idea
Sampling leaves gaps: a property checked on a million random inputs can still fail on the one input that was never drawn. When the set of cases is small enough, running every case closes the gap. A function of one 8-bit input has 256 cases. A function of one 32-bit input has cases, which a computer doing checks per second runs in about 4.3 seconds. Inside such a set, checking every case turns testing into proof.
The price is that the claim is exactly as wide as the set. Two 32-bit inputs already give cases, about 585 years at checks per second. Real enumerations therefore work on scaled-down domains: values of 2 or 3 bits, a few states, sequences of a few steps. The force of the result comes from stating that domain exactly. Its usefulness comes from choosing the small domain so that it still contains the kinds of behavior that matter.
How it works
Define the domain. List every dimension that varies and its bound: the width or range of each input value, the initial states, the operations, the largest sequence length and, for concurrent code, the thread interleavings, the orders in which the steps of different threads can run. List every dimension held fixed, such as the configuration, the memory size and the timing.
Define the oracle. The test oracle §10.5 is the rule that decides whether each case passes. State the property it checks and where its correct answer comes from, for example a simple reference implementation that uses exact arithmetic.
Count before running. The number of cases is the product of the numbers of values of the dimensions. Write it down.
Prune only with a reason. Leave out cases, such as sequences the system can never reach, only with an argument that they are impossible or cannot behave differently from cases kept. Record each rule and how many cases it removed.
Run every case and account for it. Compare the numbers of cases run, passed, failed, skipped and timed out with the count from step 3. A skipped or timed-out case is not a passed case; while any remain, the enumeration is not exhaustive.
Sequences of operations grow fast. With initial states and possible operations at each step, there are sequences of exactly steps. With 3 initial states and 2 operations, that is sequences of 2 steps but sequences of 20 steps. This exponential growth, called state explosion §3.26, is why every enumeration of sequences has a length bound.
Model checking §3.30, which explores every reachable state §3.21 of a finite model, and bounded model checking §3.29, which covers every execution up to a fixed number of steps, are exhaustive in the same sense. They do the work by systematic search or with a solver for logical constraints instead of one test run per case.
Worked example
A range check decides whether a read of bytes at offset fits inside an object of bytes. The specification is in ordinary arithmetic. Two implementations are compared. The naive check computes in the machine’s unsigned arithmetic, which wraps around, and compares the result with . The overflow-safe range check §4.17 tests and then .
The real machine uses 32-bit values, which gives triples , about years of work at checks per second. The enumeration therefore scales the width down to 2 bits and keeps the same kind of arithmetic: every value lies between 0 and 3, and a sum wraps around modulo . The domain has cases. The oracle evaluates with exact integers.
The overflow-safe check agrees with the oracle in all 64 cases. The naive check disagrees in 20 cases, and in all 20 the sum is at least 4 and wraps:
a sum of 4, from , wraps to 0 and is accepted for every from 0 to 3, giving cases;
a sum of 5, from and , wraps to 1 and is accepted for , giving cases;
the sum 6, from , wraps to 2 and is accepted for , giving 2 cases.
That makes . The specification refuses all 20, because .
The run established that the overflow-safe check is correct for every 2-bit triple and that the naive check is wrong for exactly 20 of the 64. It established nothing about 32-bit values. The 2-bit failure points to the same failure at 32 bits, and , whose sum wraps to 0; a direct test confirms it. The 2-bit success of the safe check carries over to 32 bits only with an argument that does not depend on the width, here algebra: when , the subtraction cannot wrap, and then says the same as .
Stated precisely
Let the dimensions have the finite value sets . Let the domain be a set of tuples , with each taken from , possibly restricted by a stated condition such as reachability. Let be the oracle. Exhaustive enumeration establishes when four conditions hold, each checked, not assumed.
Completeness: the generator produced every element of ; the number of cases run equals , the number of elements of , which is before any restriction.
Completion: every case ran to a verdict; none was skipped, crashed the test harness or timed out.
A correct oracle: passes exactly the cases that satisfy the property.
Correspondence: what ran behaves like the thing the claim is about, such as the real code built the same way, or a model whose agreement with the code has been argued.
The conclusion covers and nothing outside it.
Checking every operation sequence of up to steps shows that no violation of a safety property §1.11, a property saying that something bad never happens, occurs within steps; a longer sequence may still violate it. A liveness property §1.12, which says that something good eventually happens, is never violated by a finite sequence alone, so checking finite sequences one at a time cannot establish it. A model checker establishes liveness for a finite model by searching the graph of reachable states for a cycle in which the good event never happens.
Small scopes and scaled-down domains
Most enumerations use a domain far smaller than the real one, for example version numbers 0 to 3 instead of 32-bit numbers, or two possible values for a nonce §5.18, a number meant to be used only once, instead of . Two arguments connect such a result to the real system.
The small-scope hypothesis, stated by Daniel Jackson for the Alloy analyzer, a tool that checks a design against every instance up to a size bound called the scope, says that most errors have small counterexamples: cases with few objects or few steps that already show the error. It is an observation from experience, supported by some empirical studies, not a theorem. A clean result in a small scope is good evidence that a design has no shallow errors, not a proof that it has none.
A finite-domain abstraction replaces a large domain with a small one chosen so that the behavior the property depends on survives.
If the system only stores values and compares them for equality, never doing arithmetic on them, only the pattern of which values are equal matters. Such a system is called data-independent, a notion that Pierre Wolper introduced in 1986 [494]. For data-independent systems, published theorems show that, for a stated class of properties, a small fixed number of distinct values gives the same answer as all values.
If the system compares values by size, the small domain needs at least as many values as can be present at once, or some orderings are never explored.
If the system does arithmetic that wraps, the small domain must wrap the same way. Two-bit values that wrap from 3 to 0 reproduce 32-bit wraparound, as in the worked example; a model that simply forbids values above 3 never reaches wraparound.
What lies outside a scaled-down domain must be listed as outside: behavior at the real largest value, where a counter wraps or a table is full; the probability of rare events, such as two random 128-bit values being equal, which a model with two possible values makes common or rules out; limits on memory and storage; timing; and every dimension held fixed, such as power failing in the middle of a write.
Limits and common mistakes
A wrong oracle approves wrong behavior in every case. If the oracle shares an error with the implementation, for example because both were written from the same misreading of the specification, the enumeration passes completely and proves nothing.
A generator meant to produce every case can silently produce fewer, for example through a loop bound that stops one value short of the largest value. Comparing the number of cases run with the computed size of the domain catches this; a count of passes alone does not.
Exhaustive over a domain is not exhaustive over the program. Other inputs, configurations, compilers and hardware lie outside the result unless they were dimensions of the domain.
Questions answered
Exactly which dimensions and bounds were enumerated?
A claim of exhaustive enumeration must state every dimension that varied with its exact bound, every dimension held fixed, the oracle, every rule that pruned cases, and the number of cases run compared with the size of the domain. A complete answer has this shape.
Varied: each input with its width or range, for example offset, length and size, each a 2-bit unsigned value from 0 to 3 with sums taken modulo 4; the initial states; the operations; the largest sequence length; and the thread interleavings, if any.
Held fixed: the configuration, the build, the memory size, the timing, and every environment event that was not modeled, such as power loss.
Oracle: the property, and how its expected answer was computed.
Pruning: each rule that removed cases, why it is safe, and how many cases it removed.
Accounting: the size of the domain (here ) and the numbers of cases run, passed, failed, skipped and timed out.
The result then holds for exactly that domain. Extending it to the real system, for example from 2-bit to 32-bit values, needs a separate argument: a proof that the property does not depend on the width, or weaker evidence such as the small-scope hypothesis, the observation that most errors already show up in small cases, which supports the extension but does not prove it.
Related entries: Test oracle (§10.5), Model-based testing (§10.34), Signed versus unsigned comparison (§2.12), Bounded model checking (§3.29), Model checking (§3.30), State explosion (§3.26), Overflow-safe range check (§4.17). Further reading: [494].