MoonBit 0.9 Brings First-Class Formal Verification for AI-Generated Code

Why this matters
As AI starts cranking out large swathes of production code, one nagging question gets louder: how do we know the code actually does what it’s supposed to do? It has been reported that a recent AI-generated hosted application appeared complete but contained critical authentication and permission bugs that led to a leak of tens of thousands of user records. Ouch. Testing and fuzzing catch many things, sure, but they’re sample-based. They don’t answer the stronger question: does this program always satisfy a critical property?
What’s new in MoonBit 0.9
MoonBit 0.9 ships a set of machine-checked proof capabilities explicitly built for AI collaboration. The compiler and toolchain let developers (and AIs) write contracts, predicates, and loop invariants alongside the code, then automatically construct and check nontrivial proofs that implementations meet those specifications. Want an example? The release demonstrates a fully verified binary-search implementation with proof_requires and proof_ensures contracts, a separate predicate file that pins down “sorted” and “correctness” mathematically, and loop invariants that bridge code and logic. These are not comments. They’re constraints the machine verifies.
The promise—and the caveats
The MoonBit team claims this is a breakthrough for scaling verifiable code, and it has been reported that they frame 0.9 as the first of its kind for AI-assisted proof generation. If true, this could change how we think about software safety: instead of hoping tests covered the right cases, you describe the property and the machine checks it. But caveats apply—proofs only buy you guarantees under sound assumptions, and tooling and adoption remain hurdles. Can formal proofs keep pace with the rush of generated code? Maybe. It won’t be a silver bullet, but it’s one of the clearest paths out of the “it seemed to work” trap.
Sources: moonbitlang.com, Lobsters
Comments