Skip to content

Instantly share code, notes, and snippets.

@vukrosic
Created August 19, 2026 04:05
Show Gist options
  • Select an option

  • Save vukrosic/afa4096cd8b16fe17dbf413f63422b72 to your computer and use it in GitHub Desktop.

Select an option

Save vukrosic/afa4096cd8b16fe17dbf413f63422b72 to your computer and use it in GitHub Desktop.
Order-32 Costas array: reproducible bounded partial result

Order-32 Costas array: a reproducible bounded partial result

Status on 2026-08-19: the existence of an order-32 Costas array remains open. This bundle does not claim a solution, a nonexistence proof, a world record, a breakthrough, or priority for the candidate below.

Exact question

Does a permutation p of 0..31 exist such that all displacement vectors

(j-i, p[j]-p[i])  for 0 <= i < j < 32

are distinct?

Score-2 candidate

One-based:

1 2 29 21 28 18 19 22 31 27 15 10 26 12 32 30
24 6 14 7 17 16 13 4 8 20 25 9 23 3 5 11

Zero-based:

0 1 28 20 27 17 18 21 30 26 14 9 25 11 31 29
23 5 13 6 16 15 12 3 7 19 24 8 22 2 4 10

This is not a Costas array. Exact all-pairs evaluation finds 496 point pairs, 494 distinct vectors, and two repeated-vector occurrences:

vector (1,1):  pairs (0,1) and (5,6)
vector (5,17): pairs (0,5) and (1,6)

Both the pair-collision score and excess-multiplicity score are therefore 2. Three independently written evaluators (two Python, one C++) reproduced this.

Bounded exclusions

  • A checked DRAT portfolio proves that no order-32 Costas permutation lies at Hamming distance at most 12 from the candidate. Hence any solution must differ in at least 13 positions. The portfolio has 21 checked branch proofs, 3,793,883,874 proof bytes, and a fail-closed 118-cell coverage audit.
  • A separate exact C++ enumerator exhaustively found no witness in any exact Hamming shell 12 through 16. This is reproducible exhaustive-program evidence, not a substitute for the DRAT-backed radius-12 statement.
  • The eight radius-12 balls around the candidate's D4 orbit are disjoint, so the formal result excludes 334,181,973,139,327,080 permutations. This is only about 1.27e-18 of 32! and is emphatically not global nonexistence.

The 3.79 GB DRAT files are retained in the Open Discovery project and are too large for a Gist. radius12-certificate.json gives their aggregate receipt, hash-manifest identity, checker revision, and audit hash. Replaying the formal claim requires that separately retained proof package. The included C++ shell enumerator is self-contained and can be rerun directly.

Reproduce the candidate check

python3 verify_candidate.py

clang++ -O2 -std=c++17 verify_costas_cpp.cpp -o verify_costas_cpp
./verify_costas_cpp \
  0 1 28 20 27 17 18 21 30 26 14 9 25 11 31 29 \
  23 5 13 6 16 15 12 3 7 19 24 8 22 2 4 10

The Python command exits successfully only if it reproduces exactly the two listed collisions and the known order-31 positive control remains Costas.

Reproduce exact local shells

clang++ -O3 -std=c++20 -pthread repair_shell_exact.cpp -o repair_shell_exact

# Exit code 2 means COMPLETE with no witness in this research executable.
./repair_shell_exact 12 4 0 hall || test $? -eq 2
./repair_shell_exact 13 4 0 hall || test $? -eq 2
./repair_shell_exact 14 4 0 hall || test $? -eq 2
./repair_shell_exact 15 4 0 hall || test $? -eq 2
./repair_shell_exact 16 8 0 hall || test $? -eq 2

Shell 16 took about 1.9 wall-hours on the original 10-core Apple Silicon machine under concurrent load. Expected exact counters are in evidence-manifest.json.

Negative results and stopping boundary

Global CaDiCaL, Kissat, and CP-SAT runs returned UNKNOWN or were explicitly interrupted for publication. No incomplete trace is treated as evidence. publication-stop-receipt.json records those runtimes, trace sizes, hashes, and the no-verdict interpretation.

Open-status sources

