Opus 4.8 Autonomously Verifies Polygon Intersection in Lean
Get the Tech newsletter
Daily tech — startups, AI labs, chips, the launches that shape the next decade. Free.
- The verified polygon intersection project is, per its author, the first formally verified implementation of a multipolygon intersection algorithm, with correctness guaranteed by the Lean 4 proof assistant rather than testing.
- Claude Opus 4.8 wrote the implementation and its formal proofs autonomously in ...Proofs.lean and ...Impl.lean files; human review is limited to 87 lines of specification across three files, with trust resting on the Lean checker, not the LLM.
- Opus 4.8's day-after-release test ran two parallel sessions, one reproving the main theorem from scratch in an isolated container with no hints, and another handling overlapping-segment edge cases where Opus 4.7 had stalled — both succeeded within a few hours of autonomous work.
- The proof dependency surface is narrow: the correctness theorem relies only on the trusted axioms propext, Classical.choice, and Quot.sound, and can be inspected via a single lake env lean command.
- A practical tradeoff the author flags: forcing AI agents to formally verify their output tends to yield slower code that ignores other engineering concerns, likely because simpler code verifies more easily and formally verified production software is scarce in training data.
- The verification bulk came not from the algorithm itself but from proving seemingly obvious geometric facts — for instance, establishing that the ray-intersection "inside" definition is direction-independent took thousands of Lean lines.
- Prior related work includes Di Vito and Hocking's NASA Formal Methods 2021 verification of a polygon merge algorithm in PVS, which combined two overlapping simple polygons without handling holes or multipolygons.
Why it matters: For AI-assisted formal verification, the jump from Opus 4.7 to 4.8 is material: a project that had stalled for months completed autonomously in hours, without human proof strategies. The catch the source itself surfaces — that formally verifiable code is simpler and slower code — sets a real ceiling on how directly this recipe ports to performance-sensitive software.

