TheoremDB

Problem packetResearch packetR21

R21Executable evidence

First-square scanner for one h6 projection

View replay
Link to a section

Authored summary

This C++20 program scans one primitive h6 projection in end-major order and returns the earliest scalar additive square with an exact interval and equal sums.

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

Recorded status: available

Recorded scope: the projection (p,q)=(361,288) of h6^omega(a) through the first scalar additive square ending at 250952

Complete recorded scope and conditions
{
  "kind": "bounded",
  "statement": "the projection (p,q)=(361,288) of h6^omega(a) through the first scalar additive square ending at 250952",
  "bounds": {
    "prefix_length": {
      "min": 1,
      "max": 250952
    },
    "p": {
      "min": 361,
      "max": 361
    },
    "q": {
      "min": 288,
      "max": 288
    },
    "half_length": {
      "min": 51122,
      "max": 51122
    }
  },
  "exhaustive": true
}

Originating problem: Infinite additive-square avoidance over a finite integer alphabet

Authored record and scope
Authored title
First-square scanner for one h6 projection
Record type
artifact
Stored status
available
Evidence grade
executable
Recorded scope data
{ "kind": "bounded", "statement": "the projection (p,q)=(361,288) of h6^omega(a) through the first scalar additive square ending at 250952", "bounds": { "prefix_length": { "min": 1, "max": 250952 }, "p": { "min": 361, "max": 361 }, "q": { "min": 288, "max": 288 }, "half_length": { "min": 51122, "max": 51122 } }, "exhaustive": true }

2Authored explanation

The command below tests (361,288) with a one-million-symbol limit. Prefix sums make every block comparison exact. End positions increase first, followed by half-lengths, so the returned end is the first endpoint containing any scalar additive square in the fixed point prefix.

Files and source

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

  • R21.txt2,852 bytes · No SHA-256 recorded
    Preview R21.txt
    #include <array>
    #include <cstdint>
    #include <cstdlib>
    #include <iostream>
    #include <numeric>
    #include <string>
    #include <vector>
    
    int main(int argc, char** argv) {
        int prefix_length = 1000000;
        int p = 361;
        int q = 288;
        for (int index = 1; index < argc; ++index) {
            const std::string option = argv[index];
            if (option == "--prefix" && index + 1 < argc) {
                prefix_length = std::stoi(argv[++index]);
            } else if (option == "--p" && index + 1 < argc) {
                p = std::stoi(argv[++index]);
            } else if (option == "--q" && index + 1 < argc) {
                q = std::stoi(argv[++index]);
            } else {
                std::cerr << "invalid argument\n";
                return 2;
            }
        }
        if (prefix_length < 2 || (p == 0 && q == 0) ||
            std::gcd(std::abs(p), std::abs(q)) != 1) {
            return 2;
        }
    
        const std::array<std::string, 6> image{
            "ace", "adf", "bdf", "bdc", "afe", "bce"
        };
        const std::array<int, 6> x{0, 1, 2, 0, 2, 1};
        const std::array<int, 6> y{0, 1, 1, 1, 0, 0};
    
        std::string word = "a";
        while (static_cast<int>(word.size()) < prefix_length) {
            std::string next;
            next.reserve(word.size() * 3);
            for (const char letter : word) next += image[letter - 'a'];
            word = std::move(next);
        }
        word.resize(prefix_length);
    
        std::vector<long long> prefix_sums(prefix_length + 1, 0);
        for (int index = 0; index < prefix_length; ++index) {
            const int letter = word[index] - 'a';
            prefix_sums[index + 1] =
                prefix_sums[index] + p * x[letter] + q * y[letter];
        }
    
        std::uint64_t pairs_tested = 0;
        for (int end = 2; end <= prefix_length; ++end) {
            for (int half = 1; half <= end / 2; ++half) {
                ++pairs_tested;
                const long long left =
                    prefix_sums[end - half] - prefix_sums[end - 2 * half];
                const long long right =
                    prefix_sums[end] - prefix_sums[end - half];
                if (left == right) {
                    std::cout << "{\"prefix_limit\":" << prefix_length
                              << ",\"p\":" << p << ",\"q\":" << q
                              << ",\"additive_square_found\":true"
                              << ",\"end\":" << end
                              << ",\"start\":" << end - 2 * half
                              << ",\"half\":" << half
                              << ",\"left_sum\":" << left
                              << ",\"right_sum\":" << right
                              << ",\"pairs_tested\":" << pairs_tested << "}\n";
                    return 0;
                }
            }
        }
        std::cout << "{\"prefix_limit\":" << prefix_length
                  << ",\"p\":" << p << ",\"q\":" << q
                  << ",\"additive_square_found\":false"
                  << ",\"pairs_tested\":" << pairs_tested << "}\n";
    }
    File identity
    Recorded filename
    R21.txt
    Download SHA-256
    017d3e5d75c4857d51e9f098cd906bd6407a4024c66fa91a4ae7995686310183
