AI for Math and Cryptography: How LLMs Are Moving from Answering Questions to Formal Research

    This article breaks down how large language models are being applied to research-grade tasks such as formal theorem proving and cryptanalysis. It explains the three technical foundations behind recent progress—machine-verifiable proof languages, large-scale proof search with process-level rewards, and constraint-solving approaches to finding cryptographic collisions—along with the engineering challenges of building these systems: reproducible verification environments, long-context retrieval, compute cost control, and data security. It also offers a practical framework for evaluating claims of "AI breakthroughs" and a checklist enterprises can use to adopt formal verification and audit-ready AI workflows.

    1. Introduction: From Answering Questions to Doing Research

    Over the past two years, public demonstrations of LLM capability have focused mainly on exam-style tasks: code completion, unit test generation, document summarization, and structured extraction. These tasks share three traits: answers are decidable, context can be exhaustively enumerated, and evaluation criteria are clear. Mathematical theorem proving and cryptographic algorithm analysis are different—they are research-type tasks characterized by:

    • Vast and sparse search spaces: a correct proof step is a very low-probability event, while wrong paths are nearly infinite;
    • High cost of correctness checking: a single symbolic error can invalidate an entire reasoning chain;
    • Long feedback delays: one full verification may require compilation, type checking, and coordination with external solvers, taking anywhere from minutes to hours;
    • Deep knowledge dependencies: they require background knowledge built up across generations, such as abstract algebra, analytic number theory, and finite field theory.

    The real value of recent public results, therefore, is not that “a model solved a problem,” but that AI has begun to participate reliably in long-chain, verifiable, and reproducible research workflows. Such workflows demand far more from engineering infrastructure than typical conversational applications.

    2. Technical Foundation One: Formal Proof Languages and Machine Verifiability

    The first step in bringing mathematical proofs into an AI workflow is translating a “natural language proof” into “code a machine can check.” The main industry approaches include:

    • Interactive Theorem Provers (ITPs): express mathematical objects and inference rules through type theory (such as dependent type theory and simple type theory), with the compiler checking the validity of each term at every step;
    • Mathematical formalization libraries: accumulate foundational results from number theory, algebra, topology, and other areas into reusable theorem collections, avoiding repeated proofs;
    • Tactic-based proving: the prover writes “tactic scripts” that the prover expands into low-level inference steps, combining readability with automatability.

    Consider the following illustrative code (the syntax is generic pseudocode and only conveys the idea):

    1. theorem collision_exists_for_reduced_round_variant :
    2. ∃ (m1 m2 : Message),
    3. m1 ≠ m2 ∧ digest (compress m1) = digest (compress m2) := by
    4. -- 1. Construct a message difference pair (m1, m2)
    5. -- 2. Propagate the difference round by round through the round function to obtain intermediate state equalities
    6. -- 3. Apply an existing lemma: the difference vanishes after a certain number of rounds
    7. -- 4. Close the type checking and hand it to the kernel for verification
    8. constructor <;> ...

    The significance of such code is that it turns “I believe it is correct” into “a machine can check it and pass.” Proof code on the order of 17 million lines attracts attention precisely because it signals that AI can manage extremely long dependency chains—including hundreds of intermediate lemmas, cross-module references, and a large number of automatically generated bridging theorems.

    An Analogy to Business Processes

    Formal verification is not new in engineering; chip design, avionics control, and compiler kernels all use similar ideas. The incremental value of AI is that it lowers the human barrier to “writing proofs,” compressing work that once took a team of PhDs several months into days or weeks. Moreover, the output is an asset that can be regression-tested, not a one-off document.

    3. Technical Foundation Two: Large-Scale Proof Search and Process Rewards

    From an algorithmic perspective, theorem proving is a symbolic search plus reinforcement learning problem:

    • State: the current proof goal and the set of contextual hypotheses;
    • Action: applying a lemma, executing a tactic, or introducing an intermediate construction;
    • Transition: carried out by the prover kernel, deterministic in nature;
    • Reward: traditional methods use a sparse 0/1 reward (whether the proof is completed), which provides insufficient training signal.

    The mainstream approach in recent years introduces process-level feedback:

    1. Proof state encoding: serialize the current goal into a structured representation and feed it to the model;
    2. Intermediate step scoring: assign a heuristic score to each tactic choice (such as the number of remaining goals, the reduction in term complexity, or whether a known lemma is triggered);
    3. Search strategy: use best-first search, Monte Carlo tree search, or beam search to expand paths within a limited budget;
    4. Backtracking and replanning: when a branch fails repeatedly, backtrack to an earlier state and switch to a different family of tactics.

    An illustrative training loop:

    1. def proof_search(model, prover, goal, budget):
    2. frontier = PriorityQueue()
    3. frontier.push((heuristic(goal), []))
    4. while not frontier.empty() and budget > 0:
    5. score, path = frontier.pop()
    6. for tactic in model.propose_tactics(goal, top_k=5):
    7. subgoals = prover.apply(goal, tactic)
    8. if subgoals is None:
    9. continue # Illegal step, rejected by the kernel
    10. if all(prover.closed(sg) for sg in subgoals):
    11. return path + [tactic]
    12. for sg in subgoals:
    13. frontier.push((heuristic(sg), path + [tactic]))
    14. budget -= 1
    15. return None

    The compute cost of such workflows is concentrated in parallel verification: one inference produces multiple candidate steps, and the prover kernel must batch-check them. This calls for low-latency containerized inference clusters and efficient caching strategies.

    4. Technical Foundation Three: Cryptanalysis and Automated Vulnerability Discovery

    Cryptanalysis and theorem proving share mathematical structure but differ in goal: the former seeks counterexamples (collisions, distinguishers, impossible differentials), while the latter seeks universal proofs. Cryptanalysis therefore tends to rely on:

    • Constraint solving: model the algorithm’s round function as bit-vector constraints and let a solver find inputs that satisfy the collision condition;
    • Automated differential and linear analysis: search for high-probability differential paths or linear approximations;
    • Unified intermediate representation: map block ciphers, hash functions, and authenticated encryption to a bit-level intermediate representation (IR), making it easier to transfer attack patterns across algorithms.

    Illustrative modeling:

    1. # Model the compression function as bit-vector constraints
    2. inputs = [BitVec(f"m{i}", 32) for i in range(16)]
    3. state = initial_state(inputs)
    4. for r in range(rounds):
    5. state = round_function(state, round_keys[r])
    6. solver.add(state_a == state_b) # Require identical outputs
    7. solver.add(inputs_a != inputs_b) # Require different inputs
    8. solver.add(constrain_pattern(inputs_a, inputs_b)) # Differential characteristic
    9. if solver.check() == sat:
    10. m1, m2 = solver.model().eval(inputs_a), solver.model().eval(inputs_b)

    When public results mention “second-level collisions,” it usually means the following conditions hold simultaneously:

    • Attack complexity is reduced to an extremely low level: high-probability differential paths and low algebraic degree of the round function;
    • Solver efficiency is optimized: hybrid strategies such as bit-vector solving, algebraic attacks, and meet-in-the-middle;
    • Sufficient parallelism: multi-core or multi-machine coordinated search, or GPU acceleration for bitwise operations;
    • Structural weaknesses in the algorithm itself: insufficient diffusion in the round function, linearized key scheduling, or poor algebraic properties of the S-boxes.

    It is important to stress that a second-level break does not mean the algorithm is immediately broken; the boundary between a “theoretical attack” and a “practical attack” must be distinguished (see Section 6).

    5. Engineering Challenges for R&D Teams

    If an organization wants to build similar capabilities, it must confront the following engineering problems:

    5.1 High Availability of the Verification Environment

    Provers and solvers need a stable runtime environment, including a version-pinned toolchain, dependency libraries, and a reproducible build process. Any environment drift leads to “passes locally, fails in production.”

    1. # Illustrative: pin toolchain versions to ensure reproducibility
    2. toolchain pin --version theorem-prover-4.x
    3. dependency lock --file proofs.lock
    4. cache warm --target core_mathlib

    5.2 Long Context and Retrieval Augmentation

    Tens of millions of lines of proofs cannot fit into a single context. This requires:

    • Hierarchical indexing: build hybrid vector and symbolic indexes by mathematical domain, module, and theorem complexity;
    • Precise retrieval: retrieve relevant lemmas based on the current goal rather than generic semantic matching;
    • Symbolic references: preserve theorem names and dependency relationships to avoid misuse where “semantics are similar but types do not match.”

    5.3 Compute Cost Control

    Formal verification is a compute-intensive task. Common optimizations include:

    • Caching verified subgoals (proof cache);
    • Pruning failing branches as early as possible;
    • Compiling high-frequency tactics into reusable custom tactics;
    • Using elastic container clusters scheduled by task priority.

    5.4 Data Security and Compliance

    Both cryptanalysis and mathematical proofs may involve sensitive assets (such as proprietary cryptographic algorithms or core protocol implementations). This requires:

    • Classifying and grading code and proof assets;
    • Network isolation for analysis environments;
    • Retaining audit logs across the entire workflow;
    • Data masking and access control for external model calls.

    6. How to Rationally Evaluate Such Results

    When facing statements like “AI conquers a Millennium Prize problem,” R&D and security teams should establish the following evaluation framework:

    Dimension Key Question Criteria
    Verifiability Is there machine-checkable code? A formal proof passes kernel verification, not just a natural language description
    Reproducibility Can others rebuild the result in an independent environment? Are toolchain versions, datasets, random seeds, and hardware conditions disclosed
    Attack practicality What are the time, memory, and parallelism requirements of the break? Distinguish “theoretically feasible” from “actually deployable”
    Scope of impact Which algorithms and protocols are involved? The full algorithm or a reduced variant under specific parameters
    Remediation path Is there a migration plan? Parameter adjustment, more rounds, or a different construction

    For cryptographic algorithms, a practical criterion is: whether the attack complexity is below the target security strength and reproducible under real deployment parameters. If an attack holds only under a reduced number of rounds, a specific key schedule, or non-standard parameters, its real-world impact is limited, but it should still be treated as input for design improvements.

    7. An Adoption Checklist for Enterprises

    Whether or not you work directly on AI for Science, the following practices are transferable:

    1. Build a formal verification capability reserve: pilot in high-risk areas such as protocol implementations, cryptographic modules, and key algorithms first;
    2. Build a reproducible experiment platform: unified toolchain, dependency locking, containerized execution, and result archiving;
    3. Design human-AI collaboration workflows: AI handles search and draft generation, while human experts review key assumptions and make final decisions;
    4. Integrate verification results into the R&D process: treat formal proofs as part of continuous integration, like unit tests but with stronger guarantees;
    5. Prioritize algorithm agility: give cryptographic algorithms versioning and rapid replacement capabilities, avoiding hard-coding;
    6. Establish a trust chain for AI output: record model versions, prompts, intermediate artifacts, and verification logs to form an auditable loop.

    8. Conclusion

    AI participation in mathematical proofs and cryptanalysis is essentially the engineering of the “search–verify–correct” research paradigm. Its inflection point is not a single point of intelligence but the convergence of verification infrastructure, search algorithms, and large-scale compute. For developers and enterprises, the short-term payoff lies in automated verification and vulnerability discovery; the long-term value lies in turning “correctness” from a manual review task into a computable engineering property. Viewing breakthroughs rationally and building solid verification and audit capabilities is the right posture for this wave of technology.