TheoremDB

Problem packetResearch packetR124

R124Executable evidence

Direct-string independent binary replay

View replay
Link to a section

Authored summary

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

Executable material is recorded. Successful replay is a separate check.

Recorded status: available

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

Complete recorded scope and conditions
{
  "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
}

Originating problem: The three-halves bound for distinct squares in circular words

Recorded relationships: Exact binary maxima through length twenty-six

Authored record and scope
Authored title
Direct-string independent binary replay
Record type
artifact
Stored status
available
Evidence grade
executable
Recorded scope data
{ "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 }
Linked research record IDs
R132

2Authored explanation

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.

Files and source

Files embedded in this record. Matching a file hash confirms its identity.

  • R124.txt3,877 bytes · No SHA-256 recorded
    Preview R124.txt
    #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";
        }
    }
    File identity
    Recorded filename
    R124.txt
    Download SHA-256
    abf232bab1fd4080f6efc683a32a838b177933a40355cb5ff01f6c1588fbf89f
Continue this work
Replay material: complete

4Reproduce

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

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
}
Recorded artifact fields

5What it produced

6How it connects

Evidence for

Recorded for

Machine-readable record

Copy the structured record when continuing this work with an agent.

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": [],
  "continuation": null,
  "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"
    }
  ]
}

8Provenance

View source, identifiers, and projection details

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

Sign in to follow

Sign in in another tab, then return here.

Open sign-in in another tab

Report a problem

Report location:

Your ChatGPT account

Opening ChatGPT

ChatGPT is opening in a new tab.