TL;DR
SITA (Structure-to-Instance Theorem Autoformalization) is an end-to-end framework that translates informal, domain-specific mathematical problems into verified Lean 4 code. Instead of formalizing isolated statements from scratch, SITA leverages pre-formalized abstract structures (like gradient descent or ADMM), instantiates them on concrete tasks (like Lasso or image denoising) via Lean’s typeclass system, and verifies structural conditions using compiler-in-the-loop LLM refinement.
What Problem Does This Paper Address?
Most autoformalization research focuses on Olympiad-style math puzzles—translating standalone natural language questions into isolated formal statements. However, real-world and research-level mathematics rarely works in isolation. Instead, mathematicians rely heavily on structure-to-instance reasoning: they prove an abstract theorem once under general conditions (e.g., convergence guarantees for proximal gradient methods) and then reuse that theorem across dozens of applied problems (e.g., Lasso, matrix completion) by simply proving that the concrete instance satisfies the abstract assumptions.
Directly prompting large language models (LLMs) to write complete Lean files that implement this pattern fails completely (achieving 0% file-level compilation in baselines). LLMs struggle to properly define custom types, hook them into typeclasses, satisfy structural constraints, and eliminate type errors across entire multi-component files.
Methods
SITA decomposes abstract mathematical theories into four-tuples: $\mathcal{S} = \langle \mathcal{D}, \mathcal{O}, \mathcal{C}, \mathcal{T} \rangle$ (Definitions, Operations, Conditions, Theorems). The pipeline then automates the specialization to an instance $\mathcal{I}$ through three stages:
- Skeleton Construction: Given an informal problem description, SITA retrieves a formal template for the corresponding abstract structure. Using one-shot prompting, it generates instance definitions, operation classes, target theorems, and Lean typeclass declarations that tie the concrete problem to the abstract structure.
- Feedback-Driven Error Fix & Proof Refinement:
- Rule-Based Fixer: Applies deterministic rewrites to resolve common syntax, notation, and formatting issues.
- Retrieval-Augmented Automatic Fixer: When Lean’s compiler outputs type errors, the system queries an evolving Error Knowledge Base ($\mathcal{K}$) that pairs past error traces with proven repair strategies and Lean library tactics.
- Proof Refinement: For valid skeletons, the LLM attempts whole-proof synthesis to discharge instance-level assumptions (replacing
sorryplaceholders). - Output Postprocessing & Backtranslation: Safely handles stubborn errors, logs intermediate artifacts, and includes a backtranslator that maps formal Lean code back into natural language to create bi-directional datasets.
Informal Problem + Abstract Template
──> [Skeleton Construction]
──> [Static & Type-Checker Error Fix Loop (via Knowledge Base)]
──> [Proof Refinement for Assumption Verification]
──> Verified Lean Artifact
Datasets
- Optimization Benchmark: The authors created a benchmark of 42 representative numerical optimization problems from standard textbooks, spanning constrained/unconstrained and convex/nonconvex objectives across five major algorithmic paradigms:
- Gradient Descent (GD)
- Proximal Gradient Method (PGM)
- Nesterov’s Acceleration
- Block Coordinate Descent (BCD)
- Alternating Direction Method of Multipliers (ADMM)
- Base Libraries: The formalized abstract structures build upon Mathlib and Optlib.
- Opt-bench (Produced Artifact): The pipeline generated 88 successfully compiling Lean files containing 449 formal theorems, with 222 completely proved without
sorry.
Key Insights and Ideas
- Modular Proof Reuse Beats Proving from Scratch: Verifying that a specific objective function is Lipschitz-continuous or convex is far easier than re-proving convergence theorems from the ground up for every applied problem.
- Typeclasses as the Glue: Lean’s typeclass system is uniquely suited to structure-to-instance reasoning. SITA explicitly targets Lean
instancedeclarations to inherit abstract properties automatically. - Errors are Highly Localized: Even when end-to-end file compilation fails, over 90% of individual definitions and theorem statements generated by SITA are syntactically sound. Most failures stem from a few complex or ambiguous constraints.
- Self-Improving Error Memory: Querying an evolving database of prior Lean error logs dramatically stabilizes LLM code repair, outperforming naive few-shot re-prompting.
Key Results
The authors evaluated SITA against direct whole-file generation using DeepSeek-V3 and DeepSeek-R1:
| Method | Def Syntax | Thm Syntax | Instance Syntax | Full File Success | Majority Vote (0–100) |
|---|---|---|---|---|---|
| Direct-V3 | 27.9% | 28.0% | 22.8% | 0.0% | 50.2 |
| Direct-R1 | 62.8% | 25.6% | 25.7% | 0.0% | 46.0 |
| SITA-V3 | 91.0% | 86.7% | 90.8% | 27.2% | 66.1 |
| SITA-R1 | 93.8% | 95.6% | 95.4% | 57.14% | 76.9 |
- Zero-to-Fifty: Direct prompting completely failed to generate a single type-checking file (0.0%), whereas SITA-R1 achieved a 57.14% full-file compilation success rate.
- Autonomous Proving: Within successfully compiled files, SITA automatically proved 51.23% of all subgoals and condition checks (reaching >63% on simpler frameworks like Nesterov and PGM).
Limitations and Future Work
- Domain Scope: The current evaluation focuses on numerical optimization. While the conceptual framing applies broadly (e.g., abstract algebra, signal processing), templates for other fields must be implemented.
- Deep Domain Proofs: Current LLMs struggle to discharge intricate, non-trivial condition verifications autonomously (such as checking the Kurdyka–Łojasiewicz property in nonconvex settings), requiring manual fallback or leaving
sorryplaceholders. - Compute Overhead: Iterative code correction dominates runtime, with backbone and proof error repairs accounting for 79% of total execution time.
Summary updated