Spec2Weights: Certifying Networks that a Language Model Writes from a Specification

Soumik Bhattacharjee, Musa Tur Farazi, Md Nasir Uddin, Tishna Sabrina, Chowdhury Mohammad Rakin HaiderarXiv 2026

TL;DR

Instead of training small neural networks with millions of examples and gradient descent, Large Language Models (LLMs) can write a Python script that sets every network weight directly from a plain-English rulebook. This paper shows how to mathematically prove that these LLM-authored networks are 100% exact in real-world float32 arithmetic across massive input domains—and pinpoints the exact boundary where they will break.

What Problem Does This Paper Address?

Usually, getting a neural network to do something requires data and gradient descent. Recently, researchers noticed LLMs can do weight-space programming (WSP): given a plain-language specification (like how to validate a credit card number or route an IP packet) and a fixed architecture, an LLM can write code to hardcode the exact weights of an MLP, CNN, RNN, or GNN—zero data or gradients required.

If you want to ship one of these networks inside a fixed hardware accelerator or a larger hybrid model in place of standard tested software, testing it on a few random samples isn't enough. Worse, mathematical proofs over ideal real numbers can be fooled in deployment because computers use finite float32 arithmetic, where rounding errors and even the order in which numbers are summed can flip an answer. The authors ask two practical questions: Can we prove exactness in actual float32 hardware? And where, precisely, does the network stop working?

Methods

The authors pair LLM weight-generation (using Claude Opus 5.5 and Qwen3.8-27B to write Python weight-builders) with cheap, fast formal verification tailored to floating-point reality:

  • Float-Exact Enumeration (Theorem 1): Because LLMs naturally choose clean integers or short binary fractions for weights, the authors prove that if a layer's absolute partial sums stay within $2^{24}$ on its binary grid, float32 arithmetic experiences zero rounding error—regardless of summation order. Standard exact checks (dynamic programming, breadth-first search, SMT solvers) automatically become hardware-sound proofs.
  • Layered Margin Bound (Lemma 1): When weights aren't clean binary fractions (like 0.01 in tax formulas), they propagate worst-case float32 rounding bounds layer by layer.
  • Size-Free Local Induction (Theorem 2): For weight-tied recurrent networks (like shortest-path GNNs), checking a finite grid of local integer states proves correctness on graphs or mazes of any size up to a predictable saturation limit.
  • Learning Limits (Theorems 3 & 4): Alongside tuned Gradient Descent (GD) baselines on the exact same architectures, they mathematically prove why data-driven training fails on unexcited input features and parity-like checksums.

Datasets

Written networks use zero training data. For evaluation and newly introduced benchmarks, the authors use:

  • The 15-Network Suite: Pre-existing LLM-written networks spanning 8-bit ALUs, Luhn checksums ($10^{16}$ strings), Sudoku ($9^{81}$ grids), chess check detection, shortest paths, DNA gene finding, and 2024 US tax schedules.
Table 2. The certified suite. “nz” = non-zero parameters. Certificate: enum = exhaustive enumeration; DP = dynamic programme over reachable hidden pre-activations; tmpl = weight-template check plus a counting argument; SMT = z3 proof per king square (Int sort); BFS = search over reachable RNN states; local = Theorem 2; PL = exact rationals at all breakpoints. Every certificate reasons in exact integers or rationals; the last column says how it is carried to the float32 network (any summation order): T1 = Theorem 1 with the per-layer maxi Mi of App. B; L1 = Lemma 1. Times are CPU wall-clock on one or two threads. Domains: a5 operations on all pairs of 8-bit operands; bat most one piece per square, exactly one white king, kings not adjacent; cneutral molecules over C, N, O, F, S, Cl with integer bond orders 1–3 and bond-order sum at most the valence at every atom (hydrogen counts only); dinteger edge lengths 1–5 and at least |V | −1 rounds; eat least max d steps and at most 1.39M steps (T > max d keeps the guard off at d = T); freading frame 0.
  • 30 Fresh Specifications Benchmark: To rule out memorization, a seeded generator created 30 randomized rulesets after the LLM's knowledge cutoff—covering random check-digit schemes, nested routing tables, alien calendars, and hypothetical tax brackets.
  • Synthetic GD Datasets: Up to 10.24M synthetic examples per seed to train baseline networks for head-to-head comparison.

