SeQLean: Verifying SQL queries using Lean
Siddhartha Gadgil, Anirudh Gupta, Ajay Kumar Nair
Key points
From the paper's conclusion- We present SeQLean, a system that uses formal verification in Lean to increase the accuracy of translation from natural language to SQL.
Abstract
We present SeQLean, a system that uses formal verification in Lean to increase the accuracy of translation from natural language to SQL. This is based on modelling SQL in Lean via relational algebras. Since we do not have a translation known to be correct, we cannot directly prove correctness. Instead, we use proof challenges: tests of internal consistency that are unlikely to be satisfied by an incorrect translation. The simplest proof challenge is based on generating two translations of the same natural language query into SQL, ideally with one being optimized for performance and the other for understandability. If two translations are equivalent, they must give the same answer for every database. This can be checked using proof automation in Lean. Using Lean allows us to have essentially arbitrary properties as proof challenges, and also check these (including equivalence) taking into account known properties of the underlying database system. Even for equivalence queries of an arithmetic nature, we show that Lean can be more powerful than traditional tools due to the availability of Mathlib theorems. A JSON API over HTTP allows the verifier to be integrated into agentic frameworks.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Verified Proof Refactoring with Codex and QwenarXiv · 2026
- SemantEq: Faithful Bidirectional Equivalence of Formal StatementsarXiv · 2026
- Lean Finder V2: Semantic Search for Mathlib That Disambiguates User QueriesarXiv · 2026
- Efficient Proof Generation for Lean Statements with Multiple Candidate AnswersarXiv · 2026
- Fyan: A Human--AI Harness with Semantic Auditing for Document-Level FormalizationarXiv · 2026
- PaperFormalizer: Author-in-the-Loop Autoformalization of Research Papers in LeanarXiv · 2026