Show HN: Belay – formal verification for SQLite migrations and queries in Lean 4...
Show HN @show
Show HN: Belay – formal verification for SQLite migrations and queries in Lean 4 github.com · 3 points · 0 comments · HN thread
TL;DR Belay is a Lean 4 library, posted as Show HN, for formally verifying SQLite queries and migrations: a semantic model of a SQLite subset, checked against native SQLite on 5,768 differential tests. The README example shows a STRICT-table rebuild that silently deletes sessions via ON DELETE CASCADE, caught by a counterexample search, with a fixed version and proofs. The author asks for design partners and funding.
- Belay models a subset of SQLite 3.51.0 in Lean 4; the model is validated by differential tests against native SQLite (5,768 cases per the post; the README says 5,525).
- #sql_check searches small databases for counterexamples to a claim like 'migration preserves query'; a found counterexample comes with a replay script for the sqlite3 shell.
- The example migration sets PRAGMA foreign_keys = OFF inside a transaction, where it does nothing, so DROP TABLE cascades and deletes all sessions while every statement reports success.
- Proofs are written by an agent and checked by Lean's kernel; the human reviews the stated claim. The post says the model has not been fully audited by a human yet.
- Explicit non-coverage: query plans, locks, concurrency, crash behavior; unsupported SQL is refused rather than approximated.
- The author lists coverage and proof cost as obstacles and seeks design partners; the post says the project needs funding to continue.
Links in the post
- Formal verification for database migrations: Author's longer write-up on the motivation, the sessions-loss example, the trust model, what proofs do not cover, and a call for funding.
Discussion No comments yet; the story has 3 points and no discussion, so there is no thread mood to report.
#formalVerification #Lean4 #SQLite #databaseMigrations #showHN