import assert from 'node:assert/strict'; // Coordinates: Holden, arXiv:2611.19543, Section 2; Edel–Bierbrauer, Theorem 5. const blocks = new Set(['123', '124', '135', '146', '156', '236', '245', '256', '345', '346']); const V = Array.from({ length: 729 }, (_, x) => Array.from({ length: 6 }, (_, j) => Math.floor(x / 3 ** j) % 3)); const encode = (x) => x.reduce((n, d, j) => n + d * 3 ** j, 0); const support = (x) => x.flatMap((d, j) => d ? [j + 1] : []).join(''); const negative = V.map((x) => encode(x.map((d) => (3 - d) % 3))); const direction = V.map((_, x) => Math.min(x, negative[x])); const projective = V.flatMap((_, x) => x > 0 && x === direction[x] ? [x] : []); const difference = (x, y) => encode(V[x].map((d, j) => (d - V[y][j] + 3) % 3)); const dot = (x, y) => V[x].reduce((total, d, j) => total + d * V[y][j], 0) % 3; function layer(useComplement) { return V.flatMap((x, i) => { const positions = support(x); const inDesign = positions.length === 3 && blocks.has(positions) !== useComplement; const evenSigns = positions.length === 6 && x.filter((d) => d === 2).length % 2 === 0; return inDesign || evenSigns ? [i] : []; }); } function* permutations(values) { if (!values.length) yield []; for (const x of values) { for (const rest of permutations(values.filter((y) => y !== x))) yield [x, ...rest]; } } function symmetryActions(points, index) { const actions = new Map(); for (const permutation of permutations([0, 1, 2, 3, 4, 5])) { const preservesDesign = [...blocks].every((block) => blocks.has(permutation.flatMap((j, i) => block.includes(String(j + 1)) ? [i + 1] : []).join(''))); if (!preservesDesign) continue; for (let signs = 0; signs < 32; signs++) { // The sixth sign enforces even parity. Overall negation acts trivially. const sixth = popcount(signs) % 2; const image = points.map((point) => { const coordinates = permutation.map((j, i) => { const sign = i === 5 ? sixth : (signs >>> i) & 1; return ((sign ? 2 : 1) * V[point][j]) % 3; }); return index.get(direction[encode(coordinates)]); }); assert.equal(new Set(image).size, points.length); assert(image.every((i) => i !== undefined)); actions.set(image.join(','), image); } } return [...actions.values()]; } function popcount(x) { x -= (x >>> 1) & 0x55555555; x = (x & 0x33333333) + ((x >>> 2) & 0x33333333); return ((((x + (x >>> 4)) & 0x0f0f0f0f) * 0x01010101) >>> 24); } function tripleRepresentatives(actions) { const key = (a, b, c) => (a * 56 + b) * 56 + c; const seen = new Uint8Array(56 ** 3); const representatives = []; for (let a = 0; a < 56; a++) { for (let b = a + 1; b < 56; b++) { for (let c = b + 1; c < 56; c++) { if (seen[key(a, b, c)]) continue; const triple = [a, b, c]; representatives.push(triple); for (const action of actions) { const sorted = triple.map((i) => action[i]).sort((x, y) => x - y); seen[key(...sorted)] = 1; } } } } assert.equal(seen.reduce((sum, n) => sum + n, 0), 27720); return representatives; } function checkMaximum(masks, budget, claimedMaximum) { // A size-(claimedMaximum + 1) witness would also give every smaller // prefix. Prune when the union size exceeds the budget. let maximum = 0; function visit(start, lo, hi, depth) { maximum = Math.max(maximum, depth); assert(depth <= claimedMaximum, `budget ${budget} reached depth ${depth}`); for (let i = start; i < masks.length; i++) { const nextLo = lo | masks[i][0]; const nextHi = hi | masks[i][1]; if (popcount(nextLo) + popcount(nextHi) <= budget) visit(i + 1, nextLo, nextHi, depth + 1); } } visit(0, 0, 0, 0); return maximum; } function mask(indices) { const words = [0, 0]; for (const i of indices) words[Math.floor(i / 28)] |= 1 << (i % 28); return words; } function audit(cap) { const membership = new Set(cap); assert.equal(membership.size, 112); assert(cap.every((x) => x && membership.has(negative[x]))); for (const x of cap) { for (const y of cap) { if (x !== y) assert(!membership.has(difference(negative[x], y))); } } const exceptional = projective.filter((f) => { const throughOrigin = cap.filter((x) => dot(f, x) === 0).length; const twiceCoefficient = 3 * throughOrigin - 112; assert([8, -46].includes(twiceCoefficient)); return twiceCoefficient === -46; }); assert.equal(exceptional.length, 56); const points = projective.filter((x) => membership.has(x)); const index = new Map(points.map((x, i) => [x, i])); const external = projective.filter((x) => !membership.has(x)); assert.equal(external.length, 308); // For a fixed signed z, enumerate the ordered point pairs y - x = z. // An edge (i,j) marks the direction of x if y survives in both signs. const pairs = external.map((z) => { const edges = cap.flatMap((y) => { const x = difference(y, z); return membership.has(x) ? [[index.get(direction[x]), index.get(direction[y])]] : []; }); assert.equal(edges.length, 20); assert.equal(new Set(edges.map(([x]) => x)).size, 20); return edges; }); const endpointMasks = (deleted) => pairs.map((edges) => mask(edges.filter(([, y]) => !deleted.has(y)).map(([x]) => x))); const intact = endpointMasks(new Set()); const dual = external.map((z) => mask(exceptional.flatMap((f, i) => dot(z, f) === 0 ? [i] : []))); const intactLimits = [[35, 2], [39, 3], [43, 6]]; const dualLimits = [[39, 3], [43, 6]]; const puncturedLimits = [[32, 4], [33, 4], [34, 4], [35, 5], [36, 5]]; const actual = (masks, limits) => limits.map(([b, m]) => [b, checkMaximum(masks, b, m)]); console.log('intact endpoints', JSON.stringify(actual(intact, intactLimits))); console.log('exceptional frequencies', JSON.stringify(actual(dual, dualLimits))); const actions = symmetryActions(points, index); const representatives = tripleRepresentatives(actions); const maxima = puncturedLimits.map(([b]) => [b, 0]); for (const rep of representatives) { const row = actual(endpointMasks(new Set(rep)), puncturedLimits); row.forEach(([, maximum], i) => { maxima[i][1] = Math.max(maxima[i][1], maximum); }); } console.log('signed permutation actions', actions.length, 'triple representatives', representatives.length); console.log('three-direction endpoint maxima', JSON.stringify(maxima)); } const H = layer(false); const otherH = layer(true); audit(H); audit(otherH); const untouched = otherH.slice(3); const sums = new Set(H.flatMap((x) => untouched.map((y) => difference(x, negative[y])))); const missing = V.flatMap((x, i) => !sums.has(i) ? [x.join('')] : []); assert.equal(missing.length, 12); console.log('example deletions', otherH.slice(0, 3).map((x) => V[x].join('')).join(' ')); console.log('example missing sums', missing.join(' '));