Retrieving relevant lemmas is crucial for formal theorem proving, enabling provers to build machine-checkable proofs from established mathematical results. Recent retrieval systems match library declarations to a target theorem or its intermediate proof steps, but make limited use of multi-hop dependencies among declarations. These dependencies can reveal supporting lemmas that are not necessarily lexically similar to the target theorem but recur in proofs of related problems. To this end, we propose LeanGraphSearch, a graph-based retrieval method for Lean 4 that constructs a graph from Mathlib's forward dependencies and traverses it to uncover supporting lemmas through multi-hop dependency chains. Specifically, LeanGraphSearch links each declaration to the premises it depends on, uses a graph-based ranking algorithm to propagate relevance from semantically matched declarations to their dependencies, and reranks the expanded candidates against the original query. Across two mathematical retrieval benchmarks, LeanGraphSearch improves recall by up to 12% over the strongest baseline, LeanSearch v2, on MathlibQR and increases coverage of complete annotated proof routes on MathlibMPR, covering up to 3.7% of extra groups. More importantly, we evaluate whether these retrieval gains translate into improved end-to-end theorem proving by integrating LeanGraphSearch into an iterative proving loop guided by Lean feedback. Across three theorem proving benchmarks, LeanGraphSearch improves pass rate at {8, 16, 32} reflection turns by as much as 40% compared to vanilla prover and at most 10% compared to LeanSearch v2, showing higher accuracy-cost efficiency. These findings highlight the value of dependency graph search for theorem proving and motivate further research on structure-aware search for proof discovery.
Figures & tables
Figure 1: Dependency-guided retrieval with LeanGraphSearch . (a) An illustration of the dependency graph, showing how semantically retrieved declarations (blue) lead to supporting premises (green) through shared and multi-hop dependencies. (b) Selected retrieval and proving results. Gains are reported in percentage points relative to LeanSearch v2.
Figure 2: Overview of LeanGraphSearch . (a) Dependency graph construction ( Section 3.2 ). Static analysis with jixia extracts references from Mathlib declarations to construct a directed graph G . (b) Graph-based retrieval ( Section 3.3 ). It first retrieves semantic seeds using semantic embeddings, then expands the candidate set by traversing the dependency graph. Seed and graph-expanded candidates are merged and reranked to select the final top- K declarations.
nDCG@ k
Recall@ k
Method
1
5
10
10
50
100
LeanExplore
0.246
0.358
0.393
0.569
0.743
0.789
LeanFinder
0.370
0.514
0.533
0.698
0.824
0.875
LeanSearch v2 (standard mode)
0.472
0.596
0.616
0.765
0.821
0.827
LeanGraphSearch (standard mode)
0.473
0.604
0.629
0.794
0.899
0.947
Table 1: Query-to-declaration retrieval on the 810-query fair subset of MathlibQR. LeanExplore and LeanFinder are quoted from Gao et al. (2026) . The best result in each column is bold .
Method
Recall@ k (group)
Covered@ k
5
10
20
30
50
5
10
20
30
50
INF-X-Retriever
21.2
28.2
33.9
40.0
42.6
15.9
18.8
21.7
24.6
24.6
ReasonIR
23.9
26.9
33.3
35.6
43.8
17.4
18.8
20.3
21.7
30.4
DIVER
27.7
38.0
46.6
52.8
55.0
18.8
24.6
29.0
33.3
37.7
ReProver
3.0
5.5
7.6
8.8
10.3
0.0
1.4
2.9
4.3
4.3
LeanPremise
4.1
4.8
8.0
9.9
11.5
1.4
1.4
4.3
4.3
5.8
Table 2: Global premise retrieval on MathlibMPR. The two evaluated method rows are arithmetic means over Gemini 3.1 Pro and Claude Sonnet 5. Baseline results are quoted from Gao et al. (2026) .
Retrieval condition
pass@ 8
pass@ 16
pass@ 32
Relative cost
Failure Memory Disabled
No retrieval
35
42
47
1.00×
LeanSearch v2 (standard mode)
49
61
70
1.11×
LeanGraphSearch (standard mode)
53
69
71
1.09×
LeanSearch v2 (reasoning mode)
52
68
73
1.41×
LeanGraphSearch (reasoning mode)
56
70
75
1.37×
Table 3: Proving results on FATE-H , grouped by whether failure memory is enabled. Relative cost is the full-budget API cost normalized by no retrieval within each group. The best and second best results in each group are shown in bold and underlined , respectively.
Retrieval condition
pass@ 8
pass@ 16
pass@ 32
Relative cost
Failure Memory Disabled
No retrieval
15
18
23
1.00×
LeanSearch v2 (standard mode)
31
35
39
0.82×
LeanGraphSearch (standard mode)
32
38
41
0.78×
LeanSearch v2 (reasoning mode)
33
37
41
1.01×
LeanGraphSearch (reasoning mode)
33
38
39
1.06×
Table 4: Proving results on MathlibMPR-Prop , grouped by whether failure memory is enabled.
Retrieval condition
Basic Set ( n=30 )
Advanced Set ( n=30 )
pass@ 8
pass@ 16
pass@ 32
Rel. cost
pass@ 8
pass@ 16
pass@ 32
Rel. cost
Failure Memory Disabled
No retrieval
12
16
16
1.00×
7
7
8
1.00×
LeanSearch v2 (standard mode)
15
15
18
1.49×
4
8
9
1.82×
LeanGraphSearch (standard mode)
16
17
21
1.40×
5
9
10
1.88×
LeanSearch v2 (reasoning mode)
14
16
21
2.04×
7
9
10
2.56×
Table 5: Proving results on Lean-IMO-Bench , grouped by whether failure memory is enabled.
Figure 3: Cost efficiency on theorem proving. LS = LeanSearch, LGS = LeanGraphSearch , Std. = Standard Mode, Reas. = Reasoning Mode. For each of the 10 configurations, we compute total API cost divided by the number of solved problems on the union of 210 theorem-proving instances. Solved counts are measured by pass@32. Lower values indicate better cost efficiency.