Lean Proofs Verify Agent-Found Optimizations: DuckDB Query 9x Faster With Identical Results

paraschopra · x · 2026-12-06

Paras Chopra suggests using Lean to formally prove that optimizations and speedups found by coding agents don't change results — "literal free alpha."

Example: a DuckDB dashboard query got 9x faster and used one-third the RAM (1.80 → 0.20s, 547 → 182 MiB peak memory) against a stronger native baseline, with all 64 counts matching on 3.48M taxi trips. The trick: for each fare cutoff, keep the longest qualifying trip to each destination — one number answers every distance cutoff without rebuilding distinct-destination sets. Lean checked why this preserves the counts.

Original post →

More from coding & agent

coding & agent channel →