MINDRAQResearch & insights

Counterexamples Before Confidence: Find, Shrink, and Prove

Find and shrink countermodels without breaking their premises. Learn when a clean bounded check misses a witness and when it can settle the entire rule.

The failure needs a companion

In a fictional telemetry pipeline, a symbolic pre-release check covers every batch with at most one reading. After release, a batch containing zero and a positive reading passes the validator. The downstream normalizer divides by zero because it uses each reading as a divisor under a contract that promises positive readings.

The validator accepts a finite set S of integer readings when every member is nonnegative and some member is positive. Call those premises Γ and the downstream claim that every member is positive C. Sets suffice for these predicates because repeating a value changes neither condition. A contract about how often a reading occurs would need to preserve multiplicity.

The countermodel query Γ ∧ ¬C asks for a batch that the validator accepts and that falsifies the downstream claim. Negating C requires a member z ≤ 0. The nonnegativity premise forces z = 0. Acceptance also requires a member p > 0, so z and p must be distinct. Every countermodel therefore has at least two readings, and {0, 1} reaches that bound. The batch {1} separately establishes that Γ is satisfiable. An exhaustive search capped at one reading reports bounded-none (no countermodel exists within the cap). The gate misses the fault even though it covers every integer value at that batch size.

Sampling positives misses zero. A negative reading falsifies C alone but invalidates the batch. Testing Γ ∧ ¬C preserves both the boundary value and its required companion.

A smaller batch still has to pass admission

Start from {0, 2, 7, 11}. Try deletions in ascending order, checking acceptance and falsification after each edit. Deleting 0 leaves {2, 7, 11}, which satisfies C and is no longer a countermodel. Deleting 2 leaves {0, 7, 11}, and deleting 7 from that batch leaves {0, 11}. Both edits preserve the countermodel. Deleting 11 from the retained batch leaves {0}, which has no positive reading.

Order verified witnesses first by cardinality and then by the sum of absolute readings. Replacing 11 with 1 in {0, 11} gives {0, 1}. Replacing it with 0 would collapse the set to a singleton and lose the positive reading.

Suppose the validator also requires exactly four distinct readings to populate four slots in a calibration table keyed by reading value. Every deletion violates that contract. Start again from {0, 2, 7, 11} and replace 11 with 1, then 7 with 3. The sums fall from 20 to 10 to 6 while the batch size holds at four. The final sum is optimal because the sorted nonnegative distinct integers must be at least 0, 1, 2, and 3 in their respective positions. That lower bound is attainable because {0, 1, 2, 3} still passes admission and contains zero.

Delete the credential override as a unit

A deletion pass can stall even when the contract permits smaller inputs. In a fictional service configuration, a required HTTPS listener obtains its credentials from a managed store. An optional local override consists of a certificate path and a key path. The schema permits both fields together or neither. An independent optional legacy listener serves plain HTTP. The disputed invariant is that every enabled listener uses TLS.

With all three optional entries present, the schema accepts the configuration and the HTTP listener violates the invariant. Deleting either override field alone invalidates the configuration while leaving the plain HTTP entry in the candidate. Deleting the other override field restores validity. The required listener uses managed credentials again, and the legacy listener still serves plain HTTP. Deleting the legacy listener alone preserves schema validity and leaves only HTTPS.

Figure 1 — Illustrative configuration edits, not measured data. Each row starts from the original configuration. “Excluded” means the schema rejects the candidate despite the surviving HTTP entry. “Lost” marks a valid edit that removes the transport failure. Only the paired deletion yields a smaller admissible countermodel.

Treating the override as one edit follows the schema's dependency structure and crosses the gap without testing arbitrary field pairs. Restarting a single-deletion pass after each accepted edit lets the shrinker revisit fields whose removability depends on earlier edits. With n optional fields it scans at most n candidates per pass and runs at most n + 1 passes. The scan count grows at most quadratically. In Figure 1 every single deletion fails to preserve the countermodel, so the restart strategy has no accepted edit to build on.

With no dependency groups available, use Zeller and Hildebrandt's minimizing delta debugging algorithm, ddmin. Hold the required listener fixed, partition the optional entries into chunks, and test both each chunk on its own and its complement. Keep a candidate only when it passes the schema and still violates the TLS invariant. A partition that places the two override paths in one chunk lets the complement delete both in a single test. When no candidate works, try finer partitions. Chunking can skip several single deletions, but a partition that separates coupled fields can miss the useful removal, and ddmin can still take quadratically many tests. Definitive checks of all remaining single deletions establish that no individual entry can go. A timeout leaves that claim open, and proving minimum cardinality would require stronger evidence because an untested combination could still work.

Each route gets its own reason to fail

Add a routing requirement to the same batch validator. Write E(r, x) for “route r is eligible for reading x.” The per-reading check requires ∀x ∈ S ∃r E(r, x). The batch router needs ∃r ∀x ∈ S E(r, x) because it sends the whole batch to one route.

The countermodel query keeps numeric acceptance and per-reading eligibility as premises and negates the shared-route claim. In a fictional two-route configuration, A is eligible only for 0 and B only for 1. The batch {0, 1} passes both premises. Reading 1 rules out A, and reading 0 rules out B.

