Spec2Weights: Certifying Networks that a Language Model Writes from a Specification
Organizations: Department of Computer Science and Engineering, Bangladesh University of Engineering and Technology (BUET), Dhaka, Bangladesh · Department of Electrical and Electronic Engineering, University of Asia Pacific (UAP), Dhaka, Bangladesh
Abstract
A language model can write the weights of a small MLP, CNN, RNN or GNN from a plain-language specification, with no data and no gradient step. We ask when such a network can be proved exact in the float32 arithmetic it actually runs in. A float-safety lemma makes exhaustive float32 enumeration a proof for any summation order, and a layered error bound covers networks whose weights are not short binary fractions. With dynamic programming, template checks, an SMT proof, breadth-first search and induction for weight-tied recurrences, this certifies 12 of 15 written networks (one after a single constant fix) on every input of a stated domain (up to inputs, or every graph or grid up to a size bound), in a minute of CPU or less each. The certificates also say where a network stops being exact: the shortest-path network is exact iff the distance is at most 4,096 and fails at the predicted hops. Thirty new specifications were each written by a fresh session of one model family (Claude Opus 5.5). Twenty-five first submissions are certified exact for any summation order; the five tax schedules stay within $0.11 of the true tax at every whole dollar in one fixed float32 run. An open 27B model passes 23 of the 30, and 25 with more thinking and code execution, so the method transfers in part. We also prove two limits of learning from examples: input coordinates never active in training cannot be learned from more in-range data, and Luhn-type checksums have exponentially small target-dependent gradient variance across their family. Tuned gradient descent on the same architectures agrees with both, which cover two of our five failure classes.
Figures & tables
| who makes | non-transf. | float-sound | GD, same | theory of | |
|---|---|---|---|---|---|
| the weights | targets | certificate | architecture | GD failure | |
| Tracr / ALTA | compiler (DSL) | – | – | ALTA (✓) | – |
| TracrBench | LLM via RASP | – | – | – | – |
| CLRS / discrete NAR | training | GNN | – | trained | – |
| Neural Compiler | compiler (DSL) | ✓ | tests | – | – |
| WSP blog | LLM | ✓ | – | RL / GD | – |
| task | architecture | weights | nz | certified domain | certificate float32 | result | time |
|---|---|---|---|---|---|---|---|
| 8-bit ALU | MLP 21-96-64-8 | 8,840 | 626 | 327,680 inputs a | enum, T1 | exact | 4.5 s |
| day of week | MLP 83-64-192-7 | 19,207 | 4,105 | all dates 1600–2399 | enum, T1 | exact after 1 fix | 8 s |
| Roman numerals | conv-sum-linear | 513 | 98 | numerals 1–3,999 | enum, L1 | exact (margin bound) | 0.2 s |
| tic-tac-toe | MLP 27-256-9 | 9,481 | 1,524 | all games, all tie-breaks | enum, T1 | 0 losses | 2 s |
| routing | MLP 32-32-8 | 1,320 | 226 | all addresses | enum ( patterns), T1 | exact | 23 s |
| Luhn | MLP 160-192-2 | 31,298 | 21,360 | all strings | DP (145 states), T1 | exact | 0.1 s |
| network | preconditions beyond the input format | behaviour outside them | cheap guard |
|---|---|---|---|
| ALU, routing, Luhn, tic-tac-toe; fresh ∗ check digits, routing | none (the domain is every encodable input; legal positions for tic-tac-toe) | – | one-hot / bit check |
| day of week; fresh ∗ calendars | a real date in 1600–2399 | some weekday, silently | validate the date |
| Roman numerals | canonical numeral, value 1–3,999 | a value by the additive rule | canonical-form regex |
| Sudoku validity | every cell filled | incomplete grids read as invalid | count filled cells |
| tax, 2024 schedule | income $0–2M; status one-hot | error grows; status gate fails above $3.03M | flag income >\2$ M |
| chess check | one piece per square, one white king, kings apart | possible false check | one-hot, king count, kings apart |
| network, setting | prediction | kind | measured |
| shortest path, , fp32 | first wrong hop 820 | sharp | 820 |
| shortest path, , fp32 | right at 4096, wrong 4097 | sharp | 4097 |
| shortest path, fp16 / bf16 | wrong from hop 1 | sharp | 1 / 1 |
| maze, fp16 | band | 684 | |
| maze, bf16 | band | 88 | |
| maze, fp32 | none for | sharp | none |
| task, test | written | tuned GD | pred. held |
| Luhn, mix of 4 kinds (train 10.2M) | 100 | 49.3–51.0 | yes |
| Luhn, uniform digits, AUC (train 10.2M) | 1.0 | 0.499–0.503 | yes |
| Roman, random split | 100 | 95.8–97.3 | yes |
| Roman, train 1–999, test 1000 | 100 | 0.0 | yes |
| day of week, unseen centuries, one-hot | 100 | 6.7–15.4 | yes |
| day of week, unseen centuries, scalar | 100 | 0.6–2.9 | yes |
| class | task | tuned | theorem | both? |
|---|---|---|---|---|
| no signal | Luhn | ✓ | T4 (family; consistent) | yes, in part |
| no data | day of week | ✓ | T3(a) one-hot, T3(b)-type scalar | yes |
| no data | tax above $500k | – | T3(b) | theorem only |
| out of support | Roman 1000 | ✓ | – | tuned only |
| compounding | maze ( ) | ✓ | – | tuned only |
| compounding | shortest paths, gene finder | – | – | neither |
| family | result | certificate float32 | 95% LB |
|---|---|---|---|
| check digits ( 7–13, 8–14) | 10/10 certified | DP over – , T1 | 74% |
| routing (16–45 routes) | 10/10 certified | enum over – , T1 | 74% |
| calendars (week 5–10) | 5/5 certified | all 292k dates, T1 | 55% |
| tax (4–8 brackets) | 5/5 pass the rule | every $1 in one run | 55% |
| 0/5 exact to the cent | max error $0.07–0.11 | ||
| 1/5 certified within $1 | L1 bound $0.94–2.63 |
| writer | routing | check digit | tax | calendar | total |
|---|---|---|---|---|---|
| Qwen, basic | 10/10 | 9/10 | 4/5 | 0/5 | 23/30 |
| Qwen, expanded | 10/10 | 9/10 | 5/5 | 1/5 | 25/30 |
| Claude | 10/10 | 10/10 | 5/5 | 5/5 | 30/30 |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| network | certificate | per layer: (grid exponent ) |
|---|---|---|
| 8-bit ALU | enum | 766 ( ); 1,279 ( ); 30 ( ) |
| day of week | enum | 663 ( ); 5,352 ( ); 1,297,920 ( ) |
| tic-tac-toe | enum | 9 ( ); 5,061 ( ) |
| routing | enum | 27 ( ); 131,072 ( ) |
| Luhn | DP | 289 ( ); 44,405 ( ) |
| Sudoku validity | tmpl | 10 ( ); 2,435 ( ) |
| 0.0003 | 0.0003 | 0.0003 | 0.0003 | 0.001 | 0.001 | 0.001 | 0.001 | 0.003 | 0.003 | 0.003 | 0.003 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 4 | 4 | 1 | 1 | 4 | 4 | 1 | 1 | 4 | 4 | ||
| task | – | wd | – | wd | – | wd | – | wd | – | wd | – | wd | cur. |
| Luhn (mix) | 50.1 | 50.0 | 51.0 | 50.2 | 50.7 | 50.1 | 50.2 | 50.2 | 50.0 | 49.7 | 49.4 | 50.8 | 50.0 |
| Luhn (uniform, AUC) | 0.500 | 0.501 | 0.498 | 0.498 | 0.498 | 0.505 | 0.497 | 0.503 | 0.503 | 0.502 | 0.498 | 0.494 | – |
| Sudoku | 57.4 | 57.6 | 59.6 | 60.1 | 52.5 | 53.5 | 53.7 | 54.5 | 52.7 | 51.8 | 52.3 | 53.0 | – |
| day of week | 89.6 | 87.8 | 98.4 | 97.9 | 99.4 | 99.3 | 99.9 | 99.9 | 100.0 | 99.9 | 100.0 | 99.9 | – |
| task | test | per seed | seed 0 / 1 / 2 (%) | 95% CI, per seed (%) | select / final steps |
|---|---|---|---|---|---|
| Luhn (mix) | valid numbers | 20,000 | 49.87 / 50.03 / 49.32 | 48.62–50.73 | 20k / 40k |
| Luhn (mix) | invalid: random | 20,000 | 49.72 / 50.41 / 49.54 | 48.85–51.11 | 20k / 40k |
| Luhn (mix) | invalid: one digit | 20,000 | 50.33 / 50.77 / 49.71 | 49.01–51.46 | 20k / 40k |
| Luhn (mix) | invalid: swap | 20,000 | 50.26 / 51.02 / 49.61 | 48.91–51.72 | 20k / 40k |
| Luhn (uniform) | AUC, 200k strings | 200,000 | 0.5019 / 0.4992 / 0.5028 | SE | 10k / 40k |
| day of week | other centuries | 219,145 | 7.16 / 6.73 / 15.38 | – (all) | 15k / 30k |
| exp. | prediction | basis | held? |
| X1 | ALU, day of week, Roman, tic-tac-toe, routing exact; 16 Hamming codewords decode | empirical | yes |
| X1 | day of week integer magnitudes | empirical | no ( ) |
| X1 | routing: a few hundred trie cells | empirical | no (89 cells) |
| X1 | tic-tac-toe: 0 losses in 549 games | empirical | in part: 33 tied positions not foreseen; 0 losses over every tie-break |
| X2 | Luhn, Sudoku, tax, chess, chemistry hydrogens certify | empirical | yes |
| X2 | chemistry mass error Da per 100 atoms | empirical | no result (mass not certified) |
| Hamming(7,4) | written | block ML | bitwise MAP |
|---|---|---|---|
| 0 dB | 8.2797 | 8.2807 | 8.1288 |
| 2 dB | 2.8874 | 2.8883 | 2.8503 |
| 4 dB | 0.53135 | 0.53145 | 0.52928 |
| 6 dB | 0.037625 | 0.037650 | 0.037475 |
| Motion | written | Bayes | GD, 60k pairs |
| coherence 0.2 | 88.26 | 88.21 | 78.36 |
Neural Network Verification
Neural network verification develops methods to prove whether networks satisfy properties such as robustness, safety, and bounded output behavior.
See all 146 papers