Spec2Weights: Certifying Networks that a Language Model Writes from a Specification
Authors: Soumik Bhattacharjee, Musa Tur Farazi, Md Nasir Uddin, Tishna Sabrina, Chowdhury Mohammad Rakin Haider
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
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 1016 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
–
Table 1: Closest work. ✓: present; –: absent; (✓): partly. a probabilistic model checking of the policy in its environment. “Partial”: theorems for two of five classes.
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 57× 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 232 addresses
enum ( 220 patterns), T1
exact
23 s
Luhn
MLP 160-192-2
31,298
21,360
all 1016 strings
DP (145 states), T1
exact
0.1 s
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 maxiMi of App. B ; L1 = Lemma 1 . Times are CPU wall-clock on one or two threads. Domains: a 5 operations on all pairs of 8-bit operands; b at most one piece per square, exactly one white king, kings not adjacent; c neutral 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); d integer edge lengths 1–5 and at least ∣V∣−1 rounds; e at least maxd steps and at most 1.39 M steps ( T>maxd keeps the guard off at d=T ); f reading frame 0.
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
Table 3: Operating envelope of each certified network. All certificates need IEEE binary32 (or wider) with round-to-nearest in every multiply and add. Settings that break this: TF32 matrix units, float16 or bfloat16 autocast, fast-math reassociation into lower precision, and Winograd or FFT convolution. Outside its domain a network gives wrong answers silently. The guard is a cheap caller-side check; for the saturating networks the same test can be one extra ReLU unit. ∗ The 25 certified nets of Section 5.4 .
network, setting
prediction
kind
measured
shortest path, ℓ=5 , fp32
first wrong hop 820
sharp
820
shortest path, ℓ=1 , fp32
right at 4096, wrong 4097
sharp
4097
shortest path, fp16 / bf16
wrong from hop 1
sharp
1 / 1
maze, fp16
T⋆∈[512,700]
band
684
maze, bf16
T⋆∈[64,90]
band
88
maze, fp32
none for T≤3,000
sharp
none
Table 4: Failure points: logged prediction, its kind, and the measurement. Sharp : derived from Theorem 2 or exact algebra. Band : a heuristic range. Maze: a 40-cell corridor.
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
Table 5: Written network against tuned GD on the same architecture (selected on validation, then 3 seeds). Ranges are over seeds; “train” gives training sizes; test sizes and intervals are in App. C . Chance: 50% (Luhn), 0.5 AUC, 14.3% (day of week).
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 30×30 ( ×4 )
✓
–
tuned only
compounding
shortest paths, gene finder
–
–
neither
Table 6: Evidence per task. Tuned: a GD baseline tuned in this paper. Theorem: a theorem in this paper whose setting covers the task.
family
result
certificate → float32
95% LB
check digits ( m 7–13, n 8–14)
10/10 certified
DP over 108 – 1014 , T1
74%
routing (16–45 routes)
10/10 certified
enum over 218 – 220 , 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
Table 7: Thirty fresh specifications, first submissions. Certified: exact for any summation order. Tax: the pre-fixed rule is at most 1errorateverywholedollar0–2M, both statuses, float32. 95% LB: one-sided Clopper–Pearson.
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
Table 8: Fresh specifications by two writers, rules of Table 7 .
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
network
certificate
per layer: maxiMi (grid exponent e )
8-bit ALU
enum
766 ( e=0 ); 1,279 ( e=0 ); 30 ( e=0 )
day of week
enum
663 ( e=2 ); 5,352 ( e=4 ); 1,297,920 ( e=4 )
tic-tac-toe
enum
9 ( e=0 ); 5,061 ( e=0 )
routing
enum
27 ( e=0 ); 131,072 ( e=0 )
Luhn
DP
289 ( e=0 ); 44,405 ( e=0 )
Sudoku validity
tmpl
10 ( e=0 ); 2,435 ( e=0 )
Appendix
Table 9: Per-layer maxiMi and grid exponent e for every certified network (suite and X6).
Figure 1: Left: the shortest-path network is exact through hop 819 and clamps at 4096 from hop 820 in float32; in 16-bit formats it is wrong from hop 1. Right: the maze network on a 40-cell corridor first errs at T=684 (float16) and T=88 (bfloat16).
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
–
Appendix
Table 10: Validation score (%; AUC for Luhn uniform) of every grid cell, seed 0. Columns: learning rate, width, weight decay (– none, wd AdamW 10−2 ); last column: curriculum variant. Bold: selected.
task
test
n 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 ≈0.002
10k / 40k
day of week
other centuries
219,145
7.16 / 6.73 / 15.38
– (all)
15k / 30k
Appendix
Table 11: Test sets, per-seed scores and 95% intervals of the final runs. The seeds share one test set, so instead of pooling we give the range of the three per-seed 95% Clopper–Pearson intervals (lowest lower end to highest upper end). “all”: the test is every input of its domain, so there is no sampling noise. Maze cells within a maze are not independent, so no interval is given; Hamming bit errors cluster within words, so its SE is approximate. Select “–”: a fixed configuration (the written width), not selected.
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 <210
empirical
no ( 1.3×106 )
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
Table 12: Predictions logged before each run (local logs, self-attested) and outcomes.
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
Appendix
Table 13: Optimal-statistic tier. Hamming: BER % on 106 words per Eb/N0 (rate-4/7 scaling). Motion: accuracy % on 20,000 fresh pairs (SE ≤0.35 points).