AI-Assisted Mathematical Proofs: Mechanisms, Closed-Loop Workflows, and Limitations

    Recent discussions around AI's role in tackling complex mathematical problems like the Riemann Hypothesis highlight the need for rigorous verification. This article explores how large language models (LLMs) contribute to mathematical proof searches, detailing the mechanisms behind their candidate generation and reasoning. It examines the essential generate-verify closed-loop workflow—integrating LLMs with formal proof assistants like Lean 4—and outlines major limitations such as logical hallucinations and formalization costs. Finally, it offers practical engineering and development advice for building reliable AI-assisted proof systems.

    Recent news about AI participating in Riemann Hypothesis research has sparked widespread discussion. Since public information remains limited, and institutions, papers, and peer reviews need further verification, this article does not cite specific conclusions. Instead, we can focus on a more fundamental question: What can large language models (LLMs) do in strict mathematical reasoning, and how should they work with verification tools?

    The Riemann Hypothesis is one of the most famous unsolved problems in number theory. It asserts that all non-trivial zeros of the Zeta function have a real part equal to 1/2. The Generalized Riemann Hypothesis (GRH) extends this assertion to a broader class of L-functions. These propositions have been studied for over a century without a universally accepted proof. Therefore, any claim of an AI proof should only be trusted after a complete peer review and formal verification.

    LLMs generate text by predicting the next token based on probability. In mathematics, their value lies primarily in proposing candidate approaches. A model can suggest introducing an auxiliary function, trying a specific estimation method, or converting a natural language argument into a formal language. However, these outputs are merely candidates; the model itself cannot guarantee the validity of each step.

    Chain-of-thought (CoT) is currently the most common reasoning enhancement method. The model breaks a large problem into several intermediate steps, providing verifiable conclusions at each step. This decomposition makes errors easier to locate and facilitates subsequent external checks.

    Tree search is another approach. Monte Carlo Tree Search (MCTS) expands multiple candidate branches simultaneously, deciding which to explore and which to prune based on a scoring function. MCTS cannot be directly applied to all tasks. It relies on a reliable scoring function, such as feedback from a formal verifier or quantifiable intermediate metrics. In tasks lacking such signals, tree search relies solely on the model’s self-evaluation, making its effectiveness difficult to guarantee.

    2. How to Build a Generate-Verify Loop

    The reliability of AI-assisted proofs comes mainly from closed-loop design. A basic loop involves three types of actors. The first is the generator (the LLM), responsible for proposing candidate proofs. The second is the verifier (a formal proof assistant), responsible for checking the logic of each step. The third is the human, responsible for confirming that the statement to be proven aligns with the original intent and reviewing the final conclusion.

    Choosing a Theorem Prover

    Common theorem provers include Lean 4, Coq (now Rocq), and Isabelle/HOL. Selection can be based on four factors. First, the completeness of libraries in the target mathematical domain. Lean 4, paired with the Mathlib library, covers a vast amount of modern mathematics, making it a popular choice among researchers. Second, the degree of automation; stronger automation means fewer simple steps need to be written manually. Third, community activity, which determines the availability of documentation, error explanations, and third-party tools. Fourth, team familiarity; tools the team already knows can be deployed faster.

    Input, Output, and Debugging in the Loop

    In the loop, each round’s input typically includes three parts: the formal statement to be proven, lemmas that have already passed verification, and the error information from the previous round. The output is the candidate complete proof code. The verifier returns one of two results: pass, or fail with an error location and message.

    Effective debugging relies heavily on feedback content. Simply telling the model “verification failed” makes improvement difficult. The error line number, error type, and relevant context should be passed back together. Additionally, a maximum number of rounds should be set to avoid infinite retries on the same error. It is best to log the failure types of each round for subsequent statistical analysis of error-prone steps.

    Below is a minimal example to illustrate the workflow structure. It is for demonstration only and not intended for direct research use.

    1. import subprocess
    2. from pathlib import Path
    3. from typing import Callable, Optional, Tuple
    4. def verify_lean(code: str, project_dir: Path) -> Tuple[bool, str]:
    5. """Check candidate proof with Lean 4, returning (is_passed, error_message)."""
    6. # In Lean, code containing 'sorry' or 'admit' still exits with code 0, so it must be intercepted separately.
    7. if "sorry" in code or "admit" in code:
    8. return False, "Code contains incomplete placeholder proofs"
    9. target = project_dir / "Candidate.lean"
    10. target.write_text(code, encoding="utf-8")
    11. try:
    12. result = subprocess.run(
    13. ["lake", "env", "lean", str(target)],
    14. cwd=project_dir,
    15. capture_output=True,
    16. text=True,
    17. timeout=600,
    18. )
    19. except subprocess.TimeoutExpired:
    20. return False, "Verification timed out"
    21. output = (result.stdout + result.stderr).strip()
    22. return result.returncode == 0, output
    23. def prove(statement: str, lemmas: str, generate: Callable[[str], str],
    24. project_dir: Path, max_rounds: int = 10) -> Optional[str]:
    25. """'generate' is your LLM calling function, taking a prompt and returning Lean code."""
    26. feedback = ""
    27. for _ in range(max_rounds):
    28. prompt = (
    29. f"Proposition to prove (Lean syntax):\n{statement}\n\n"
    30. f"Verified lemmas:\n{lemmas}\n\n"
    31. )
    32. if feedback:
    33. prompt += f"Previous round verification error:\n{feedback}\nPlease fix and output the complete code."
    34. else:
    35. prompt += "Please output the complete Lean proof code, including import Mathlib."
    36. code = generate(prompt)
    37. ok, output = verify_lean(code, project_dir)
    38. if ok:
    39. return code
    40. feedback = output
    41. return None

    Before running this code, you need to set up a Lean project depending on Mathlib and ensure the lake command is available. The generate function must be implemented according to the API of the model you are using.

    Final Checks Cannot Be Omitted

    Passing verification only indicates that the code has no logical errors under the given definitions and axioms. It does not mean the proven proposition is the one originally intended. A common issue is formalizing a statement too weakly, or writing it as a known true special case. Therefore, manual verification of the statement is a necessary step.

    Additionally, check whether the proof introduces extra axioms. In Lean, you can use #print axioms to view the axioms a theorem depends on. Any items outside standard axioms require manual confirmation; otherwise, the proof might rely on unverified assumptions.

    3. Major Limitations

    First is logical hallucination. A model might produce fluent arguments with seemingly reasonable steps that contain an incorrect reference or implicit assumption. Formal verification can catch most syntax and reasoning errors, but it cannot replace manual review of propositions and assumptions.

    Second is long-range dependency. The longer the proof, the more likely early conventions are forgotten or diluted in the context. A common mitigation is to store verified lemmas in files and pass only the segments relevant to the current step to the model each round.

    Third is the cost of formalization. The formal libraries for many mathematical branches are still incomplete. When encountering concepts not in the library, teams often need to define and prove basic results themselves first, a step that can take far more work than the proof itself.

    Fourth is the credibility of the verifier itself. The kernel of the proof assistant, the implementation of external libraries, and the choice of axioms used all affect the credibility of the conclusion. Passing verification only means there are no issues within the current formal system.

    4. Computing and Engineering Resources

    The mathematical search space is vast, so running multiple candidate branches in parallel is a natural approach. Each branch involves one model call and one formal verification. A single verification may take several minutes, and complex proofs take even longer. Therefore, costs scale synchronously with parallelism and verification time.

    Engineering-wise, several issues need addressing. Tasks require queuing and scheduling; timeouts and failures require retry strategies; verified lemmas need caching to avoid redundant computation. Logs should record the source, duration, and result of each candidate for post-hoc analysis.

    Cloud platforms can provide elastic computing resources, making it easy to scale up during search peaks. When choosing a platform, compare unit costs, data compliance requirements, and team experience. Computing specifications are only one factor.

    5. Advice for Developers

    First, test the loop on known theorems. Use small, already-proven theorems to verify that prompts, verifiers, and retry logic work correctly before tackling real problems.

    Second, label the status of each conclusion. Distinguish between three statuses: “passed formal verification,” “non-formal argument only,” and “human-reviewed,” to avoid spreading candidate results as final conclusions.

    Third, retain evidence for public release. When publishing results, include the formal code, the list of axioms used, and the verification environment information to facilitate reproduction by others.

    Conclusion

    Currently, the main value of AI in mathematical research is proposing candidate approaches and shortening the trial-and-error cycle. Whether it can provide an acceptable proof for difficult problems like the Riemann Hypothesis requires formal checks and long-term peer review by the mathematics community. Until then, any related conclusions should be treated as unverified.