Back to browse
GitHub Repository

Formally verified 3D mesh intersection - trust 93 lines of spec, not 1000+ lines of AI-written code

2 starsLean

Formally verified 3D CSG: Trust 93 lines spec, not 1000 lines AI code

by permute·Jul 28, 2026·113 points·48 comments

AI Analysis

●●●●GemWizardryBig BrainZero to One

First formally verified 3D CSG operation where humans only trust 93 lines of spec.

Strengths
  • AI autonomously generated 60,000 lines of Lean proofs that require zero human review.
  • Lean checker guarantees correctness at compile time with mathematical certainty.
  • Web demo runs verified kernel locally in browser with no server-side computation.
Weaknesses
  • 24 seconds to intersect two 70k-triangle meshes is too slow for production CAD workflows.
  • Only intersection operation verified; union and difference operations remain unimplemented.
Category
Target Audience

Formal methods researchers and CAD/graphics engineers

Post Description

To my knowledge, this is the first formally verified implementation of a 3D constructive solid geometry (CSG) operation: mesh intersection, implemented in Lean 4 and verified against a concise specification that pins down the surface of the resulting mesh exactly and guarantees practical well-formedness conditions on the triangulation.

This project is also an experiment in avoiding having to trust AI-generated code. A human reviewer only needs to read 93 lines of formal specification and run the Lean checker to certify the correctness of the kernel, skipping the intricate 1000+ lines of AI-written implementation. To prove correctness, AI autonomously wrote over 60,000 lines of Lean proofs, which also never have to be inspected by a human. The Lean checker guarantees conformance to the specification at compile time, with zero trust placed in any LLM. This allows us to treat the implementation and proofs as a black box. I guided the agent through the milestones described in the readme to arrive at the result presented here.

Also take a look at the web demo https://schildep.github.io/verified-3d-mesh-intersection/, which runs the verified mesh intersection kernel compiled to WebAssembly in your browser.

Similar Projects