# LeanReviewBench: Semantic Alignment Review in Mathematical Lean Projects

> LeanReviewBench introduces the first benchmark for project-level semantic alignment review in Lean, showing GPT-6.1 Sol achieves 0.827 accuracy at detecting formalization errors.

- **Source:** [arXiv](https://arxiv.org/abs/2611.30361)
- **Published:** 2026-11-28
- **Permalink:** https://picx.dev/p/qTejH9
- **Whiteboard:** https://picx.dev/p/qTejH9/image

## Summary

## Summary (Overview)

- **LeanReviewBench** is a new benchmark for project-level semantic alignment review in Lean formalization projects, containing **197 versioned inputs** from **18 real Lean projects**, with **87 aligned** and **110 misaligned** reference judgments.
- The benchmark evaluates whether selected Lean declarations, interpreted through their project dependencies, preserve the mathematical content of independently sourced informal targets—addressing the gap between Lean's kernel verification and faithful specification.
- A novel construction pipeline combines **development-history discovery**, **independent target binding**, **reconstruction under a common Lean 4.34.1 environment**, and **GPT-6 Astra annotation with human review** of uncertain cases.
- The collection includes **69 historical pairs** (138 inputs) capturing real development changes, spanning diverse mathematical domains including analysis, number theory, geometry, probability, and applied modeling.
- Baseline evaluations of six language models show **GPT-6.1 Sol with Direct prompting achieves the highest accuracy (0.827)** and misalignment-detection F1 (0.844); prompting effects vary significantly across models.

## Introduction and Theoretical Foundation

### Background and Motivation

The paper addresses a critical gap in formal verification: while Lean provides machine checking of formal proofs, **proof correctness does not guarantee faithful specification**. The authors highlight a concrete example from OpenAI's HyperbolicObstruction manuscript, where the informal source requires a two-dimensional simplicial complex, but the formalization omits this requirement.

### The Semantic Alignment Problem

In large Lean projects, alignment becomes more difficult because:
- A theorem's meaning can depend on **project-defined predicates, structures, and quantitative expressions** distributed across files.
- A condition absent from the displayed theorem type may be **encoded in a structure field**.
- A predicate with an appropriate name may **omit a substantive requirement**.

As the paper notes, for the Brownian Motion project's main theorem, Lean Atlas illustrates a dependency cone of 227 nodes, from which Lean Compass selects only 14 nodes for semantic verification.

### Task Definition

Each review instance is a triple:

$$x_t = (I_t, F_t, \mathcal{C})$$

comprising:
- **$I_t$**: an informal target (source-grounded mathematical claim with source definitions, notation, and standing assumptions)
- **$F_t$**: one or more selected Lean declarations (roots) that jointly express the target
- **$\mathcal{C}$**: a formal dependency context supplying the dependencies needed to interpret the roots

The reviewer returns a binary prediction:

$$\hat{y}_t \in \{\text{aligned, misaligned}\}$$

**Aligned** means $F_t$, interpreted through $\mathcal{C}$, preserves the mathematical content of $I_t$, allowing equivalent reformulations. **Misaligned** identifies a substantive semantic discrepancy, including strict strengthening or weakening of the target.

## Methodology

### Data Source Selection

Three criteria guide repository selection:
1. **Recent mathematical development**: Substantive formalization activity in 2026
2. **Traceable development history**: Commits, issues, or PRs allowing location of mathematical changes
3. **Source-grounded project-level formalization**: Coherent theory with identifiable mathematical source

Excluded repositories (OpenAI, Anthropic) lack traceable development history.

### Construction Pipeline

The pipeline consists of five stages:

**1. Historical Discovery**: Inspect author reports, documentation, commits, issues, and PRs to identify candidate roots and recover relevant source revisions. Snapshots are linked as before/after pairs when possible.

**2. Independent Target Binding**: Each root is bound to an identifiable mathematical claim from a paper, blueprint, or specification. Historical records guide discovery, but alignment is judged against the mathematical target independently.

**3. Historical Reconstruction**: Reconstruct historical sources under Lean 4.34.1 with pinned dependencies. File-level selection reduces scope (e.g., FormalSLT: from 119 files to 9 files containing ~80 declarations).

**4. Dependency Context Extraction**: Using LeanTrace, extract roots and declaration dependencies from the compiled environment. The traversal:
- Follows declaration dependencies from roots' elaborated types and defining values
- Includes predicate definitions and constructor types exposing inductive, structure, and class constraints
- **Retains mathematical definitions while excluding proof bodies** (replaced by `sorry`)
- Retains external-library references with identities and types but does not expand recursively

**5. Reference Review**: GPT-6 Astra in Codex provides initial annotations; uncertain cases go to a human annotator. Misalignment judgments include mathematical explanations tied to the informal target.

### Misalignment Classification

Discrepancies are classified into five categories:
- **O**: Object and concept mismatch (identity or interpretation of mathematical objects)
- **A**: Applicability mismatch (input domains or substantive premises)
- **Q**: Quantification mismatch (quantifier structure or witness dependence)
- **F**: Formula and quantitative mismatch (mathematical expressions or quantitative relations)
- **P**: Property and coverage mismatch (required properties or conclusion coverage)

## Empirical Validation / Results

### Data Distribution

**Table 2: Source repositories and mathematical categories** (selected rows)

| Repository | Category | Roots | Inputs |
|---|---|---|---|
| AlexKontorovich/PrimeNumberTheoremAnd | Analytic number theory | 21 | 40 |
| nikhgarg/AppliedModelingLib | Applied modeling and economics | 26 | 30 |
| teorth/pfr | Additive combinatorics | 14 | 24 |
| qinzlyang/differential-geometry | Differential geometry and topology | 10 | 15 |
| Verified-zkEVM/ArkLib | Cryptographic protocols | 7 | 12 |
| frenzymath/Poincare-Conjecture | Riemannian geometry | 12 | 11 |
| thefundamentaltheor3m/Sphere-Packing-Lean | Discrete geometry | 6 | 9 |

Key statistics:
- **197 versioned inputs** with 87 aligned and 110 misaligned labels
- **69 historical pairs** covering 138 inputs (70.1%)
- Median formal context size: **10 project-local declaration nodes** (range 1–425)
- Applicability mismatch is most frequent (48 inputs), followed by formula/quantitative (30), property/coverage (26), object/concept (22), and quantification (8)

### Model Evaluation

**Table 3: Comparison of prompting strategies on 197 evaluation instances**

| Model | Prompt | Accuracy | Valid output | Precision | Recall | F1 |
|---|---|---|---|---|---|---|
| **GPT-6.1 Sol** | **Direct** | **0.827** | 196 | **0.881** | 0.809 | **0.844** |
| GPT-6.1 Sol | ReForm | 0.746 | 194 | 0.721 | **0.927** | 0.811 |
| Qwen3.8 Max | Direct | 0.614 | 193 | 0.821 | 0.426 | 0.561 |
| Qwen3.8 Max | ReForm | 0.650 | 191 | 0.800 | 0.556 | 0.656 |
| Kimi K3.1 Pro | Direct | 0.701 | 196 | 0.871 | 0.555 | 0.678 |
| Kimi K3.1 Pro | ReForm | 0.777 | 192 | 0.863 | 0.759 | 0.808 |
| Qwen3.8 27B | Direct | 0.609 | 166 | 0.795 | 0.652 | 0.716 |
| Qwen3.8 27B | ReForm | 0.533 | 141 | 0.742 | 0.697 | 0.719 |
| Gemma 4 E4B | Direct | 0.492 | 188 | 0.710 | 0.212 | 0.326 |
| Gemma 4 E4B | ReForm | 0.137 | 42 | 0.789 | 0.577 | 0.667 |
| Jev 1.14 | Direct | 0.645 | 195 | 0.828 | 0.482 | 0.609 |
| Jev 1.14 | ReForm | 0.650 | 190 | 0.667 | 0.819 | 0.735 |

### Prompt Sensitivity Analysis

- **ReForm improves F1 for 5 of 6 models** (GPT-6.1 Sol is the exception), particularly for Gemma 4 E4B (0.326 → 0.667)
- **ReForm produces fewer valid outputs** than Direct for all six models
- ReForm increases **recall** but reduces **precision** for GPT-6.1 Sol, Qwen3.8 Max, and Jev 1.14
- The tradeoff matters: false negatives allow discrepancies to pass undetected; false positives incur review costs

### Reliability of Judgment Reasons

The paper demonstrates that **correct binary verdicts can coexist with explicit mathematical errors in explanations**. In the `arklib:sumcheck-full-rbr-after` case, GPT-6.1 Sol predicts misaligned correctly but dismisses the algebraic mismatch with a false claim about finite commutative domain semirings admitting field structure.

The counterexample uses the Boolean semiring:

$$B = \{0, 1\}, \quad a + b := a \vee b, \quad a \cdot b := a \wedge b$$

This is a finite commutative semiring satisfying cancellation (its only nonzero element is the multiplicative identity), yet $1 + x = 1$ for every $x \in B$, so 1 has no additive inverse—these operations cannot extend to a field structure.

## Theoretical and Practical Implications

### Contributions to Semantic Alignment Research

LeanReviewBench uniquely combines three features absent from prior benchmarks:
1. **Project interpretation context** (dependency-based, not just root statements)
2. **Discovered errors** from real formalization work (not constructed perturbations)
3. **Development-history-based construction** under a fixed Lean 4.34.1 environment

### Comparison with Prior Benchmarks

| Benchmark | Lean | Context | Discovered | History | Public |
|---|---|---|---|---|---|
| FormalAlign | 4.7.0-rc2 | ✕ | ✕ | ✕ | √ |
| ProofNetVerif | 4.8.0 | ✕ | √ | ✕ | √ |
| CriticLeanBench | N/S | ✕ | √ | ✕ | √ |
| ConsistencyCheck | N/S | ✕ | √ | ✕ | √ |
| MA-Align | 4.24.0 | ✕ | √ | ✕ | √ |
| FormalRx-Test | 4.24.0 | ✕ | ✕ | ✕ | ▲ |
| DriftBench | N/S | ✕ | √ | ✕ | ✕ |
| FaithAlign | N/S | √ | ▲ | ✕ | ✕ |
| **LeanReviewBench** | **4.34.1** | **√** | **√** | **√** | **√** |

### Practical Applications

- **Screening workflows**: Models predicting misalignment can trigger further human review; the precision/recall tradeoff informs deployment decisions
- **Version comparison**: The 69 historical pairs support research on semantic change localization and repair review
- **Dependency-based review**: Demonstrates that excluding proof bodies while retaining mathematical definitions provides sufficient context for semantic judgments

## Conclusion

LeanReviewBench provides a testbed for reviewing semantic correspondence in existing mathematical formalization projects. The benchmark's key strengths are its grounding in **real development history**, **independent target binding**, and **dependency-based interpretation context**.

### Limitations

- Without a context ablation, the contribution of supplied dependencies is not established
- Uneven project contributions (PrimeNumberTheoremAnd, AppliedModelingLib, and PFR contribute 94 of 197 inputs) limit generalization
- Model-provided reasons may be unreliable even when labels are correct

### Future Directions

1. **Context ablation studies** to quantify the value of dependency context
2. **Project-by-project and case-group reporting** for more nuanced evaluation
3. **Reason validity assessment** alongside label correctness to evaluate whether automated judgments provide reliable mathematical evidence
4. **Version comparison tasks** leveraging the 69 historical pairs for semantic change localization

The benchmark is publicly available at https://github.com/MechMath/LeanReviewBench.

---

_Markdown view of https://picx.dev/p/qTejH9, served by PicX — AI-generated visual whiteboard summaries of research papers._