Files

  • verify_candidate.py - standalone Python all-vector replay with assertions.
  • verify_costas_cpp.cpp - independently written C++ all-vector verifier.
  • repair_shell_exact.cpp - exact support/assignment shell enumerator.
  • candidate-score2-manifest.json - candidate provenance and verifier hashes.
  • radius12-certificate.json - formal local-certificate receipt.
  • evidence-manifest.json - claims, counters, hashes, and evidence boundaries.
  • publication-stop-receipt.json - terminal status of unfinished global runs.
  • make_candidate_plot.py / candidate-plot.png - reproducible visual.
{
"claim": "This is an order-32 permutation with score 2 under both listed collision metrics; it is not a Costas array.",
"claim_scope": "near-witness only; no existence or nonexistence claim for order 32",
"n": 32,
"permutation_zero_based": [
0, 1, 28, 20, 27, 17, 18, 21, 30, 26, 14, 9, 25, 11, 31, 29,
23, 5, 13, 6, 16, 15, 12, 3, 7, 19, 24, 8, 22, 2, 4, 10
],
"permutation_one_based": [
1, 2, 29, 21, 28, 18, 19, 22, 31, 27, 15, 10, 26, 12, 32, 30,
24, 6, 14, 7, 17, 16, 13, 4, 8, 20, 25, 9, 23, 3, 5, 11
],
"pair_count": 496,
"distinct_displacement_vectors": 494,
"scores": {
"pair_collision_score": 2,
"excess_multiplicity_score": 2,
"pair_collision_definition": "sum over displacement classes of binomial(multiplicity,2)",
"excess_multiplicity_definition": "sum over displacement classes of max(multiplicity-1,0)"
},
"duplicate_occurrences": [
{
"vector": [1, 1],
"first_pair": [0, 1],
"second_pair": [5, 6]
},
{
"vector": [5, 17],
"first_pair": [0, 5],
"second_pair": [1, 6]
}
],
"construction": {
"method": "insert new minimum row and column into the exceptional order-31 W0 Costas array",
"parent_order": 31,
"parent_zero_based": [
0, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28, 22,
4, 12, 5, 15, 14, 11, 2, 6, 18, 23, 7, 21, 1, 3, 9
],
"direct_extensions_checked": 1024,
"minimum_score": 2,
"source": "w0_extension.py",
"source_sha256": "7d1a2bcdf0bad6d5aac14ff948c4f46d410c0dabafeae4ff9872331e08c12e10",
"result": "w0-extension-results.json",
"result_sha256": "73ff0f49f31de5e695437fd595ce16161904c70f9b270312b1bc0662f9e2a56a"
},
"database_provenance": {
"source_url": "https://jameskbeard.com/Files_for_download/CA_Database_3-100.zip",
"archive_sha256": "fea1074ffdda7e55183df49273fba26c61a644dca027b1eb548aa5f8d8345c10",
"member": "3-100/Generated/Costas_essense_N=31.txt"
},
"independent_verifiers": [
{
"language": "Python",
"source": "verify.py",
"source_sha256": "b4d546cd4ce1d3a60bd287f72777a881bc7dc785e5a4bf1c9994e514dd94fda4",
"result": "w0-best-verification.json",
"result_sha256": "5230139f591c542157a4c037bb2ac34bcb07073b271fcc8f1d00df29f3817dc9"
},
{
"language": "Python",
"source": "verify_independent.py",
"source_sha256": "cf963674133c0d332b0bf2f9e19dfc7cbcfe77f751dd42509457d734b2610095",
"result": "w0-best-independent-verification.json",
"result_sha256": "9e59e143ef00bce4dda98f69c3eed560ae4f8ec199da0d5c2c6d78573da6537f"
},
{
"language": "C++17",
"source": "verify_costas_cpp.cpp",
"source_sha256": "7c580ce737e4293cb8e40e9da041bab7d48d6a56ea7ed3be1ac7a24b129130ef",
"result": "runs/near32-cpp-verification.log",
"result_sha256": "43ebcaa89d60d5a9733b7773b2535b6f352c5423abd2e3e82a44b9cb1c79c4fa",
"sanitizer_result": "runs/near32-cpp-verification-sanitized.log",
"sanitizer_result_sha256": "43ebcaa89d60d5a9733b7773b2535b6f352c5423abd2e3e82a44b9cb1c79c4fa",
"positive_control": "runs/w0-order31-cpp-positive-control.log",
"positive_control_sha256": "b8ee910a13d31910f29bfd956c37f44ce97710e08be850f494ef6408b4265cfa"
}
],
"novelty_status": "provisional only; no equal-or-better public order-32 candidate was located, but private computations and specialist folklore are not excluded",
"publication_gate": "second-machine replay plus a Costas-specialist priority check before any public novelty claim",
"platform": "arm64 macOS; Python 3.13.7; Apple clang 21.0.0",
"verified_utc": "2026-08-19T03:17:22Z"
}
{
"schema_version": 1,
"title": "Order-32 Costas array bounded partial result",
"date_utc": "2026-08-19",
"global_problem_status": "OPEN",
"claims_not_made": [
"order-32 Costas solution",
"global nonexistence",
"world record",
"breakthrough",
"priority or novelty"
],
"candidate_zero_based": [
0, 1, 28, 20, 27, 17, 18, 21, 30, 26, 14, 9, 25, 11, 31, 29,
23, 5, 13, 6, 16, 15, 12, 3, 7, 19, 24, 8, 22, 2, 4, 10
],
"candidate_exact_evaluation": {
"pair_count": 496,
"distinct_vectors": 494,
"pair_collision_score": 2,
"excess_multiplicity_score": 2,
"is_costas": false,
"duplicate_classes": [
{"vector": [1, 1], "pairs": [[0, 1], [5, 6]]},
{"vector": [5, 17], "pairs": [[0, 5], [1, 6]]}
],
"independent_evaluator_implementations": 3
},
"formal_local_result": {
"claim": "No order-32 Costas permutation is within Hamming distance at most 12 of the candidate.",
"minimum_distance_for_any_solution": 13,
"proof_style": "21 checked DRAT branch proofs over a disjoint 118-cell exact-shell-12 partition plus the checked radius-11 dependency",
"proof_bytes": 3793883874,
"proofs_in_this_gist": false,
"reason_not_in_gist": "The checked DRAT package is 3.79 GB; its receipt and hashes are included, while the artifacts remain in the Open Discovery project.",
"certificate_receipt_file": "radius12-certificate.json",
"certificate_receipt_sha256": "40a9e013acd48fa3eb191e64cdffeb1ce4ed8a14c85aa25886fc86299545f018",
"fail_closed_audit_log_sha256": "0f36c02de2177be8ced4322a1c9c556eb3d021ab5a56c743ca6c2f0709423d0a",
"checker": "drat-trim commit 2e3b2dc0ecf938addbd779d42877b6ed69d9a985"
},
"d4_corollary": {
"disjoint_radius_12_balls": 8,
"excluded_permutations": 334181973139327080,
"fraction_of_32_factorial": 1.2700220811578149e-18
},
"exhaustive_program_shells": [
{"radius": 12, "supports": 225792840, "persistent": 30421755, "empty_domain": 193121761, "matching_fail": 2224596, "matching_pass": 24728, "dfs_nodes": 52613, "log_sha256": "ac1671718c20e4c586e835ac7c4dfa7d1026e2f4235a91dcca5ffdeea4189df1"},
{"radius": 13, "supports": 347373600, "persistent": 37442160, "empty_domain": 275612769, "matching_fail": 32155223, "matching_pass": 2163448, "dfs_nodes": 5018362, "log_sha256": "51da29aa5d062c16f2862d0125a0a2bf2aafd1d0d7224b13d17c2611053c8b7d"},
{"radius": 14, "supports": 471435600, "persistent": 40116600, "empty_domain": 248080283, "matching_fail": 130456576, "matching_pass": 52782141, "dfs_nodes": 149471237, "log_sha256": "2b4feb9f168de284283cae01a259d50c393b806a26ab949d4115d2e466004dd2"},
{"radius": 15, "supports": 565722720, "persistent": 37442160, "empty_domain": 114537438, "matching_fail": 125233681, "matching_pass": 288509441, "dfs_nodes": 946056772, "dynamic_matching_fail": 235884393, "log_sha256": "b7d9faf4a9ee10e5a81030c31a18b18f91fe6ceb7261362c304d722462437d11"},
{"radius": 16, "supports": 601080390, "persistent": 30421755, "empty_domain": 25972762, "matching_fail": 32457769, "matching_pass": 512228104, "dfs_nodes": 4116754528, "dynamic_matching_fail": 1048133613, "log_sha256": "1ed0b696b680e8c6ea792841b70c0f5c9cbec5351867f45ea9c8227d36ce1190"}
],
"included_source": {
"verify_candidate.py_sha256": "71c6cb2530341b2f9ef7c096a469a496384bb49a067ff45b5dcfbe1027c7d82c",
"repair_shell_exact.cpp_sha256": "0f9aeebe1f7b01c89eafb82e21d49b42076ffacfc0ac8c36a22f8642acbca38e",
"verify_costas_cpp.cpp_sha256": "7c580ce737e4293cb8e40e9da041bab7d48d6a56ea7ed3be1ac7a24b129130ef"
},
"global_search_terminal_status": "NO_VERDICT",
"global_search_receipt_file": "publication-stop-receipt.json",
"open_status_sources": [
"https://doi.org/10.1007/s00500-022-06969-1",
"https://par.nsf.gov/servlets/purl/10442480",
"https://arxiv.org/abs/2602.03407",
"https://jameskbeard.com/Files.html",
"https://www.math.nus.edu.sg/cqf/events/seminars/"
]
}
#!/usr/bin/env python3
"""Render the candidate and its two repeated-vector classes with Pillow."""
from PIL import Image, ImageDraw, ImageFont
P = [
0, 1, 28, 20, 27, 17, 18, 21, 30, 26, 14, 9, 25, 11, 31, 29,
23, 5, 13, 6, 16, 15, 12, 3, 7, 19, 24, 8, 22, 2, 4, 10,
]
WIDTH, HEIGHT = 1600, 900
BG = "#F5F2EA"
INK = "#14213D"
GRID = "#D7D1C5"
BLUE = "#2563EB"
RED = "#DC2626"
AMBER = "#D97706"
def font(size: int, bold: bool = False):
path = (
"/System/Library/Fonts/Supplemental/Arial Bold.ttf"
if bold else "/System/Library/Fonts/Supplemental/Arial.ttf"
)
return ImageFont.truetype(path, size)
def main() -> None:
image = Image.new("RGB", (WIDTH, HEIGHT), BG)
draw = ImageDraw.Draw(image)
left, top, side = 90, 120, 700
step = side / 31
for index in range(32):
x = left + index * step
y = top + side - index * step
width = 2 if index in (0, 31) else 1
draw.line((x, top, x, top + side), fill=GRID, width=width)
draw.line((left, y, left + side, y), fill=GRID, width=width)
draw.rectangle((left, top, left + side, top + side), outline=INK, width=3)
def point(index: int):
return left + index * step, top + side - P[index] * step
collision_segments = [
((0, 1), RED), ((5, 6), RED),
((0, 5), AMBER), ((1, 6), AMBER),
]
for (a, b), color in collision_segments:
draw.line((*point(a), *point(b)), fill=color, width=9)
involved = {0, 1, 5, 6}
for index in range(32):
x, y = point(index)
radius = 9 if index in involved else 6
fill = INK if index in involved else BLUE
draw.ellipse((x-radius, y-radius, x+radius, y+radius), fill=fill, outline=BG, width=2)
tx = 875
draw.text((tx, 110), "ORDER-32 COSTAS", font=font(52, True), fill=INK)
draw.text((tx, 172), "bounded partial result", font=font(42), fill=INK)
draw.rounded_rectangle((tx, 250, 1490, 350), radius=18, fill="#FFFFFF", outline="#CCC4B5", width=2)
draw.text((tx + 28, 270), "SCORE 2 - NOT A SOLUTION", font=font(34, True), fill=RED)
draw.text((tx, 405), "496 point pairs", font=font(31, True), fill=INK)
draw.text((tx, 449), "494 distinct displacement vectors", font=font(28), fill=INK)
draw.text((tx, 515), "Repeated vectors", font=font(31, True), fill=INK)
draw.line((tx, 575, tx + 54, 575), fill=RED, width=9)
draw.text((tx + 76, 553), "(1, 1) twice", font=font(28), fill=INK)
draw.line((tx, 635, tx + 54, 635), fill=AMBER, width=9)
draw.text((tx + 76, 613), "(5, 17) twice", font=font(28), fill=INK)
draw.text((tx, 708), "Exact local exclusions", font=font(31, True), fill=INK)
draw.text((tx, 752), "DRAT checked through radius 12", font=font(27), fill=INK)
draw.text((tx, 790), "Program-enumerated through shell 16", font=font(27), fill=INK)
draw.text((90, 846), "Order 32 remains open | Open Discovery | 2026-08-19", font=font(24), fill=INK)
image.save("candidate-plot.png", optimize=True)
if __name__ == "__main__":
main()
{
"stopped_utc": "2026-08-19T03:55:45Z",
"receipt_recorded_utc": "2026-08-19T03:58:05Z",
"reason": "Vuk authorized immediate publication and requested stopping the long proof search at the next safe checkpoint.",
"terminal_interpretation": "No global solver returned SAT or UNSAT. CP-SAT returned UNKNOWN cleanly. The externally interrupted SAT traces are incomplete and are not mathematical evidence.",
"all_solver_processes_stopped": true,
"cp_sat_orbitcuts_seed_1701": {
"status": "UNKNOWN",
"wall_seconds": 3028.95,
"conflicts": 3303443,
"branches": 11951447
},
"cp_sat_orbitcuts_seed_907": {
"status": "UNKNOWN",
"wall_seconds": 2884.14,
"conflicts": 1331053,
"branches": 5080943,
"log_sha256": "063231332e7aec6499749e7fc442d821601f6acc8b5d2ae2e1ea5adc4fde6e05"
},
"cadical_inverse": {
"status": "INTERRUPTED_NO_VERDICT",
"wall_seconds": 2884.79,
"partial_proof_bytes": 668123136,
"partial_proof_sha256": "c769903c364e0affdd5ad1016b52de63bfff742d02caa60f78f0224e6a5217e2",
"log_sha256": "9f15cf459e303fdaf51cae39234a775a876553284ea81a1efcb23200661cc3e0"
},
"cadical_inverse_shortcores": {
"status": "INTERRUPTED_NO_VERDICT",
"wall_seconds": 1402.73,
"partial_proof_bytes": 314257408,
"partial_proof_sha256": "e05c51836fbe54328571abe69ece4206824fe09a081df60d14f12a590eda91d3",
"log_sha256": "7d8a641304cfee393f3af30e38c1bfb78546ac2df806ecb2dc386b9c4ab4d640"
},
"cadical_direct": {
"status": "INTERRUPTED_NO_VERDICT",
"wall_seconds": 652.62,
"partial_proof_bytes": 259518464,
"partial_proof_sha256": "b5f28bfbb007766bbf57008367c270312c692eb0bdbbcc70c0899a0544cb71c7",
"log_sha256": "fd0823b6d8dafbbb0613dfc73081f6f53cf1e154f7cd0012000a0793969ebc45"
},
"kissat_direct": {
"status": "INTERRUPTED_NO_VERDICT",
"wall_seconds": 8249.03,
"reported_process_seconds": 6543.86,
"partial_proof_bytes": 6735003648,
"partial_proof_sha256": "dced98645781900662277e20964327a82285c7dbf3d536d8a66dd7fadc0cc4ae",
"log_sha256": "bd2d26fdac55b6b6cda66d953e2f7379bed8158e33591efd4433e38b06ea8eaf"
},
"endpoint_shortcore_cubes": {
"status": "FOUR_UNKNOWN_THEN_STOPPED",
"seconds_per_cell": 600,
"cells": [[14, 16], [14, 15], [11, 18], [11, 17]],
"shard_2_log_sha256": "a3d5c12e010b6409c279b49ff01aac809732c6d53e220d0472a006f91b558097",
"shard_3_log_sha256": "43f63e955b96f6f49ac7754d636fdcdebd87bc5ab56075460873c4d4e13cbbe6"
}
}
{
"claim": "No order-32 Costas permutation is within Hamming distance at most 12 of the listed seed.",
"claim_scope": "local Hamming ball only; not global order-32 nonexistence",
"formal_minimum_distance_for_any_solution": 13,
"n": 32,
"seed_zero_based": [
0, 1, 28, 20, 27, 17, 18, 21, 30, 26, 14, 9, 25, 11, 31, 29,
23, 5, 13, 6, 16, 15, 12, 3, 7, 19, 24, 8, 22, 2, 4, 10
],
"radius_0_through_11_dependency": {
"path": "sat/radius11-certificate.json",
"sha256": "858111b8089044c8fff6870b7dd77b789b2a46ddd12182646f2e7981467a6c8b",
"checker_result": "s VERIFIED"
},
"exact_shell_12_formula": {
"path": "sat/order32-shell12-core.cnf",
"bytes": 13712179,
"sha256": "79d01eb9eabd619d89d0b791a1156270773401e49488a3a79ca25aa1ddc53916",
"variables": 32576,
"clauses": 832929,
"metadata_path": "sat/order32-shell12-core.json",
"metadata_sha256": "c1874a2a7bba1769bdd2e101dafd8367c61769eaaa4c67cacaf46c91cb2871c9"
},
"partition": {
"cells": 118,
"rule": "first changed position among 0,1,5,6, then concrete assigned value where needed",
"position_0_cells": 31,
"position_1_cells": 30,
"position_5_cells": 29,
"position_6_cells": 28,
"grouped_case_1_values": 18,
"adaptive_case_1_values": 5,
"target_case_1_values": 8,
"grouped_case_2_relevant_values": 26,
"target_case_2_values": 4,
"coverage_check": "PASS",
"coverage_script": "verify_shell12_grouped_value_coverage.py",
"coverage_script_sha256": "7c9601d3262f7bb0f73cec7680d89034d831c16f4f3034fdd379c855418d7f89"
},
"proof_portfolio": {
"style": "checked DRAT proofs for exact branch formulas; not one monolithic proof",
"proof_artifacts": 21,
"proof_bytes": 3793883874,
"metadata_manifest": "runs/shell12-radius12-metadata.sha256",
"metadata_manifest_sha256": "6b84a3052c1051a95830e951971f8be1842914dbf82e60de1002745f516097c9",
"checker": "drat-trim commit 2e3b2dc0ecf938addbd779d42877b6ed69d9a985",
"checker_binary_sha256": "f58f63b0f76945d4c4c9ff6e87afaf870f579e67c0f7cca589492df8fc7ebd47"
},
"fail_closed_audit": {
"script": "verify_shell12_radius12_certificate.py",
"script_sha256": "1bdec0119afd256a3ccc71169d8171f67e9035e6350cf429595957f27d00ce32",
"log": "runs/shell12-radius12-certificate-audit.log",
"log_sha256": "0f36c02de2177be8ced4322a1c9c556eb3d021ab5a56c743ca6c2f0709423d0a",
"result": "PASS exact_shell=12 partition_cells=118 proof_artifacts=21 proof_bytes=3793883874 all_hashes_match=true all_drat_checks_verified=true",
"checks": [
"base formula hash",
"exact branch CNF body and assumption suffix",
"partition disjointness and coverage",
"proof sizes and SHA-256 hashes",
"checker-log SHA-256 hashes and s VERIFIED verdicts",
"checker binary identity"
]
},
"d4_corollary": {
"disjoint_radius_12_balls": 8,
"excluded_permutations": 334181973139327080,
"fraction_of_32_factorial": 1.2700220811578149e-18
},
"replay_commands": [
"shasum -a 256 -c runs/shell12-radius12-metadata.sha256",
"python3 verify_shell12_radius12_certificate.py"
],
"toolchain": {
"cadical": "3.0.1 commit c60730422e758ef1cebe7aeddf2dda31c996bf04",
"kissat": "4.0.4 commit 8af8e56f174b778aef3aa45af9f739b2a5f492c2",
"drat_trim": "commit 2e3b2dc0ecf938addbd779d42877b6ed69d9a985",
"platform": "arm64 macOS, Apple clang 21.0.0"
},
"verified_utc": "2026-08-19T03:05:31Z"
}
#include <algorithm>
#include <array>
#include <atomic>
#include <chrono>
#include <cstdint>
#include <iostream>
#include <mutex>
#include <set>
#include <string>
#include <thread>
#include <vector>
using Perm = std::array<int, 32>;
static constexpr int N = 32;
static constexpr Perm seed = {
0, 1, 28, 20, 27, 17, 18, 21, 30, 26, 14, 9, 25, 11, 31, 29,
23, 5, 13, 6, 16, 15, 12, 3, 7, 19, 24, 8, 22, 2, 4, 10,
};
struct Task { uint32_t mask; int next; };
struct Counts {
uint64_t subsets = 0, persistent = 0, empty_domain = 0;
uint64_t matching_fail = 0, matching_pass = 0, dfs_nodes = 0;
uint64_t dynamic_matching_fail = 0;
};
static std::array<std::array<std::vector<uint32_t>, N>, N> blockers;
static std::vector<Task> tasks;
static std::atomic<size_t> next_task{0};
static std::atomic<bool> stop{false};
static std::chrono::steady_clock::time_point started;
static double seconds_limit = 0.0;
static bool use_dynamic_matching = false;
static Perm witness{};
static std::mutex witness_mutex;
static std::pair<int, int> vector_of(int x1, int y1, int x2, int y2) {
if (x1 < x2) return {x2 - x1, y2 - y1};
return {x1 - x2, y1 - y2};
}
static void build_blockers() {
uint64_t total = 0, triples = 0, quads = 0;
for (int pos = 0; pos < N; ++pos) for (int source = 0; source < N; ++source) {
if (pos == source) continue;
std::set<uint32_t> raw;
std::vector<std::pair<std::pair<int, int>, int>> incident;
for (int other = 0; other < N; ++other) {
if (other == pos || other == source) continue;
incident.push_back({vector_of(pos, seed[source], other, seed[other]), other});
}
for (size_t a = 0; a < incident.size(); ++a)
for (size_t b = a + 1; b < incident.size(); ++b)
if (incident[a].first == incident[b].first)
raw.insert((1u << incident[a].second) |
(1u << incident[b].second));
for (const auto& [candidate_vector, other] : incident) {
for (int left = 0; left < N; ++left) {
if (left == pos || left == source) continue;
for (int right = left + 1; right < N; ++right) {
if (right == pos || right == source) continue;
if (candidate_vector == vector_of(left, seed[left], right, seed[right]))
raw.insert((1u << other) | (1u << left) | (1u << right));
}
}
}
for (uint32_t mask : raw) {
bool minimal = true;
for (uint32_t other : raw)
if (other != mask && (other & mask) == other) { minimal = false; break; }
if (minimal) blockers[pos][source].push_back(mask);
}
total += blockers[pos][source].size();
for (uint32_t mask : blockers[pos][source]) {
const int length = 1 + __builtin_popcount(mask);
triples += length == 3;
quads += length == 4;
}
}
if (total != 6578 || triples != 372 || quads != 6206) {
std::cerr << "blocker self-test failed total=" << total
<< " ternary=" << triples << " quaternary=" << quads << '\n';
std::exit(3);
}
}
static uint32_t domain(int pos, uint32_t changed) {
uint32_t result = 0;
uint32_t sources = changed & ~(1u << pos);
while (sources) {
const int source = __builtin_ctz(sources);
sources &= sources - 1;
bool allowed = true;
for (uint32_t blocker : blockers[pos][source])
if (!(blocker & changed)) { allowed = false; break; }
if (allowed) result |= 1u << source;
}
return result;
}
static bool matching_rec(uint32_t positions, uint32_t used,
const std::array<uint32_t, N>& domains) {
if (!positions) return true;
int chosen = -1, best = N + 1;
for (uint32_t scan = positions; scan; scan &= scan - 1) {
int pos = __builtin_ctz(scan);
int count = __builtin_popcount(domains[pos] & ~used);
if (!count) return false;
if (count < best) { best = count; chosen = pos; }
}
uint32_t available = domains[chosen] & ~used;
while (available) {
uint32_t bit = available & -available;
available -= bit;
if (matching_rec(positions & ~(1u << chosen), used | bit, domains))
return true;
}
return false;
}
struct SearchState {
Perm values;
uint32_t assigned = 0, used_sources = 0;
std::array<uint64_t, N> seen{};
};
static bool compatible(const SearchState& state, int pos, int source) {
std::array<uint64_t, N> local{};
for (uint32_t scan = state.assigned; scan; scan &= scan - 1) {
int other = __builtin_ctz(scan);
auto [lag, difference] = vector_of(pos, seed[source], other, state.values[other]);
uint64_t bit = 1ull << (difference + 31);
if ((state.seen[lag] | local[lag]) & bit) return false;
local[lag] |= bit;
}
return true;
}
static void set_point(SearchState& state, int pos, int source, bool add) {
if (add) {
for (uint32_t scan = state.assigned; scan; scan &= scan - 1) {
int other = __builtin_ctz(scan);
auto [lag, difference] = vector_of(pos, seed[source], other, state.values[other]);
state.seen[lag] |= 1ull << (difference + 31);
}
state.values[pos] = seed[source];
state.assigned |= 1u << pos;
state.used_sources |= 1u << source;
} else {
state.assigned &= ~(1u << pos);
state.used_sources &= ~(1u << source);
for (uint32_t scan = state.assigned; scan; scan &= scan - 1) {
int other = __builtin_ctz(scan);
auto [lag, difference] = vector_of(pos, seed[source], other, state.values[other]);
state.seen[lag] &= ~(1ull << (difference + 31));
}
state.values[pos] = -1;
}
}
static bool solve_moves(uint32_t remaining, const std::array<uint32_t, N>& domains,
SearchState& state, Counts& counts) {
++counts.dfs_nodes;
if (!remaining) {
std::lock_guard<std::mutex> lock(witness_mutex);
witness = state.values;
stop.store(true);
return true;
}
int chosen = -1, best = N + 1;
uint32_t chosen_sources = 0;
std::array<uint32_t, N> viable_domains{};
for (uint32_t scan = remaining; scan; scan &= scan - 1) {
int pos = __builtin_ctz(scan), count = 0;
uint32_t viable = 0, sources = domains[pos] & ~state.used_sources;
while (sources) {
uint32_t bit = sources & -sources;
sources -= bit;
int source = __builtin_ctz(bit);
if (compatible(state, pos, source)) { viable |= bit; ++count; }
}
viable_domains[pos] = viable;
if (!count) return false;
if (count < best) { best = count; chosen = pos; chosen_sources = viable; }
}
if (use_dynamic_matching &&
!matching_rec(remaining, state.used_sources, viable_domains)) {
++counts.dynamic_matching_fail;
return false;
}
while (chosen_sources && !stop.load()) {
uint32_t bit = chosen_sources & -chosen_sources;
chosen_sources -= bit;
int source = __builtin_ctz(bit);
set_point(state, chosen, source, true);
if (solve_moves(remaining & ~(1u << chosen), domains, state, counts)) return true;
set_point(state, chosen, source, false);
}
return false;
}
static void check_subset(uint32_t changed, Counts& counts) {
++counts.subsets;
constexpr uint32_t core = (1u << 0) | (1u << 1) | (1u << 5) | (1u << 6);
if (!(changed & core)) { ++counts.persistent; return; }
std::array<uint32_t, N> domains{};
for (uint32_t scan = changed; scan; scan &= scan - 1) {
int pos = __builtin_ctz(scan);
domains[pos] = domain(pos, changed);
if (!domains[pos]) { ++counts.empty_domain; return; }
}
if (!matching_rec(changed, 0, domains)) { ++counts.matching_fail; return; }
++counts.matching_pass;
SearchState state;
state.values.fill(-1);
uint32_t fixed = ~changed;
for (int pos = 0; pos < N; ++pos) if (fixed >> pos & 1u) {
if (!compatible(state, pos, pos)) std::exit(4);
set_point(state, pos, pos, true);
}
solve_moves(changed, domains, state, counts);
}
static void choose_rest(int next, int left, uint32_t mask, Counts& counts) {
if (stop.load()) return;
if (!left) {
check_subset(mask, counts);
if ((counts.subsets & 4095u) == 0 && seconds_limit > 0.0) {
double elapsed = std::chrono::duration<double>(
std::chrono::steady_clock::now() - started).count();
if (elapsed >= seconds_limit) stop.store(true);
}
return;
}
for (int pos = next; pos <= N - left && !stop.load(); ++pos)
choose_rest(pos + 1, left - 1, mask | (1u << pos), counts);
}
static void worker(int radius, Counts& counts) {
while (!stop.load()) {
size_t index = next_task.fetch_add(1);
if (index >= tasks.size()) return;
const Task task = tasks[index];
choose_rest(task.next, radius - 4, task.mask, counts);
}
}
static uint64_t choose(int n, int k) {
uint64_t result = 1;
for (int i = 1; i <= k; ++i) result = result * (n - k + i) / i;
return result;
}
int main(int argc, char** argv) {
int radius = argc > 1 ? std::stoi(argv[1]) : 12;
int workers = argc > 2 ? std::stoi(argv[2]) : 8;
seconds_limit = argc > 3 ? std::stod(argv[3]) : 0.0;
use_dynamic_matching = argc > 4 && std::string(argv[4]) == "hall";
if (radius < 4 || radius > N) return 2;
witness.fill(-1);
build_blockers();
for (int a = 0; a <= N - radius; ++a)
for (int b = a + 1; b <= N - radius + 1; ++b)
for (int c = b + 1; c <= N - radius + 2; ++c)
for (int d = c + 1; d <= N - radius + 3; ++d)
tasks.push_back({(1u << a) | (1u << b) | (1u << c) | (1u << d), d + 1});
started = std::chrono::steady_clock::now();
std::vector<Counts> per_worker(workers);
std::vector<std::thread> threads;
for (int i = 0; i < workers; ++i) threads.emplace_back(worker, radius, std::ref(per_worker[i]));
for (auto& thread : threads) thread.join();
Counts total;
for (const Counts& item : per_worker) {
total.subsets += item.subsets; total.persistent += item.persistent;
total.empty_domain += item.empty_domain; total.matching_fail += item.matching_fail;
total.matching_pass += item.matching_pass; total.dfs_nodes += item.dfs_nodes;
total.dynamic_matching_fail += item.dynamic_matching_fail;
}
double elapsed = std::chrono::duration<double>(
std::chrono::steady_clock::now() - started).count();
bool complete = total.subsets == choose(N, radius);
std::cout << "RESULT radius=" << radius << " workers=" << workers
<< " status=" << (complete ? "COMPLETE" : (witness[0] >= 0 ? "WITNESS" : "UNKNOWN"))
<< " subsets=" << total.subsets << " expected=" << choose(N, radius)
<< " persistent=" << total.persistent << " empty_domain=" << total.empty_domain
<< " matching_fail=" << total.matching_fail << " matching_pass=" << total.matching_pass
<< " dfs_nodes=" << total.dfs_nodes
<< " dynamic_matching_fail=" << total.dynamic_matching_fail
<< " dynamic_matching=" << (use_dynamic_matching ? "true" : "false")
<< " elapsed_seconds=" << elapsed << '\n';
if (witness[0] >= 0) {
std::cout << "witness_zero_based=";
for (int value : witness) std::cout << value << ',';
std::cout << '\n';
return 0;
}
return complete ? 2 : 1;
}
a316924236555bdf0eac0c31228644728655bdc25bf6382fa99d20ff2accefa6 ./00_README.md
26569f71e28e2e43798686c42e96c6dbad6d4b58adc6800fe4e7d0dd0d93045e ./candidate-plot.png
13f79b8e0d9302be2f28bb59b223f247b7ee9305c3ca4b6981b4d3cb9b6fff5e ./candidate-score2-manifest.json
373f3d69e87366e71075b7f3869d031a90a2345863c6996272207e6399f7e35b ./evidence-manifest.json
b60e8bb95399bb069295b232f5246f3707ee9ec6dac8cc9320d27e42365a812c ./make_candidate_plot.py
c1c89313a9a1813866a87e728dc957c6640977092001cbcad2936bb250dddfc6 ./publication-stop-receipt.json
40a9e013acd48fa3eb191e64cdffeb1ce4ed8a14c85aa25886fc86299545f018 ./radius12-certificate.json
0f9aeebe1f7b01c89eafb82e21d49b42076ffacfc0ac8c36a22f8642acbca38e ./repair_shell_exact.cpp
ce05520bdc3a748ad68f02bcbb328f077e5850d4df73135242a7c1bff763a491 ./verify-candidate-output.json
43ebcaa89d60d5a9733b7773b2535b6f352c5423abd2e3e82a44b9cb1c79c4fa ./verify-cpp-output.txt
71c6cb2530341b2f9ef7c096a469a496384bb49a067ff45b5dcfbe1027c7d82c ./verify_candidate.py
7c580ce737e4293cb8e40e9da041bab7d48d6a56ea7ed3be1ac7a24b129130ef ./verify_costas_cpp.cpp
{
"candidate": {
"collisions": [
{
"pairs": [
[
0,
1
],
[
5,
6
]
],
"vector": [
1,
1
]
},
{
"pairs": [
[
0,
5
],
[
1,
6
]
],
"vector": [
5,
17
]
}
],
"distinct_vectors": 494,
"excess_multiplicity_score": 2,
"is_costas": false,
"n": 32,
"pair_collision_score": 2,
"pair_count": 496
},
"order31_positive_control": {
"collisions": [],
"distinct_vectors": 465,
"excess_multiplicity_score": 0,
"is_costas": true,
"n": 31,
"pair_collision_score": 0,
"pair_count": 465
},
"status": "PASS"
}
RESULT n=32 is_permutation=true pair_count=496 distinct_vectors=494 duplicate_occurrences=2 is_costas=false
DUP lag=5 difference=17 first_pair=0,5 second_pair=1,6
DUP lag=1 difference=1 first_pair=0,1 second_pair=5,6
#!/usr/bin/env python3
"""Standalone exact replay of the order-32 score-2 candidate."""
from __future__ import annotations
import json
from collections import defaultdict
CANDIDATE = [
0, 1, 28, 20, 27, 17, 18, 21, 30, 26, 14, 9, 25, 11, 31, 29,
23, 5, 13, 6, 16, 15, 12, 3, 7, 19, 24, 8, 22, 2, 4, 10,
]
W0_ORDER31 = [
0, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28, 22,
4, 12, 5, 15, 14, 11, 2, 6, 18, 23, 7, 21, 1, 3, 9,
]
def evaluate(permutation: list[int]) -> dict:
n = len(permutation)
if sorted(permutation) != list(range(n)):
raise AssertionError("input is not a zero-based permutation")
groups: dict[tuple[int, int], list[tuple[int, int]]] = defaultdict(list)
for first in range(n):
for second in range(first + 1, n):
vector = (second - first, permutation[second] - permutation[first])
groups[vector].append((first, second))
collisions = [
{"vector": list(vector), "pairs": [list(pair) for pair in pairs]}
for vector, pairs in sorted(groups.items())
if len(pairs) > 1
]
pair_score = sum(
len(item["pairs"]) * (len(item["pairs"]) - 1) // 2
for item in collisions
)
excess_score = sum(len(item["pairs"]) - 1 for item in collisions)
return {
"n": n,
"pair_count": n * (n - 1) // 2,
"distinct_vectors": len(groups),
"pair_collision_score": pair_score,
"excess_multiplicity_score": excess_score,
"is_costas": pair_score == 0,
"collisions": collisions,
}
def main() -> None:
candidate = evaluate(CANDIDATE)
positive_control = evaluate(W0_ORDER31)
expected = [
{"vector": [1, 1], "pairs": [[0, 1], [5, 6]]},
{"vector": [5, 17], "pairs": [[0, 5], [1, 6]]},
]
assert candidate["pair_count"] == 496
assert candidate["distinct_vectors"] == 494
assert candidate["pair_collision_score"] == 2
assert candidate["excess_multiplicity_score"] == 2
assert candidate["collisions"] == expected
assert not candidate["is_costas"]
assert positive_control["pair_count"] == 465
assert positive_control["distinct_vectors"] == 465
assert positive_control["is_costas"]
print(json.dumps({
"status": "PASS",
"candidate": candidate,
"order31_positive_control": positive_control,
}, indent=2, sort_keys=True))
if __name__ == "__main__":
main()
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>
struct Duplicate {
int lag;
int difference;
int first_start;
int first_end;
int second_start;
int second_end;
};
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "usage: " << argv[0] << " ZERO_BASED_PERMUTATION...\n";
return 2;
}
const int n = argc - 1;
std::vector<int> permutation;
permutation.reserve(n);
for (int index = 1; index < argc; ++index)
permutation.push_back(std::stoi(argv[index]));
std::vector<int> sorted = permutation;
std::sort(sorted.begin(), sorted.end());
bool is_permutation = true;
for (int value = 0; value < n; ++value)
is_permutation &= sorted[value] == value;
if (!is_permutation) {
std::cout << "RESULT n=" << n
<< " is_permutation=false is_costas=false\n";
return 3;
}
std::map<std::pair<int, int>, std::pair<int, int>> first_pair;
std::vector<Duplicate> duplicates;
for (int first = 0; first < n; ++first) {
for (int second = first + 1; second < n; ++second) {
const auto vector = std::make_pair(
second - first, permutation[second] - permutation[first]);
const auto [iterator, inserted] =
first_pair.emplace(vector, std::make_pair(first, second));
if (!inserted) {
duplicates.push_back({
vector.first, vector.second,
iterator->second.first, iterator->second.second,
first, second,
});
}
}
}
const long long pair_count = static_cast<long long>(n) * (n - 1) / 2;
std::cout << "RESULT n=" << n
<< " is_permutation=true pair_count=" << pair_count
<< " distinct_vectors=" << first_pair.size()
<< " duplicate_occurrences=" << duplicates.size()
<< " is_costas=" << (duplicates.empty() ? "true" : "false")
<< '\n';
for (const Duplicate& duplicate : duplicates) {
std::cout << "DUP lag=" << duplicate.lag
<< " difference=" << duplicate.difference
<< " first_pair=" << duplicate.first_start << ','
<< duplicate.first_end
<< " second_pair=" << duplicate.second_start << ','
<< duplicate.second_end << '\n';
}
return duplicates.empty() ? 0 : 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment