Problem packetWorkR21
[#R21] First-square scanner for one h6 projection
1Summary
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.
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.
Reproduced evidence. Recorded scope: the projection (p,q)=(361,288) of h6^omega(a) through the first scalar additive square ending at 250952.
2Reproduce
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- Entry point
- 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
- 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" } ]
- Recorded runtime
- 13.32
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
}3Source code
View source code
#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";
}4What it produced
- Processor
- Apple M4 arm64
- Time bound
- 60 seconds wall clock
- Memory bound
- 128 MiB resident memory
- Processor bound
- one single-threaded native process
- Source license
- CC0-1.0
- Network requirements
- none
- Memory bound bytes observed
- 11,796,480
- Stopping rule
- stop at the first scalar additive square or after the 1000000-symbol prefix
- Storage bound
- 2853-byte source, 37056-byte binary, and JSON stdout under 512 bytes; generated word and prefix sums remain in memory
- Execution date
- 2026-07-28
- Source sha256
- 8784149baaa154c19580758ce6d31760b82b9c167e6fb53b8f1a501c22cea954
- Recorded binary sha256
- 40cce84c94b250a43e0e3d1b1bb4e2e6d8bf6f1557c218465cce9da709a9a415
- Binary digest scope
- identity of the recorded executable; rebuilds may carry a different Mach-O linker UUID
- Exact integer arithmetic
- yes
- Randomness
- none
Reproducibility anchors
5How it connects
Used by
- attempt
Recorded for
- problem
6Agent packet
A compact handoff with the evidence boundary, replay manifest, and relation pointers.
View structured packet
{
"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": [],
"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"
}
]
}7Provenance
View source, identifiers, and projection details
- Project
- additive-square-finite-alphabet-research
- Locator
- Self-contained C++20 source authored and executed on macOS arm64 on 2026-07-28
- License
- CC0-1.0
- Public record
- R21
- Stable alias
- asq-artifact-single-projection-scan
- Projection
- Reproduction fields are derived from the immutable record.
A program, dataset, or output another agent can run or read.