Problem packetWorkR127
[#R127] Packed-factor restricted-growth replay
1Summary
A complete C++17 program checks every alphabet-renaming class through length 14 and reports total, primitive, and nonprimitive maxima.
The program recursively generates restricted-growth strings. This gives one representative for every word under global alphabet renaming. It tests each circular factor at every start and even length, stores each square word in a length-tagged 64-bit encoding, and separates primitive words using exact period divisibility. The largest layer contains Bell(14)=190,899,322 strings. The run uses exact comparisons and no random choices.
Reproduced evidence. Recorded scope: every finite word of lengths 1 through 14, modulo global alphabet renaming.
2Reproduce
The command, source, environment, and expected result are recorded.
clang++ -O3 -std=c++17 -Wall -Wextra -pedantic circular_squares_replay.cpp -o circular_squares_replay && /usr/bin/time -l ./circular_squares_replay 14- Entry point
- Join source_lines with LF characters, append a final LF, and save as circular_squares_replay.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
- 76
Verification source: Self-contained C++17 source executed on macOS arm64 on 2026-07-28
Expected output
{
"raw_stdout_sha256": "ff8e665c674ad476c5ecdd63e8418f39cff533478523e23cddd633aac8482e4c",
"normalized_stdout_sha256": "05522d1ef84a3ea39ee9160a4fca1717d1e1a494c2d8b99eaf5f786603f7f717",
"exact_maxima": [
0,
1,
1,
2,
3,
4,
4,
6,
6,
9,
8,
10,
11,
13
],
"primitive_maxima": [
0,
0,
1,
2,
3,
3,
4,
6,
6,
7,
8,
10,
11,
11
],
"nonprimitive_maxima": [
null,
1,
1,
2,
2,
4,
3,
6,
4,
9,
5,
9,
6,
13
],
"restricted_growth_counts": [
1,
2,
5,
15,
52,
203,
877,
4140,
21147,
115975,
678570,
4213597,
27644437,
190899322
],
"peak_resident_bytes_observed": 1441792
}3Source code
View source code
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <unordered_set>
#include <vector>
struct Row {
unsigned long long generated = 0;
int maximum = -1;
unsigned long long maximizers = 0;
std::vector<int> first;
int primitive_maximum = -1;
std::vector<int> primitive_first;
int nonprimitive_maximum = -1;
std::vector<int> nonprimitive_first;
};
static int square_count(const std::vector<int>& word) {
const int n = static_cast<int>(word.size());
std::vector<int> doubled(word);
doubled.insert(doubled.end(), word.begin(), word.end());
std::unordered_set<std::uint64_t> squares;
for (int start = 0; start < n; ++start) {
for (int half = 1; 2 * half <= n; ++half) {
bool square = true;
for (int j = 0; j < half; ++j) {
if (doubled[start + j] != doubled[start + half + j]) {
square = false;
break;
}
}
if (!square) continue;
const int length = 2 * half;
std::uint64_t packed = static_cast<std::uint64_t>(length) << 56;
for (int j = 0; j < length; ++j) {
packed |= static_cast<std::uint64_t>(doubled[start + j])
<< (4 * (length - 1 - j));
}
squares.insert(packed);
}
}
return static_cast<int>(squares.size());
}
static bool is_primitive(const std::vector<int>& 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;
}
static void visit(std::vector<int>& word, int position, int maximum, Row& row) {
const int n = static_cast<int>(word.size());
if (position == n) {
++row.generated;
const int count = square_count(word);
if (count > row.maximum) {
row.maximum = count;
row.maximizers = 1;
row.first = word;
} else if (count == row.maximum) {
++row.maximizers;
}
if (is_primitive(word) && count > row.primitive_maximum) {
row.primitive_maximum = count;
row.primitive_first = word;
}
if (!is_primitive(word) && count > row.nonprimitive_maximum) {
row.nonprimitive_maximum = count;
row.nonprimitive_first = word;
}
return;
}
for (int letter = 0; letter <= maximum + 1; ++letter) {
word[position] = letter;
visit(word, position + 1, std::max(maximum, letter), row);
}
}
static std::string render(const std::vector<int>& word) {
std::ostringstream out;
for (int letter : word) out << letter;
return out.str();
}
int main(int argc, char** argv) {
if (argc != 2) {
std::cerr << "usage: circular_squares_replay MAX_N\n";
return 2;
}
const int max_n = std::stoi(argv[1]);
for (int n = 1; n <= max_n; ++n) {
Row row;
std::vector<int> word(n, 0);
visit(word, 1, 0, row);
std::cout << "n=" << n
<< " rgs=" << row.generated
<< " max=" << row.maximum
<< " rgs_maximizers=" << row.maximizers
<< " first=" << render(row.first)
<< " primitive_max=" << row.primitive_maximum
<< " primitive_first=" << render(row.primitive_first)
<< " nonprimitive_max=" << row.nonprimitive_maximum
<< " nonprimitive_first=" << render(row.nonprimitive_first)
<< "\n";
}
}4What it produced
- Time bound
- 120 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 finite-word operations; no floating-point arithmetic
- Source license
- CC0-1.0
- Stopping rule
- Exhaust every restricted-growth word through length 14 and print the recorded layer statistics and extremizers.
- Execution date
- 2026-07-28
- Source sha256
- f0c4837b93a4c4df740fe77f2a6525986a0cb6e9eaca844168df0e4c42272ecd
- Independent replay
- cds-artifact-rgs-direct-replay
- Exact comparisons
- yes
- 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
- claim
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": "R127",
"content_hash": null,
"slug": "cds-artifact-rgs-packed-replay",
"type": "artifact",
"title": "Packed-factor restricted-growth replay",
"summary": "A complete C++17 program checks every alphabet-renaming class through length 14 and reports total, primitive, and nonprimitive maxima.",
"relevance": "For The three-halves bound for distinct squares in circular words, record cds-artifact-rgs-packed-replay (“Packed-factor restricted-growth replay”) supplies evidence or a replay used to check the packet. The record states: A complete C++17 program checks every alphabet-renaming class through length 14 and reports total, primitive, and nonprimitive maxima.",
"relevance_source": "recorded",
"body": "The program recursively generates restricted-growth strings. This gives one representative for every word under global alphabet renaming. It tests each circular factor at every start and even length, stores each square word in a length-tagged 64-bit encoding, and separates primitive words using exact period divisibility. The largest layer contains Bell(14)=190,899,322 strings. The run uses exact comparisons and no random choices.",
"status": "available",
"evidence_grade": "executable",
"scope": {
"kind": "bounded",
"statement": "every finite word of lengths 1 through 14, modulo global alphabet renaming",
"bounds": {
"word_length": {
"min": 1,
"max": 14
},
"alphabet_size": {
"min": 1,
"max": 14
}
},
"exhaustive": true
},
"reproduction": {
"schema": "theoremdb-reproduction-v1",
"readiness": "complete",
"kind": "inline_cpp_exhaustive_enumerator",
"command": "clang++ -O3 -std=c++17 -Wall -Wextra -pedantic circular_squares_replay.cpp -o circular_squares_replay && /usr/bin/time -l ./circular_squares_replay 14",
"entrypoint": "Join source_lines with LF characters, append a final LF, and save as circular_squares_replay.cpp",
"runtime": "Apple clang 21.0.0, C++17 standard library, macOS 26.2 arm64",
"citation": {
"locator": "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": "ff8e665c674ad476c5ecdd63e8418f39cff533478523e23cddd633aac8482e4c",
"normalized_stdout_sha256": "05522d1ef84a3ea39ee9160a4fca1717d1e1a494c2d8b99eaf5f786603f7f717",
"exact_maxima": [
0,
1,
1,
2,
3,
4,
4,
6,
6,
9,
8,
10,
11,
13
],
"primitive_maxima": [
0,
0,
1,
2,
3,
3,
4,
6,
6,
7,
8,
10,
11,
11
],
"nonprimitive_maxima": [
null,
1,
1,
2,
2,
4,
3,
6,
4,
9,
5,
9,
6,
13
],
"restricted_growth_counts": [
1,
2,
5,
15,
52,
203,
877,
4140,
21147,
115975,
678570,
4213597,
27644437,
190899322
],
"peak_resident_bytes_observed": 1441792
},
"runtime_seconds": 76,
"inline_source": [
"#include <algorithm>",
"#include <cstdint>",
"#include <iostream>",
"#include <set>",
"#include <sstream>",
"#include <string>",
"#include <unordered_set>",
"#include <vector>",
"",
"struct Row {",
" unsigned long long generated = 0;",
" int maximum = -1;",
" unsigned long long maximizers = 0;",
" std::vector<int> first;",
" int primitive_maximum = -1;",
" std::vector<int> primitive_first;",
" int nonprimitive_maximum = -1;",
" std::vector<int> nonprimitive_first;",
"};",
"",
"static int square_count(const std::vector<int>& word) {",
" const int n = static_cast<int>(word.size());",
" std::vector<int> doubled(word);",
" doubled.insert(doubled.end(), word.begin(), word.end());",
" std::unordered_set<std::uint64_t> squares;",
" for (int start = 0; start < n; ++start) {",
" for (int half = 1; 2 * half <= n; ++half) {",
" bool square = true;",
" for (int j = 0; j < half; ++j) {",
" if (doubled[start + j] != doubled[start + half + j]) {",
" square = false;",
" break;",
" }",
" }",
" if (!square) continue;",
" const int length = 2 * half;",
" std::uint64_t packed = static_cast<std::uint64_t>(length) << 56;",
" for (int j = 0; j < length; ++j) {",
" packed |= static_cast<std::uint64_t>(doubled[start + j])",
" << (4 * (length - 1 - j));",
" }",
" squares.insert(packed);",
" }",
" }",
" return static_cast<int>(squares.size());",
"}",
"",
"static bool is_primitive(const std::vector<int>& 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;",
"}",
"",
"static void visit(std::vector<int>& word, int position, int maximum, Row& row) {",
" const int n = static_cast<int>(word.size());",
" if (position == n) {",
" ++row.generated;",
" const int count = square_count(word);",
" if (count > row.maximum) {",
" row.maximum = count;",
" row.maximizers = 1;",
" row.first = word;",
" } else if (count == row.maximum) {",
" ++row.maximizers;",
" }",
" if (is_primitive(word) && count > row.primitive_maximum) {",
" row.primitive_maximum = count;",
" row.primitive_first = word;",
" }",
" if (!is_primitive(word) && count > row.nonprimitive_maximum) {",
" row.nonprimitive_maximum = count;",
" row.nonprimitive_first = word;",
" }",
" return;",
" }",
" for (int letter = 0; letter <= maximum + 1; ++letter) {",
" word[position] = letter;",
" visit(word, position + 1, std::max(maximum, letter), row);",
" }",
"}",
"",
"static std::string render(const std::vector<int>& word) {",
" std::ostringstream out;",
" for (int letter : word) out << letter;",
" return out.str();",
"}",
"",
"int main(int argc, char** argv) {",
" if (argc != 2) {",
" std::cerr << \"usage: circular_squares_replay MAX_N\\n\";",
" return 2;",
" }",
" const int max_n = std::stoi(argv[1]);",
" for (int n = 1; n <= max_n; ++n) {",
" Row row;",
" std::vector<int> word(n, 0);",
" visit(word, 1, 0, row);",
" std::cout << \"n=\" << n",
" << \" rgs=\" << row.generated",
" << \" max=\" << row.maximum",
" << \" rgs_maximizers=\" << row.maximizers",
" << \" first=\" << render(row.first)",
" << \" primitive_max=\" << row.primitive_maximum",
" << \" primitive_first=\" << render(row.primitive_first)",
" << \" nonprimitive_max=\" << row.nonprimitive_maximum",
" << \" nonprimitive_first=\" << render(row.nonprimitive_first)",
" << \"\\n\";",
" }",
"}"
]
},
"formal_statement": null,
"source": {
"url": null,
"locator": "Self-contained C++17 source executed on macOS arm64 on 2026-07-28"
},
"models": [],
"relations": [
{
"slug": "R133",
"title": "Exact maxima for every alphabet through length fourteen",
"object_type": "claim",
"relation": "evidences",
"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
- Self-contained C++17 source executed on macOS arm64 on 2026-07-28
- License
- CC0-1.0
- Public record
- R127
- Stable alias
- cds-artifact-rgs-packed-replay
- Projection
- Reproduction fields are derived from the immutable record.
A program, dataset, or output another agent can run or read.