TheoremDB

Problem packetWorkR124

R124artifactStatus: availableEvidence: ReproducedReplay: completeexhaustive over its scope

[#R124] Direct-string independent binary replay

View replay

1Summary

A second binary implementation uses substring comparison and reproduces all five maxima series through length 26.

This program represents each word as a string, checks square halves with string comparison, and deduplicates factors by direct substring comparison. Exact string periods separate primitive and nonprimitive words. It independently reproduces the total, short, long, primitive, and nonprimitive maxima. Its raw 26-line output equals the normalized rows of the packed replay.

Reproduced evidence. Recorded scope: every binary word of lengths 1 through 26, with complements identified.

2Reproduce

Replay package: complete

The command, source, environment, and expected result are recorded.

clang++ -O3 -std=c++17 -Wall -Wextra -pedantic circular_squares_binary_direct.cpp -o circular_squares_binary_direct && /usr/bin/time -l ./circular_squares_binary_direct 26
Entry point
Join source_lines with LF characters, append a final LF, and save as circular_squares_binary_direct.cpp
Runtime
Apple clang 21.0.0, C++17 standard library, macOS 26.2 arm64
Dependencies
[ { "name": "Apple clang and libc++", "version": "21.0.0", "license": "Apache-2.0 WITH LLVM-exception" } ]
Recorded runtime
178.83

Verification source: Independent self-contained C++17 source executed on macOS arm64 on 2026-07-28

Expected output

{
  "raw_stdout_sha256": "1d5976f1b85dfa11ce67701e6dfe7cf5dadbe470719821d2bb7de00019f3cf18",
  "normalized_rows_sha256": "1d5976f1b85dfa11ce67701e6dfe7cf5dadbe470719821d2bb7de00019f3cf18",
  "exact_binary_maxima": [
    0,
    1,
    1,
    2,
    3,
    4,
    4,
    6,
    6,
    9,
    8,
    10,
    11,
    13,
    13,
    16,
    15,
    18,
    17,
    19,
    21,
    22,
    22,
    25,
    24,
    28
  ],
  "exact_binary_primitive_maxima": [
    0,
    0,
    1,
    2,
    3,
    3,
    4,
    6,
    6,
    7,
    8,
    10,
    11,
    11,
    13,
    15,
    15,
    17,
    17,
    19,
    21,
    20,
    22,
    24,
    24,
    26
  ],
  "exact_binary_nonprimitive_maxima": [
    null,
    1,
    1,
    2,
    2,
    4,
    3,
    6,
    4,
    9,
    5,
    9,
    6,
    13,
    9,
    16,
    8,
    18,
    9,
    19,
    13,
    22,
    11,
    25,
    14,
    28
  ],
  "exact_binary_short_maxima": [
    0,
    0,
    0,
    2,
    2,
    2,
    2,
    4,
    4,
    5,
    5,
    9,
    8,
    10,
    9,
    12,
    12,
    13,
    13,
    16,
    16,
    17,
    18,
    19,
    20,
    20
  ],
  "exact_binary_long_maxima": [
    0,
    1,
    1,
    2,
    2,
    3,
    3,
    4,
    4,
    6,
    7,
    6,
    7,
    9,
    11,
    10,
    11,
    14,
    13,
    13,
    17,
    16,
    17,
    20,
    19,
    20
  ],
  "peak_resident_bytes_observed": 1376256
}

3Source code

View source code
Source code
#include <cstdint>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

struct Counts { int total = 0, short_count = 0, long_count = 0; };

static std::string make_word(std::uint32_t code, int n) {
    std::string word(n, '0');
    for (int i = 0; i < n; ++i) word[i] = char('0' + ((code >> i) & 1U));
    return word;
}

static Counts inspect(const std::string& word) {
    const int n = static_cast<int>(word.size());
    const std::string doubled = word + word;
    std::vector<std::pair<int, int>> factors;
    Counts counts;
    for (int start = 0; start < n; ++start) {
        for (int length = 2; length <= n; length += 2) {
            const int half = length / 2;
            if (doubled.compare(start, half, doubled, start + half, half) != 0) {
                continue;
            }
            bool duplicate = false;
            for (auto [old_start, old_length] : factors) {
                if (length == old_length &&
                    doubled.compare(start, length, doubled, old_start, length) == 0) {
                    duplicate = true;
                    break;
                }
            }
            if (duplicate) continue;
            factors.emplace_back(start, length);
            ++counts.total;
            if (2 * length <= n) ++counts.short_count;
            else ++counts.long_count;
        }
    }
    return counts;
}

static bool primitive(const std::string& word) {
    const int n = static_cast<int>(word.size());
    for (int period = 1; period < n; ++period) {
        if (n % period != 0) continue;
        bool repeats = true;
        for (int i = period; i < n; ++i) {
            if (word[i] != word[i % period]) {
                repeats = false;
                break;
            }
        }
        if (repeats) return false;
    }
    return true;
}

int main(int argc, char** argv) {
    if (argc != 2) return 2;
    const int max_n = std::stoi(argv[1]);
    for (int n = 1; n <= max_n; ++n) {
        const std::uint32_t count = 1U << (n - 1);
        Counts maxima{-1, -1, -1};
        int primitive_maximum = -1, nonprimitive_maximum = -1;
        std::string total_word, short_word, long_word;
        std::string primitive_word, nonprimitive_word;
        for (std::uint32_t tail = 0; tail < count; ++tail) {
            const std::string word = make_word(tail << 1, n);
            const Counts value = inspect(word);
            const bool is_primitive = primitive(word);
            if (value.total > maxima.total) {
                maxima.total = value.total;
                total_word = word;
            }
            if (value.short_count > maxima.short_count) {
                maxima.short_count = value.short_count;
                short_word = word;
            }
            if (value.long_count > maxima.long_count) {
                maxima.long_count = value.long_count;
                long_word = word;
            }
            if (is_primitive && value.total > primitive_maximum) {
                primitive_maximum = value.total;
                primitive_word = word;
            }
            if (!is_primitive && value.total > nonprimitive_maximum) {
                nonprimitive_maximum = value.total;
                nonprimitive_word = word;
            }
        }
        std::cout << "length=" << n
                  << " checked=" << count
                  << " total=" << maxima.total << " total_word=" << total_word
                  << " short=" << maxima.short_count << " short_word=" << short_word
                  << " long=" << maxima.long_count << " long_word=" << long_word
                  << " primitive=" << primitive_maximum
                  << " primitive_word=" << primitive_word
                  << " nonprimitive=" << nonprimitive_maximum
                  << " nonprimitive_word=" << nonprimitive_word
                  << "\n";
    }
}

4What it produced

Time bound
300 seconds wall clock after compilation
Memory bound
128 MiB resident memory
Processor
Apple M4 arm64
Processor bound
one single-threaded native process
Storage bound
16 MiB for source, executable, and standard output; no disk-backed search state
Network requirements
none
Randomness
none; the enumeration is deterministic
Arithmetic
exact integer and direct string-factor operations; no floating-point arithmetic
Source license
CC0-1.0
Stopping rule
Exhaust every binary word through length 26 with the independent direct-string counter.
Execution date
2026-07-28
Source sha256
aeb77859ebfc5a0c61f1a6d69c8f1c96038a9001ede87345eeff3c763594b150
Replay of
cds-artifact-binary-packed-replay
Processor
Apple M4, arm64
Storage bound bytes
1,048,576
Storage bound basis
source, compiled executable, and stdout; no disk-backed search state
Network required
no
Randomness
none

5How it connects

Evidence for

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": "R124",
  "content_hash": null,
  "slug": "cds-artifact-binary-direct-replay",
  "type": "artifact",
  "title": "Direct-string independent binary replay",
  "summary": "A second binary implementation uses substring comparison and reproduces all five maxima series through length 26.",
  "relevance": "For The three-halves bound for distinct squares in circular words, record cds-artifact-binary-direct-replay (“Direct-string independent binary replay”) supplies evidence or a replay used to check the packet. The record states: A second binary implementation uses substring comparison and reproduces all five maxima series through length 26.",
  "relevance_source": "recorded",
  "body": "This program represents each word as a string, checks square halves with string comparison, and deduplicates factors by direct substring comparison. Exact string periods separate primitive and nonprimitive words. It independently reproduces the total, short, long, primitive, and nonprimitive maxima. Its raw 26-line output equals the normalized rows of the packed replay.",
  "status": "available",
  "evidence_grade": "executable",
  "scope": {
    "kind": "bounded",
    "statement": "every binary word of lengths 1 through 26, with complements identified",
    "bounds": {
      "word_length": {
        "min": 1,
        "max": 26
      },
      "alphabet_size": {
        "min": 2,
        "max": 2
      }
    },
    "exhaustive": true
  },
  "reproduction": {
    "schema": "theoremdb-reproduction-v1",
    "readiness": "complete",
    "kind": "inline_cpp_independent_binary_enumerator",
    "command": "clang++ -O3 -std=c++17 -Wall -Wextra -pedantic circular_squares_binary_direct.cpp -o circular_squares_binary_direct && /usr/bin/time -l ./circular_squares_binary_direct 26",
    "entrypoint": "Join source_lines with LF characters, append a final LF, and save as circular_squares_binary_direct.cpp",
    "runtime": "Apple clang 21.0.0, C++17 standard library, macOS 26.2 arm64",
    "citation": {
      "locator": "Independent self-contained C++17 source executed on macOS arm64 on 2026-07-28"
    },
    "dependencies": [
      {
        "name": "Apple clang and libc++",
        "version": "21.0.0",
        "license": "Apache-2.0 WITH LLVM-exception"
      }
    ],
    "outputs": {
      "raw_stdout_sha256": "1d5976f1b85dfa11ce67701e6dfe7cf5dadbe470719821d2bb7de00019f3cf18",
      "normalized_rows_sha256": "1d5976f1b85dfa11ce67701e6dfe7cf5dadbe470719821d2bb7de00019f3cf18",
      "exact_binary_maxima": [
        0,
        1,
        1,
        2,
        3,
        4,
        4,
        6,
        6,
        9,
        8,
        10,
        11,
        13,
        13,
        16,
        15,
        18,
        17,
        19,
        21,
        22,
        22,
        25,
        24,
        28
      ],
      "exact_binary_primitive_maxima": [
        0,
        0,
        1,
        2,
        3,
        3,
        4,
        6,
        6,
        7,
        8,
        10,
        11,
        11,
        13,
        15,
        15,
        17,
        17,
        19,
        21,
        20,
        22,
        24,
        24,
        26
      ],
      "exact_binary_nonprimitive_maxima": [
        null,
        1,
        1,
        2,
        2,
        4,
        3,
        6,
        4,
        9,
        5,
        9,
        6,
        13,
        9,
        16,
        8,
        18,
        9,
        19,
        13,
        22,
        11,
        25,
        14,
        28
      ],
      "exact_binary_short_maxima": [
        0,
        0,
        0,
        2,
        2,
        2,
        2,
        4,
        4,
        5,
        5,
        9,
        8,
        10,
        9,
        12,
        12,
        13,
        13,
        16,
        16,
        17,
        18,
        19,
        20,
        20
      ],
      "exact_binary_long_maxima": [
        0,
        1,
        1,
        2,
        2,
        3,
        3,
        4,
        4,
        6,
        7,
        6,
        7,
        9,
        11,
        10,
        11,
        14,
        13,
        13,
        17,
        16,
        17,
        20,
        19,
        20
      ],
      "peak_resident_bytes_observed": 1376256
    },
    "runtime_seconds": 178.83,
    "inline_source": [
      "#include <cstdint>",
      "#include <iostream>",
      "#include <string>",
      "#include <utility>",
      "#include <vector>",
      "",
      "struct Counts { int total = 0, short_count = 0, long_count = 0; };",
      "",
      "static std::string make_word(std::uint32_t code, int n) {",
      "    std::string word(n, '0');",
      "    for (int i = 0; i < n; ++i) word[i] = char('0' + ((code >> i) & 1U));",
      "    return word;",
      "}",
      "",
      "static Counts inspect(const std::string& word) {",
      "    const int n = static_cast<int>(word.size());",
      "    const std::string doubled = word + word;",
      "    std::vector<std::pair<int, int>> factors;",
      "    Counts counts;",
      "    for (int start = 0; start < n; ++start) {",
      "        for (int length = 2; length <= n; length += 2) {",
      "            const int half = length / 2;",
      "            if (doubled.compare(start, half, doubled, start + half, half) != 0) {",
      "                continue;",
      "            }",
      "            bool duplicate = false;",
      "            for (auto [old_start, old_length] : factors) {",
      "                if (length == old_length &&",
      "                    doubled.compare(start, length, doubled, old_start, length) == 0) {",
      "                    duplicate = true;",
      "                    break;",
      "                }",
      "            }",
      "            if (duplicate) continue;",
      "            factors.emplace_back(start, length);",
      "            ++counts.total;",
      "            if (2 * length <= n) ++counts.short_count;",
      "            else ++counts.long_count;",
      "        }",
      "    }",
      "    return counts;",
      "}",
      "",
      "static bool primitive(const std::string& word) {",
      "    const int n = static_cast<int>(word.size());",
      "    for (int period = 1; period < n; ++period) {",
      "        if (n % period != 0) continue;",
      "        bool repeats = true;",
      "        for (int i = period; i < n; ++i) {",
      "            if (word[i] != word[i % period]) {",
      "                repeats = false;",
      "                break;",
      "            }",
      "        }",
      "        if (repeats) return false;",
      "    }",
      "    return true;",
      "}",
      "",
      "int main(int argc, char** argv) {",
      "    if (argc != 2) return 2;",
      "    const int max_n = std::stoi(argv[1]);",
      "    for (int n = 1; n <= max_n; ++n) {",
      "        const std::uint32_t count = 1U << (n - 1);",
      "        Counts maxima{-1, -1, -1};",
      "        int primitive_maximum = -1, nonprimitive_maximum = -1;",
      "        std::string total_word, short_word, long_word;",
      "        std::string primitive_word, nonprimitive_word;",
      "        for (std::uint32_t tail = 0; tail < count; ++tail) {",
      "            const std::string word = make_word(tail << 1, n);",
      "            const Counts value = inspect(word);",
      "            const bool is_primitive = primitive(word);",
      "            if (value.total > maxima.total) {",
      "                maxima.total = value.total;",
      "                total_word = word;",
      "            }",
      "            if (value.short_count > maxima.short_count) {",
      "                maxima.short_count = value.short_count;",
      "                short_word = word;",
      "            }",
      "            if (value.long_count > maxima.long_count) {",
      "                maxima.long_count = value.long_count;",
      "                long_word = word;",
      "            }",
      "            if (is_primitive && value.total > primitive_maximum) {",
      "                primitive_maximum = value.total;",
      "                primitive_word = word;",
      "            }",
      "            if (!is_primitive && value.total > nonprimitive_maximum) {",
      "                nonprimitive_maximum = value.total;",
      "                nonprimitive_word = word;",
      "            }",
      "        }",
      "        std::cout << \"length=\" << n",
      "                  << \" checked=\" << count",
      "                  << \" total=\" << maxima.total << \" total_word=\" << total_word",
      "                  << \" short=\" << maxima.short_count << \" short_word=\" << short_word",
      "                  << \" long=\" << maxima.long_count << \" long_word=\" << long_word",
      "                  << \" primitive=\" << primitive_maximum",
      "                  << \" primitive_word=\" << primitive_word",
      "                  << \" nonprimitive=\" << nonprimitive_maximum",
      "                  << \" nonprimitive_word=\" << nonprimitive_word",
      "                  << \"\\n\";",
      "    }",
      "}"
    ]
  },
  "formal_statement": null,
  "source": {
    "url": null,
    "locator": "Independent self-contained C++17 source executed on macOS arm64 on 2026-07-28"
  },
  "models": [],
  "relations": [
    {
      "slug": "R132",
      "title": "Exact binary maxima through length twenty-six",
      "object_type": "claim",
      "relation": "evidences",
      "direction": "outgoing"
    },
    {
      "slug": "R130",
      "title": "The short-square half-length charge fails at twelve",
      "object_type": "attempt",
      "relation": "tests",
      "direction": "outgoing"
    },
    {
      "slug": "circular-distinct-squares-three-halves",
      "title": "circular distinct squares three halves",
      "object_type": "problem",
      "relation": "recorded_for",
      "direction": "outgoing"
    }
  ]
}

7Provenance

View source, identifiers, and projection details
Project
circular-distinct-squares-three-halves-research
Locator
Independent self-contained C++17 source executed on macOS arm64 on 2026-07-28
License
CC0-1.0
Public record
R124
Stable alias
cds-artifact-binary-direct-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.