News for hackers. Stuff that matters.
Re:Show HN: Formally verified 3D CSG: Trust 93 lines spec, n... by peetle on Tuesday July 28, 2026 @11:36AM (#49085508)
This is a really cool project. Love it. Why not extend to union, difference, and xor? Is that exercise left to the reader or is it not tractable? ;)

I'm also curious if you've consider fuzz testing this system to verify the results.

Re:Show HN: Formally verified 3D CSG: Trust 93 lines spec, n... by permute on Tuesday July 28, 2026 @12:17PM (#49086156)
Regarding fuzzing. It cannot find the special cases I listed in the readme, because these cases are very rare.

Yet with formal verification we can prove that the implementation actually satisfies the specification for all of infinitely many possible inputs.

Re:Show HN: Formally verified 3D CSG: Trust 93 lines spec, n... by permute on Tuesday July 28, 2026 @12:10PM (#49086056)
Good question!

One complication: For union the spec would look a little bit different than for intersection. I defined the solid associated to a mesh in a way that does not include the surface of the mesh itself. That works for the intersection. For union we would have:

solidWithSurface (meshUnion M₁ M₂) = solidWithSurface M₁ ∪ solidWithSurface M₂

I think it would not be hard to reduce the implementation and the proof of correctness to the intersection: There are some tricks which you can do like flipping the orientation of a mesh and putting a large cube that contains both meshes around it and then intersect these. (Hopefully the implementation would not actually do this, but this construction could be used in the proof.)