# Anthropic Papers on Lattice Attacks

> Source: <https://github.com/anthropics/formal-math/tree/main/lattices>
> Published: 2026-11-30 23:02:12+00:00

**Key takeaway:** Anthropic's internal Claude model discovered lattice-cryptography results that were then formalized in Lean 4, with 132 main theorems checked by Comparator against only the axioms propext, Classical.choice and Quot.sound, though the algorithms remain asymptotic and impractical for ML-KEM and ML-DSA

This folder holds four papers on lattice problems and lattice-based cryptography, and a Lean 4 formalization of their results.

The results were discovered by an internal research Claude model. The formalization was written by AI models.

Research artifact. Not maintained and not accepting contributions.

The main theorems are stated in [`PaperDefs/`](https://github.com/anthropics/formal-math/blob/main/lattices/PaperDefs), under their printed numbers. They assume no conjecture and no published theorem: the cited results that the proofs use are formalized as well, with their proofs. Algorithms are programs of a quantum word RAM, defined in about 1,000 lines in [`CryptoDefs/`](https://github.com/anthropics/formal-math/blob/main/lattices/CryptoDefs), and time is the number of its steps.

| What | Stated in | Checked by | 
|---|---|---|
| The main theorems: 132 statements | `PaperDefs/` | Comparator | 
| Intermediate theorems, remarks and detailed forms: 190 statements | `PaperDetails/` | Comparator | 
| The machine defines the standard P, BPP, PSPACE and BQP; simulations, oracles, resources: 63 theorems | `Challenge/Machine.lean` | Comparator | 
| The papers' lemmas, and that explicit programs execute the printed algorithms | `proof/QLStatement/` ,`proof/QL/` | `lake build` | 

A good place to start is [`PaperDefs/P01/Cases.lean`](https://github.com/anthropics/formal-math/blob/main/lattices/PaperDefs/P01/Cases.lean), which states eight results on paper 1 in a few lines each. For example, one quantum program solves search Module-LWE in quasi-polynomial time, for every fixed rank, all large degrees, moduli above a polynomial bound and almost all square matrices:

```
def ModuleLWETheorem : Prop :=
  ∃ program : QuantumProgram, ∃ c : ℕ, ∀ rank ≥ (1 : ℕ),
    ∀ᶠ n : ℕ in largePowersOfTwo, ∀ noise ≥ 1, ∀ q ∈ Set.Icc (11 * rank * noise ^ 2 * n) (2 ^ n),
      ForAllButFraction (2 ^ (-(n : ℝ) / (240 * rank))) fun A : Fin rank → Fin rank → Fin n → Fin q =>
        program.SolvesEveryInstance (moduleLWE A noise) (told := [n, rank, rank])
          (time := 2 ^ (c * rank ^ 8 * n.log2 ^ 2))
```

The results are asymptotic, and the algorithms are not practical for the parameter sets of ML-KEM and ML-DSA.

Running times count steps of the machine, so some bounds differ from the printed ones by logarithmic factors. That a program executes a printed algorithm means that it records the printed values and makes the printed calls and random choices, in order. Where a paper cites a subroutine without giving it, the programs use one of ours. Two remarks, one heuristic and one with open questions, are not formalized, and Remark 7.17 of paper 4 is conditional on an open question, as in the paper. [`docs/departures.md`](https://github.com/anthropics/formal-math/blob/main/lattices/docs/departures.md) lists the differences between the Lean statements and the text.

With [elan](https://github.com/leanprover/elan) installed, in this folder:

```
lake exe cache get
lake build
lake env lean scripts/PrintAxioms.lean
```

The build takes a little over an hour on 12 cores, with 12 GB of memory and 21 GB of disk. Only `Challenge/` contains `sorry`. The last command prints the axioms behind each compared theorem: `propext`, `Classical.choice` and `Quot.sound`.

The fuller check is [Comparator](https://github.com/leanprover/comparator) (`bash ../.github/scripts/comparator-check.sh`, on Linux). It verifies that `Solution/` proves exactly the statements of `Challenge/`, from these three axioms, and replays the proofs in Lean's kernel and in the independent kernel `nanoda`. Its three configurations take about 60, 40 and 5 minutes and up to 14 GB of memory.

**What a reader has to trust:** the statements and the definitions that they use (`CryptoDefs/`, `PaperDefs/`, `PaperDetails/`, `ConsistencyDefs/`, Mathlib), `Challenge/`, the configuration files, and the checkers; for the last row of the table above, also the statements in `proof/`. That the statements say what the papers say is for the reader to judge; AI readers have compared them with the text.

**Security.** Building downloads the Lean toolchain, Mathlib and Mathlib's compiled files, and compiling Lean code runs its tactics and macros with the rights of your user.

| Path | What it holds | 
|---|---|
| `papers/` | the four papers | 
| `CryptoDefs/` | the machine, resources and problems | 
| `ConsistencyDefs/` | Turing machines, circuits and classes, against which `Challenge/Machine.lean` holds the machine | 
| `PaperDefs/` | the main theorems | 
| `PaperDetails/` | the further statements | 
| `Challenge/` ,`comparator-*.json` | one theorem for each statement, with `sorry` in place of its proof; which theorems Comparator compares | 
| `Solution/` | one file for each file of `Challenge/` , which imports the proofs and adds nothing | 
| `proof/Crypto/` | the library on the machine: a language, its compiler, circuits | 
| `proof/CryptoConsistency/` | the proofs of the theorems on the machine; end theorems in `Theorems/` | 
| `proof/QLStatement/` | the full statements, with the printed algorithms | 
| `proof/QL/` | the proofs: mathematics ( `Tactic/` to`Lattice/` ), computation (`Tree/` to`Quantum/` ),`Algo/` ,`Crypto/` ,`Cited/` , one folder for each paper;`Papers/` has nearly all compared theorems,`Named/` the theorems on named programs | 
| `proof/CryptoMeta/` ,`proof/QLMeta/` | tactics and programs on terms that import Lean alone; Lake compiles them to native code (untrusted) | 
| `docs/departures.md` | where the Lean statements differ from the papers | 
| `docs/INDEX.md` | the papers item by item | 
| `scripts/PrintAxioms.lean` | prints the axioms behind the compared theorems | 

`QL.P04.Corollary_1_4a` is Corollary 1.4 (a) of paper 4, and `QL.P04.corollary_1_4a` says that it holds. [`docs/INDEX.md`](https://github.com/anthropics/formal-math/blob/main/lattices/docs/INDEX.md) leads from a printed number to the Lean declarations. [`proof/QLStatement/README.md`](https://github.com/anthropics/formal-math/blob/main/lattices/proof/QLStatement/README.md) explains the statements on explicit programs, the marks in doc comments and the keys of cited works. In the documents, a path that begins with `QL/`, `QLStatement/`, `Crypto/` or `CryptoConsistency/` is a file of `proof/`.
