TheoremGraph
Bridging formal and informal mathematics
Simon Kurgan*, Evan Wang*, Eric Leonen*, Sophie Szeto, Luke Alexander, Artemii Remizov, Jarod Alper, Giovanni Inchiostro, Vasily Ilin
* denotes equal contribution
What is TheoremGraph?
It is an informal dependency graph of results from papers, a formal dependency graph of declarations in Lean, and a set of links between statements that express the same mathematics.
Those links show where published mathematics meets machine-checked mathematics.
The hypothesis of this talk is that this map can help us choose formalization targets and build better context for proof agents.
How do we compare Lean and Prose?
To a mathematician, the underlying mathematical ideas may be immediately the same, but to a model the difference can't easily be bridged.
What do the two sources give us?
arXiv
arXiv is a public repository of research papers and their source files.
- Choose mathematical subject categories.
- Read paper metadata and the LaTeX document.
- Use the bibliography and local references to recover structure.
Lean
Lean gives us a checked environment rather than a document.
- Resolved declaration names and types.
- Proof terms accepted by the kernel.
- The declarations each result depends on.
Most correspondences have never been written down.
The literature is broad, Lean is exact, and blueprint projects expose only a sparse set of hand-authored links between them.
Autoformalization becomes three concrete questions.
- Which paper result should we formalize next?
- How much of its mathematical foundation already exists in Lean?
- Which declarations should a prover receive as context?
Recover the links papers only imply.
- Explicit: LaTeX references and citations.
- Heuristic: prose such as "by the previous lemma."
- Notation: shared symbols traced to prior definitions.
11.75M statements · 18.32M candidate dependencies
Every edge records which extractor proposed it, so users can choose their precision/coverage tradeoff.
LeanGraph reads the checked environment.
It runs as a Lean metaprogram, walks human-facing declarations, and records dependencies after names and types have been resolved.
Six kinds of formal dependency.
- extendsstructure inheritance
- fieldfield composition
- sigconstants in type signatures
- proofconstants invoked by theorem proofs
- defconstants invoked by definition bodies
- docrefvalid references in docstrings
The checked world is smaller and much denser.
How do we make comparison possible?
We need a shared representation, a fast search index, and a separate verification step.
Put both worlds into the same kind of language.
A slogan is a short natural-language approximation of a mathematical statement. We generate one from Lean and one from paper LaTeX.
What is an embedding?
An embedding model turns text into a vector: a long list of numbers that acts like a location.
Texts with related meanings tend to land nearby, so distance becomes useful for search.
Use one embedding space for both corpora.
Qwen3-Embedding-8B maps every slogan to a normalized 4,096-dimensional vector.
What is HNSW?
HNSW is an approximate nearest-neighbor index. It takes long jumps through sparse upper layers, then descends into denser layers to refine the search.
ann_k is the shortlist kept from approximate search before exact cosine reranking. Larger values cost more, but are less likely to discard a good neighbor.
Search from each formal declaration to its nearest paper statement.
- Embed the formal slogan.
- Search HNSW with ann_k = 50.
- Rerank the shortlist by exact cosine.
- Keep the rank-1 paper candidate.
Blueprint links give us a human-written reference set.
- 43.5%annotated partner appears at rank 1
- 69.9%annotated partner appears in the top 10
- 65%of different high-similarity rank-1 results were still judged valid matches
A different result is not automatically a retrieval failure: one paper statement can have multiple valid formal counterparts.
Most formal declarations do not produce a close paper neighbor.
213,346 declarations return a candidate at the minimum retrieval similarity.
100,865 land at cosine 0.8 or above and enter the fully judged tiers.
Which candidates are most important?
- 0.6-0.7: 2% affirmed
- 0.7-0.8: 23% affirmed
- 0.8 and above: judge the complete candidate set
The 0.8 floor focuses expensive comparison where similarity produces useful leads.
Use an LLM to compare the full records.
The judge sees both slogans, the Lean signature, the original informal LaTeX, and paper context. It does not see the cosine score.
- exact same result
- inexact related by specialization, generalization, or direction
- wrong related topic, different claim
How stable is the LLM-as-judge?
Cohen's κ measures agreement beyond what chance alone would produce.
- 93.2%agreement across 500 repeated judgments
- κ = 0.86strong beyond-chance agreement
- 8 / 10agreement with a blinded expert on a small review set
Judge policy changes the density of the resulting graph.
Both judges affirm more candidates as cosine rises, but DeepSeek is consistently more lenient. GPT-5.4 remains the stricter judge of record.
47,952 affirmed matches.
Exact and inexact verdicts both count as matches.
- 100,799 valid labels above the 0.8 floor
- 47.7% affirmed overall
- 87% affirmed in the ≥ 0.9 tier
The output is a graph, not only a table of pairs.
Every matched statement remains connected to the dependencies around it in papers and Lean.
What is TheoremGraph good for?
- Concept retrieval: find the Lean declaration behind an informal query.
- Attribution and matching: connect equivalent results across papers and libraries.
- Formalization targets: identify results near a proof-complete formal frontier.
- Agent context: retrieve nearby declarations instead of searching the whole library.
- Dependency auditing: locate missing imports, unfinished assumptions, and library gaps.
Does retrieved context help write Lean statements?
We tested 24 unseen informal targets. The model wrote a Lean declaration with a proof hole; experts then checked whether the statement preserved the intended mathematics.
RAG reached 8 correct statements with 14k output tokens and 68 calls; library search used 52k tokens and 275 calls for 6.
Can an informal query recover its target Lean declaration?
MathlibQR fair-810 contains 810 query rows over 171 target declarations, with up to six query styles: English, LaTeX, Lean-like text, slogan, nickname, and special case.
The task is to place the known target in the top 10.
Same Qwen3-Reranker-8B scoring protocol; our top-50 candidate pool.
Put names and signatures where queries can reach them.
- Name and signature: embed the fully qualified name and Lean type alongside a second representation.
- Name index: give bare-name queries a direct lexical route.
- HyDE: restate terse or Lean-like queries in language closer to indexed descriptions.
Keep good candidates alive, then expand through the graph.
Approximate search is fast because it prunes aggressively. The risk is that the right declaration disappears before we score the shortlist exactly.
- Wider shortlist:
ann_kis how many approximate neighbors survive into exact cosine scoring. Increasing it gives plausible declarations another chance. - Exact reranking: recompute cosine over that candidate pool.
- Graph expansion: a retrieved declaration may be one dependency hop from the intended concept. For
Lattice, that hop surfaces names such asSemilatticeInfandSemilatticeSup.
Matches expose a formalization frontier.
Formalization distance K is the shortest dependency path from a paper result with a proof-complete exact Lean match to a candidate paper result.
K asks how many informal result steps separate a target from a clean formal anchor.
sorryAx is not proof-complete.We tested targets at different positions on the frontier.
- Write a Lean statement faithful to the paper.
- Make the statement elaborate under the pinned project.
- Prove it using the available formal foundation.
Strict success: the statement matches the paper, the proof compiles with fixed imports, contains no placeholder, and does not depend on unfinished declarations through sorryAx.
Separate blinded statement pilot: 4 statements typechecked; independent reviewers judged 3 faithful.
Dependency health mattered more than distance alone.
The current sample does not show that K by itself predicts proof success.
- 11valid with fixed imports
- 3valid after adding imports
- 12compiled through unfinished
sorryAxdependencies - 6still contained placeholders
- 2failed at the service level
Aristotle proved a missing submartingale bound.
for a submartingale X and elementary predictable set A
sorry, the Brownian-motion project, and no informal proof or graph context.Aristotle combined existing ingredients into a new corollary.
sorry, the Sphere-Packing-Lean project, and no informal proof or graph context.Design the graph for the task you actually want.
- Define node and edge semantics first. Use a richer edge taxonomy when the parser or formal environment can support it.
- Retain source content. Keep the paper, module, code, and provenance for every parsed or inferred object.
- Separate statements from proofs. TheoremGraph is strongest for elaboration and concept context; it does not reliably map every paper theorem to the proof material an agent needs.
Treat comparison quality as a first-class system.
- Calibrate LLM-as-judge carefully. At this scale, small error rates become thousands of questionable edges.
- Use richer reasoning than slogan similarity. Preserve hypotheses, quantifiers, direction, definitions, and surrounding dependency context.
- Keep humans at the final quality gate. Human judgments are the training signal for better comparison reasoning and the safeguard for high-value downstream data.
TheoremGraph