CleverLang: fast software you can prove

CleverLang is a programming language that finds what testing can’t.

This is a story about one small function.

It finds the middle of two numbers. What could go wrong?

This many ways to call it.

Two 64-bit numbers go in. You could try every pair.

The obvious code looks fine.

Add, then halve. Binary searches shipped this mistake for years.

Until you look closer.

CleverLang found the pair that breaks it. The sum wraps around, and the middle comes out as zero.

So write down what must always be true.

A law sits beside the code. Fix the function, and CleverLang has to prove the law holds.

Every input. Proven.

None left to check. All 2128 pairs, in about 6 seconds on an M5 Max.

Then the checks vanish.

CleverLang guards sums by default. It proved neither guard could fire, and the corrected function became five instructions and a return.

One source. Everywhere.

The same loop, compiled to C and three kinds of GPU code.