TheoremDB

Problem packetWorkR358

R358artifactStatus: availableEvidence: ReproducedReplay: partialexhaustive over its scope

[#R358] Exact cycle replay with an orbit digest

View replayOpen source ↗

1Summary

Standard-library Python checks the first return, selected states, the predecessor, and the period again with Floyd's algorithm.

The program performs exactly 294,672 direct modular updates. It rejects any early return to the start and checks the first four states, the predecessor, and the final return. A second pass uses Floyd's constant-memory algorithm and requires preperiod zero and period 294,672.

During the direct pass, each cycle state is encoded as x followed by y, each a four-byte little-endian unsigned integer. SHA-256 of the resulting 2,357,376-byte logical stream is printed as `trace_sha256`. This supplies a portable orbit checksum for independent runs.

Reproduced evidence. Recorded scope: every state in the 294672-cycle through (0,2) over F_65537, checked by direct replay and Floyd cycle finding.

2Reproduce

Replay package: partial

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

Entry point
Execute code with python3
Runtime
Python 3.9 or newer, standard library only

Verification source: doi.org ↗, Self-contained Python 3 standard-library replay derived from candidate record 155

Missing for a complete replay: command, expected output.

3Source code

View source code
Source code
from hashlib import sha256
p = 65537
start = (0, 2)
target = 294672

def step(state):
    x, y = state
    return y, (y*y + 1 - x) % p

expected = {
    0: (0, 2),
    1: (2, 5),
    2: (5, 24),
    3: (24, 572),
    target - 1: (65536, 0),
}
h = sha256()
state = start
for time in range(target):
    if time in expected:
        assert state == expected[time]
    h.update(state[0].to_bytes(4, 'little'))
    h.update(state[1].to_bytes(4, 'little'))
    state = step(state)
    assert time + 1 == target or state != start
assert state == start

tortoise = step(start)
hare = step(step(start))
while tortoise != hare:
    tortoise = step(tortoise)
    hare = step(step(hare))
mu = 0
tortoise = start
while tortoise != hare:
    tortoise = step(tortoise)
    hare = step(hare)
    mu += 1
period = 1
hare = step(tortoise)
while tortoise != hare:
    hare = step(hare)
    period += 1
assert (mu, period, tortoise) == (0, target, start)
print(f'period={period} predecessor={expected[target-1]} trace_sha256={h.hexdigest()}')

4What it produced

Arithmetic
exact integer arithmetic reduced modulo 65537
Trace encoding
for times 0 through 294671, concatenate x then y as little-endian unsigned 32-bit integers
Trace bytes
2,357,376
Digest algorithm
SHA-256
Digest disposition
computed and printed by the replay

5How it connects

Verifies

Tested by

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": "R358",
  "content_hash": null,
  "slug": "h65537-artifact-exact-witness-replay",
  "type": "artifact",
  "title": "Exact cycle replay with an orbit digest",
  "summary": "Standard-library Python checks the first return, selected states, the predecessor, and the period again with Floyd's algorithm.",
  "relevance": "For Largest cycle of a Hénon permutation over the 65537 field, record h65537-artifact-exact-witness-replay (“Exact cycle replay with an orbit digest”) supplies evidence or a replay used to check the packet. The record states: Standard-library Python checks the first return, selected states, the predecessor, and the period again with Floyd's algorithm.",
  "relevance_source": "recorded",
  "body": "The program performs exactly 294,672 direct modular updates. It rejects any early return to the start and checks the first four states, the predecessor, and the final return. A second pass uses Floyd's constant-memory algorithm and requires preperiod zero and period 294,672.\n\nDuring the direct pass, each cycle state is encoded as x followed by y, each a four-byte little-endian unsigned integer. SHA-256 of the resulting 2,357,376-byte logical stream is printed as `trace_sha256`. This supplies a portable orbit checksum for independent runs.",
  "status": "available",
  "evidence_grade": "executable",
  "scope": {
    "kind": "bounded",
    "statement": "every state in the 294672-cycle through (0,2) over F_65537, checked by direct replay and Floyd cycle finding",
    "bounds": {
      "prime": {
        "min": 65537,
        "max": 65537
      },
      "cycle_updates": {
        "min": 294672,
        "max": 294672
      },
      "independent_cycle_methods": {
        "min": 2,
        "max": 2
      }
    },
    "exhaustive": true
  },
  "reproduction": {
    "schema": "theoremdb-reproduction-v1",
    "readiness": "partial",
    "kind": "inline_python_exact_computation",
    "entrypoint": "Execute code with python3",
    "runtime": "Python 3.9 or newer, standard library only",
    "citation": {
      "url": "https://doi.org/10.1088/0951-7715/18/5/015",
      "locator": "Self-contained Python 3 standard-library replay derived from candidate record 155"
    },
    "inline_source": "from hashlib import sha256\np = 65537\nstart = (0, 2)\ntarget = 294672\n\ndef step(state):\n    x, y = state\n    return y, (y*y + 1 - x) % p\n\nexpected = {\n    0: (0, 2),\n    1: (2, 5),\n    2: (5, 24),\n    3: (24, 572),\n    target - 1: (65536, 0),\n}\nh = sha256()\nstate = start\nfor time in range(target):\n    if time in expected:\n        assert state == expected[time]\n    h.update(state[0].to_bytes(4, 'little'))\n    h.update(state[1].to_bytes(4, 'little'))\n    state = step(state)\n    assert time + 1 == target or state != start\nassert state == start\n\ntortoise = step(start)\nhare = step(step(start))\nwhile tortoise != hare:\n    tortoise = step(tortoise)\n    hare = step(step(hare))\nmu = 0\ntortoise = start\nwhile tortoise != hare:\n    tortoise = step(tortoise)\n    hare = step(hare)\n    mu += 1\nperiod = 1\nhare = step(tortoise)\nwhile tortoise != hare:\n    hare = step(hare)\n    period += 1\nassert (mu, period, tortoise) == (0, target, start)\nprint(f'period={period} predecessor={expected[target-1]} trace_sha256={h.hexdigest()}')\n",
    "missing": [
      "command",
      "expected_output"
    ]
  },
  "formal_statement": null,
  "source": {
    "url": "https://doi.org/10.1088/0951-7715/18/5/015",
    "locator": "Self-contained Python 3 standard-library replay derived from candidate record 155"
  },
  "models": [],
  "relations": [
    {
      "slug": "R360",
      "title": "A certified cycle has length 294,672",
      "object_type": "claim",
      "relation": "verifies",
      "direction": "outgoing"
    },
    {
      "slug": "R357",
      "title": "Complete p=1009 cycle decomposition",
      "object_type": "artifact",
      "relation": "tests",
      "direction": "incoming"
    },
    {
      "slug": "henon-65537-max-cycle",
      "title": "henon 65537 max cycle",
      "object_type": "problem",
      "relation": "recorded_for",
      "direction": "outgoing"
    }
  ]
}

7Provenance

View source, identifiers, and projection details
Project
henon-65537-max-cycle
Locator
Self-contained Python 3 standard-library replay derived from candidate record 155
License
CC0-1.0
Contributors
TheoremDB entry research, 2026-07-25
Public record
R358
Stable alias
h65537-artifact-exact-witness-replay
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.