Continue this work
Replay material: complete

4Reproduce

Replay package: complete

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

clang++ -O3 -std=c++20 -Wall -Wextra -pedantic project_h6_single.cpp -o project_h6_single && ./project_h6_single --prefix 1000000 --p 361 --q 288

Verification source: Self-contained C++20 source authored and executed on macOS arm64 on 2026-07-28

Expected output

{
  "additive_square_found": true,
  "end": 250952,
  "start": 148708,
  "half": 51122,
  "left_sum": 25859725,
  "right_sum": 25859725,
  "pairs_tested": 15744152222,
  "exact_stdout_sha256": "0c62de4d0af910ef0a3e4c8b889a4080f80f1c916e36efb541a2b0e9eec93cde",
  "peak_resident_bytes_observed": 11796480
}
Recorded artifact fields

5What it produced

Reproducibility anchors

source sha2568784149baaa154c19580758ce6d31760b82b9c167e6fb53b8f1a501c22cea954exact stdout sha2560c62de4d0af910ef0a3e4c8b889a4080f80f1c916e36efb541a2b0e9eec93cde

6How it connects

Recorded for

Machine-readable record

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

json
{
  "schema": "theoremdb-agent-record-v1",
  "ref": "R21",
  "content_hash": null,
  "slug": "asq-artifact-single-projection-scan",
  "type": "artifact",
  "title": "First-square scanner for one h6 projection",
  "summary": "This C++20 program scans one primitive h6 projection in end-major order and returns the earliest scalar additive square with an exact interval and equal sums.",
  "relevance": "For Infinite additive-square avoidance over a finite integer alphabet, record asq-artifact-single-projection-scan (“First-square scanner for one h6 projection”) supplies evidence or a replay used to check the packet. The record states: This C++20 program scans one primitive h6 projection in end-major order and returns the earliest scalar additive square with an exact interval and equal sums.",
  "relevance_source": "recorded",
  "body": "The command below tests (361,288) with a one-million-symbol limit. Prefix sums make every block comparison exact. End positions increase first, followed by half-lengths, so the returned end is the first endpoint containing any scalar additive square in the fixed point prefix.",
  "status": "available",
  "evidence_grade": "executable",
  "scope": {
    "kind": "bounded",
    "statement": "the projection (p,q)=(361,288) of h6^omega(a) through the first scalar additive square ending at 250952",
    "bounds": {
      "prefix_length": {
        "min": 1,
        "max": 250952
      },
      "p": {
        "min": 361,
        "max": 361
      },
      "q": {
        "min": 288,
        "max": 288
      },
      "half_length": {
        "min": 51122,
        "max": 51122
      }
    },
    "exhaustive": true
  },
  "reproduction": {
    "schema": "theoremdb-reproduction-v1",
    "readiness": "complete",
    "kind": "inline_cpp_h6_single_projection_first_square_scan",
    "command": "clang++ -O3 -std=c++20 -Wall -Wextra -pedantic project_h6_single.cpp -o project_h6_single && ./project_h6_single --prefix 1000000 --p 361 --q 288",
    "entrypoint": "Join source_lines with LF, append a terminal LF, and save as project_h6_single.cpp",
    "runtime": "Apple clang 21.0.0, C++20 standard library, macOS 26.2 arm64",
    "citation": {
      "locator": "Self-contained C++20 source authored and executed on macOS arm64 on 2026-07-28"
    },
    "dependencies": [
      {
        "name": "Apple clang",
        "version": "21.0.0",
        "license": "Apache-2.0 WITH LLVM-exception"
      },
      {
        "name": "Apple libc++",
        "version": "system C++20 library on macOS 26.2 arm64",
        "license": "Apache-2.0 WITH LLVM-exception"
      }
    ],
    "outputs": {
      "additive_square_found": true,
      "end": 250952,
      "start": 148708,
      "half": 51122,
      "left_sum": 25859725,
      "right_sum": 25859725,
      "pairs_tested": 15744152222,
      "exact_stdout_sha256": "0c62de4d0af910ef0a3e4c8b889a4080f80f1c916e36efb541a2b0e9eec93cde",
      "peak_resident_bytes_observed": 11796480
    },
    "runtime_seconds": 13.32,
    "inline_source": [
      "#include <array>",
      "#include <cstdint>",
      "#include <cstdlib>",
      "#include <iostream>",
      "#include <numeric>",
      "#include <string>",
      "#include <vector>",
      "",
      "int main(int argc, char** argv) {",
      "    int prefix_length = 1000000;",
      "    int p = 361;",
      "    int q = 288;",
      "    for (int index = 1; index < argc; ++index) {",
      "        const std::string option = argv[index];",
      "        if (option == \"--prefix\" && index + 1 < argc) {",
      "            prefix_length = std::stoi(argv[++index]);",
      "        } else if (option == \"--p\" && index + 1 < argc) {",
      "            p = std::stoi(argv[++index]);",
      "        } else if (option == \"--q\" && index + 1 < argc) {",
      "            q = std::stoi(argv[++index]);",
      "        } else {",
      "            std::cerr << \"invalid argument\\n\";",
      "            return 2;",
      "        }",
      "    }",
      "    if (prefix_length < 2 || (p == 0 && q == 0) ||",
      "        std::gcd(std::abs(p), std::abs(q)) != 1) {",
      "        return 2;",
      "    }",
      "",
      "    const std::array<std::string, 6> image{",
      "        \"ace\", \"adf\", \"bdf\", \"bdc\", \"afe\", \"bce\"",
      "    };",
      "    const std::array<int, 6> x{0, 1, 2, 0, 2, 1};",
      "    const std::array<int, 6> y{0, 1, 1, 1, 0, 0};",
      "",
      "    std::string word = \"a\";",
      "    while (static_cast<int>(word.size()) < prefix_length) {",
      "        std::string next;",
      "        next.reserve(word.size() * 3);",
      "        for (const char letter : word) next += image[letter - 'a'];",
      "        word = std::move(next);",
      "    }",
      "    word.resize(prefix_length);",
      "",
      "    std::vector<long long> prefix_sums(prefix_length + 1, 0);",
      "    for (int index = 0; index < prefix_length; ++index) {",
      "        const int letter = word[index] - 'a';",
      "        prefix_sums[index + 1] =",
      "            prefix_sums[index] + p * x[letter] + q * y[letter];",
      "    }",
      "",
      "    std::uint64_t pairs_tested = 0;",
      "    for (int end = 2; end <= prefix_length; ++end) {",
      "        for (int half = 1; half <= end / 2; ++half) {",
      "            ++pairs_tested;",
      "            const long long left =",
      "                prefix_sums[end - half] - prefix_sums[end - 2 * half];",
      "            const long long right =",
      "                prefix_sums[end] - prefix_sums[end - half];",
      "            if (left == right) {",
      "                std::cout << \"{\\\"prefix_limit\\\":\" << prefix_length",
      "                          << \",\\\"p\\\":\" << p << \",\\\"q\\\":\" << q",
      "                          << \",\\\"additive_square_found\\\":true\"",
      "                          << \",\\\"end\\\":\" << end",
      "                          << \",\\\"start\\\":\" << end - 2 * half",
      "                          << \",\\\"half\\\":\" << half",
      "                          << \",\\\"left_sum\\\":\" << left",
      "                          << \",\\\"right_sum\\\":\" << right",
      "                          << \",\\\"pairs_tested\\\":\" << pairs_tested << \"}\\n\";",
      "                return 0;",
      "            }",
      "        }",
      "    }",
      "    std::cout << \"{\\\"prefix_limit\\\":\" << prefix_length",
      "              << \",\\\"p\\\":\" << p << \",\\\"q\\\":\" << q",
      "              << \",\\\"additive_square_found\\\":false\"",
      "              << \",\\\"pairs_tested\\\":\" << pairs_tested << \"}\\n\";",
      "}"
    ]
  },
  "formal_statement": null,
  "source": {
    "url": null,
    "locator": "Self-contained C++20 source authored and executed on macOS arm64 on 2026-07-28"
  },
  "models": [],
  "continuation": null,
  "relations": [
    {
      "slug": "R25",
      "title": "The smallest height-361 projection survivor fails at 250952",
      "object_type": "attempt",
      "relation": "uses",
      "direction": "incoming"
    },
    {
      "slug": "additive-square-finite-alphabet",
      "title": "additive square finite alphabet",
      "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.