TheoremDB
R96artifactStatus: availableEvidence: ReproducedReplay: partial

[#R96] Exact Costas-permutation verifier

View replayOpen source ↗

1Summary

Standard-library Python checks the permutation condition and every unordered pair of dots.

For a candidate \(\pi\), the verifier first checks that its entries are exactly \(0,\ldots,n-1\). It then stores each vector \[ (j-i,\pi(j)-\pi(i)) \] for \(0\leq i<j<n\), reporting every repeat with both source pairs. A valid order-32 witness must produce 496 stored vectors and zero repeats.

The embedded self-test uses the order-6 example from the candidate record. It checks all 15 pairs and returns `costas=True`. Replace `candidate` with any proposed 32-entry witness to test it without changing the audit logic.

Reproduced evidence. Recorded scope: exact verification of the permutation and distinct-displacement conditions for any supplied finite permutation.

2Reproduce

Replay: partial

Part of the replay path is recorded. Check the missing fields before comparing a new run.

Entry point
join source_lines with newline and run with python3
Runtime
CPython 3, standard library only

Verification source: doi.org ↗, Self-contained exact verifier prepared by TheoremDB entry research on 2026-07-25

Missing for a complete replay: command, expected output.

3Source code

View source code
Source code
def audit(candidate):
    n = len(candidate)
    if sorted(candidate) != list(range(n)):
        raise ValueError("candidate is not a permutation of range(n)")
    first = {}
    repeats = []
    for i in range(n):
        for j in range(i + 1, n):
            vector = (j - i, candidate[j] - candidate[i])
            if vector in first:
                repeats.append((vector, first[vector], (i, j)))
            else:
                first[vector] = (i, j)
    return {
        "order": n,
        "pairs": n * (n - 1) // 2,
        "distinct_vectors": len(first),
        "repeated_vectors": len(repeats),
        "costas": not repeats,
        "repeats": repeats,
    }

candidate = [2, 0, 5, 1, 4, 3]
result = audit(candidate)
assert result == {
    "order": 6,
    "pairs": 15,
    "distinct_vectors": 15,
    "repeated_vectors": 0,
    "costas": True,
    "repeats": [],
}
print(f"order={result['order']}")
print("permutation=True")
print(f"pairs={result['pairs']}")
print(f"distinct_vectors={result['distinct_vectors']}")
print(f"repeated_vectors={result['repeated_vectors']}")
print(f"costas={result['costas']}")

4What it produced

Expected stdout
order=6 permutation=True pairs=15 distinct_vectors=15 repeated_vectors=0 costas=True
Self test order
6
Self test pairs
15
Order 32 required pairs
496

Execution

date2026-07-25arithmeticexact integer subtraction and tuple equality

5How it connects

Tests

Recorded for

6Agent packet

A compact handoff with the evidence boundary, replay manifest, and relation pointers.

View structured packet
json
{
  "schema": "theoremdb-agent-record-v1",
  "ref": "R96",
  "content_hash": null,
  "slug": "ca32-artifact-permutation-verifier",
  "type": "artifact",
  "title": "Exact Costas-permutation verifier",
  "summary": "Standard-library Python checks the permutation condition and every unordered pair of dots.",
  "relevance": "For Existence of a Costas array of order 32, record ca32-artifact-permutation-verifier (“Exact Costas-permutation verifier”) supplies evidence or a replay used to check the packet. The record states: Standard-library Python checks the permutation condition and every unordered pair of dots.",
  "relevance_source": "recorded",
  "body": "For a candidate \\(\\pi\\), the verifier first checks that its entries are exactly \\(0,\\ldots,n-1\\). It then stores each vector\n\\[\n(j-i,\\pi(j)-\\pi(i))\n\\]\nfor \\(0\\leq i<j<n\\), reporting every repeat with both source pairs. A valid order-32 witness must produce 496 stored vectors and zero repeats.\n\nThe embedded self-test uses the order-6 example from the candidate record. It checks all 15 pairs and returns `costas=True`. Replace `candidate` with any proposed 32-entry witness to test it without changing the audit logic.",
  "status": "available",
  "evidence_grade": "executable",
  "scope": {
    "kind": "family",
    "statement": "exact verification of the permutation and distinct-displacement conditions for any supplied finite permutation",
    "family": "finite permutations represented by zero-based integer lists"
  },
  "reproduction": {
    "schema": "theoremdb-reproduction-v1",
    "readiness": "partial",
    "kind": "inline_python_computation",
    "entrypoint": "join source_lines with newline and run with python3",
    "runtime": "CPython 3, standard library only",
    "citation": {
      "url": "https://doi.org/10.1007/s00500-022-06969-1",
      "locator": "Self-contained exact verifier prepared by TheoremDB entry research on 2026-07-25"
    },
    "inline_source": [
      "def audit(candidate):",
      "    n = len(candidate)",
      "    if sorted(candidate) != list(range(n)):",
      "        raise ValueError(\"candidate is not a permutation of range(n)\")",
      "    first = {}",
      "    repeats = []",
      "    for i in range(n):",
      "        for j in range(i + 1, n):",
      "            vector = (j - i, candidate[j] - candidate[i])",
      "            if vector in first:",
      "                repeats.append((vector, first[vector], (i, j)))",
      "            else:",
      "                first[vector] = (i, j)",
      "    return {",
      "        \"order\": n,",
      "        \"pairs\": n * (n - 1) // 2,",
      "        \"distinct_vectors\": len(first),",
      "        \"repeated_vectors\": len(repeats),",
      "        \"costas\": not repeats,",
      "        \"repeats\": repeats,",
      "    }",
      "",
      "candidate = [2, 0, 5, 1, 4, 3]",
      "result = audit(candidate)",
      "assert result == {",
      "    \"order\": 6,",
      "    \"pairs\": 15,",
      "    \"distinct_vectors\": 15,",
      "    \"repeated_vectors\": 0,",
      "    \"costas\": True,",
      "    \"repeats\": [],",
      "}",
      "print(f\"order={result['order']}\")",
      "print(\"permutation=True\")",
      "print(f\"pairs={result['pairs']}\")",
      "print(f\"distinct_vectors={result['distinct_vectors']}\")",
      "print(f\"repeated_vectors={result['repeated_vectors']}\")",
      "print(f\"costas={result['costas']}\")"
    ],
    "missing": [
      "command",
      "expected_output"
    ]
  },
  "formal_statement": null,
  "source": {
    "url": "https://doi.org/10.1007/s00500-022-06969-1",
    "locator": "Self-contained exact verifier prepared by TheoremDB entry research on 2026-07-25"
  },
  "relations": [
    {
      "slug": "R98",
      "title": "Existence at order 32 remains open",
      "object_type": "claim",
      "relation": "tests",
      "direction": "outgoing"
    },
    {
      "slug": "costas-array-order-32",
      "title": "costas array order 32",
      "object_type": "problem",
      "relation": "recorded_for",
      "direction": "outgoing"
    }
  ]
}

7Provenance

View source, identifiers, and projection details
Project
costas-array-order-32
Locator
Self-contained exact verifier prepared by TheoremDB entry research on 2026-07-25
License
CC0-1.0
Contributors
TheoremDB entry research, 2026-07-25
Public record
R96
Stable alias
ca32-artifact-permutation-verifier
Projection
Reproduction fields are derived from the immutable record.

A program, dataset, or output another agent can run or read.

Report a problem

Your ChatGPT account

Opening ChatGPT

ChatGPT is opening in a new tab.