{"challengeId":"ising-ground","entry":"verifier.mjs","sha256":"bd23db41615f3fa3bd93dc48d3ee3632cd76c0f3f5c54d55f0a57e13e7869201","scoreDirection":"minimize","scoreLabel":"Ising energy","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for ising-ground. Self-contained (no imports). The fixed graph\n// and the integer couplings J_ij in {-1,+1} below ARE the instance — protected but\n// readable. The agent submits a spin assignment s in {-1,+1}^n and the checker\n// recomputes the EXACT integer Ising Hamiltonian\n//\n//     H(s) = - sum over edges (u,v) of  J_uv * s_u * s_v\n//\n// Lower energy wins (scoreDirection \"minimize\"). Finding the lowest-energy spin\n// configuration of a frustrated Ising spin glass is the ground-state problem at\n// the core of quantum annealing, Ising machines, and QUBO optimization.\n//\n// PURE INTEGER arithmetic only — every term is a product of {-1,+1} integers, so\n// the energy is an exact integer. No Math.* transcendentals, no non-integer **.\n// Deterministic; seedPolicy \"fixed\" (the same instance every run).\n\nconst N = 20;\n\n// Undirected edge list (u < v). Fixed forever.\nconst EDGES = [\n  [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9],\n  [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17],\n  [17, 18], [18, 19], [0, 19], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8],\n  [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16],\n  [14, 17], [15, 18], [16, 19], [0, 17], [1, 18], [2, 19], [0, 7], [1, 8],\n  [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15], [9, 16],\n  [10, 17], [11, 18], [12, 19],\n];\n\n// Integer couplings J_uv in {-1, +1}, one per edge, aligned to EDGES by index.\n// A mix of ferromagnetic (+1) and antiferromagnetic (-1) bonds makes the lattice\n// FRUSTRATED: no spin assignment can satisfy every bond, so all-up is far from\n// optimal and the true ground state requires real search.\nconst J = [\n  1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1,\n  1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1,\n  -1, 1, 1, -1, 1, 1, -1,\n];\n\nfunction gate(name, pass, detail) { return { name, pass, detail }; }\nfunction bad(name, detail) {\n  return { ok: false, score: null, gates: [gate(name, false, detail)], behavior: {}, logs: [] };\n}\n\nexport function verify(ctx) {\n  const spins = ctx && ctx.solution && typeof ctx.solution === 'object' ? ctx.solution.spins : undefined;\n  if (!Array.isArray(spins) || spins.length !== N) {\n    return bad('structure', `expected { spins: [${N} values, each -1 or +1] }`);\n  }\n  for (const s of spins) {\n    if (s !== -1 && s !== 1) return bad('structure', `each spin must be -1 or +1; got ${String(s)}`);\n  }\n\n  // Exact integer Hamiltonian: H = - sum_edges J_uv * s_u * s_v.\n  let energy = 0;\n  let satisfied = 0;\n  for (let i = 0; i < EDGES.length; i++) {\n    const u = EDGES[i][0];\n    const v = EDGES[i][1];\n    const bond = J[i] * spins[u] * spins[v]; // integer in {-1, +1}\n    energy -= bond;\n    if (bond > 0) satisfied += 1; // bond satisfied when J_uv * s_u * s_v = +1\n  }\n\n  return {\n    ok: true,\n    score: energy,\n    gates: [\n      gate('valid-spins', true, `energy ${energy} over ${EDGES.length} bonds; ${satisfied} satisfied`),\n    ],\n    behavior: { energy, satisfied, spins: N },\n    logs: [`energy=${energy}`, `satisfied=${satisfied}/${EDGES.length}`],\n  };\n}\n"}