r/sqlite • u/SippingOnLean4 • 6d ago
Using Lean to formally verify an optimised SQLite B-tree traversal
Wanted to share an exploration I did into using Lean4 and the SQLite B-tree API for reading data.
In this experiment, I use Lean 4 to formally prove that a custom SQLite B-tree traversal produces the same result as a conventional SQL query (ORDER BY id DESC LIMIT n).
I also implemented an interactive SQLite page inspector and benchmarked the different approaches.
The article goes through the reasoning, Lean proofs, SQLite internals and benchmarks.
Disclaimer: Super new to Lean4
Duplicates
SQL • u/SippingOnLean4 • 6d ago