Build a Math Research Agent Workflow: AI-Assisted Theorem Proving with Attribution and Formal Verification [2026]
Build a Math Research Agent workflow with LangGraph: AI-assisted theorem proving with Lean 4 formal verification, literature contextualization, and community attribution.
Elena Rostova
Principal Distributed Systems Architect
The misalignment of AI in mathematics declaration that reached 1134 points on Hacker News highlighted a critical tension: AI systems can solve major mathematical problems, but they cannot do mathematics in the way that mathematicians understand it. This workflow builds a LangGraph agent that bridges that gap -- using AI to accelerate mathematical research while preserving the human-centric values of conceptual understanding, attribution, and community validation.
The Math Research Agent workflow combines theorem proving, literature search, code verification, and collaborative review into a structured pipeline designed for mathematical research assistance rather than problem-solving competition.
The Workflow Architecture
The Math Research Agent uses five LangGraph nodes that mirror the mathematical research process:
Node 1: Literature Contextualizer -- Searches the mathematical literature (arXiv, MathSciNet, zbMATH) for relevant prior work on the research question. The contextualizer prioritizes papers that have strong citation networks, recent survey articles, and active research communities. It surfaces not just the results but the conceptual framework and methods used.
Node 2: Conjecture Formulator -- Given the research context, formulates precise conjectures and identifies open problems that the agent can attempt to make progress on. This node explicitly marks each conjecture with a confidence estimate and a list of prerequisite knowledge.
Node 3: Proof Assistant -- Attempts to construct proofs or proof sketches using formal verification tools (Lean, Isabelle) where possible, and natural language reasoning where formal tools are not applicable. The assistant documents each step with precise citations to prior work and a chain-of-reasoning log.
Node 4: Community Validator -- Generates a structured writeup of any results, including explicit attribution to prior work, discussion of methodology, and open questions. The writeup is formatted for mathematical community review with clear separation of verified and unverified claims.
Node 5: Attribution Checker -- Validates that all claims in the writeup are properly attributed to their original sources. Flags any statement that lacks a citation or that paraphrases a known result without attribution.
LangGraph Implementation
The workflow connects through a state graph that prioritizes the research process:
from langgraph.graph import StateGraph, END
from typing import TypedDict, List
class MathResearchState(TypedDict):
research_question: str
literature_context: List[dict]
conjectures: List[dict]
proofs: List[dict]
community_writeup: str
attribution_issues: List[str]
workflow = StateGraph(MathResearchState)
workflow.add_node("contextualize", literature_contextualizer)
workflow.add_node("formulate", conjecture_formulator)
workflow.add_node("prove", proof_assistant)
workflow.add_node("validate", community_validator)
workflow.add_node("check_attribution", attribution_checker)
workflow.set_entry_point("contextualize")
workflow.add_edge("contextualize", "formulate")
workflow.add_edge("formulate", "prove")
workflow.add_edge("prove", "validate")
workflow.add_edge("validate", "check_attribution")
workflow.add_conditional_edges("check_attribution",
lambda s: "formulate" if s["attribution_issues"] else END)
workflow.compile()
Integration with Mathematical Tools
The literature contextualizer integrates with arXiv API, MathSciNet, and Semantic Scholar. The proof assistant supports formal verification through Lean 4's API, which can check proof steps for logical correctness. The OKF Agent Architecture provides the memory layer, storing research progress, conjectures, and proof attempts in a version-controlled repository.
The Attribution Checker
The attribution checker is the most important node for addressing the concerns raised in the math declaration. It validates that every claim in the research writeup includes a citation to the original source:
def attribution_checker(state: MathResearchState) -> MathResearchState:
issues = []
writeup = state["community_writeup"]
known_results = state["literature_context"]
for statement in extract_claims(writeup):
has_citation = find_citation(statement, writeup)
if not has_citation:
matches = match_to_known(statement, known_results)
if matches:
issues.append(f"Uncited result: '{statement[:80]}' matches {matches[0]['title']}")
return {**state, "attribution_issues": issues}
This node directly addresses the attribution crisis described in the AI and Math Alignment Declaration. No result is output without explicit attribution to its source, ensuring that the collaborative fabric of mathematical research is respected.
Verification Through Formal Tools
The proof assistant node uses Lean 4 for formal verification where possible. Formal verification produces machine-checkable proofs that eliminate the uncertainty of natural language reasoning. However, formal verification is resource-intensive and applicable only to a subset of mathematical problems.
For problems where formal verification is not feasible, the proof assistant produces structured natural language proofs with explicit reasoning chains. The TokenTab Context Management Protocol helps manage the long context windows required for multi-step mathematical reasoning without exceeding token limits.
Human-in-the-Loop Review
The community validator node produces a writeup that is explicitly designed for human review:
- Verified claims are marked with green checkmarks and include the Lean verification transcript
- Unverified claims are marked with yellow warnings and include the reasoning chain for human evaluation
- Open questions are collected in a separate section, not mixed with conclusions
- Every citation includes a link to the original source and a note on how it was used
The Obra Superpowers Agentic Workflow demonstrated that transparency in agent reasoning builds trust with human reviewers. The Math Research Agent applies the same principle to mathematical research, where transparency is not just a trust issue but a methodological necessity.
Why This Workflow Matters
The Math Research Agent does not solve the fundamental misalignment identified in the math declaration. It cannot replace the conceptual understanding that makes mathematics a human endeavor. But it can accelerate the parts of mathematical research that are mechanical -- literature search, proof verification, attribution checking, and writeup generation -- while leaving the conceptual work to human mathematicians.
The workflow respects the values that the math declaration identified as essential: attribution, community validation, conceptual understanding, and the collaborative process of building mathematical knowledge. It does not claim to do mathematics. It claims to help mathematicians do mathematics faster.
Lean 4 Integration Details
The proof assistant node connects to Lean 4's server mode, which provides a JSON-RPC interface for proof checking and theorem development:
import requests, json
class LeanClient:
def __init__(self, server_url="http://localhost:8080"):
self.server = server_url
def check_theorem(self, theorem_statement: str, proof: str) -> dict:
payload = {
"command": "check",
"theorem": theorem_statement,
"proof": proof
}
response = requests.post(f"{self.server}/api", json=payload)
return response.json()
def search_library(self, concept: str) -> list:
payload = {"command": "search", "query": concept}
response = requests.post(f"{self.server}/api", json=payload)
return response.json().get("results", [])
The Lean client runs locally, keeping the proof development process fully under the user's control. All proof attempts and verification results are stored in the OKF memory repository for future reference.
The Conjecture Lifecycle
The conjecture formulator node manages a lifecycle for each conjecture:
- Draft: A preliminary conjecture based on literature analysis. Contains high uncertainty.
- Refined: The conjecture has been validated against known results and no immediate contradiction found.
- Attacked: The proof assistant has attempted to prove or disprove the conjecture. May include partial proof steps.
- Verified: The conjecture has been formally verified using Lean 4.
- Published: The verified result has been formatted for community review.
Each conjecture progresses through these stages with full tracking, ensuring that no unverified claim is presented as a result. The lifecycle mirrors the research progression described in the AI and Math Alignment Declaration, where the process of mathematical discovery is valued as much as the result.
Handling Uncertainty
The workflow is explicit about uncertainty. Every claim includes a confidence score:
- Verified: Formally proven using Lean 4. Virtual certainty -- the proof can be independently checked.
- Likely: The reasoning chain is complete and consistent, but formal verification has not been completed.
- Speculative: The claim is a plausible conjecture based on the literature, but no proof attempt has been made.
- Uncertain: The literature is contradictory or insufficient to form a clear conjecture.
This explicit uncertainty handling addresses the core concern of the math declaration: that AI systems present results as definitive without surfacing the uncertainty inherent in mathematical research. The Math Research Agent never presents an unverified claim as a conclusion.
The Collaborative Workflow
The community validator node formats the writeup for human review with clear sections that serve different audiences:
- Executive summary: A one-paragraph overview for mathematicians who want to understand the contribution
- Methodology: A detailed description of the approach, including reasoning chains and formal verification steps
- Verified results: Claims that have been formally verified, with Lean transcripts
- Open questions: Conjectures that remain unproven, with suggestions for future work
- Attribution appendix: Every claim with its source citation, ensuring proper credit
This structure ensures that the agent's output is useful to the mathematical community regardless of whether the results are verified or speculative. The Obra Superpowers Agentic Workflow demonstrated that well-structured agent output is more trusted and more useful than raw results. The Math Research Agent extends this principle to the domain where trust and attribution matter most. By @deepakb.
Enjoyed this breakdown? Get our morning dispatch in your inbox.
Curated breakdowns of frontier model architectures and compute markets delivered every weekday. Zero fluff.
Elena Rostova
Principal Distributed Systems Architect
Elena Rostova leads coverage on high-concurrency multi-agent frameworks, LangGraph orchestration, event-driven pipelines, and self-healing systems.
Retrospectively Reverse-Engineering Apple's Neural Engine: What the ANE Architecture Reveals About On-Device AI Inference [2026]
Next Story →Build a Click Fraud Detection Agent Workflow: Real-Time AI Bot Detection with LangGraph and Google Ads API [2026]
Related Intelligence Analysis
The Step-by-Step Guide to Automating Meeting Tasks with Whisper
You're spending 45 minutes after every client meeting typing up notes and manually assigning tasks in Jira. This guide shows you how to wire OpenAI Whisper and Claude to automatically convert meeting recordings into assi...
Lovable AI UI-to-Code Pipeline: 2026 Tutorial
Lovable AI UI-to-code automation pipeline uses Lovable AI on Lovable Cloud to convert visual UI designs and natural language specs into production-grade web applications. UI/UX designers and frontend developers bridging...
Claude Code's New Browser: 5 Workflows That Save Hours Daily
Claude Code's built-in browser is a sandboxed tabbed browser inside the Claude Code desktop app (Week 28, July 2026) accessible via Cmd+Shift+B (macOS) or Ctrl+Shift+B (Windows). It lets Claude open websites, read docume...