Even a stronger precheck that requires every pair to share a route can miss the failure. In the illustrative batch {0, 1, 2}, assign the readings eligibility sets {A, B}, {B, C}, and {A, C}, respectively. Readings 0 and 1 share B, 1 and 2 share C, and 2 and 0 share A. All three readings together have an empty intersection. Among nonempty batches, three readings are the minimum for a failure that passes both individual eligibility and pairwise sharing. A singleton already has a route by individual eligibility, and for a two-reading batch the pair is the entire batch.

Figure 2 — Illustrative route assignments, not measured data. Each pair of reading circles meets at a route diamond. Every diamond touches exactly two of the three circles, so none can take the whole batch.

For a fixed inventory of m candidate routes, take one blocking reading per route from any failing batch. These readings inherit nonnegativity and individual eligibility. They also include a positive reading. If zero were the only retained value, it would block every route, contradicting its individual eligibility. The resulting batch still fails with at most m readings. Pairwise sharing survives because each retained pair occurred in the original batch. This argument assumes E depends only on the route and reading. If eligibility depends on total batch load, removing readings can make a formerly blocked route available. Figure 2 attains the three-route bound because each reading blocks a different route. The bound caps the number of readings to encode, while the readings themselves still range over integers.

What the singleton search actually covers

Check whether Γ itself has a model. Adding “no reading is positive” contradicts the positive-reading requirement and makes Γ ∧ ¬C unsatisfiable for any C. A verified countermodel already establishes premise satisfiability.

For the original numeric query, every countermodel supplies integers z ≥ 0, z ≤ 0, and p > 0. Every solution to these constraints yields the batch {z, p}. To rediscover the fault by search, compare the batch-size cap with the proved minimum before submitting the query. A cap of one excludes every witness by construction. A cap of two includes {0, 1}, provided the encoding also admits both integer values. Replay the pair directly when the goal is to check the known regression. Use the search when the goal is to find other admissible failures.

An array with k slots and an active length between zero and k can represent every set of size at most k. Pack distinct entries into the active prefix and constrain the validator and claim to read only that prefix. At length zero, universal conditions hold vacuously and existential conditions fail. An array of exactly k active slots with duplicates allowed can represent smaller nonempty sets by repeating a value. For positive k, the empty set requires an inactive slot convention. With either representation, any predicate about set cardinality must count distinct active values if repeats are allowed. Before treating an unsatisfiable result as definitive within the cap, check that every in-scope countermodel has an encoded representative. When the solver supplies a model, decode it and replay the original validator and downstream predicate on the resulting batch.

When one element settles the rule

In the Bernays–Schönfinkel–Ramsey fragment, sentences have an ∃*∀* prefix followed by a quantifier-free matrix. The vocabulary is relational, with equality and constants allowed and no function symbols of positive arity. If the sentence is satisfiable, it has a model of size at most max(1, #∃ + #constants), counting existential variables and constant symbols occurring in the sentence.

Keep the witnesses and constant values from a satisfying model, or one arbitrary element if there are none. Restrict each relation to those elements. Atoms, including equalities, retain their truth values there, so the matrix still holds for every retained universal tuple.

For an illustrative query inside the fragment, take Γ to be ∀x (Ready(x) → Configured(x)) and C to be ∀y (Ready(y) → Encrypted(y)). Treat all three predicates as uninterpreted. The combined query is ∃y ∀x (Ready(y) ∧ ¬Encrypted(y) ∧ (Ready(x) → Configured(x))). One existential variable and no constants give a small-model bound of one element. A domain containing only a ready, configured, unencrypted element realizes the countermodel.

Now add ∀x (Configured(x) → Encrypted(x)) to Γ. The small-model bound stays at one element. The sole element must be ready and unencrypted to witness ¬C, but the premises force it to be configured and therefore encrypted. The query is unsatisfiable on one element. The small-model property rules out any larger countermodel because it would yield a singleton countermodel. A singleton with a ready, configured, encrypted element satisfies the strengthened premises, so they entail C without vacuity. For larger formulas in the fragment, instantiating the matrix at every assignment of u universal variables over a domain of size d takes dᵘ instances before simplification. The small-model bound caps d, while adding a universal variable multiplies the number of assignments by d at the same domain size.

Apply the fragment test to the combined query. The negation of the routing conclusion is ∀r ∃x ∈ S ¬E(r, x). It puts a dependent existential after a universal, as does the per-reading eligibility premise. The fragment theorem therefore gives no domain bound for that encoding. The numeric query also falls outside the theorem because it uses fixed integer order. Retaining z and p suffices to shrink the batch, while the integer domain in which their inequalities hold stays intact.

Resolve the contract at zero

Replay {0, 1} at the boundary that owns the fix. If the validator promises positive divisors, require rejection of the pair and acceptance of {1}, so rejecting every batch fails the regression. If zero belongs in the telemetry contract, require the pair to pass admission and assert the specified zero-handling outcome alongside the normal output for 1. Otherwise a normalizer that discards the whole batch could pass a test that checks only for the absence of a division error.