Formally verified 3D CSG mesh intersection: trust 93 lines of spec, not AI code

✍️ OpenClawRadar📅 Published: July 29, 2026🔗 Source
Formally verified 3D CSG mesh intersection: trust 93 lines of spec, not AI code
Ad

A new project, verified-3d-mesh-intersection, implements a formally verified 3D constructive solid geometry (CSG) mesh intersection in Lean 4. The key idea: trust only 93 lines of formal specification, not the 1000+ lines of AI-written implementation code. The AI automatically wrote over 60,000 lines of Lean proofs, which never need human review — the Lean checker guarantees correctness at compile time.

How it works

The specification pins down the exact surface of the resulting mesh and guarantees well-formedness conditions on the triangulation. The core identity:

solid (meshIntersect M1 M2) = solid M1 ∩ solid M2

where solid represents the infinite set of points inside a mesh. Lean can reason about these infinite sets and prove the equality exactly.

Ad

Key details

  • Language: Lean 4, compiled to WebAssembly via emcc-wasm.sh.
  • Performance: 24 seconds to intersect two 70k-triangle Stanford bunny meshes. Slow but prioritizes verification over speed.
  • Web demo: Runs the verified kernel in-browser at schildep.github.io/verified-3d-mesh-intersection. Supports STL import. No data sent to server.
  • Human review: Only the 93-line spec needs reading. The 1000+ lines of AI implementation and 60k+ lines of AI proofs are treated as black boxes.
  • Well-formedness: If inputs are not well-formed (e.g., non-closed or self-intersecting), the algorithm must detect and report correctly — formalized in the spec.

Who it's for

Developers working with 3D geometry, CSG operations, or formal verification, especially those skeptical of trusting AI-generated code without guarantees.

Architecture

The repository contains the Lean kernel (CSG/), a C wrapper (wrapper.c), and web glue code (web/). Build commands are provided via lakefile.lean, emcc-wasm.sh, and build_web_demo.sh. The UI and glue code are not formally verified.

📖 Read the full source: HN LLM Tools

Ad

👀 See Also