diff --git a/research/depth5-connector-independent-bfs/README.md b/research/depth5-connector-independent-bfs/README.md new file mode 100644 index 0000000000..0911cb4ddb --- /dev/null +++ b/research/depth5-connector-independent-bfs/README.md @@ -0,0 +1,96 @@ +# Independent BFS for #4281's depth-five chain connector minima + +**Claim type: an independent exhaustive finite computation and certificate +check. No new κ.** It reproduces the one part of #4281 that its CI does not +rerun. + +## Object + +[PR #4281](https://github.com/CrocSwap/integer-mult-bounds/pull/4281) +(petalas) finds the shortest unsigned depth-five dirty chain connector `z_l += +B_l z_{l−1}`, `l = 1..5`. Its claims: + +- **m = 2 and 3:** the minimum is `8m`, by exhaustive BFS; +- **m = 4:** 28 for `c = 1, 3` and 24 for `c = 2`; +- **m = 5 to 20:** 173 witnesses of length `5m`. + +The m = 4 lower bounds come from a BFS over `4^15 ≈ 1.07·10⁹` group elements. +#4281 runs that BFS only as an opt-in command needing about 20 GB, so CI never +repeats it, and nothing else had. + +## Model + +A positive word is correct for residue `c` exactly when its product of the +generators `I + E[l][l−1]` in the unitriangular group mod `m` equals +`I + c·E[5][0]`. This is #4281's Lemma 1, here in lower-triangular form. BFS +distance from the identity is therefore the exact minimum. + +## Results + +| Case | This package | #4281 | +| --- | --- | --- | +| depth 5, m = 2 | 16 (Python and C) | 16 | +| depth 5, m = 3 | 24, 24 (C) | 24 | +| depth 5, m = 4 | **28, 24, 28** for `c = 1, 2, 3` (C, 51 s, 1.07 GB) | 28, 24, 28 (opt-in) | +| depth 4, m = 2..5 (control) | 12, 18, 20, 25 (Python for m ≤ 4, C for all) | #4249's values | + +**Witnesses.** All 173 vendored witnesses pass three checks: + +- the length is `5m`, with each call used `m` times; +- the group product is correct; +- three literal replays, with random dirty registers in `(Z/m)²` and random + noncommuting `2×2` maps, restore `z_1..z_4` and add exactly + `c·B5B4B3B2B1·x` to `y`. + +Every `c` is present for `9 ≤ m ≤ 20`. The three m = 4 words have lengths 28, +24 and 28 and are correct. + +**Controls.** Dropping a call, or swapping two adjacent noncommuting calls, +makes a witness incorrect. + +## Method and independence + +Nothing is imported from #4281, and its numpy BFS is not used. + +- **`bfs.c`** is a separate implementation: a `uint8` distance table over + base-`m` digit states, with layer scans. It stops once every target residue + is reached. +- **`verify.py`** has its own standard-library BFS for the small cases. It also + checks that `evidence/BFS-RUNS.txt` was recorded for this exact `bfs.c`, by + SHA256. + +The C runs are **local evidence**: Apple clang 21, arm64, macOS. CI reads the +recorded output and does not recompile. + +## Not covered + +- The residues at m = 5 to 8 that #4281's search did not find, and every + m > 20. +- Any physical price, admission or caller. + +## Reproduce + +```sh +python3.12 -B research/depth5-connector-independent-bfs/verify.py +cc -O2 -DM=4 -DD=5 -o bfs research/depth5-connector-independent-bfs/bfs.c && ./bfs +``` + +The first prints `PASS_DEPTH5_CONNECTOR_INDEPENDENT_BFS` in about 9 seconds. +The second takes about a minute and 1.1 GB of memory, and prints the m = 4 +distances. + +## Open next questions + +1. **Decide the eleven missing residues at m = 5 to 8.** + - *Why it matters:* #4281 calls them search failures, not bounds. A BFS + shows whether the floor `5m` is attainable there. + - *First step:* `bfs.c` at m = 5, which has `5^15 ≈ 3.1·10¹⁰` states, needs a + 30 GB table. A meet-in-the-middle search to depth `5m/2` is the cheaper + route. + - *Blocked by:* memory on this machine. + +## Credit + +The connector model, Lemma 1, the witnesses and the m = 4 words are Nick +Petalas's (#4281, building on #4249 and #4263). Prepared by Ryanson Jonathan +with substantial Claude Code (Claude Opus 5.5) assistance. Apache-2.0. diff --git a/research/depth5-connector-independent-bfs/SOURCES.json b/research/depth5-connector-independent-bfs/SOURCES.json new file mode 100644 index 0000000000..fcfba8aa31 --- /dev/null +++ b/research/depth5-connector-independent-bfs/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + } + ] +} diff --git a/research/depth5-connector-independent-bfs/TASK.json b/research/depth5-connector-independent-bfs/TASK.json new file mode 100644 index 0000000000..f9b3cfe441 --- /dev/null +++ b/research/depth5-connector-independent-bfs/TASK.json @@ -0,0 +1,62 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 7, + "base_commit": "12fa8c5c844be21bfefb38a19503fbd867a11244", + "original_card": { + "id": "connector-alphabet-change", + "question": "Does one explicit extension of the connector alphabet offer a favorable completed budget?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/universal-connector-boundary/README.md", + "certificates/selected-result.json" + ], + "methods": [ + "Construct and charge a legal extra operation on a minimal instance.", + "Prove a target-specific bound after adding one specified operation family." + ], + "acceptance_gate": "State which fixed-alphabet premise changes and charge its implementation; do not declare it free. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/universal-connector-boundary/verify.py" + ], + "expected": "PASS_UNIVERSAL_CONNECTOR_BOUNDARY", + "inspect": "Reproduce the 945-pairing control, then read Exact interface to list the allowed calls.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Add exactly one legally priced operation and test a tiny dirty-input instance before enumerating larger cases.", + "bottleneck_link": "A new legal connector operation could change recursive interface cost; a larger census in the same alphabet is a separate side result.", + "allowed_variations": [ + "Choose one additional operation and a small source count for its first counterexample." + ], + "scope_change_triggers": [ + "Keeping the alphabet and only increasing the source count; record this as a changed assignment.", + "Extending a source-count census without naming a supplier/interface decision it could change; audit #2973 pruning concerns before relying on the affected predecessor exclusions." + ], + "overlap_terms": [ + "universal connector", + "source-toggle", + "connector alphabet" + ] + }, + "scope_status": "refined", + "actual_scope": "Independently reproduce #4281's exhaustive depth-five minima (m = 2, 3, 4, including the opt-in m = 4 run CI never repeats) and verify every witness and m = 4 word with separate code.", + "scope_change_reason": "The card's open question was answered by #4281; its m = 4 lower bound rested on one opt-in 20 GB run on the author's machine, so an independent reproduction is the missing coverage.", + "bottleneck_link": "Connector premiums at small characteristic decide which alphabet changes are worth pricing; #4281's m = 4 residue dependence is new and needed a second implementation.", + "budget_minutes": 40, + "stop_rule": "Stop once every #4281 minimum and witness is reproduced or contradicted.", + "outcome": "completed", + "evidence": "bfs.c (separate uint8-table BFS): depth 5 gives 16 (m=2), 24 (m=3) and 28/24/28 (m=4, 1.07e9 states, 51 s, 1.07 GB); depth-4 control 12/18/20/25. Python BFS reproduces m <= 4 depth 4 and m = 2 depth 5. All 173 witnesses and the three m = 4 words pass shape, product and literal noncommuting replays; dropped-call and swap controls fail.", + "author": "Ryanson Jonathan, with Claude Code (Claude Opus 5.5) assistance", + "ai_assistance": "Substantial Claude Code (Claude Opus 5.5) assistance in reading, verifier implementation and writing; no independent human or proof-kernel review.", + "open_questions": [ + { + "question": "Decide the eleven residues at m = 5 to 8 that #4281's search missed.", + "why_it_matters": "They are search failures, not bounds; BFS would show whether 5m is attainable.", + "first_step": "Meet-in-the-middle to depth 5m/2 at m = 5, avoiding a 30 GB table.", + "blocked_by": "Memory for the plain table." + } + ] +} diff --git a/research/depth5-connector-independent-bfs/VERIFY.json b/research/depth5-connector-independent-bfs/VERIFY.json new file mode 100644 index 0000000000..eee242eabb --- /dev/null +++ b/research/depth5-connector-independent-bfs/VERIFY.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Vendored witnesses.json hash; standard-library BFS for depth 4 (m = 2..4) and depth 5 (m = 2); every witness by shape, unitriangular product and literal 2x2 noncommuting replay; full rows 9..20; m = 4 words; recorded bfs.c runs bound to bfs.c by SHA256 and matching #4281's minima; dropped-call and swap controls." + } + ] +} diff --git a/research/depth5-connector-independent-bfs/bfs.c b/research/depth5-connector-independent-bfs/bfs.c new file mode 100644 index 0000000000..16d9b93b3a --- /dev/null +++ b/research/depth5-connector-independent-bfs/bfs.c @@ -0,0 +1,62 @@ +/* Exhaustive BFS over the unitriangular group of the depth-D chain connector, mod M. + * + * State: the strictly lower part X[i][j] (0 <= j < i <= D) of a unitriangular matrix, as + * base-M digits, row by row. Call l (1..D) is z_l += B_l z_{l-1}, i.e. left multiplication by + * I + E[l][l-1]: row l gains row l-1, whose diagonal 1 sits in column l-1. The target for + * residue c is I + c E[D][0]. Distances are exact shortest positive-word lengths. + * Build: cc -O2 -DM=4 -DD=5 -o bfs bfs.c ; run: ./bfs (prints one line per residue) + * Ryanson Jonathan with Claude Code (Claude Opus 5.5) assistance. Apache-2.0. + */ +#include +#include +#include +#include + +#define E (D * (D + 1) / 2) + +static uint64_t pw[E + 1]; +static int off[D + 1]; + +static uint64_t step(uint64_t s, int l) { + int dig[E]; + uint64_t t = s; + for (int k = 0; k < E; k++) { dig[k] = (int)(t % M); t /= M; } + for (int j = 0; j < l - 1; j++) dig[off[l] + j] = (dig[off[l] + j] + dig[off[l - 1] + j]) % M; + dig[off[l] + l - 1] = (dig[off[l] + l - 1] + 1) % M; + uint64_t r = 0; + for (int k = E - 1; k >= 0; k--) r = r * M + (uint64_t)dig[k]; + return r; +} + +int main(void) { + pw[0] = 1; + for (int k = 1; k <= E; k++) pw[k] = pw[k - 1] * M; + for (int i = 1; i <= D; i++) off[i] = (i - 1) * i / 2; /* row i starts after rows 1..i-1 */ + uint64_t n = pw[E]; + uint8_t *dist = malloc(n); + if (!dist) { fprintf(stderr, "alloc\n"); return 1; } + memset(dist, 255, n); + dist[0] = 0; + uint64_t target[M]; + int found = 0, best[M]; + for (int c = 1; c < M; c++) { target[c] = (uint64_t)c * pw[off[D]]; best[c] = -1; } + uint64_t reached = 1; + for (int d = 0; d < 254 && found < M - 1; d++) { + uint64_t layer = 0; + for (uint64_t s = 0; s < n; s++) { + if (dist[s] != d) continue; + for (int l = 1; l <= D; l++) { + uint64_t r = step(s, l); + if (dist[r] == 255) { dist[r] = (uint8_t)(d + 1); layer++; } + } + } + if (!layer) break; + reached += layer; + for (int c = 1; c < M; c++) + if (best[c] < 0 && dist[target[c]] == d + 1) { best[c] = d + 1; found++; } + } + for (int c = 1; c < M; c++) printf("M=%d D=%d c=%d dist=%d\n", M, D, c, best[c]); + printf("M=%d D=%d states=%llu reached_by_stop=%llu\n", M, D, (unsigned long long)n, (unsigned long long)reached); + free(dist); + return 0; +} diff --git a/research/depth5-connector-independent-bfs/evidence/BFS-RUNS.txt b/research/depth5-connector-independent-bfs/evidence/BFS-RUNS.txt new file mode 100644 index 0000000000..8547953a7a --- /dev/null +++ b/research/depth5-connector-independent-bfs/evidence/BFS-RUNS.txt @@ -0,0 +1,26 @@ +# Recorded runs of bfs.c (SHA256 1180b2a5d1f67d329b348fa0b85b7a009e9aafe6811339c716a0f7885aa3c452) +# Apple clang 21.0.0, arm64, macOS 27.2; built with: cc -O2 -DM= -DD= -o bfs bfs.c +# Local evidence: CI does not rerun these. depth 5, m = 4 took 51 s and 1.07 GB peak memory. +M=2 D=4 c=1 dist=12 +M=2 D=4 states=1024 reached_by_stop=1024 +M=3 D=4 c=1 dist=18 +M=3 D=4 c=2 dist=18 +M=3 D=4 states=59049 reached_by_stop=59049 +M=4 D=4 c=1 dist=20 +M=4 D=4 c=2 dist=20 +M=4 D=4 c=3 dist=20 +M=4 D=4 states=1048576 reached_by_stop=1048500 +M=5 D=4 c=1 dist=25 +M=5 D=4 c=2 dist=25 +M=5 D=4 c=3 dist=25 +M=5 D=4 c=4 dist=25 +M=5 D=4 states=9765625 reached_by_stop=9765625 +M=2 D=5 c=1 dist=16 +M=2 D=5 states=32768 reached_by_stop=31588 +M=3 D=5 c=1 dist=24 +M=3 D=5 c=2 dist=24 +M=3 D=5 states=14348907 reached_by_stop=14348905 +M=4 D=5 c=1 dist=28 +M=4 D=5 c=2 dist=24 +M=4 D=5 c=3 dist=28 +M=4 D=5 states=1073741824 reached_by_stop=1073739652 diff --git a/research/depth5-connector-independent-bfs/vendor/NOTICE.md b/research/depth5-connector-independent-bfs/vendor/NOTICE.md new file mode 100644 index 0000000000..f645717ab0 --- /dev/null +++ b/research/depth5-connector-independent-bfs/vendor/NOTICE.md @@ -0,0 +1,11 @@ +# Vendored file + +`witnesses.json` is a byte-identical copy of +`research/depth5-chain-connector/witnesses.json` from +[PR #4281](https://github.com/CrocSwap/integer-mult-bounds/pull/4281) at head +`87f4a21e02c83fab559dcf1470dd0a97dfb89b8f` (Git blob +`aebd77d7a68a7f7acfc9a56314528b58d8ca8875`). + +It is copied, not pinned, because that PR head is not reachable from canonical main. +`verify.py` checks its SHA256 before use. The witnesses were found by Nick Petalas's +search (#4281) and are Apache-2.0, as that package states. diff --git a/research/depth5-connector-independent-bfs/vendor/witnesses.json b/research/depth5-connector-independent-bfs/vendor/witnesses.json new file mode 100644 index 0000000000..aebd77d7a6 --- /dev/null +++ b/research/depth5-connector-independent-bfs/vendor/witnesses.json @@ -0,0 +1,217 @@ +{ + "schema_version": 1, + "description": "One word per listed (m, c) with exactly m copies of each call 1..5; found by search_witnesses.c. Pairs absent from a row were not found by the bounded search; absence is not a proof of impossibility.", + "witnesses": { + "5": { + "1": "3452312415342513243152415" + }, + "6": { + "3": "432515234514352342421311523451" + }, + "7": { + "1": "41545521341233132545311545421342223", + "2": "12342513251144325514123351523435442", + "3": "12125323435155411325321243145245434", + "4": "54553233125115243415124134234421235" + }, + "8": { + "1": "3521314132344545354123551543521431222214", + "2": "1345523512523415432434511524432412115233", + "3": "5123212413445241251535234535111343245342", + "4": "4454453324115142333532415245153322211251", + "6": "2523412331151553423151354523421244512344" + }, + "9": { + "1": "233315251125314354323414452131445541255322241", + "2": "432122154132334554135412531344535254321221154", + "3": "252354122535332114232523541455511324414344131", + "4": "334251344221432112355455355431124122135244315", + "5": "145423343525315255312232431424125432551141431", + "6": "331345524411315511225233452512344433452421251", + "7": "412511352524243412135231454411435215323543523", + "8": "143155244514351231352444152342215335142352312" + }, + "10": { + "1": "45124315542123335224255312215133415544214134312435", + "2": "14523234444513154353122145515522233542312543114213", + "3": "12434322154433222535214511321423541545155233135144", + "4": "33111233451543234145535454254523312413512412124522", + "5": "13333415143121523325112242452112454553454534542123", + "6": "11454313225122435211131223524534443555214335541423", + "7": "31234525323143514552212213524134153412513454134254", + "8": "44543222432321242515353154351351111445532141324523", + "9": "54452532224553152412335344145411553312134232421113" + }, + "11": { + "1": "4441535214213534342225313414542111215333124453252351255", + "2": "2325253254115435324421454344511341215332452313515123214", + "3": "4121244133421532441553513124342122525353454343552131215", + "4": "2234242432545531353324131114511312243254551321442341555", + "5": "1244132351152554552431124231354542231445234511234135323", + "6": "3543534134414113325412311552552422241533455232432152411", + "7": "2353224535234521451421531242344431355452153341131522141", + "8": "1232245535135541353345321414345424511134423252112523124", + "9": "5111234124553454541221334152132532543422351314532543412", + "10": "4412535322415313111413521344231524442553451524322313525" + }, + "12": { + "1": "134524544135212143321541314224253125351342551341133525254342", + "2": "435231531523114244542415543332151111553213244135445433225222", + "3": "415555542212142523433511432142121331131524343544452523453213", + "4": "242553122124535314114514212232215155313452135344134432345453", + "5": "213513113545114534444121552442525243323254113352435225124133", + "6": "345333545343522315112444313551512524222542131315241314412524", + "7": "523431211122231553343542143432412412313155234544544355152152", + "8": "343324232211235155153254435342533512414441111122424334512555", + "9": "323241311243225524455514154432331432342411155532413552511234", + "10": "435352245415325235115435214231131542223132454531512413314244", + "11": "232454341254445355342212311534154431425123314515253311223521" + }, + "13": { + "1": "21324451513512314234324144413553541323355212245215422143113525543", + "2": "32113113433342555324115324512432442145554225311343245553224211514", + "3": "31113423112221445244355231255353254252433451441133525124134253541", + "4": "54132212313324452445341235512125311452415532143313523124554124453", + "5": "33432132442451224341315553215521444434135522512422535141535113321", + "6": "44253551324332134512554131245143115513524225414434332533421221215", + "7": "23414512525553151524352453315113234421513422345112441322343443215", + "8": "43351315213215442531524422315321435453455141412423545222512133413", + "9": "44123421515142355512453521451224432433432453552332132154111453213", + "10": "54525313251525431324155143142132245414121123443432532523143425351", + "11": "12414253554235142112235434332525143112435451245143443221151535233", + "12": "31234551553431344124531412232113242555213543152214213531243425445" + }, + "14": { + "1": "1544111511515415552334232333121223523325123344324545322542414215445431", + "2": "3334511525453514125112314112322441553231315254142334244455542342213235", + "3": "1551235552432344122434531142345415552234113223223341415524331145123541", + "4": "2335315432511113122334143251443111243424452532552132431523425254455451", + "5": "5254344411241241255242355345432125513324211143331554315342552231412331", + "6": "3135452425223143415422142121353314242315411153445315232351251324545543", + "7": "3453243552412352313222114354141111243215243423521334551414315554422355", + "8": "2433334241455254141233332245125125512132244152151235154154144233551433", + "9": "3215345242323331414125132132353521531454422241532155154315451432544142", + "10": "3454112544245552235523444212531351111121345353223113324314153252434452", + "11": "5143522345354122413231545521154553454124122131141324243233213415345523", + "12": "1354132251254253542214112521453442213334331254553135241455212345133414", + "13": "1133212421455522113152124323354531445535325445414112135242332434354521" + }, + "15": { + "1": "414314151455252531354232344452245131433532231431424153451231531321122545522", + "2": "154314315241113321424153552433524214422352543141513341345322423355512125542", + "3": "433244452241121153542213245414514315323433214413321525514352251515423531235", + "4": "144345413452131211233555453452425552423123331211314343551254453114223521224", + "5": "241154123124425531153332231224135545255551412144434331323324415555324214312", + "6": "143134451422242422332235543314151252352153454551113132224554151353314154324", + "7": "454532514151323234223133232541531143245451115551242541344211542152433342235", + "8": "515354321234251342412243413231314521535315125431424441132245511453554232325", + "9": "422541533553121552421354433433151551522453135324242141224541534341122321341", + "10": "345144234254151114323253132244551333211423354443322121235551145242145312555", + "11": "232543132522535445111522211245144312314244435454343143313235525131514155223", + "12": "241235412532512332334143555313443435141511454512432214155222431142423155253", + "13": "544124513242154411322533244115512551243552512534231142211345351333432434235", + "14": "453552334315543524233421145151235431452524531132414514224511511224231234323" + }, + "16": { + "1": "33325245113454332211451522244525114251453243553311435123422213151521253445143344", + "2": "34543231434113212344535431455435535131212323414522342255352511245444121152311225", + "3": "23551524534443353352324533124552222131442455311411225141522114343343213415412155", + "4": "34152553434534321513214352511454213451223321141525334524523354144231112255242413", + "5": "53452315252144324343431323155215431134412531431211115522435332252445254125434512", + "6": "55553445451322141312312122325312232323511234354554454414445532231243141455311231", + "7": "55443141212534512421523452534541451331525343122253111355415224142321534433123432", + "8": "24311324341135452252411125345521553132525222114155122443335341435452412433354341", + "9": "24353313334341522421112431454441341433124213215425253343555152512541525521252431", + "10": "24321215134134454141334532433215423141251152212335553355241432154225234452513154", + "11": "53522244152415312314523114151534534324145532533152214234453233415113521542314242", + "12": "12121554455233454133143325545524211232155241243425444242542511123335231133154331", + "13": "25351541521143313232152342354253522335152354221512142343144435544114142133125454", + "14": "22214545121511415335541335431543325523514411334124515545322323241142345212343224", + "15": "43525521155452312135515413334413413241343444515525121213442255253214414323212323" + }, + "17": { + "1": "2551233222542551113144532125113541424243131542523524352211114253424134344433335354155", + "2": "4353122345512114332353114111215235453555434312445552512422214334434432123551221442513", + "3": "1235554342434235521115151442253235511234414115245423335432233552323124425411114421533", + "4": "2434224333153411251432314541233513355433423115242554144534223454521515521212552123411", + "5": "3114333525524312135143231444434454453525225235353211432114453322415131111525521224524", + "6": "3433234111412542113524242351431434215411232112442323453355251124544335352125452551553", + "7": "1123145112422534113555143334321543122322444241335423355242514141533125445552352311425", + "8": "2512554143323455112214524435425432312324223155114343545143512435343311215225514134123", + "9": "1442541324435132152533145244325553152153155141212431341543143245231422332152443512523", + "10": "3224323521532335121522352441144325151545441355332412141322415141553215453444334231152", + "11": "1323534535414254145412442323345421215533152331344215352411441241532551315215222451332", + "12": "1532214231552311552322142322444445521411113331344135155332335214442522444135551324553", + "13": "2513533353231153442145225444431411311315454243153124352142211123254221524425535553432", + "14": "4341235423252211543342543153435434231542325231415435551311135515251114152342424243212", + "15": "1523411243534244113151544535133232224353211451424334522435554515214413122535352143212", + "16": "2312341215541351334455523332122352244423533454534335111455454411111213214242225152534" + }, + "18": { + "1": "432554243341534415345244233452331234415511454313254152121125124514123334232212531512153255", + "2": "213441413242331113542353122513325115453434515552312123444242225543354525412421145143235135", + "3": "321541342443333252432311431414213234225432423111425431155155535545242325132442115455311255", + "4": "341435451335115533135542133234241312323425213545225444521513241551131434224522154142423251", + "5": "115214524312511545512332254555233133422434335154554351425243234414214431511114252232412333", + "6": "351422341411115545122553352342335253524452322125213453243312141523451441145453231441543321", + "7": "152425445234251214353553153251532131352111231251221344451545133542324523434134423541242314", + "8": "151544513244445443521533332352141435511335523443244512322112151254433122515511231322244532", + "9": "422514515344412233241531513222155344522135414355454544352132353132512351433124443212111523", + "10": "312332215442423513243422531514545421155521154324443331334451513142211532215535244513534212", + "11": "411345434252553112435323153124443415211214224145255345351524311243242244312332351315535251", + "12": "145133443533544551444422125352535424131252343421241212522332135353515211235441512351413142", + "13": "323255521111154533142513122241111541455433222125234351341553523321432234545244434435144532", + "14": "323534234124325324245453353455415333551522334221123114221455251212141244545441135131542311", + "15": "432314244524154351212144321352355421511253513121253544223441535211124312342244533534133555", + "16": "111234543412553131332312454522335545325221425443122332144211311554231352241454135412344555", + "17": "443455535255322512454114551535122413311121332322324421235331542331143411421543521245432454" + }, + "19": { + "1": "23322322425213451155433411144532523154341355153355114253443452244324113451352415225121143243215", + "2": "45515351242533341424114325533251554141213535425144524123411112335341322532241434132125455234322", + "3": "35221155253241333213134315543142542222255333234124551245342414443451415513311143242515553411224", + "4": "21342245151553214141354244123535344231351122331252552451525524151143433335532514344144213231422", + "5": "53332512431545521233425254112221124534435332421335513214114543311441332232521444254311514455525", + "6": "42122135215544135315522122232423343253141341245551222131543552344443435134414313553122415145315", + "7": "12421341234255445431132234525115534115245343433214125241353522315454312111254234213334551543252", + "8": "24513215234235313254545123444543241151412415414235232313411453423345225125323211415512555343231", + "9": "43421145552233344215312345543311521322231322312443155235554422453531215124155114151344324254341", + "10": "34125421432312155213431355543353521144234511225334125344222234521532452354151111425143431424355", + "11": "54522331432532554432212433214145543315554351521131324135433115421353554112242441125351243421422", + "12": "15325455213431314444313344255453412512242114434134255213523432342511335342153524232125155212151", + "13": "21513322413521323432134255352453231444243414423215151351452153115111433213455245251523544244253", + "14": "55334353313421131314535534225214134244552441131312521231213325512215253544152144524443543421522", + "15": "42414531212525321123512254235135353214344232245213125145444555144423134335311511533113452452432", + "16": "15215243212323535114215543442552215252311244213544331135112121454453334133413134452242234355554", + "17": "22112535514413333344445135425334152211254315215332544512325232514113245211354134522413451425342", + "18": "32542253454121455152213315221521215443335531415443324134351544454233453144131522511332223541122" + }, + "20": { + "1": "3232335151132455122521143421452514532445452443333234532131124212544453543112151132555152253412441334", + "2": "5311521421533315534152421445144424431211133443514421542334234122542553351231322522455531221353354125", + "3": "1235432153152453343254213111314345454532145141121133225245255242324443542225113453335232152445513141", + "4": "4324343332541542512313515144315325535244241514232422251135114251451344225233233451423115354451221351", + "5": "2335343451211512145325114432521435511344255544432252153323532234251134312544344322545551123231142141", + "6": "5322533111124422334352525144345441155535135322351211433255411234314244234153242551215332351414124245", + "7": "3551444542353214535225242525424252433314323132545534552235114443331322312112114151315241143151132445", + "8": "4511352421451222124411524243123334525331155432511115433143255225514451442543353353113445542342231322", + "9": "1255324422145441245342133232234451153331334225234142521523352145531515341533345125152414521445132114", + "10": "1321155142422341352323354345341421535512421431121422454313433112121521243332435553444435242515515525", + "11": "5123441543354341515242132433211254541545232121321125143532333135241524535415443522155434342152243112", + "12": "3245435111133331551525544241312121214441134131352342421152423234333322442515254312254555452245355314", + "13": "2534112221153523445312531542325521512424455553134441321334552422242334445333415533132121111451453421", + "14": "1445411555523452541444241531323253513133352353522121544545311122234241541133114243214322524331422535", + "15": "5451344255431121332341512324434513515523125243312525554445334112224152152234115143133132324452435412", + "16": "5114434543544251115211354243315223541255532125234333512115145232413425252234534324115153142432134234", + "17": "2434415243543231542353314243524511122144412211551255315435424512111443544233324331523552133151235252", + "18": "5451221155341144355422432545432415111455353222524354121124255153334433314241313313453145122423222513", + "19": "2142354212344243153215422422325411112154131542151223153151541245534235333234343333245451455425453151" + } + }, + "m4_minimal_words": { + "1": "5523234534232123452343232111", + "2": "553345433212334543321211", + "3": "2345234553232123234534232111" + }, + "m4_description": "Depth five at m = 4: one shortest word per c, read back from the exhaustive BFS distance table (lengths 28, 24, 28)." +} diff --git a/research/depth5-connector-independent-bfs/verify.py b/research/depth5-connector-independent-bfs/verify.py new file mode 100644 index 0000000000..b86d6e6dc6 --- /dev/null +++ b/research/depth5-connector-independent-bfs/verify.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python3 +"""Independent check of #4281's depth-five chain connector minima and witnesses. + +Call l is z_l += B_l z_{l-1}. A positive word is correct for residue c exactly when its product +of I + E[l][l-1] in the unitriangular group mod m is I + c E[D][0] (#4281's Lemma 1, here in +lower-triangular form). This file: a standard-library BFS for the small cases, a check of every +vendored witness by that product and by a literal replay with random noncommuting 2x2 maps, and +a check of the recorded C runs (bfs.c) for the large ones. No code from #4281. +Ryanson Jonathan with Claude Code (Claude Opus 5.5) assistance. Apache-2.0. +""" +import hashlib +import json +from pathlib import Path +import random +import sys + +HERE = Path(__file__).resolve().parent +WITNESS_SHA256 = "ea320e9f069de8864952ad4b5e492875c1102bd1d12074f606b8aad2b54fe254" +EXPECTED_BFS = {(4, 2): {1: 12}, (4, 3): {1: 18, 2: 18}, (4, 4): {1: 20, 2: 20, 3: 20}, + (5, 2): {1: 16}} +EXPECTED_C = {(4, 5): {1: 25, 2: 25, 3: 25, 4: 25}, (5, 3): {1: 24, 2: 24}, (5, 4): {1: 28, 2: 24, 3: 28}} + + +def need(condition, message): + if not condition: + raise AssertionError(message) + + +def product(word, m, depth): + """strictly lower entries of prod (I + E[l][l-1]) applied in word order, mod m""" + x = [[int(i == j) for j in range(depth + 1)] for i in range(depth + 1)] + for ch in word: + l = int(ch) + x[l] = [(a + b) % m for a, b in zip(x[l], x[l - 1])] + return x + + +def correct(word, m, c, depth=5): + x = product(word, m, depth) + return all(x[i][j] == (c % m if (i, j) == (depth, 0) else 0) for i in range(depth + 1) for j in range(i)) + + +def literal(word, m, c, rng): + """replay with dirty registers in (Z/m)^2 and random 2x2 maps; z_1..z_4 restored, y += c B5..B1 x""" + def mul(a, b): + return [[sum(a[i][k] * b[k][j] for k in range(2)) % m for j in range(2)] for i in range(2)] + + def app(a, v): + return [sum(a[i][k] * v[k] for k in range(2)) % m for i in range(2)] + B = {l: [[rng.randrange(m) for _ in range(2)] for _ in range(2)] for l in range(1, 6)} + z0 = [[rng.randrange(m) for _ in range(2)] for _ in range(6)] + z = [v[:] for v in z0] + for ch in word: + l = int(ch) + z[l] = [(a + b) % m for a, b in zip(z[l], app(B[l], z[l - 1]))] + chain = mul(B[5], mul(B[4], mul(B[3], mul(B[2], B[1])))) + gain = app(chain, z0[0]) + return z[:5] == z0[:5] and z[5] == [(a + c * b) % m for a, b in zip(z0[5], gain)] + + +def bfs(m, depth): + """exact distances from the identity to every I + c E[depth][0]""" + rows = [(i, j) for i in range(1, depth + 1) for j in range(i)] + pos = {cell: k for k, cell in enumerate(rows)} + + def step(s, l): + d = [(s // m ** k) % m for k in range(len(rows))] + for j in range(l - 1): + d[pos[l, j]] = (d[pos[l, j]] + d[pos[l - 1, j]]) % m + d[pos[l, l - 1]] = (d[pos[l, l - 1]] + 1) % m + return sum(v * m ** k for k, v in enumerate(d)) + targets = {c * m ** pos[depth, 0]: c for c in range(1, m)} + seen, frontier, dist, found = {0}, [0], 0, {} + while frontier and len(found) < m - 1: + dist += 1 + nxt = [] + for s in frontier: + for l in range(1, depth + 1): + r = step(s, l) + if r not in seen: + seen.add(r) + nxt.append(r) + if r in targets: + found[targets[r]] = dist + frontier = nxt + return found + + +def main(): + raw = (HERE / "vendor/witnesses.json").read_bytes() + need(hashlib.sha256(raw).hexdigest() == WITNESS_SHA256, "vendored witnesses.json") + data = json.loads(raw) + rng = random.Random(4281) + + # exact minima, standard library + for (depth, m), want in EXPECTED_BFS.items(): + need(bfs(m, depth) == want, f"BFS depth {depth} m {m}") + + # every 5m witness: length, call multiplicities, product, literal replay + count = 0 + for m_s, row in data["witnesses"].items(): + m = int(m_s) + for c_s, word in row.items(): + c = int(c_s) + need(len(word) == 5 * m and all(word.count(str(l)) == m for l in range(1, 6)), f"({m},{c}) shape") + need(correct(word, m, c), f"({m},{c}) product") + need(all(literal(word, m, c, rng) for _ in range(3)), f"({m},{c}) literal replay") + count += 1 + need(count == 173, "173 witnesses") + need(all(sorted(map(int, data["witnesses"][str(m)])) == list(range(1, m)) for m in range(9, 21)), "full rows 9..20") + + # the three m = 4 words read back from #4281's BFS + m4 = {int(c): w for c, w in data["m4_minimal_words"].items()} + need({c: len(w) for c, w in m4.items()} == {1: 28, 2: 24, 3: 28}, "m=4 word lengths") + need(all(correct(w, 4, c) and literal(w, 4, c, rng) for c, w in m4.items()), "m=4 words correct") + + # recorded runs of bfs.c (built and run as in the README); local evidence, not replayed here + runs, text = {}, (HERE / "evidence/BFS-RUNS.txt").read_text() + need(f"bfs.c (SHA256 {hashlib.sha256((HERE / 'bfs.c').read_bytes()).hexdigest()})" in text, "runs recorded for this bfs.c") + for line in text.splitlines(): + if " c=" in line and line.startswith("M="): + f = dict(kv.split("=") for kv in line.split()) + runs.setdefault((int(f["D"]), int(f["M"])), {})[int(f["c"])] = int(f["dist"]) + need(all(runs.get(k) == v for k, v in EXPECTED_C.items()), "recorded C runs give #4281's minima") + need(all(runs.get(k) == v for k, v in EXPECTED_BFS.items()), "C runs agree with the Python BFS") + + # controls: a dropped call and an adjacent swap of noncommuting calls are rejected + w = data["witnesses"]["14"]["1"] + need(not correct(w[1:], 14, 1), "control: dropped call") + k = next(i for i in range(len(w) - 1) if abs(int(w[i]) - int(w[i + 1])) == 1) + need(not correct(w[:k] + w[k + 1] + w[k] + w[k + 2:], 14, 1), "control: adjacent noncommuting swap") + + print(json.dumps({ + "status": "PASS_DEPTH5_CONNECTOR_INDEPENDENT_BFS", + "python_bfs": {f"depth{d}_m{m}": v for (d, m), v in EXPECTED_BFS.items()}, + "c_bfs_recorded": {f"depth{d}_m{m}": v for (d, m), v in EXPECTED_C.items()}, + "witnesses": count, + "m4_words": 3, + "new_kappa_claimed": False, + }, indent=1)) + + +if __name__ == "__main__": + sys.exit(main())