andrew f23d8a28d3
CI / build-and-check (push) Successful in 8m5s
Remove dispatch-redundant tests from fast.cpp
Two mutation rounds plus z3 checks found conditions that an enclosing
dispatch already decides, and two places that re-tested the same split.

* crossed complete: HeadBottom implies NonposBottom, so drop it; inline
  the clamp dispatch so EndOne/LongNonpos are not tested twice; after the
  failed strict ordering test the non-strict one is free.
* reversed truncation: the dispatch has failed end.offset <= 1, so
  BelowEnd does not need to re-test end.offset >= 2; the two TopCrossed
  cases split on end.key < last, so test that once; revTruncGeTwoLarge
  was a tautological split of TopLarge on isTop begin.
* TopLarge's sentinel re-tested TopLarge even though the caller had
  established it; only the sentinel test is needed.
* complete forward: begin is bottom exactly when clampsToBottom, and
  bottom <= end always, so the disjunction is just the key comparison.

z3 refutes the negation of each implication.  Sweep, golden, corpus, SMT,
extreme, and fuzz pass; fast.cpp stays at 100% line/branch coverage.
2026-11-18 14:31:52 -05:00

conflict-range

A closed-form algorithm that computes the minimal conflict range for an observed range read and result, based on the semantics used by FoundationDB.

See Statement.lean for definitions and the headline claim that the algorithm's output is minimal. Intuitively, the minimal range is the smallest range that preserves serializability (i.e. pinning this range pins the validity of any inference you can make from the observed range read and result), and the key set is unique: any two minimal ranges denote the same set of keys, though their endpoints may differ.

See cpp/src/fast.cpp for the C++20 implementation.

The rest of this README documents the Lean proof and the C++/test support for these claims.

Layout

Path Purpose
Statement.lean The statement: keys, selectors, reads, results, conflict ranges, soundness, minimality, and the closed form itself. It imports only Mathlib and states the definitions and headlines without using theorem, axiom, or sorry.
FormalConflictRange/ The reference development that proves the closed form minimal.
Bridge.lean Definitional bridge from Statement's types to the reference development, plus the transport lemmas.
Proof.lean Proves Statement.ClosedFormMinimal and Statement.MinimalUnique by transporting the reference theorems across the bridge.
Challenge.lean The same two headline statements with placeholder proofs (sorry). This is the trusted statement side of the comparator check.
Solution.lean The solution side of the comparator check; it imports Proof.
comparator.json Comparator configuration: challenge/solution modules, theorem names, and permitted axioms.
cpp/ A C++20 translation of closedForm, an equivalent summarised implementation, golden-vector and fuzz tests, and a benchmark. See cpp/README.md.

Build and check

lake exe cache get   # clean checkout: download Mathlib's prebuilt oleans
lake build
./scripts/check-axioms.sh
lake comparator

This repository pins Lean v4.35.0 and Mathlib v4.35.0 (lean-toolchain, lakefile.toml). lake exe cache get downloads Mathlib's prebuilt .olean files; without it a fresh clone compiles Mathlib from source. lake build then compiles the default targets (Statement and Proof, which pull in the reference development); run it before the checks so that a manifest is present and dependencies are resolved.

./scripts/check-axioms.sh prints the axiom dependencies of Statement.closedFormMinimal and Statement.minimalUnique and fails unless both are exactly [propext, Classical.choice, Quot.sound]. This catches sorry (sorryAx) and newly introduced axioms without needing the comparator sandbox.

lake comparator then builds Challenge and Solution independently and checks that the solution proves the challenge's statements and uses only propext, Quot.sound, and Classical.choice. It requires bubblewrap and either unprivileged user namespaces or a setuid-root bwrap; on systems where user namespaces are restricted, lake comparator will fail before checking the proof.

Status and scope

  • Statement.ClosedFormMinimal and Statement.MinimalUnique are proved, and no proof in Proof.lean, Bridge.lean, or FormalConflictRange/ uses sorry.
  • Challenge.lean deliberately contains sorry: it is the statement side of the comparator check, not part of the proof.
  • The headline argument is the closed-form development under FormalConflictRange/. FormalConflictRange/Algorithm.lean and FormalConflictRange/Prototype.lean also supply shared ingredients used by that development: the empty-result theory (emptyValue, EmptyInferenceWitness, minimal_emptyValue_of_emptyInference) and the ascending-key list and constraint collectors (ascendingKeys, emptyConstraints), respectively. Their partial-algorithm and prototype sections are earlier case-analysis and search material; those sections are not the route taken by the final closed-form proof.
  • The C++ tree is validated against Lean-generated golden vectors, by differential fuzzing, and by a deterministic finite sweep of small readable instances; cpp/README.md describes the model, the tests, the coverage check, and the benchmark. The summarised implementation has 100% line and branch coverage via cpp/run-coverage.sh.

Continuous integration

.gitea/workflows/ci.yml runs the Lean build, the axiom audit, and the C++ test suite (including the coverage gate) on pushes to main and on pull requests. It is written for Gitea Actions; a GitHub mirror would need an equivalent workflow under .github/workflows/.

License

Apache License 2.0; see LICENSE.

S
Description
A closed-form algorithm that computes the minimal conflict range for an observed range read and result.
Readme Apache-2.0
1.1 MiB
2 Watchers 0 Forks
Languages
Lean 97.5%
C++ 2.3%
Shell 0.1%