Key Insights and Ideas

  • LLM-written networks are uniquely easy to verify: Verifying trained ReLU networks is notoriously NP-hard because weights are messy decimals and thousands of neurons fire together. LLM-authored networks use sparse, clean integer logic, shrinking the reachable state space of a $10^{16}$-input Luhn network down to just 145 states!
  • Proofs predict exact breaking points; random tests miss them: Standard tests up to 200 nodes say the shortest-path GNN is flawless. The certificate reveals it clamps distances at $B = 4,096$—predicting before running a single test that a path of length-5 edges will fail at hop 820, and a unit path at hop 4,097.
Table 4. Failure points: logged prediction, its kind, and the mea- surement. Sharp: derived from Theorem 2 or exact algebra. Band: a heuristic range. Maze: a 40-cell corridor.
  • Specs beat data where gradients go blind: On Luhn checksums, any proper subset of digits looks completely random, starving gradient descent of low-order signal (staying at 50% chance after 10M examples). On calendar centuries or high tax brackets never seen in training data, gradient descent cannot adjust the unexcited weights, whereas an LLM reads the rule and wires the unseen cases effortlessly.
  • Never underestimate well-tuned GD: The authors initially conjectured GD couldn't learn Sudoku validity; after tuning AdamW properly, GD hit 100%, prompting them to honestly withdraw their conjecture.

Key Results

  • Fast, Sound Certification: 12 of the 15 suite networks are certified 100% exact in float32 (one—day of week—needed a single off-by-one constant fixed), and 1 tax network is certified within \$1.90 across all real incomes up to \$2M. Each proof takes under 63 seconds on a CPU (most under 2 seconds).
  • Fresh Specs Generalization: On first-try submissions for the 30 novel specs, Claude Opus 5.5 got 25/25 discrete tasks certified exact for any summation order, and 5/5 tax networks within \$0.11 on whole-dollar tests. An open-weights 27B model (Qwen3.8) passed 23/30 basic, rising to 25/30 with more thinking tokens and Python error feedback.
Table 7. Thirty fresh specifications, first submissions. Certified: exact for any summation order. Tax: the pre-fixed rule is at most $1 error at every whole dollar $0–2M, both statuses, float32. 95% LB: one-sided Clopper–Pearson.
  • Catching Mutants: While random testing of 20,000 inputs missed 7.4% of single-weight bugs injected into the networks, the certificates caught 100% of them.

Limitations and Future Work

  • Familiar Idioms, Not Alien Algorithms: While the 30 fresh specs use randomized numbers, they belong to familiar algorithmic families (checksums, calendars, routing, taxes) and the prompt hints at using per-digit tables.
  • No Transformers Yet: The work certifies MLPs, CNNs, RNNs, and GNNs, leaving self-attention architectures and fuzzier tasks without exact closed-form specs for the future.
  • Silent Failures Outside the Envelope: Hardware settings like TF32 tensor cores, float16 autocast, or fast-math compiler flags invalidate the float32 proofs, and invalid inputs (like February 30th) produce silent wrong answers unless paired with lightweight caller-side guards.

Summary updated

BibTeX
@misc{bhattacharjee2026spec,
  author = {Soumik Bhattacharjee and Musa Tur Farazi and Md Nasir Uddin and Tishna Sabrina and Chowdhury Mohammad Rakin Haider},
  title = {{Spec2Weights: Certifying Networks that a Language Model Writes from a Specification}},
  year = {2026},
  eprint = {2611.34711},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.34711},
}
Figure