Assisting Mathematical Proof Writing with Large Language Models: Methods and Verification

    Writing mathematical proofs with Large Language Models (LLMs) poses unique challenges due to the strict logical requirements of mathematics. This article outlines practical methods for leveraging LLMs in proof writing while ensuring rigor. It covers task scoping, structured prompt design, step-by-step generation, manual and automated logical verification (including dependency tracking via Python), reference validation, and cost estimation. By following these practices, users can effectively use LLMs to organize ideas and draft proofs while keeping logical risks manageable.

    1. Why Mathematical Proofs Are Challenging for LLMs

    Mathematical proofs require that every step follows strictly from the premises. Natural language generation prioritizes fluency, meaning models might skip conditions, confuse quantifiers, or use seemingly plausible but unproven conclusions. Therefore, evaluating a model’s performance on proof tasks depends not on the smoothness of the text, but on whether each step can be independently verified.

    Common failure modes in such tasks include:

    • Using a sufficient condition as a necessary one;
    • Implicitly assuming the existence of an object or the uniqueness of a mapping;
    • Citing a non-existent theorem name or number;
    • Omitting necessary verifications in the base or inductive steps of mathematical induction.

    2. Define the Task Scope First

    Before submitting a request, three things must be clarified:

    1. The complete statement of the proposition, including all premises, domains of objects, and the order of quantifiers;
    2. The scope of allowed prior conclusions, e.g., only basic theorems from standard textbooks, or citing proven conclusions from specific public materials;
    3. The purpose of the output, whether it is an explanatory draft for learning or a draft for formal publication.

    The clearer the scope, the less likely the model is to expand premises on its own. If the proposition lacks a complete proof in public materials, this should be noted, and the generated content must be marked as “pending review derivation” rather than published directly as an authoritative conclusion.

    3. Prompt Design: Structuring the Task for Verifiability

    An effective prompt typically consists of four parts: role, proposition, constraints, and output format. An example is as follows:

    1. Role: You are a graduate teaching assistant in algebraic geometry, write rigorously.
    2. Proposition: [Paste the complete statement here, along with relevant definitions]
    3. Constraints:
    4. 1. Only use the following prior conclusions: A, B, C;
    5. 2. Annotate the basis for each reasoning step (definition, prior conclusion number, or direct calculation in this step);
    6. 3. If a step requires a conclusion not provided, explicitly list it as a "lemma to be supplemented" and do not assume it holds;
    7. 4. Do not fabricate theorem names or numbers.
    8. Output: Divide into three parts: list of lemmas, main proof, and remarks.

    This design ensures that every step carries its justification, facilitating subsequent line-by-line verification. The more specific the constraints, the less room the model has to secretly alter premises.

    4. Step-by-Step Generation and Intermediate Checks

    Generating the entire text at once is not recommended. A more robust approach is to proceed in three rounds:

    • Round 1: Only request the proof outline to check if the approach matches the proposition;
    • Round 2: Expand the lemmas one by one and verify each individually;
    • Round 3: Assemble the verified lemmas into the main proof and perform a comprehensive review.

    Intermediate results should be saved in each round. If the outline direction is found to be wrong in Round 1, early corrections can be made, preventing the subsequent discarding of large amounts of text.

    5. Specific Methods for Logical Verification

    During manual verification, the following checklist can be used:

    • Are all premises present in the statement, without any extra assumptions secretly added?
    • Does every existential conclusion provide a construction or citation?
    • Is the quantifier exchange legal? Are “for all… there exists…” and “there exists… for all…” confused?
    • Do the base cases of induction cover all necessary starting points?
    • Are the conditions met for exchanging the order of limits, summations, and integrals?

    For computational steps, symbolic computation tools or simple numerical experiments can be used for spot-checking. Numerical experiments cannot prove a proposition, but they can quickly reveal obvious errors.

    6. Dependency Tracking and Automated Checking

    Each step of the proof should record the prior steps it depends on. The following script is used to check whether all dependencies have been established:

    1. from dataclasses import dataclass, field
    2. @dataclass
    3. class Step:
    4. idx: str
    5. claim: str
    6. justification: str # Definition / prior conclusion number / direct calculation
    7. depends_on: list = field(default_factory=list)
    8. def find_unresolved(steps, known):
    9. """Returns dependencies that are neither in the known set nor recorded as earlier steps."""
    10. done = set(known)
    11. problems = []
    12. for s in steps:
    13. missing = [d for d in s.depends_on if d not in done]
    14. if missing:
    15. problems.append((s.idx, missing))
    16. done.add(s.idx)
    17. return problems
    18. steps = [
    19. Step("L1", "A certain set is compact", "Prior conclusion A", ["A"]),
    20. Step("L2", "The image of a continuous function is compact", "Prior conclusion B", ["L1", "B"]),
    21. Step("M1", "The main proposition holds", "Directly follows from L2", ["L2", "C"]),
    22. ]
    23. print(find_unresolved(steps, known={"A", "B"}))
    24. # Output: [('M1', ['C'])], indicating that C has not been provided and needs to be added as a lemma or the dependency removed

    This check cannot determine whether the reasoning itself is correct, but it can detect broken dependency chains, which are the easiest issues to overlook during manual review.

    7. Reference and Citation Verification

    One of the most error-prone areas for models is citation. Every theorem name, number, and page number appearing in the generated text should be cross-referenced one by one with the original materials. If a source cannot be found, the citation should be deleted, rewritten as a direct argument in the proof, or listed as a lemma to be supplemented.

    A simple registration table can be used to manage citations:

    ID Location Citation Content Verification Status
    R1 Lemma 2, Step 1 A certain compactness criterion Verified against the corresponding textbook chapter
    R2 Main proof, Step 3 A basic property of a certain homomorphism To be verified

    Unverified citations should not enter the final draft.

    8. Typesetting and Documentation

    Mathematical lecture notes typically require generation using a formula typesetting system (e.g., LaTeX). It is recommended to place definitions, lemmas, propositions, and proofs into separate environments to facilitate automatic numbering and cross-referencing. When writing, ensure logical correctness before handling typesetting. Formatting adjustments can easily introduce new errors, such as mistakenly altering formula symbols or breaking the correspondence between numbers and references. Therefore, a final read-through is still required after typesetting is complete.

    9. Resource and Cost Estimation

    Most LLM services meter usage based on the volume of input and output text. To estimate the consumption of a task, the following approximation can be used:

    Total consumption ≈ rounds × (average input length + average output length)

    Generating in multiple rounds increases the frequency of repeated input, but reduces rework. Compressing the context into a summary and retaining only the verified lemmas can significantly reduce the input volume for subsequent rounds. For lengthy proofs, this approach is usually more economical than generating everything at once.

    10. Conclusion

    LLMs can serve as auxiliary tools for proof writing. They excel at organizing ideas, generating outlines, polishing expressions, and supplementing explanations, but every logical step and citation requires human verification. Adopting step-by-step generation, dependency tracking, and line-by-line verification can keep risks within an acceptable range.