Lean 4 and differential testing expose 17 unreported bugs in Clojure's core

I checked Clojure's core with Lean and found unreported bugs

Lean 4 and differential testing expose 17 unreported bugs in Clojure's core

After reading how Lean 4 formal verification uncovered bugs in popular Rust projects, the author applied the same approach to Clojure's Java core. Modeling integer and bit arithmetic in Lean and running differential tests against java.util collections, they found 17 bugs not reported in Clojure's JIRA or ask.clojure.org. These include an infinite loop in reduce on vector-of, a HAMT collision node losing keys after dissoc, and inconsistent removeIf behavior with type hints. The HAMT and vector trees themselves passed millions of operations.

The HAMT itself showed no mismatch in 3 million operations of differential testing, and the vector tree showed none around its boundaries. The bugs sat in separate code outside the trees, and in places where two mechanisms meet, such as = and hashing.

More from this day

2026-11-25