[#R4] Independent C++ replay of the leading all-four incidence count
1Summary
A direct C++17 enumeration independently reproduces the finite image pools, the 1,146 prolongable matrices and 588 complement orbits, and the exact 23,298,600 incidence-valid tuples for matrix (8,1,2,2).
This replay enumerates every word over \(\{0,1,2,3\}\) of lengths 8 through 12 by two-bit integer code. It scans every possible additive-cube factor in block-length and start-position order, then records length, sum, first letter, and support mask for each surviving word. This implementation is separate from the recursive Python generator in `ac0123-artifact-finite-image-pools`.
The program independently obtains 1,146 expanding matrices whose four image pools are nonempty and permit a self-starting image, then reduces them to 588 complement-conjugacy orbits. It reproduces the first twelve prolongability-ranked representatives. For the incidence-leading matrix \((8,1,2,2)\), it partitions each image pool by support mask and whether the image begins with its own letter. Exact directed reachability over those categories gives 23,298,600 tuples with a prolongation letter whose fixed-point component uses all four letters.
Reproduced evidence. Recorded scope: all finite image words of lengths 8 through 12 and the exact all-four incidence count for affine matrix (8,1,2,2).
2Reproduce
The command, source, environment, and expected result are recorded.
clang++ -O3 -std=c++17 -Wall -Wextra -pedantic additive_cube_incidence_verify.cpp -o additive_cube_incidence_verify && /usr/bin/time -lp ./additive_cube_incidence_verify > additive_cube_incidence_verify.out- Entry point
- Join source_lines with LF characters and append one terminal LF as additive_cube_incidence_verify.cpp; source_sha256 includes that terminal LF
- Runtime
- Apple clang version 21.0.0, target arm64-apple-darwin25.2.0, ISO C++17, standard library only
- Dependencies
- [ { "name": "Apple clang", "version": "21.0.0", "license": "Apache-2.0 WITH LLVM-exception" }, { "name": "Apple libc++", "version": "system toolchain for arm64-apple-darwin25.2.0", "license": "Apache-2.0 WITH LLVM-exception" } ]
- Recorded runtime
- 0.47
Verification source: Inline C++17 source prepared and replayed on 2026-07-28 as an independent check of ac0123-artifact-finite-image-pools
Expected output
{
"source_sha256": "ce1387c000d0b071cb3213302323443a791e8f69777c359a1f8922de45cfb79b",
"stdout_sha256": "7d7282fe69ef972424cb0c179d40b183c1fafc3408ad92aa825c05d2c930d5b1",
"additive_cube_free_word_counts": {
"8": 42070,
"9": 150560,
"10": 538214,
"11": 1924738,
"12": 6772220
},
"prolongable_matrices": 1146,
"complement_matrix_orbits": 588,
"selected_matrix": [
8,
1,
2,
2
],
"selected_image_lengths": [
8,
9,
10,
11
],
"selected_image_sums": [
2,
4,
6,
8
],
"selected_image_pool_sizes": [
1,
33,
510,
5831
],
"incidence_valid_image_tuples": "23298600",
"maximum_resident_bytes": 1835008
}3Overview
The replay checks the claimed leading incidence count. The primary Python artifact performs the exhaustive incidence ranking across all 588 orbits; this C++ program does not repeat that global ranking.
4Source code
View source code
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <vector>
using Matrix = std::array<int, 4>;
using u64 = std::uint64_t;
using u128 = unsigned __int128;
static bool expanding(const Matrix &m) {
const auto [a, b, c, d] = m;
const std::int64_t determinant = a * d - b * c;
const std::int64_t trace = a + d;
return determinant != 0
&& (determinant - trace + 1) * determinant > 0
&& (determinant + trace + 1) * determinant > 0
&& (determinant - 1) * determinant > 0;
}
static Matrix conjugate(const Matrix &m) {
const auto [a, b, c, d] = m;
return {a + 3 * b, -b, 3 * a + 9 * b - c - 3 * d, d - 3 * b};
}
static std::string decimal(u128 value) {
if (value == 0) return "0";
std::string result;
while (value) {
result.push_back(static_cast<char>('0' + value % 10));
value /= 10;
}
std::reverse(result.begin(), result.end());
return result;
}
int main() {
std::array<std::array<u64, 37>, 13> counts{};
std::array<std::array<std::array<u64, 4>, 37>, 13> first_counts{};
std::array<std::array<std::array<u64, 16>, 37>, 13> mask_counts{};
std::array<std::array<std::array<std::array<u64, 16>, 4>, 37>, 13>
first_mask_counts{};
for (int n = 8; n <= 12; ++n) {
const u64 limit = u64{1} << (2 * n);
for (u64 code = 0; code < limit; ++code) {
std::array<int, 13> prefix{};
u64 value = code;
const int first_letter = static_cast<int>(value & 3);
int support_mask = 0;
for (int i = 0; i < n; ++i) {
const int letter = static_cast<int>(value & 3);
prefix[i + 1] = prefix[i] + letter;
support_mask |= 1 << letter;
value >>= 2;
}
bool safe = true;
for (int block = 1; 3 * block <= n && safe; ++block) {
for (int start = 0; start + 3 * block <= n; ++start) {
const int x = prefix[start + block] - prefix[start];
const int y = prefix[start + 2 * block] - prefix[start + block];
const int z = prefix[start + 3 * block] - prefix[start + 2 * block];
if (x == y && y == z) {
safe = false;
break;
}
}
}
if (safe) {
++counts[n][prefix[n]];
++first_counts[n][prefix[n]][first_letter];
++mask_counts[n][prefix[n]][support_mask];
++first_mask_counts[n][prefix[n]][first_letter][support_mask];
}
}
}
for (int n = 8; n <= 12; ++n) {
u64 total = 0;
for (int sum = 0; sum <= 3 * n; ++sum) total += counts[n][sum];
std::cout << "n=" << n << " total=" << total << " counts=";
for (int sum = 0; sum <= 3 * n; ++sum) {
if (sum) std::cout << ',';
std::cout << counts[n][sum];
}
std::cout << '\n';
}
std::map<Matrix, u128> matrix_counts;
for (int a = 8; a <= 12; ++a) {
for (int b = -4; b <= 4; ++b) {
std::array<int, 4> lengths{};
for (int x = 0; x < 4; ++x) lengths[x] = a + b * x;
if (std::any_of(lengths.begin(), lengths.end(),
[](int length) { return length < 8 || length > 12; })) {
continue;
}
for (int c = 0; c <= 3 * lengths[0]; ++c) {
for (int d = -36; d <= 36; ++d) {
Matrix matrix{a, b, c, d};
if (!expanding(matrix)) continue;
std::array<int, 4> sums{};
bool feasible = true;
for (int x = 0; x < 4; ++x) {
sums[x] = c + d * x;
feasible &= 0 <= sums[x] && sums[x] <= 3 * lengths[x];
feasible &= feasible && counts[lengths[x]][sums[x]] != 0;
}
if (!feasible) continue;
u128 all = 1;
u128 none = 1;
bool any_start = false;
for (int x = 0; x < 4; ++x) {
const u64 pool = counts[lengths[x]][sums[x]];
const u64 starts = first_counts[lengths[x]][sums[x]][x];
all *= pool;
none *= pool - starts;
any_start |= starts != 0;
}
if (any_start) matrix_counts[matrix] = all - none;
}
}
}
}
std::map<Matrix, u128> orbits;
for (const auto &[matrix, count] : matrix_counts) {
const Matrix representative = std::min(matrix, conjugate(matrix));
const auto [it, inserted] = orbits.emplace(representative, count);
assert(inserted || it->second == count);
}
std::vector<std::pair<u128, Matrix>> ranked;
for (const auto &[matrix, count] : orbits) ranked.emplace_back(count, matrix);
std::sort(ranked.begin(), ranked.end());
std::cout << "matrices=" << matrix_counts.size()
<< " orbits=" << orbits.size() << '\n';
for (int i = 0; i < 12; ++i) {
const auto &[count, matrix] = ranked[i];
const auto [a, b, c, d] = matrix;
std::cout << a << ',' << b << ',' << c << ',' << d
<< ' ' << decimal(count) << '\n';
}
struct Category {
int mask;
bool self_start;
u64 count;
};
const std::array<int, 4> lengths{8, 9, 10, 11};
const std::array<int, 4> sums{2, 4, 6, 8};
std::array<std::vector<Category>, 4> categories;
for (int letter = 0; letter < 4; ++letter) {
for (int mask = 1; mask < 16; ++mask) {
const u64 all = mask_counts[lengths[letter]][sums[letter]][mask];
const u64 self =
first_mask_counts[lengths[letter]][sums[letter]][letter][mask];
if (self) categories[letter].push_back({mask, true, self});
if (all > self) categories[letter].push_back({mask, false, all - self});
}
}
const auto reaches_all = [](int start, const std::array<int, 4> &masks) {
int reached = 1 << start;
while (true) {
int expanded = reached;
for (int letter = 0; letter < 4; ++letter) {
if (reached & (1 << letter)) expanded |= masks[letter];
}
if (expanded == reached) return reached == 15;
reached = expanded;
}
};
u128 incidence_count = 0;
for (const auto &a : categories[0])
for (const auto &b : categories[1])
for (const auto &c : categories[2])
for (const auto &d : categories[3]) {
const std::array<Category, 4> selected{a, b, c, d};
const std::array<int, 4> masks{a.mask, b.mask, c.mask, d.mask};
bool accepted = false;
u128 multiplicity = 1;
for (int letter = 0; letter < 4; ++letter) {
accepted |= selected[letter].self_start
&& reaches_all(letter, masks);
multiplicity *= selected[letter].count;
}
if (accepted) incidence_count += multiplicity;
}
std::cout << "matrix=8,1,2,2 incidence_valid="
<< decimal(incidence_count) << '\n';
}5What it produced
- Processor
- Apple M4, arm64
- Time bound
- 10 seconds wall clock
- Memory bound
- 128 MiB resident memory
- Processor bound
- one single-threaded native process
- Network requirements
- none
- Artifact license
- CC0-1.0
- Arithmetic
- exact integer, with unsigned 128-bit tuple counts
- Randomness
- none
- Network during execution
- none
- Independence
- direct two-bit word enumeration and block-first cube scans, separate from the recursive Python generator
- Coverage limit
- recomputes the leading matrix incidence count but does not independently rerank all 588 matrices by incidence count
Storage bound
6How it connects
Tests
- artifact
Recorded for
- problem
7Agent packet
A compact handoff with the evidence boundary, replay manifest, and relation pointers.
View structured packet
{
"schema": "theoremdb-agent-record-v1",
"ref": "R4",
"content_hash": null,
"slug": "ac0123-artifact-independent-incidence-replay",
"type": "artifact",
"title": "Independent C++ replay of the leading all-four incidence count",
"summary": "A direct C++17 enumeration independently reproduces the finite image pools, the 1,146 prolongable matrices and 588 complement orbits, and the exact 23,298,600 incidence-valid tuples for matrix (8,1,2,2).",
"relevance": "For Additive-cube avoidance on the alphabet zero through three, record ac0123-artifact-independent-incidence-replay (“Independent C++ replay of the leading all-four incidence count”) supplies evidence or a replay used to check the packet. The record states: A direct C++17 enumeration independently reproduces the finite image pools, the 1,146 prolongable matrices and 588 complement orbits, and the exact 23,298,600 incidence-valid tuples for matrix (8,1,2,2).",
"relevance_source": "recorded",
"body": "This replay enumerates every word over \\(\\{0,1,2,3\\}\\) of lengths 8 through 12 by two-bit integer code. It scans every possible additive-cube factor in block-length and start-position order, then records length, sum, first letter, and support mask for each surviving word. This implementation is separate from the recursive Python generator in `ac0123-artifact-finite-image-pools`.\n\nThe program independently obtains 1,146 expanding matrices whose four image pools are nonempty and permit a self-starting image, then reduces them to 588 complement-conjugacy orbits. It reproduces the first twelve prolongability-ranked representatives. For the incidence-leading matrix \\((8,1,2,2)\\), it partitions each image pool by support mask and whether the image begins with its own letter. Exact directed reachability over those categories gives 23,298,600 tuples with a prolongation letter whose fixed-point component uses all four letters.\n\nThe replay checks the claimed leading incidence count. The primary Python artifact performs the exhaustive incidence ranking across all 588 orbits; this C++ program does not repeat that global ranking.",
"status": "available",
"evidence_grade": "executable",
"scope": {
"kind": "bounded",
"statement": "all finite image words of lengths 8 through 12 and the exact all-four incidence count for affine matrix (8,1,2,2)",
"bounds": {
"image_length": {
"min": 8,
"max": 12
},
"alphabet_size": {
"min": 4,
"max": 4
},
"matrix_a": {
"min": 8,
"max": 8
},
"matrix_b": {
"min": 1,
"max": 1
},
"matrix_c": {
"min": 2,
"max": 2
},
"matrix_d": {
"min": 2,
"max": 2
}
},
"exhaustive": true
},
"reproduction": {
"schema": "theoremdb-reproduction-v1",
"readiness": "complete",
"kind": "inline_cpp17_deterministic_independent_incidence_check",
"command": "clang++ -O3 -std=c++17 -Wall -Wextra -pedantic additive_cube_incidence_verify.cpp -o additive_cube_incidence_verify && /usr/bin/time -lp ./additive_cube_incidence_verify > additive_cube_incidence_verify.out",
"entrypoint": "Join source_lines with LF characters and append one terminal LF as additive_cube_incidence_verify.cpp; source_sha256 includes that terminal LF",
"runtime": "Apple clang version 21.0.0, target arm64-apple-darwin25.2.0, ISO C++17, standard library only",
"citation": {
"locator": "Inline C++17 source prepared and replayed on 2026-07-28 as an independent check of ac0123-artifact-finite-image-pools"
},
"dependencies": [
{
"name": "Apple clang",
"version": "21.0.0",
"license": "Apache-2.0 WITH LLVM-exception"
},
{
"name": "Apple libc++",
"version": "system toolchain for arm64-apple-darwin25.2.0",
"license": "Apache-2.0 WITH LLVM-exception"
}
],
"outputs": {
"source_sha256": "ce1387c000d0b071cb3213302323443a791e8f69777c359a1f8922de45cfb79b",
"stdout_sha256": "7d7282fe69ef972424cb0c179d40b183c1fafc3408ad92aa825c05d2c930d5b1",
"additive_cube_free_word_counts": {
"8": 42070,
"9": 150560,
"10": 538214,
"11": 1924738,
"12": 6772220
},
"prolongable_matrices": 1146,
"complement_matrix_orbits": 588,
"selected_matrix": [
8,
1,
2,
2
],
"selected_image_lengths": [
8,
9,
10,
11
],
"selected_image_sums": [
2,
4,
6,
8
],
"selected_image_pool_sizes": [
1,
33,
510,
5831
],
"incidence_valid_image_tuples": "23298600",
"maximum_resident_bytes": 1835008
},
"runtime_seconds": 0.47,
"inline_source": [
"#include <algorithm>",
"#include <array>",
"#include <cassert>",
"#include <cstdint>",
"#include <iostream>",
"#include <map>",
"#include <string>",
"#include <tuple>",
"#include <vector>",
"",
"using Matrix = std::array<int, 4>;",
"using u64 = std::uint64_t;",
"using u128 = unsigned __int128;",
"",
"static bool expanding(const Matrix &m) {",
" const auto [a, b, c, d] = m;",
" const std::int64_t determinant = a * d - b * c;",
" const std::int64_t trace = a + d;",
" return determinant != 0",
" && (determinant - trace + 1) * determinant > 0",
" && (determinant + trace + 1) * determinant > 0",
" && (determinant - 1) * determinant > 0;",
"}",
"",
"static Matrix conjugate(const Matrix &m) {",
" const auto [a, b, c, d] = m;",
" return {a + 3 * b, -b, 3 * a + 9 * b - c - 3 * d, d - 3 * b};",
"}",
"",
"static std::string decimal(u128 value) {",
" if (value == 0) return \"0\";",
" std::string result;",
" while (value) {",
" result.push_back(static_cast<char>('0' + value % 10));",
" value /= 10;",
" }",
" std::reverse(result.begin(), result.end());",
" return result;",
"}",
"",
"int main() {",
" std::array<std::array<u64, 37>, 13> counts{};",
" std::array<std::array<std::array<u64, 4>, 37>, 13> first_counts{};",
" std::array<std::array<std::array<u64, 16>, 37>, 13> mask_counts{};",
" std::array<std::array<std::array<std::array<u64, 16>, 4>, 37>, 13>",
" first_mask_counts{};",
" for (int n = 8; n <= 12; ++n) {",
" const u64 limit = u64{1} << (2 * n);",
" for (u64 code = 0; code < limit; ++code) {",
" std::array<int, 13> prefix{};",
" u64 value = code;",
" const int first_letter = static_cast<int>(value & 3);",
" int support_mask = 0;",
" for (int i = 0; i < n; ++i) {",
" const int letter = static_cast<int>(value & 3);",
" prefix[i + 1] = prefix[i] + letter;",
" support_mask |= 1 << letter;",
" value >>= 2;",
" }",
" bool safe = true;",
" for (int block = 1; 3 * block <= n && safe; ++block) {",
" for (int start = 0; start + 3 * block <= n; ++start) {",
" const int x = prefix[start + block] - prefix[start];",
" const int y = prefix[start + 2 * block] - prefix[start + block];",
" const int z = prefix[start + 3 * block] - prefix[start + 2 * block];",
" if (x == y && y == z) {",
" safe = false;",
" break;",
" }",
" }",
" }",
" if (safe) {",
" ++counts[n][prefix[n]];",
" ++first_counts[n][prefix[n]][first_letter];",
" ++mask_counts[n][prefix[n]][support_mask];",
" ++first_mask_counts[n][prefix[n]][first_letter][support_mask];",
" }",
" }",
" }",
" for (int n = 8; n <= 12; ++n) {",
" u64 total = 0;",
" for (int sum = 0; sum <= 3 * n; ++sum) total += counts[n][sum];",
" std::cout << \"n=\" << n << \" total=\" << total << \" counts=\";",
" for (int sum = 0; sum <= 3 * n; ++sum) {",
" if (sum) std::cout << ',';",
" std::cout << counts[n][sum];",
" }",
" std::cout << '\\n';",
" }",
"",
" std::map<Matrix, u128> matrix_counts;",
" for (int a = 8; a <= 12; ++a) {",
" for (int b = -4; b <= 4; ++b) {",
" std::array<int, 4> lengths{};",
" for (int x = 0; x < 4; ++x) lengths[x] = a + b * x;",
" if (std::any_of(lengths.begin(), lengths.end(),",
" [](int length) { return length < 8 || length > 12; })) {",
" continue;",
" }",
" for (int c = 0; c <= 3 * lengths[0]; ++c) {",
" for (int d = -36; d <= 36; ++d) {",
" Matrix matrix{a, b, c, d};",
" if (!expanding(matrix)) continue;",
" std::array<int, 4> sums{};",
" bool feasible = true;",
" for (int x = 0; x < 4; ++x) {",
" sums[x] = c + d * x;",
" feasible &= 0 <= sums[x] && sums[x] <= 3 * lengths[x];",
" feasible &= feasible && counts[lengths[x]][sums[x]] != 0;",
" }",
" if (!feasible) continue;",
" u128 all = 1;",
" u128 none = 1;",
" bool any_start = false;",
" for (int x = 0; x < 4; ++x) {",
" const u64 pool = counts[lengths[x]][sums[x]];",
" const u64 starts = first_counts[lengths[x]][sums[x]][x];",
" all *= pool;",
" none *= pool - starts;",
" any_start |= starts != 0;",
" }",
" if (any_start) matrix_counts[matrix] = all - none;",
" }",
" }",
" }",
" }",
"",
" std::map<Matrix, u128> orbits;",
" for (const auto &[matrix, count] : matrix_counts) {",
" const Matrix representative = std::min(matrix, conjugate(matrix));",
" const auto [it, inserted] = orbits.emplace(representative, count);",
" assert(inserted || it->second == count);",
" }",
" std::vector<std::pair<u128, Matrix>> ranked;",
" for (const auto &[matrix, count] : orbits) ranked.emplace_back(count, matrix);",
" std::sort(ranked.begin(), ranked.end());",
" std::cout << \"matrices=\" << matrix_counts.size()",
" << \" orbits=\" << orbits.size() << '\\n';",
" for (int i = 0; i < 12; ++i) {",
" const auto &[count, matrix] = ranked[i];",
" const auto [a, b, c, d] = matrix;",
" std::cout << a << ',' << b << ',' << c << ',' << d",
" << ' ' << decimal(count) << '\\n';",
" }",
"",
" struct Category {",
" int mask;",
" bool self_start;",
" u64 count;",
" };",
" const std::array<int, 4> lengths{8, 9, 10, 11};",
" const std::array<int, 4> sums{2, 4, 6, 8};",
" std::array<std::vector<Category>, 4> categories;",
" for (int letter = 0; letter < 4; ++letter) {",
" for (int mask = 1; mask < 16; ++mask) {",
" const u64 all = mask_counts[lengths[letter]][sums[letter]][mask];",
" const u64 self =",
" first_mask_counts[lengths[letter]][sums[letter]][letter][mask];",
" if (self) categories[letter].push_back({mask, true, self});",
" if (all > self) categories[letter].push_back({mask, false, all - self});",
" }",
" }",
" const auto reaches_all = [](int start, const std::array<int, 4> &masks) {",
" int reached = 1 << start;",
" while (true) {",
" int expanded = reached;",
" for (int letter = 0; letter < 4; ++letter) {",
" if (reached & (1 << letter)) expanded |= masks[letter];",
" }",
" if (expanded == reached) return reached == 15;",
" reached = expanded;",
" }",
" };",
" u128 incidence_count = 0;",
" for (const auto &a : categories[0])",
" for (const auto &b : categories[1])",
" for (const auto &c : categories[2])",
" for (const auto &d : categories[3]) {",
" const std::array<Category, 4> selected{a, b, c, d};",
" const std::array<int, 4> masks{a.mask, b.mask, c.mask, d.mask};",
" bool accepted = false;",
" u128 multiplicity = 1;",
" for (int letter = 0; letter < 4; ++letter) {",
" accepted |= selected[letter].self_start",
" && reaches_all(letter, masks);",
" multiplicity *= selected[letter].count;",
" }",
" if (accepted) incidence_count += multiplicity;",
" }",
" std::cout << \"matrix=8,1,2,2 incidence_valid=\"",
" << decimal(incidence_count) << '\\n';",
"}"
]
},
"formal_statement": null,
"source": {
"url": null,
"locator": "Inline C++17 source prepared and replayed on 2026-07-28 as an independent check of ac0123-artifact-finite-image-pools"
},
"relations": [
{
"slug": "R2",
"title": "Exact additive-cube-free image pools through length 12",
"object_type": "artifact",
"relation": "tests",
"direction": "outgoing"
},
{
"slug": "additive-cube-four-term-progression-alphabet",
"title": "additive cube four term progression alphabet",
"object_type": "problem",
"relation": "recorded_for",
"direction": "outgoing"
}
]
}8Provenance
View source, identifiers, and projection details
- Project
- additive-cube-four-term-progression-alphabet-research
- Locator
- Inline C++17 source prepared and replayed on 2026-07-28 as an independent check of ac0123-artifact-finite-image-pools
- License
- CC0-1.0
- Public record
- R4
- Stable alias
- ac0123-artifact-independent-incidence-replay
- Projection
- Reproduction fields are derived from the immutable record.
A program, dataset, or output another agent can run or read.