← All stories
● Covered by 1 source · 1 reportMedium impact1 neutral

Formal Verification with Lean 4 Uncovers 17 Unreported Bugs in Clojure Core

🔄 Updated 22h ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • Lean 4 used to verify Clojure 1.12.7 core functions.
  • 17 unreported bugs found in integer/bit arithmetic and specific data structure interactions.
  • Bugs located outside core tree structures, at mechanism intersections.
  • HAMT and vector tree structures showed no mismatches in differential testing.

Lean 4 Verification Process

Inspired by a similar verification effort on Rust projects, a developer applied Lean 4 to parts of Clojure's core library. The process involved modeling small Clojure functions, particularly those involving integer and bit arithmetic, as Lean definitions. Properties were then written to compare these models against naive specifications, with `bv_decide` used to search for counterexamples.

Bug Discovery and Reproduction

When Lean 4 identified a counterexample, the input was translated back to Clojure to reproduce the bug in the original code. After confirming the bug, the corrected code was modeled in Lean, and the same property was proven. This method allowed for precise identification and validation of issues.

Differential Testing for Data Structures

For larger persistent data structures, such as Clojure's HAMT (PersistentHashMap) and vector trees, differential testing was employed. This involved applying identical random operation sequences to both Clojure's implementations and `java.util` equivalents, then comparing the results. The HAMT showed no mismatches across 3 million operations, and the vector tree also performed correctly around its boundaries.

Nature of the Discovered Bugs

A total of 17 previously unreported bugs were found in Clojure 1.12.7, which was released on 2026-11-18 and tested with JDK 21. These bugs were not present in Clojure's JIRA or on ask.clojure.org. The issues included problems with `reduce` on `vector-of`, specific behaviors in the hash collision node of the HAMT, and calls to functional interfaces lacking type hints. The bugs were generally located in code separate from the main tree structures, often at the intersection points of different mechanisms like equality (`=`) and hashing.

Implications for Clojure Development

The discovery highlights that even mature and widely used codebases can contain subtle bugs, particularly in areas involving complex interactions of primitive operations or edge cases in data structure implementations. Formal verification tools like Lean 4 can provide a rigorous method for uncovering such issues that might be missed by traditional testing methods.

✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →

The daily brief

One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.

One email a day. Unsubscribe in one click, any time.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~4 min · 3 stories · Nov 26

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

A developer used the Lean 4 theorem prover to formally verify parts of Clojure's core library, specifically focusing on integer and bit arithmetic, and found 17 previously unreported bugs. The issues were identified in areas like `reduce` on `vector-of`, hash collision nodes in HAMT, and functional interface calls without type hints, despite extensive prior use of Clojure's data structures.