Agentic Algorithm Design: LLMs that Propose, Formalise, and Prove Runtime Bounds for Evolutionary Algorithms in Lean
Summary (Overview)
-
Novel pipeline: The paper presents a staged pipeline that combines LLMs with the Lean theorem prover to automatically design black-box optimisation algorithms and prove their expected runtime bounds—with no empirical evaluation whatsoever.
-
Key results: Across 8 problem classes, 12 of 15 runs with frontier models completed the pipeline with machine-checked runtime bounds. The agent designed an algorithm for a novel CYCLEUNCOVER problem where the classical (1+1) EA requires runtime, and achieved the classical runtime on LEADINGONES.
-
Ablation findings: Removing the staging and asking for zero-shot algorithmic design leads to copies of the seeded baseline algorithm (random search) or incomplete proofs. Open-weight models (Goedel-Prover-V2-32B, Gemma 4) failed to complete the pipeline.
-
Submodular minimisation: Over five generations of the pipeline, the agent rediscovered projected subgradient descent on the Lovász extension for integer-valued submodular minimisation, improving the runtime bound from to .
-
First of its kind: To the authors' knowledge, this is the first automated pipeline that designs efficient black-box optimisation algorithms with machine-checked runtime bounds in Lean.
Introduction and Theoretical Foundation
Background and Motivation
From a theoretical computer science perspective, algorithm design requires two artefacts: (1) the algorithm itself—a finite sequence of instructions, and (2) the analysis—a mathematical proof of correctness and complexity guarantees. Traditional algorithmic design is costly and requires deep expertise, motivating research into automated design of heuristics.
Recent LLM-based heuristic design approaches (e.g., AlphaEvolve, ShinkaEvolve, LLaMEA) evaluate candidate heuristics empirically on benchmark functions. While successful, these methods provide no guarantees on correctness or performance. The paper addresses the open problem of whether AI agents can carry out algorithmic design as understood in theoretical computer science—producing both algorithms and rigorous proofs of their efficiency.
Black-Box Optimisation Framework
The paper adopts the black-box optimisation scenario (also called the query model) from the theory of evolutionary algorithms:
- An adversary picks a fitness function ,
- The algorithm queries search points and receives fitness values
- Runtime is the number of queries until the algorithm queries an optimal search point
- An algorithm is a tuple
The worst-case expected runtime over a function class is .
Drift Analysis
The pipeline builds on drift analysis (Hajek, 1982; He & Yao, 2001), which measures algorithm progress via a potential function . The drift is the change in potential per time step: where .
The paper introduces a simplified drift theorem (Corollary 3.1) that avoids measure-theoretic complications. For all , with :
These conditions together yield the runtime bound .
Methodology
The Staged Pipeline
The pipeline (Figure 2 in the paper) is seeded with a problem card and an initial algorithm (uniform random search with expected runtime ). It consists of informal stages (prose descriptions) and formal stages (Lean definitions/proofs verified by the prover). Stages are repeated upon Lean failure, with backtracking determined by a Luby sequence.
Algorithm Design Stages (0–8):
- Stage 0 (DesignLock): Agent proposes informal algorithm design with justification
- Stage 1 (ConstructAlgorithmComponents): Formalise the algorithm as tuple
- Stage 2 (Completeness): Algorithm must be able to query any search point from any reachable state
- Stage 3 (NonAbsorbing): Algorithm must use randomness
- Stage 4 (NotRandomSearch): Algorithm must differ from uniform random search
- Stage 5 (Adaptiveness): State update must depend on fitness responses
- Stage 6 (QueryNonInjectivity): State must carry information beyond the current query
Potential Function Stages (9a–9f):
- Agent proposes candidate potential functions with a "drift story"
- Potential must be in , measurable, and zero iff the state queries an optimum
- Guard against two-valued potentials (0 and 1 only)
Drift Certificates and Runtime Bound (10a–10j):
- Define sets Good(y), Worsen(y), BigWorsen(y) for each state y
- Prove drift conditions (1)–(3) of Corollary 3.1
- Prove jump probability lower bound
- Final stage applies the runtime bound
Models and Implementation
- Frontier models: Claude Opus 5, Opus 5.5, Fable 5.1 (CLI backend)
- Open-weight models: Goedel-Prover-V2-32B (formal stages, pass@256) + Gemma 4 26B-A4B (prose stages) via vLLM backend
- Two backends: CLI and vLLM, with the Kimina Lean server
Empirical Validation / Results
Benchmark Functions
| # | Problem | Model | Algorithm | Runtime Bound |
|---|---|---|---|---|
| 1 | ONEMAX | Opus 5 | (1+1) EA, rate | |
| 2 | LEADINGONES | Opus 5.5 | fitness-dependent rate | |
| 3 | LEADINGONES, lemma | Opus 5.5 | fitness-dependent rate | |
| 4 | JUMP | Opus 5.5 | (1+1) EA, rate | |
| 5 | JUMP, lemma | Opus 5.5 | rate cycling with learned phase bit | |
| 6 | CYCLEUNCOVER | Fable 5.1 | cycle walk (learn-then-solve) | |
| 7 | WELLCOVEREDVC | Fable 5.1 | fitness-directed asym. mutation | |
| 9 | WELLCOVEREDVC, anonymised | Opus 5.5 | regime-switching asym. mutation | |
| 10 | VERTEXCOVER, flat fitness | Fable 5.1 | edge probing + exact solve | |
| 11 | BANDWIDTHVC, flat fitness | Fable 5.1 | window probing + exact solve | |
| 14 | BANDWIDTHVC | Opus 5.5 | window-repair random search | |
| 15 | SUBMODULARMIN | Opus 5.5 | Lovász subgradient descent |
CYCLEUNCOVER: A Novel Problem
The agent designed a fundamentally different algorithm from evolutionary approaches:
- Build a two-colouring of the cycle graph by walking along it
- Sample uniformly random vertices until finding an uncoloured neighbour of current vertex
- Colour it oppositely to and make it the new current vertex
- After steps, query the optimum (all vertices of one colour)
The algorithm needs queries per step in expectation (probability of finding the single uncoloured neighbour), giving total runtime . This contrasts with the classical result:
Theorem 5.1: The expected runtime of the (1+1) EA on CYCLEUNCOVER is .
Submodular Minimisation Over Generations
The pipeline was looped for 5 generations on integer-valued submodular minimisation:
| Generation | Runtime Bound |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 5 |
The final bound matches the asymptotic complexity of the classical Fujishige-Wolfe algorithm.
Ablation Studies
- Zero-shot ablation: Without staging, the agent reproduced the seeded random search algorithm for CYCLEUNCOVER, or failed to produce a runtime bound (BANDWIDTHVC)
- Weaker models: Claude Sonnet passed Stages 0–10g but failed at the mass bound (Stage 10h); open-weight models stopped much earlier (Stages 3–9d) and generated 25–124M output tokens per run
Theoretical and Practical Implications
On the Role of Formal Verification
The paper demonstrates that machine-checked specifications in Lean can replace empirical evaluation in open-ended algorithm discovery. This is significant because:
- It provides rigorous guarantees that empirical benchmarking cannot
- It eliminates the risk of overfitting to benchmark functions
- It enables verification of stochastic algorithms (not just deterministic ones)
On Algorithm Discovery
The pipeline discovered algorithms that differ qualitatively from standard evolutionary approaches:
- CYCLEUNCOVER: A learn-then-solve strategy exploiting graph structure
- VERTEXCOVER (flat fitness): An edge-probing strategy that "cheats" by exploiting the black-box model's free offline computation
- Submodular minimisation: Rediscovery of Lovász subgradient descent, a classical convex optimisation technique
Limitations and Caveats
- Runtime bounds are often not tight (e.g., vs true for ONEMAX)
- The simplified drift theorem (Corollary 3.1) prevents multiplicative drift analysis
- Only frontier models completed the pipeline; open-weight models failed
- The black-box model does not charge for offline computation, enabling "cheating" strategies
Conclusion
The paper presents the first automated pipeline that designs efficient black-box optimisation algorithms with machine-checked runtime bounds in Lean. Key takeaways:
- Staging is essential: Breaking the design-and-analysis task into stages with formal guards is crucial for success; zero-shot attempts fail
- Formal verification works: Lean guards effectively filter out flawed designs and enable rigorous runtime guarantees
- LLMs can do theoretical computer science: The agent discovered novel algorithms for new problems (CYCLEUNCOVER) and rediscovered classical results (Lovász subgradient descent)
Future directions identified by the authors:
- Richer drift theorems for tighter bounds
- More iterations of the design loop
- Extension to continuous search spaces
- More comprehensive experimental design with statistical analysis
The authors acknowledge limitations: only frontier models completed the pipeline, the simplified drift theorem leads to non-tight bounds, and the search space is restricted to bitstrings. Nevertheless, this work establishes that automated formal algorithm design is feasible, potentially transforming how optimisation algorithms are discovered and verified.
Related papers
- LinQuant: Functional Invariances for Low-Precision Linear Recurrences
LinQuant's seven functional invariances—basis changes and decay/write absorptions—enable low-precision linear recurrent inference, improving perplexity over SSDi8 on Mamba-2 and Nemotron-H without added latency.
- Improving Data-Constrained Scaling with Hyperparameter Transfer and Ensembling
Data-constrained scaling laws must treat ensembling as a third compute-allocation axis and scale hyperparameters via power laws, yielding 14% lower perplexity than prior recipes.
- ParaTTT: Parallelizing Test-Time Training Layers with Deep Memories
ParaTTT parallelizes test-time training layers with deep memories by iterative refinement, achieving 32× speedup over TTT-MLP and competitive language modeling without sacrificing accuracy.